Skip to content

Add skip-computation pattern for bearing/seal element loading#1260

Merged
raphaeltimbo merged 2 commits intopetrobras:mainfrom
raphaeltimbo:add-skip-computation
Feb 14, 2026
Merged

Add skip-computation pattern for bearing/seal element loading#1260
raphaeltimbo merged 2 commits intopetrobras:mainfrom
raphaeltimbo:add-skip-computation

Conversation

@raphaeltimbo
Copy link
Collaborator

@raphaeltimbo raphaeltimbo commented Feb 14, 2026

Summary

  • Override read_toml_data in BearingElement so saved coefficients (kxx, cxx, etc.) are passed through to __init__ via **kwargs, fixing a gap where subclass coefficients were dropped on load
  • Add early-return skip paths in MagneticBearingElement, CylindricalBearing, BallBearingElement, and RollerBearingElement to avoid recomputing coefficients when loading from file (triggered when kxx is present in kwargs)
  • Introduce _save_attrs class-level attribute for persisting derived quantities beyond init parameters, used by CylindricalBearing to round-trip eccentricity, attitude_angle, sommerfeld, and modified_sommerfeld

Test plan

  • Added test_save_load_subclasses — round-trip save/load for BallBearing, RollerBearing, CylindricalBearing, MagneticBearing; verifies equality, isinstance, and derived attribute preservation
  • Added test_save_load_skips_computation — verifies K/C matrices match after load
  • All 33 bearing/seal tests pass
  • Run full test suite (pytest ross)

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-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.62%. Comparing base (a71eded) to head (0b12f6b).

Files with missing lines Patch % Lines
ross/bearing_seal_element.py 93.33% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
ross/rotor_assembly.py 93.26% <100.00%> (+0.04%) ⬆️
ross/bearing_seal_element.py 89.08% <93.33%> (+0.35%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a71eded...0b12f6b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raphaeltimbo raphaeltimbo merged commit d4aa6fc into petrobras:main Feb 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants