Skip to content

MNT: Rename radius to radius_function in CylindricalTank and SphericalTank#957

Merged
Gui-FernandesBR merged 7 commits into
developfrom
copilot/fix-tankgeometry-radius-conflict
Jun 19, 2026
Merged

MNT: Rename radius to radius_function in CylindricalTank and SphericalTank#957
Gui-FernandesBR merged 7 commits into
developfrom
copilot/fix-tankgeometry-radius-conflict

Conversation

Copilot AI commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

CylindricalTank and SphericalTank stored their scalar radius input privately (__input_radius) while the TankGeometry.radius property returns a PiecewiseFunction. This meant StochasticModel (which calls getattr(obj, input_name)) would get the Function instead of the original scalar when accessing obj.radius.

Changes

  • CylindricalTank / SphericalTank: Renamed constructor parameter radiusradius_function; stored as self.radius_function (public), replacing the private __input_radius
  • Backward compat: Old radius= keyword arg accepted via **kwargs with a DeprecationWarning pointing to radius_function
  • Serialization: to_dict() now emits "radius_function" key; from_dict() handles both keys (deprecated "radius" triggers DeprecationWarning)
  • Tests: Regression tests added for new attribute, deprecation paths (kwarg and deserialization), and to_dict key name

Migration

# Old (still works, raises DeprecationWarning)
tank = CylindricalTank(radius=0.1, height=2.0)
tank = SphericalTank(radius=0.05)

# New
tank = CylindricalTank(radius_function=0.1, height=2.0)
tank = SphericalTank(radius_function=0.05)

# Positional calls are unchanged
tank = CylindricalTank(0.1, 2.0)

After this change, obj.radius_function returns the original scalar input while obj.radius continues to return the PiecewiseFunction of height.

Pull request type

  • Code maintenance (refactoring, formatting, tests)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

CylindricalTank(radius=0.1, height=2.0).radius returns a PiecewiseFunction, not 0.1. StochasticModels that call getattr(obj, 'radius') to retrieve the nominal scalar value get the wrong type.

New behavior

obj.radius_function exposes the original scalar input. obj.radius is unchanged (still the PiecewiseFunction). Old radius= usage triggers DeprecationWarning.

Breaking change

  • Yes

Keyword-argument callers using radius= will see a DeprecationWarning. Serialized data with a "radius" key in to_dict() output will trigger a DeprecationWarning on from_dict(). Positional callers are unaffected.

Copilot AI linked an issue Apr 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix name conflict in radius property and input of TankGeometry MNT: Rename radius to radius_function in CylindricalTank and SphericalTank Apr 29, 2026
Copilot AI requested a review from Gui-FernandesBR April 29, 2026 19:46
@Gui-FernandesBR Gui-FernandesBR force-pushed the copilot/fix-tankgeometry-radius-conflict branch from 17c4ac8 to df04850 Compare June 19, 2026 02:15
@Gui-FernandesBR Gui-FernandesBR marked this pull request as ready for review June 19, 2026 02:16
@Gui-FernandesBR Gui-FernandesBR requested a review from a team as a code owner June 19, 2026 02:16
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.17%. Comparing base (9cf3dd4) to head (0afb22f).
⚠️ Report is 80 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/motors/tank_geometry.py 81.25% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #957      +/-   ##
===========================================
+ Coverage    80.27%   81.17%   +0.90%     
===========================================
  Files          104      113       +9     
  Lines        12769    14689    +1920     
===========================================
+ Hits         10250    11924    +1674     
- Misses        2519     2765     +246     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Comment thread CHANGELOG.md
Comment thread rocketpy/motors/tank_geometry.py

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Gui-FernandesBR Gui-FernandesBR merged commit 3fbecdd into develop Jun 19, 2026
7 checks passed
@Gui-FernandesBR Gui-FernandesBR deleted the copilot/fix-tankgeometry-radius-conflict branch June 19, 2026 03:03
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.

MNT: Name Conflict in radius property and input of TankGeometry

2 participants