Skip to content

Commit 4ee4c7d

Browse files
committed
ENH: remove set_deployment_level and cached_property
1 parent 85f3a47 commit 4ee4c7d

File tree

6 files changed

+19
-36
lines changed

6 files changed

+19
-36
lines changed

docs/notebooks/air_brakes_example.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
"\n",
228228
" # If below 1500 meters above ground level, air_brakes are not deployed\n",
229229
" if altitude_AGL < 1500:\n",
230-
" air_brakes.set_deployment_level(0)\n",
230+
" air_brakes.deployment_level = 0\n",
231231
"\n",
232232
" # Else calculate the deployment level\n",
233233
" else:\n",
@@ -244,7 +244,7 @@
244244
" upper_bound = air_brakes.deployment_level + max_change\n",
245245
" new_deployment_level = min(max(new_deployment_level, lower_bound), upper_bound)\n",
246246
"\n",
247-
" air_brakes.set_deployment_level(new_deployment_level)\n",
247+
" air_brakes.deployment_level = new_deployment_level\n",
248248
"\n",
249249
" # Return variables of interest to be saved in the observed_variables list\n",
250250
" return (\n",

docs/user/airbrakes.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,9 @@ To create an air brakes model, we essentially need to define the following:
9191
- The **controller function**, which takes in as argument information about the
9292
simulation up to the current time step, and the ``AirBrakes`` instance being
9393
defined, and sets the desired air brakes' deployment level. The air brakes'
94-
deployment level must be between 0 and 1, and must be set using the
95-
``set_deployment_level`` method of the ``AirBrakes`` instance being controlled.
96-
Inside this function, any controller logic, filters, and apogee prediction
97-
can be implemented.
94+
deployment level must be between 0 and 1, and is set using the
95+
``deployment_level`` attribute. Inside this function, any controller logic,
96+
filters, and apogee prediction can be implemented.
9897

9998
- The **sampling rate** of the controller function, in seconds. This is the time
10099
between each call of the controller function, in simulation time. Must be
@@ -197,7 +196,7 @@ Lets define the controller function:
197196

198197
# If below 1500 meters above ground level, air_brakes are not deployed
199198
if altitude_AGL < 1500:
200-
air_brakes.set_deployment_level(0)
199+
air_brakes.deployment_level = 0
201200

202201
# Else calculate the deployment level
203202
else:
@@ -214,7 +213,7 @@ Lets define the controller function:
214213
upper_bound = air_brakes.deployment_level + max_change
215214
new_deployment_level = min(max(new_deployment_level, lower_bound), upper_bound)
216215

217-
air_brakes.set_deployment_level(new_deployment_level)
216+
air_brakes.deployment_level = new_deployment_level
218217

219218
# Return variables of interest to be saved in the observed_variables list
220219
return (

rocketpy/rocket/aero_surface.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,21 +2015,6 @@ def deployment_level(self, value):
20152015
)
20162016
self._deployment_level = value
20172017

