Add skip-computation pattern for bearing/seal element loading#1260
Merged
raphaeltimbo merged 2 commits intopetrobras:mainfrom Feb 14, 2026
Merged
Add skip-computation pattern for bearing/seal element loading#1260raphaeltimbo merged 2 commits intopetrobras:mainfrom
raphaeltimbo merged 2 commits intopetrobras:mainfrom
Conversation
Override read_toml_data in BearingElement to pass saved coefficients through to __init__ via kwargs. Add early-return skip paths in MagneticBearingElement, CylindricalBearing, BallBearingElement, and RollerBearingElement to avoid recomputing coefficients when loading from file. Introduce _save_attrs class-level attribute for persisting derived quantities (e.g. eccentricity, sommerfeld) beyond init parameters, used by CylindricalBearing to round-trip its derived attributes.
Update save() and load() docstrings to explain that element coefficients are restored without recomputation on load. Add a warning comment at the top of saved files (TOML comment for .toml, "_note" key for .json) stating that manual edits will not trigger recalculation. Skip keys starting with "_" in Rotor.load() to handle the JSON warning key.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1260 +/- ##
==========================================
+ Coverage 77.57% 77.62% +0.05%
==========================================
Files 48 48
Lines 13310 13347 +37
==========================================
+ Hits 10325 10361 +36
- Misses 2985 2986 +1
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_toml_datainBearingElementso saved coefficients (kxx, cxx, etc.) are passed through to__init__via**kwargs, fixing a gap where subclass coefficients were dropped on loadMagneticBearingElement,CylindricalBearing,BallBearingElement, andRollerBearingElementto avoid recomputing coefficients when loading from file (triggered whenkxxis present in kwargs)_save_attrsclass-level attribute for persisting derived quantities beyond init parameters, used byCylindricalBearingto round-tripeccentricity,attitude_angle,sommerfeld, andmodified_sommerfeldTest plan
test_save_load_subclasses— round-trip save/load for BallBearing, RollerBearing, CylindricalBearing, MagneticBearing; verifies equality, isinstance, and derived attribute preservationtest_save_load_skips_computation— verifies K/C matrices match after loadpytest ross)