Skip to content
Snippets Groups Projects

Added custom LofarDeviceProxy to enhance support for high-dimensional arrays in attribtues

Merged Jan David Mol requested to merge reshape-highdim-arrays into main
Compare and Show latest version
3 files
+ 24
7
Compare changes
  • Side-by-side
  • Inline
Files
3
from tango import DeviceProxy
from tango import ExtractAs
import ast
from functools import lru_cache
import numpy
import ast
from functools import lru_cache
from tango import DeviceProxy
from tango import ExtractAs
class LofarDeviceProxy(DeviceProxy):
""" A LOFAR-specific tango.DeviceProxy that provides
a richer experience. """
"""A LOFAR-specific tango.DeviceProxy that provides
a richer experience."""
# cache attribute configurations, as they are not expected to change,
# but carry a cost to retrieve from the server.
@@ -22,7 +23,7 @@ class LofarDeviceProxy(DeviceProxy):
# "format" property describes actual dimensions as a tuple (x, y, z, ...),
# so reshape the value accordingly.
fmt = self.get_attribute_config(name).format
if fmt and fmt[0] == "(" and type(attr.value) == numpy.ndarray:
if fmt and fmt[0] == "(" and isinstance(attr.value, numpy.ndarray):
shape = ast.literal_eval(fmt)
attr.value = attr.value.reshape(shape)
Loading