Skip to content

Commit

Permalink
Revert "demo changes"
Browse files Browse the repository at this point in the history
This reverts commit e879a9e.
  • Loading branch information
lachlangrose committed Mar 25, 2024
1 parent e879a9e commit 00a34aa
Showing 1 changed file with 4 additions and 39 deletions.
43 changes: 4 additions & 39 deletions LoopStructural/modelling/core/geological_model.py
Expand Up @@ -172,51 +172,16 @@ def to_dict(self):
json : str
json string of the geological model
"""

def convert_to_serializable(obj): #inf and nan to none
if isinstance(obj, dict):
return {key: convert_to_serializable(value) for key, value in obj.items()}
elif isinstance(obj, list):
return [convert_to_serializable(item) for item in obj]
elif isinstance(obj, float):
if np.isinf(obj) or np.isnan(obj):
return None
else:
return obj
else:
return obj
json = {}
json["model"] = {}

json["model"]["features"] = [f.name for f in self.features]
# json["model"]["data"] = convert_to_serializable(self.data.to_dict(orient='records'))
json["model"]["data"] = self.data.to_json()
json["model"]["origin"] = self.origin.tolist()
json["model"]["maximum"] = self.maximum.tolist()
json["model"]["nsteps"] = list(self.nsteps)
json["model"]["stratigraphic_column"] = convert_to_serializable(self.stratigraphic_column)
json["features"] = [convert_to_serializable(f.to_json()) for f in self.features]

json["model"]["nsteps"] = self.nsteps
json["model"]["stratigraphic_column"] = self.stratigraphic_column
json["features"] = [f.to_json() for f in self.features]
return json

# def to_dict(self):
# """
# Convert the geological model to a json string

# Returns
# -------
# json : str
# json string of the geological model
# """
# json = {}
# json["model"] = {}
# json["model"]["features"] = [f.name for f in self.features]
# json["model"]["data"] = self.data.to_json()
# json["model"]["origin"] = self.origin.tolist()
# json["model"]["maximum"] = self.maximum.tolist()
# json["model"]["nsteps"] = self.nsteps
# json["model"]["stratigraphic_column"] = self.stratigraphic_column
# json["features"] = [f.to_json() for f in self.features]
# return json

# @classmethod
# def from_json(cls,json):
Expand Down

0 comments on commit 00a34aa

Please sign in to comment.