def _validate_NuFlav(self, signature): if self.interactions: if not isinstance(signature, flavInt.NuFlavInt): signature = flavInt.NuFlavInt(signature) else: if not isinstance(signature, flavInt.NuFlav): signature = flavInt.NuFlav(signature) if signature not in self._spline_dict: raise ValueError('signature {0} not loaded, choices are: ' '{1}'.format(signature, self._spline_dict.keys())) return signature
def __getattr__(self, attr): try: if self.interactions: sign = str(flavInt.NuFlavInt(attr)) else: sign = str(flavInt.NuFlav(attr)) except: raise ValueError('{0} is not a value signature'.format(attr)) for signature in self._spline_data.iterkeys(): if self._spline_data[signature].name == sign: return self._spline_data[signature] return super(CombinedSpline, self).__getattribute__(sign)
def __init__(self, inSpline, interactions=True, ver=None): super(CombinedSpline, self).__init__() self.interactions = interactions if isinstance(inSpline, Spline): inSpline = [inSpline] if not all(isinstance(x, Spline) for x in inSpline): raise TypeError('Argument/object unhandled type: ' '{0}'.format(type(inSpline))) if interactions: self._spline_dict = {flavInt.NuFlavInt(flavint.name): flavint for flavint in inSpline} self._spline_data = {flavInt.NuFlavInt(flavint.name): None for flavint in inSpline} else: self._spline_dict = {flavInt.NuFlav(flav.name): flav for flav in inSpline} self._spline_data = {flavInt.NuFlav(flav.name): None for flav in inSpline} self._update_data_dict()
def _update_data_dict(self): assert set(self._spline_dict.keys()) == set(self._spline_data.keys()) with flavInt.BarSep('_'): spline = {str(f): {str(it): None for it in flavInt.ALL_NUINT_TYPES} for f in flavInt.ALL_NUFLAVS} for x in self._spline_data.iterkeys(): for y in flavInt.ALL_NUINT_TYPES: if self.interactions: spline[str(flavInt.NuFlav(x))][str(y)] = \ self._spline_data[x] else: spline[str(x)][str(y)] = self._spline_data[x] super(CombinedSpline, self).validate(spline) self.validate_spline(spline) self.update(spline)