# Licensed under a 3-clause BSD style license - see LICENSE.rstimportabcimportinspectfromcopyimportdeepcopyimportnumpyasnpfromastropyimportunitsasufromgammapy.mapsimportMapAxisfromgammapy.modeling.modelsimportModelBase__all__=["Estimator"]
[docs]classEstimator(abc.ABC):"""Abstract estimator base class."""_available_selection_optional={}@property@abc.abstractmethoddeftag(self):pass
@propertydefselection_optional(self):""""""returnself._selection_optional@selection_optional.setterdefselection_optional(self,selection):"""Set optional selection"""available=self._available_selection_optionalifselectionisNone:self._selection_optional=[]elif"all"inselection:self._selection_optional=availableelse:ifset(selection).issubset(set(available)):self._selection_optional=selectionelse:difference=set(selection).difference(set(available))raiseValueError(f"{difference} is not a valid method.")def_get_energy_axis(self,dataset):"""Energy axis"""ifself.energy_edgesisNone:energy_axis=dataset.counts.geom.axes["energy"].squash()else:energy_axis=MapAxis.from_energy_edges(self.energy_edges)returnenergy_axis