Skip to content

Commit 9adc5fd

Browse files
committed
Run formatter
1 parent ed2fe8b commit 9adc5fd

6 files changed

Lines changed: 98 additions & 65 deletions

File tree

rocketpy/environment/environment.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,22 +2434,26 @@ def add_wind_gust(self, wind_gust_x, wind_gust_y):
24342434

24352435
# Reset wind heading and velocity magnitude
24362436
self.wind_heading = Function(
2437-
lambda h: (180 / np.pi)
2438-
* np.arctan2(
2439-
self.wind_velocity_x.get_value_opt(h),
2440-
self.wind_velocity_y.get_value_opt(h),
2441-
)
2442-
% 360,
2437+
lambda h: (
2438+
(180 / np.pi)
2439+
* np.arctan2(
2440+
self.wind_velocity_x.get_value_opt(h),
2441+
self.wind_velocity_y.get_value_opt(h),
2442+
)
2443+
% 360
2444+
),
24432445
"Height (m)",
24442446
"Wind Heading (degrees)",
24452447
extrapolation="constant",
24462448
)
24472449
self.wind_speed = Function(
24482450
lambda h: (
2449-
self.wind_velocity_x.get_value_opt(h) ** 2
2450-
+ self.wind_velocity_y.get_value_opt(h) ** 2
2451-
)
2452-
** 0.5,
2451+
(
2452+
self.wind_velocity_x.get_value_opt(h) ** 2
2453+
+ self.wind_velocity_y.get_value_opt(h) ** 2
2454+
)
2455+
** 0.5
2456+
),
24532457
"Height (m)",
24542458
"Wind Speed (m/s)",
24552459
extrapolation="constant",

rocketpy/rocket/aero_surface/nose_cone.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,16 @@ def theta(x):
237237
return np.arccos(1 - 2 * max(min(x / self.length, 1), 0))
238238

239239
self.y_nosecone = Function(
240-
lambda x: self.base_radius
241-
* (theta(x) - np.sin(2 * theta(x)) / 2 + (np.sin(theta(x)) ** 3) / 3)
242-
** (0.5)
243-
/ (np.pi**0.5)
240+
lambda x: (
241+
self.base_radius
242+
* (
243+
theta(x)
244+
- np.sin(2 * theta(x)) / 2
245+
+ (np.sin(theta(x)) ** 3) / 3
246+
)
247+
** (0.5)
248+
/ (np.pi**0.5)
249+
)
244250
)
245251

246252
elif value in ["tangent", "tangentogive", "ogive"]:
@@ -253,15 +259,19 @@ def theta(x):
253259
area = np.pi * self.base_radius**2
254260
self.k = 1 - volume / (area * self.length)
255261
self.y_nosecone = Function(
256-
lambda x: np.sqrt(rho**2 - (min(x - self.length, 0)) ** 2)
257-
+ (self.base_radius - rho)
262+
lambda x: (
263+
np.sqrt(rho**2 - (min(x - self.length, 0)) ** 2)
264+
+ (self.base_radius - rho)
265+
)
258266
)
259267

260268
elif value == "elliptical":
261269
self.k = 1 / 3
262270
self.y_nosecone = Function(
263-
lambda x: self.base_radius
264-
* np.sqrt(1 - ((x - self.length) / self.length) ** 2)
271+
lambda x: (
272+
self.base_radius
273+
* np.sqrt(1 - ((x - self.length) / self.length) ** 2)
274+
)
265275
)
266276

267277
elif value == "vonkarman":
@@ -271,15 +281,19 @@ def theta(x):
271281
return np.arccos(1 - 2 * max(min(x / self.length, 1), 0))
272282

273283
self.y_nosecone = Function(
274-
lambda x: self.base_radius
275-
* (theta(x) - np.sin(2 * theta(x)) / 2) ** (0.5)
276-
/ (np.pi**0.5)
284+
lambda x: (
285+
self.base_radius
286+
* (theta(x) - np.sin(2 * theta(x)) / 2) ** (0.5)
287+
/ (np.pi**0.5)
288+
)
277289
)
278290
elif value == "parabolic":
279291
self.k = 0.5
280292
self.y_nosecone = Function(
281-
lambda x: self.base_radius
282-
* ((2 * x / self.length - (x / self.length) ** 2) / (2 - 1))
293+
lambda x: (
294+
self.base_radius
295+
* ((2 * x / self.length - (x / self.length) ** 2) / (2 - 1))
296+
)
283297
)
284298
elif value == "powerseries":
285299
self.k = (2 * self.power) / ((2 * self.power) + 1)

