def merge(self, other, selfContainer, otherContainer, fileType, exceptionClass): """ Merge the contents of two metadata instances. Parameters ---------- other: Similar Metadata class as self Metadata to be compared against selfContainer: class otherContainer: class Objects that hold the two metadata instances fileType: str File type that created this metadata. Examples: ``'ISOTXS', 'GAMISO', 'COMPXS'``` exceptionClass: Exception Type of exception to raise in the event of dissimilar metadata values Returns ------- mergedData: Metadata Returns a metadata instance of similar type as ``self`` and ``other`` containing the correctly merged data of the two """ mergedData = self.__class__() if not (any(self.keys()) and any(other.keys())): mergedData.update(self) mergedData.update(other) return mergedData self._mergeLibrarySpecificData(other, selfContainer, otherContainer, mergedData) skippedKeys = self._getSkippedKeys(other, selfContainer, otherContainer, mergedData) for key in set(list(self.keys()) + list(other.keys())) - skippedKeys: selfVal = self[key] otherVal = other[key] mergedVal = None if not properties.numpyHackForEqual(selfVal, otherVal): raise exceptionClass( "{libType} {key} metadata differs between {lib1} and {lib2}; Cannot Merge\n" "{key} has values of {val1} and {val2}".format( libType=fileType, lib1=selfContainer, lib2=otherContainer, key=key, val1=selfVal, val2=otherVal, )) else: mergedVal = selfVal mergedData[key] = mergedVal return mergedData
def compareNuclideXS(nuc1, nuc2): equal = nuc1.pmatrxMetadata.compare(nuc2.pmatrxMetadata, nuc1.container, nuc2.container) for attrName in [ "neutronHeating", "neutronDamage", "gammaHeating", "isotropicProduction", "linearAnisotropicProduction", "nOrderProductionMatrix", ]: val1 = getattr(nuc1, attrName) val2 = getattr(nuc2, attrName) if not properties.numpyHackForEqual(val1, val2): runLog.important( "{} and {} have different `{}` attributes:\n{}\n{}".format( nuc1, nuc2, attrName, val1, val2)) equal &= False return equal