fix None models case
@@ -470,6 +470,7 @@ class ProperModels(Models):
else:
raise TypeError(f"Invalid type: {other!r}")
for d in self._datasets:
+ if d._models is not None:
for m in other:
if m not in d._models:
d._models.append(m)
@@ -482,6 +483,7 @@ class ProperModels(Models):
def __delitem__(self, key):
for d in self._datasets:
+ if d._models is not None:
if key in d._models.names:
datasets_names = d._models[key].datasets_names
if datasets_names is None or d.name in datasets_names:
@@ -491,6 +493,7 @@ class ProperModels(Models):
from gammapy.modeling.models import SkyModel, SkyDiffuseCube
for d in self._datasets:
+ if d._models is not None:
if model in d._models:
if isinstance(model, (SkyModel, SkyDiffuseCube)):
d._models[key] = model
@@ -507,6 +510,7 @@ class ProperModels(Models):
from gammapy.modeling.models import SkyModel, SkyDiffuseCube
for d in self._datasets:
+ if d._models is not None:
if model.name not in d._models.names:
if isinstance(model, (SkyModel, SkyDiffuseCube)):
d._models.insert(idx, model)
