Skip to content

Commit

Permalink
Add warning about not saving modal_results
Browse files Browse the repository at this point in the history
To save modal_results inside CampbellResults we would need to edit the
data dictionary which is dumped in the .toml file.
The key for each modal_result would need to be changed from float to str
and we would need to add nested dicts inside data to store the modal
result.
The load method for the CampbellResults class would also need to be
modified to first load the modal_results and then the remaining data to
be able to instantiate the CampbellResults.
  • Loading branch information
raphaeltimbo committed Aug 24, 2023
1 parent fb18445 commit 1f2a044
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ross/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def save(self, file):
data = {}

data[f"{self.__class__.__name__}"] = args

try:
del data["CampbellResults"]["modal_results"]
except KeyError:
pass

with open(file, "w") as f:
toml.dump(data, f, encoder=toml.TomlNumpyEncoder())

Expand Down Expand Up @@ -148,6 +154,8 @@ def load(cls, file):

data = toml.load(file)
data = list(data.values())[0]
if cls == CampbellResults:
data["modal_results"] = None
for key, value in data.items():
if key == "rotor":
aux_file = str(file)[:-5] + "_rotor" + str(file)[-5:]
Expand Down Expand Up @@ -1667,6 +1675,20 @@ def _plot_with_mode_shape_callback(trace, points, state):

return VBox([camp_fig, plot_mode_3d])

def save(self, file):
# TODO save modal results
warn(
"The CampbellResults.save method is not saving the attribute 'modal_results' for now."
)
super().save(file)

@classmethod
def load(cls, file):
warn(
"The CampbellResults.save method is not saving the attribute 'modal_results' for now."
)
return super().load(file)


class FrequencyResponseResults(Results):
"""Class used to store results and provide plots for Frequency Response.
Expand Down

0 comments on commit 1f2a044

Please sign in to comment.