rocketpy/rocket/aero_surface/tail.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ def evaluate_lift_coefficient(self):
164164
"""
165165
# Calculate clalpha
166166
self.clalpha = Function(
167-
lambda mach: 2
168-
* (
169-
(self.bottom_radius / self.rocket_radius) ** 2
170-
- (self.top_radius / self.rocket_radius) ** 2
167+
lambda mach: (
168+
2
169+
* (
170+
(self.bottom_radius / self.rocket_radius) ** 2
171+
- (self.top_radius / self.rocket_radius) ** 2
172+
)
171173
),
172174
"Mach",
173175
f"Lift coefficient derivative for {self.name}",

rocketpy/rocket/parachute.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,10 @@ def __init__(
211211
)
212212

213213
alpha, beta = self.noise_corr
214-
self.noise_function = lambda: alpha * self.noise_signal[-1][
215-
1
216-
] + beta * np.random.normal(noise[0], noise[1])
214+
self.noise_function = lambda: (
215+
alpha * self.noise_signal[-1][1]
216+
+ beta * np.random.normal(noise[0], noise[1])
217+
)
217218

218219
self.prints = _ParachutePrints(self)
219220

rocketpy/rocket/rocket.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,14 @@ def evaluate_stability_margin(self):
625625
self.stability_margin.set_source(
626626
lambda mach, time: (
627627
(
628-
self.center_of_mass.get_value_opt(time)
629-
- self.cp_position.get_value_opt(mach)
628+
(
629+
self.center_of_mass.get_value_opt(time)
630+
- self.cp_position.get_value_opt(mach)
631+
)
632+
/ (2 * self.radius)
630633
)
631-
/ (2 * self.radius)
634+
* self._csys
632635
)
633-
* self._csys
634636
)
635637
return self.stability_margin
636638

@@ -647,10 +649,12 @@ def evaluate_static_margin(self):
647649
# Calculate static margin
648650
self.static_margin.set_source(
649651
lambda time: (
650-
self.center_of_mass.get_value_opt(time)
651-
- self.cp_position.get_value_opt(0)
652+
(
653+
self.center_of_mass.get_value_opt(time)
654+
- self.cp_position.get_value_opt(0)
655+
)
656+
/ (2 * self.radius)
652657
)
653-
/ (2 * self.radius)
654658
)
655659
# Change sign if coordinate system is upside down
656660
self.static_margin *= self._csys

rocketpy/simulation/flight.py

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,12 @@ def __simulate(self, verbose):
772772
lambda self, parachute_porosity=parachute.porosity: setattr(
773773
self, "parachute_porosity", parachute_porosity
774774
),
775-
lambda self,
776-
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
777-
self,
778-
"parachute_added_mass_coefficient",
779-
added_mass_coefficient,
775+
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: (
776+
setattr(
777+
self,
778+
"parachute_added_mass_coefficient",
779+
added_mass_coefficient,
780+
)
780781
),
781782
]
782783
self.flight_phases.add_phase(
@@ -1020,33 +1021,40 @@ def __simulate(self, verbose):
10201021
i += 1
10211022
# Create flight phase for time after inflation
10221023
callbacks = [
1023-
lambda self,
1024-
parachute_cd_s=parachute.cd_s: setattr(
1025-
self, "parachute_cd_s", parachute_cd_s
1024+
lambda self, parachute_cd_s=parachute.cd_s: (
1025+
setattr(
1026+
self,
1027+
"parachute_cd_s",
1028+
parachute_cd_s,
1029+
)
10261030
),
1027-
lambda self,
1028-
parachute_radius=parachute.radius: setattr(
1029-
self,
1030-
"parachute_radius",
1031-
parachute_radius,
1031+
lambda self, parachute_radius=parachute.radius: (
1032+
setattr(
1033+
self,
1034+
"parachute_radius",
1035+
parachute_radius,
1036+
)
10321037
),
1033-
lambda self,
1034-
parachute_height=parachute.height: setattr(
1035-
self,
1036-
"parachute_height",
1037-
parachute_height,
1038+
lambda self, parachute_height=parachute.height: (
1039+
setattr(
1040+
self,
1041+
"parachute_height",
1042+
parachute_height,
1043+
)
10381044
),
1039-
lambda self,
1040-
parachute_porosity=parachute.porosity: setattr(
1041-
self,
1042-
"parachute_porosity",
1043-
parachute_porosity,
1045+
lambda self, parachute_porosity=parachute.porosity: (
1046+
setattr(
1047+
self,
1048+
"parachute_porosity",
1049+
parachute_porosity,
1050+
)
10441051
),
1045-
lambda self,
1046-
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
1047-
self,
1048-
"parachute_added_mass_coefficient",
1049-
added_mass_coefficient,
1052+
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: (
1053+
setattr(
1054+
self,
1055+
"parachute_added_mass_coefficient",
1056+
added_mass_coefficient,
1057+
)
10501058
),
10511059
]
10521060
self.flight_phases.add_phase(

0 commit comments

Comments
 (0)