Skip to content

Commit

Permalink
fix cosmo serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
andreatramacere committed Apr 14, 2024
1 parent 388856a commit 14f2ede
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion jetset/cosmo_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def get_DL_cm(self,z=None):
return _d

def _serialize_model(self):
#print("serializing cosmo")
_model = {}
if self._c is not None:
_model['_astropy_cosmo']=Table(self._c.to_format('astropy.table'))
Expand All @@ -82,6 +81,11 @@ def __getstate__(self):
def __setstate__(self,state):
astropy_cosmo,DL_cm=self._decode_model(state)
self.__init__(astropy_cosmo=astropy_cosmo,DL_cm=DL_cm)

@classmethod
def from_model(cls,model):
astropy_cosmo,DL_cm = cls._decode_model(model)
return cls(astropy_cosmo,DL_cm)


@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions jetset/jet_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ def _decode_model(self,_model):
self._set_version(_model['version'])
else:
self._set_version(v='unknown(<1.1.2)')

self.cosmo = Cosmo(astropy_cosmo=_model['cosmo']['_astropy_cosmo'],DL_cm=_model['cosmo']['_DL_cm'])
self.cosmo = Cosmo.from_model(_model['cosmo'])
self.model_type = 'jet'
self.name = _model['name']
if 'geometry' in _model.keys():
Expand Down

0 comments on commit 14f2ede

Please sign in to comment.