2018-
def set_deployment_level(self, deployment_level):
2019-
"""Set airbrake deployment level.
2020-
2021-
Parameters
2022-
----------
2023-
deployment_level : float
2024-
Current deployment level, ranging from 0 to 1. Deployment level is the
2025-
fraction of the total airbrake area that is deployment.
2026-
2027-
Returns
2028-
-------
2029-
None
2030-
"""
2031-
self.deployment_level = deployment_level
2032-
20332018
def evaluate_center_of_pressure(self):
20342019
"""Evaluates the center of pressure of the aerodynamic surface in local
20352020
coordinates.

rocketpy/simulation/flight.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2912,7 +2912,6 @@ def retrieve_temporary_values_arrays(self):
29122912

29132913
return temporary_values
29142914

2915-
@cached_property
29162915
def get_controller_observed_variables(self):
29172916
"""Retrieve the observed variables related to air brakes from the
29182917
controllers. If there is only one set of observed variables, it is

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ def controller_function(
12821282
if time < 3.9:
12831283
return None
12841284
if z < 1500:
1285-
air_brakes.set_deployment_level(0)
1285+
air_brakes.deployment_level = 0
12861286
else:
12871287
new_deployment_level = (
12881288
air_brakes.deployment_level + 0.1 * vz + 0.01 * previous_vz**2
@@ -1295,7 +1295,7 @@ def controller_function(
12951295
new_deployment_level = air_brakes.deployment_level - 0.2 / sampling_rate
12961296
else:
12971297
new_deployment_level = air_brakes.deployment_level
1298-
air_brakes.set_deployment_level(new_deployment_level)
1298+
air_brakes.deployment_level = new_deployment_level
12991299

13001300
return controller_function
13011301

tests/test_rocket.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def test_airfoil(
141141
@patch("matplotlib.pyplot.show")
142142
def test_air_brakes_clamp_on(mock_show, calisto_air_brakes_clamp_on):
143143
"""Test the air brakes class with clamp on configuration. This test checks
144-
the basic attributes and the set_deployment_level method. It also checks the
144+
the basic attributes and the deployment_level setter. It also checks the
145145
all_info method.
146146
147147
Parameters
@@ -160,13 +160,13 @@ def test_air_brakes_clamp_on(mock_show, calisto_air_brakes_clamp_on):
160160
air_brakes_clamp_on.reference_area
161161
== calisto_air_brakes_clamp_on.radius**2 * np.pi
162162
)
163-
air_brakes_clamp_on.set_deployment_level(0.5)
163+
air_brakes_clamp_on.deployment_level = 0.5
164164
assert air_brakes_clamp_on.deployment_level == 0.5
165-
air_brakes_clamp_on.set_deployment_level(1.5)
165+
air_brakes_clamp_on.deployment_level = 1.5
166166
assert air_brakes_clamp_on.deployment_level == 1
167-
air_brakes_clamp_on.set_deployment_level(-1)
167+
air_brakes_clamp_on.deployment_level = -1
168168
assert air_brakes_clamp_on.deployment_level == 0
169-
air_brakes_clamp_on.set_deployment_level(0)
169+
air_brakes_clamp_on.deployment_level = 0
170170
assert air_brakes_clamp_on.deployment_level == 0
171171

172172
assert air_brakes_clamp_on.all_info() == None
@@ -175,7 +175,7 @@ def test_air_brakes_clamp_on(mock_show, calisto_air_brakes_clamp_on):
175175
@patch("matplotlib.pyplot.show")
176176
def test_air_brakes_clamp_off(mock_show, calisto_air_brakes_clamp_off):
177177
"""Test the air brakes class with clamp off configuration. This test checks
178-
the basic attributes and the set_deployment_level method. It also checks the
178+
the basic attributes and the deployment_level setter. It also checks the
179179
all_info method.
180180
181181
Parameters
@@ -195,13 +195,13 @@ def test_air_brakes_clamp_off(mock_show, calisto_air_brakes_clamp_off):
195195
== calisto_air_brakes_clamp_off.radius**2 * np.pi
196196
)
197197

198-
air_brakes_clamp_off.set_deployment_level(0.5)
198+
air_brakes_clamp_off.deployment_level = 0.5
199199
assert air_brakes_clamp_off.deployment_level == 0.5
200-
air_brakes_clamp_off.set_deployment_level(1.5)
200+
air_brakes_clamp_off.deployment_level = 1.5
201201
assert air_brakes_clamp_off.deployment_level == 1.5
202-
air_brakes_clamp_off.set_deployment_level(-1)
202+
air_brakes_clamp_off.deployment_level = -1
203203
assert air_brakes_clamp_off.deployment_level == -1
204-
air_brakes_clamp_off.set_deployment_level(0)
204+
air_brakes_clamp_off.deployment_level = 0
205205
assert air_brakes_clamp_off.deployment_level == 0
206206

207207
assert air_brakes_clamp_off.all_info() == None

0 commit comments

Comments
 (0)