def testSignalAxes(self, container=None): """ Recursively parse tree Assert all signals contain 'axes' attribute Assert all signals contain 'time' attribute Assert all 'axes' elements are axis objects Assert all axis attributes are in 'axes' """ if not container: container = self.shot if not isinstance(container, fdp.classes.shot.Shot): if isinstance(container._parent, fdp.classes.shot.Shot): print('Parsing {}'.format(container._name)) else: print('Parsing {}.{}'.format(container._parent._name, container._name)) for attrname in dir(container): attr = getattr(container, attrname) if isContainer(attr): self.testSignalAxes(attr) elif isSignal(attr): self.assertTrue( hasattr(attr, 'axes'), "Signal {} does not have 'axes' attr".format(attr._name)) self.assertTrue( hasattr(attr, 'time'), "Signal {} does not have 'time' attr".format(attr._name)) self.assertTrue( isAxis(getattr(attr, 'time')), "'time' attr is not axis object for signal {}".format( attr._name)) for axisname in attr.axes: self.assertTrue( hasattr(attr, axisname), "'axes' element {} not an attribute for signal {}". format(axisname, attr._name)) axis = getattr(attr, axisname) self.assertTrue( isAxis(axis), "'axes' element {} is not axis object for signal {}". format(axisname, attr._name)) for sigattrname in dir(attr): sigattr = getattr(attr, sigattrname) if isAxis(sigattr): self.assertIn( sigattrname, attr.axes, "{} is axis but not in 'axes' attr for signal {}". format(sigattrname, attr._name))
def testSignalAxes(self, container=None): """ Recursively parse tree Assert all signals contain 'axes' attribute Assert all signals contain 'time' attribute Assert all 'axes' elements are axis objects Assert all axis attributes are in 'axes' """ if not container: container = self.shot if not isinstance(container, fdp.classes.shot.Shot): if isinstance(container._parent, fdp.classes.shot.Shot): print('Parsing {}'.format(container._name)) else: print('Parsing {}.{}'.format(container._parent._name, container._name)) for attrname in dir(container): attr = getattr(container, attrname) if isContainer(attr): self.testSignalAxes(attr) elif isSignal(attr): self.assertTrue(hasattr(attr, 'axes'), "Signal {} does not have 'axes' attr".format(attr._name)) self.assertTrue(hasattr(attr, 'time'), "Signal {} does not have 'time' attr".format(attr._name)) self.assertTrue(isAxis(getattr(attr, 'time')), "'time' attr is not axis object for signal {}".format(attr._name)) for axisname in attr.axes: self.assertTrue(hasattr(attr, axisname), "'axes' element {} not an attribute for signal {}".format( axisname, attr._name)) axis = getattr(attr, axisname) self.assertTrue(isAxis(axis), "'axes' element {} is not axis object for signal {}".format( axisname, attr._name)) for sigattrname in dir(attr): sigattr = getattr(attr, sigattrname) if isAxis(sigattr): self.assertIn(sigattrname, attr.axes, "{} is axis but not in 'axes' attr for signal {}".format( sigattrname, attr._name))
def infoSignal(obj, verbose=False, *args, **kwargs): obj[:] if obj.size == 0: return print('Name: {}'.format(dottedPath(obj))) if verbose: print(' Shot: {}'.format(obj.shot)) print(' Description: {}'.format(obj._desc)) print(' Title: {}'.format(obj._title)) print(' MDS node: {}'.format(obj._mdsnode)) print(' MDS tree: {}'.format(obj._mdstree)) print(' Shape: {}'.format(obj.shape)) for attrname in obj.listAttributes(): attr = getattr(obj, attrname) if isAxis(attr): print(' Axis {}: {} points'.format(attr._name, attr.size)) else: print(' {}: {}'.format(attrname, attr))