Commit 5540d1eb authored by Tiago Peixoto's avatar Tiago Peixoto

Include PropertyMap.a property

This provides convienent access to the underlying array values, such as:

   p.a = random(len(p.a))

instead of:

   p.get_array()[:] = random(len(p.get_array()))

(the latter is still supported)
parent 41a677ae
...@@ -182,7 +182,7 @@ class PropertyMap(object): ...@@ -182,7 +182,7 @@ class PropertyMap(object):
return self.__map.value_type() return self.__map.value_type()
def get_array(self): def get_array(self):
"""Get an array with property values """Get an array with property values.
.. WARNING:: .. WARNING::
...@@ -201,6 +201,17 @@ class PropertyMap(object): ...@@ -201,6 +201,17 @@ class PropertyMap(object):
n = 1 n = 1
return self.__map.get_array(n) return self.__map.get_array(n)
def __get_array(self):
return self.get_array()[:]
def __set_array(self, v):
self.get_array()[:] = v
a = property(__get_array, __set_array,
doc=r"""Shortcut to the :meth:`~PropertyMap.get_array` method
as a property. A view to the array is returned, instead of the
array, for convenience.""")
def is_writable(self): def is_writable(self):
"""Return True if the property is writable.""" """Return True if the property is writable."""
return self.__map.is_writable() return self.__map.is_writable()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment