From 1f2a044f018f989eb5593fffd690b53c9d7f4721 Mon Sep 17 00:00:00 2001 From: raphaeltimbo Date: Thu, 24 Aug 2023 15:18:43 -0300 Subject: [PATCH] Add warning about not saving modal_results 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. --- ross/results.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ross/results.py b/ross/results.py index 55d9083ac..0c7ee249b 100644 --- a/ross/results.py +++ b/ross/results.py @@ -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()) @@ -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:] @@ -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.