Skip to content

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

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-tankgeometry-radius-conflict
Draft

MNT: Rename radius to radius_function in CylindricalTank and SphericalTank#957
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-tankgeometry-radius-conflict

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

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 and others added 2 commits April 29, 2026 19:43
…lTank

Agent-Logs-Url: https://github.com/RocketPy-Team/RocketPy/sessions/34182dad-3a90-44dc-96a2-e29c6a9b9f55

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
…ion parameter

Agent-Logs-Url: https://github.com/RocketPy-Team/RocketPy/sessions/34182dad-3a90-44dc-96a2-e29c6a9b9f55

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
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
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