def checkUnmodifiedDetectors(self): for detName in UNMODIFIED_DETS: myDet = self.refReader.detectors[detName] otherDet = self.otherReader.detectors[detName] finalMsg = finalCompareMsg(myDet, otherDet, True) self.assertMsgInLogs("INFO", finalMsg)
def compare(self, other, lower=DEF_COMP_LOWER, upper=DEF_COMP_UPPER, sigma=DEF_COMP_SIGMA, verbosity=None): """ Compare the results of this reader to another. For values without uncertainties, the upper and lower arguments control what passes and what messages get raised. If a quantity in ``other`` is less than ``lower`` percent different that the same quantity on this object, consider this allowable and make no messages. Quantities that are greater than ``upper`` percent different will have a error messages printed and the comparison will return ``False``, but continue. Quantities with difference between these ranges will have warning messages printed. Parameters ---------- other: Other reader instance against which to compare. Must be a similar class as this one. {compLimits} {sigma} verbosity: None or str If given, update the verbosity just for this comparison. Returns ------- bool: ``True`` if the objects are in agreement with each other according to the parameters specified Raises ------ {compTypeErr} ValueError If upper > lower, If sigma, lower, or upper are negative """ upper = float(upper) lower = float(lower) sigma = int(sigma) if upper < lower: raise ValueError("Upper limit must be greater than lower. " "{} is not greater than {}".format(upper, lower)) for item, key in zip((upper, lower, sigma), ('upper', 'lower', 'sigma')): if item < 0: raise ValueError("{} must be non-negative, is {}".format( key, item)) self._checkCompareObj(other) previousVerb = None if verbosity is not None: previousVerb = rc['verbosity'] rc['verbosity'] = verbosity self._compareLogPreMsg(other, lower, upper, sigma) areSimilar = self._compare(other, lower, upper, sigma) if areSimilar: herald = info else: herald = warning herald(finalCompareMsg(self, other, areSimilar)) if previousVerb is not None: rc['verbosity'] = previousVerb return areSimilar
def checkFinalStatus(self, obj0, obj1, status): """Assert that the correct final status is logged.""" expected = finalCompareMsg(obj0, obj1, status) level = "INFO" if status else "WARNING" self.assertMsgInLogs(level, expected)