Eliminate special-casing of NonHierarchyIndexableObject
Rather than checking the type of `self` in the method, lets just put this in the right class to begin with.
This changes the behavior when this method is called on subclasses, but every subclass overrides this method anyway.
@@ -405,13 +405,6 @@ class NonHierarchyObject(SimHandleBase):
@property
def value(self):
"A reference to the value"
- if type(self) is NonHierarchyIndexableObject:
- # need to iterate over the sub-object
- result = []
- for x in range(len(self)):
- result.append(self[x].value)
- return result
- else:
raise TypeError("Not permissible to get values of object %s of type %s" % (self._name, type(self)))
def setimmediatevalue(self, value):
@@ -549,6 +542,14 @@ class NonHierarchyIndexableObject(NonHierarchyObject):
yield left
left = left + 1
+ @NonHierarchyObject.value.getter
+ def value(self):
+ # need to iterate over the sub-object
+ result = []
+ for x in range(len(self)):
+ result.append(self[x].value)
+ return result
+
class _SimIterator(collections_abc.Iterator):
"""Iterator over simulator objects. For internal use only."""
