From 4f9458f3a4f32f88a6362778c059b9e2b3feb96e Mon Sep 17 00:00:00 2001 From: DiegoMargoni Date: Sun, 22 Sep 2024 18:36:17 +0200 Subject: [PATCH] change: Refactor method names for animating mode 2 in Example2 and Example3 - Renamed `Pali_ss.anim_mode_g2` to `Pali_ss.anim_mode_geo2` in `Example2 - Real dataset.rst` - Renamed `msp.anim_mode_g2` to `msp.anim_mode_geo2` in `Example3 - Multisetup PoSER.rst` - Updated method calls in relevant test files --- CHANGELOG.md | 5 +++++ Examples/Example2.ipynb | 4 ++-- Examples/Example3.ipynb | 4 ++-- docs/Example2 - Real dataset.rst | 2 +- docs/Example3 - Multisetup PoSER.rst | 2 +- src/pyoma2/algorithms/data/result.py | 11 ++--------- src/pyoma2/algorithms/data/run_params.py | 14 +++++++------- src/pyoma2/support/geometry/mixin.py | 2 +- tests/integration/setup/test_multi_setup_poser.py | 2 +- tests/integration/setup/test_single_setup.py | 2 +- 10 files changed, 23 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bc64..a84686e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Renamed `anim_mode_g2` to `anim_mode_geo2` in `GeometryMixin` class +- Updated hierarchy for results and run_params classes + ## [1.0.0] - 2024-09-12 diff --git a/Examples/Example2.ipynb b/Examples/Example2.ipynb index bac52f5..85cb8a8 100644 --- a/Examples/Example2.ipynb +++ b/Examples/Example2.ipynb @@ -647,7 +647,7 @@ "outputs": [], "source": [ "# Animate mode 1 (geometry 2)\n", - "_ = Pali_ss.anim_mode_g2(\n", + "_ = Pali_ss.anim_mode_geo2(\n", " algo_res=ssicov.result, mode_nr=1, scaleF=3)" ] }, @@ -733,7 +733,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/Examples/Example3.ipynb b/Examples/Example3.ipynb index 3c2a421..26b8b4c 100644 --- a/Examples/Example3.ipynb +++ b/Examples/Example3.ipynb @@ -369,7 +369,7 @@ "outputs": [], "source": [ "# Animate mode 5 (geometry 2, pyvista)\n", - "_ = msp.anim_mode_g2(\n", + "_ = msp.anim_mode_geo2(\n", " algo_res=algoRes, mode_nr=5, scaleF=3, notebook=True)" ] }, @@ -414,7 +414,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/Example2 - Real dataset.rst b/docs/Example2 - Real dataset.rst index 1a482aa..952eff3 100644 --- a/docs/Example2 - Real dataset.rst +++ b/docs/Example2 - Real dataset.rst @@ -248,7 +248,7 @@ the analysis .. code:: python # Animate mode 1 (geometry 2) - Pali_ss.anim_mode_g2( + Pali_ss.anim_mode_geo2( algo_res=ssicov.result, mode_nr=1, scaleF=3) .. image:: /img/Ex2-Fig15.gif diff --git a/docs/Example3 - Multisetup PoSER.rst b/docs/Example3 - Multisetup PoSER.rst index e75ac6d..5a677ac 100644 --- a/docs/Example3 - Multisetup PoSER.rst +++ b/docs/Example3 - Multisetup PoSER.rst @@ -148,7 +148,7 @@ geometry on it and then plot or animate the mode shapes _, _ = msp.plot_mode_geo2_mpl( algo_res=algoRes, mode_nr=4, view="xz", scaleF=3) # Animate mode 5 (geometry 2, pyvista) - _ = msp.anim_mode_g2( + _ = msp.anim_mode_geo2( algo_res=algoRes, mode_nr=5, scaleF=3) .. figure:: /img/Ex3-Fig4.png diff --git a/src/pyoma2/algorithms/data/result.py b/src/pyoma2/algorithms/data/result.py index 54ce635..15c53e1 100644 --- a/src/pyoma2/algorithms/data/result.py +++ b/src/pyoma2/algorithms/data/result.py @@ -54,7 +54,7 @@ class FDDResult(BaseResult): S_vec: typing.Optional[npt.NDArray[np.float64]] = None -class EFDDResult(BaseResult): +class EFDDResult(FDDResult): """ Class for storing results data from Enhanced Frequency Domain Decomposition (EFDD) and Frequency Spatial Domain Decomposition (FSDD). @@ -75,10 +75,6 @@ class EFDDResult(BaseResult): A list to store data for plotting purposes. """ - freq: typing.Optional[npt.NDArray[np.float64]] = None - Sy: typing.Optional[npt.NDArray[np.float64]] = None - S_val: typing.Optional[npt.NDArray[np.float64]] = None - S_vec: typing.Optional[npt.NDArray[np.float64]] = None # dopo mpe, MPE_forPlot Xi: typing.Optional[npt.NDArray[np.float64]] = None # array of damping ratios forPlot: typing.Optional[typing.List] = None @@ -193,7 +189,7 @@ class pLSCFResult(BaseResult): order_out: typing.Union[typing.List[int], int, None] = None -class MsPoserResult(BaseModel): +class MsPoserResult(BaseResult): """ Base class for MultiSetup Poser result data. @@ -211,9 +207,6 @@ class MsPoserResult(BaseModel): Covariance of damping ratios. """ - model_config = ConfigDict(from_attributes=True, arbitrary_types_allowed=True) - Phi: npt.NDArray[np.float64] - Fn: npt.NDArray[np.float64] Fn_cov: npt.NDArray[np.float64] Xi: npt.NDArray[np.float64] Xi_cov: npt.NDArray[np.float64] diff --git a/src/pyoma2/algorithms/data/run_params.py b/src/pyoma2/algorithms/data/run_params.py index 4f46c53..4a244a5 100644 --- a/src/pyoma2/algorithms/data/run_params.py +++ b/src/pyoma2/algorithms/data/run_params.py @@ -44,7 +44,7 @@ class FDDRunParams(BaseRunParams): # METODO 1: run nxseg: int = 1024 - method_SD: str = "per" + method_SD: typing.Literal["per", "cor"] = "per" pov: float = 0.5 # METODO 2: mpe e mpe_from_plot sel_freq: typing.Optional[npt.NDArray[np.float64]] = None @@ -85,7 +85,7 @@ class EFDDRunParams(BaseRunParams): # METODO 1: run nxseg: int = 1024 - method_SD: str = "per" + method_SD: typing.Literal["per", "cor"] = "per" pov: float = 0.5 # METODO 2: mpe e mpe_from_plot sel_freq: typing.Optional[npt.NDArray[np.float64]] = None @@ -154,8 +154,8 @@ class SSIRunParams(BaseRunParams): ordmin: int = 0 ordmax: typing.Optional[int] = None step: int = 1 - sc: dict = dict(err_fn=0.01, err_xi=0.05, err_phi=0.03) # soft criteria - hc: dict = dict( + sc: typing.Dict = dict(err_fn=0.01, err_xi=0.05, err_phi=0.03) # soft criteria + hc: typing.Dict = dict( conj=True, xi_max=0.1, mpc_lim=0.7, mpd_lim=0.3, cov_max=0.2 ) # hard criteria calc_unc: bool = False # uncertainty calculations @@ -217,12 +217,12 @@ class pLSCFRunParams(BaseRunParams): ordmax: int ordmin: int = 0 nxseg: int = 1024 - method_SD: str = "per" + method_SD: typing.Literal["per", "cor"] = "per" pov: float = 0.5 # sgn_basf: int = -1 # step: int = 1 - sc: dict = dict(err_fn=0.01, err_xi=0.05, err_phi=0.03) - hc: dict = dict(conj=True, xi_max=0.1, mpc_lim=0.7, mpd_lim=0.3) + sc: typing.Dict = dict(err_fn=0.01, err_xi=0.05, err_phi=0.03) + hc: typing.Dict = dict(conj=True, xi_max=0.1, mpc_lim=0.7, mpd_lim=0.3) # METODO 2: mpe e mpe_from_plot sel_freq: typing.Optional[typing.List[float]] = None order_in: typing.Union[int, str] = "find_min" diff --git a/src/pyoma2/support/geometry/mixin.py b/src/pyoma2/support/geometry/mixin.py index 77a15e8..f9549da 100644 --- a/src/pyoma2/support/geometry/mixin.py +++ b/src/pyoma2/support/geometry/mixin.py @@ -708,7 +708,7 @@ def plot_mode_geo2_mpl( return fig, ax # PLOT MODI - PyVista plotter - def anim_mode_g2( + def anim_mode_geo2( self, algo_res: BaseResult, mode_nr: int = 1, diff --git a/tests/integration/setup/test_multi_setup_poser.py b/tests/integration/setup/test_multi_setup_poser.py index 5930001..3cc97a5 100644 --- a/tests/integration/setup/test_multi_setup_poser.py +++ b/tests/integration/setup/test_multi_setup_poser.py @@ -69,7 +69,7 @@ def test_geo2(ms_poser: MultiSetup_PoSER) -> None: # define results variable algo_res = result["the_coolest_algo"] - # PLOTE_MODE_G2 + # PLOTE_MODE_geo2 try: _ = ms_poser.plot_mode_geo2(algo_res=algo_res, mode_nr=1, scaleF=3, notebook=True) # assert isinstance(fig, Figure) diff --git a/tests/integration/setup/test_single_setup.py b/tests/integration/setup/test_single_setup.py index e2be3c9..f73a6b5 100644 --- a/tests/integration/setup/test_single_setup.py +++ b/tests/integration/setup/test_single_setup.py @@ -489,7 +489,7 @@ def test_run(ss: SingleSetup) -> None: except Exception as e: assert False, f"plot_mode_geo1 raised an exception {e} for FDD" - # PLOTE_MODE_G2 + # PLOTE_MODE_geo2 try: _ = ss.plot_mode_geo2(algo_res=fsdd.result, mode_nr=2, view="3D", scaleF=2) except Exception as e: