Skip to content

Commit c9a4cf4

Browse files
lint-actionGui-FernandesBR
authored andcommitted
Fix code style issues with Black
1 parent 6e434d3 commit c9a4cf4

File tree

11 files changed

+65
-75
lines changed

11 files changed

+65
-75
lines changed

rocketpy/environment/environment_analysis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,10 @@ def __parse_surface_data(self):
901901
# Extract data from weather file
902902
indices = (time_index, lon_index, lat_index)
903903
for key, value in surface_file_dict.items():
904-
dictionary[date_string][hour_string][
905-
key
906-
] = self.__extract_surface_data_value(
907-
surface_data, value, indices, lon_array, lat_array
904+
dictionary[date_string][hour_string][key] = (
905+
self.__extract_surface_data_value(
906+
surface_data, value, indices, lon_array, lat_array
907+
)
908908
)
909909

910910
# Get elevation, time index does not matter, use last one

rocketpy/mathutils/function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
and more. This is a core class of our package, and should be maintained
44
carefully as it may impact all the rest of the project.
55
"""
6+
67
import warnings
78
from collections.abc import Iterable
89
from copy import deepcopy

rocketpy/plots/flight_plots.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,11 @@ def rail_buttons_forces(self):
400400
)
401401
ax1.set_xlim(
402402
0,
403-
self.flight.out_of_rail_time
404-
if self.flight.out_of_rail_time > 0
405-
else self.flight.tFinal,
403+
(
404+
self.flight.out_of_rail_time
405+
if self.flight.out_of_rail_time > 0
406+
else self.flight.tFinal
407+
),
406408
)
407409
ax1.legend()
408410
ax1.grid(True)
@@ -431,9 +433,11 @@ def rail_buttons_forces(self):
431433
)
432434
ax2.set_xlim(
433435
0,
434-
self.flight.out_of_rail_time
435-
if self.flight.out_of_rail_time > 0
436-
else self.flight.tFinal,
436+
(
437+
self.flight.out_of_rail_time
438+
if self.flight.out_of_rail_time > 0
439+
else self.flight.tFinal
440+
),
437441
)
438442
ax2.legend()
439443
ax2.grid(True)
@@ -557,9 +561,11 @@ def energy_data(self):
557561
)
558562
ax1.set_xlim(
559563
0,
560-
self.flight.apogee_time
561-
if self.flight.apogee_time != 0.0
562-
else self.flight.t_final,
564+
(
565+
self.flight.apogee_time
566+
if self.flight.apogee_time != 0.0
567+
else self.flight.t_final
568+
),
563569
)
564570
ax1.ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
565571
ax1.set_title("Kinetic Energy Components")
@@ -587,9 +593,11 @@ def energy_data(self):
587593
)
588594
ax2.set_xlim(
589595
0,
590-
self.flight.apogee_time
591-
if self.flight.apogee_time != 0.0
592-
else self.flight.t_final,
596+
(
597+
self.flight.apogee_time
598+
if self.flight.apogee_time != 0.0
599+
else self.flight.t_final
600+
),
593601
)
594602
ax2.ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
595603
ax2.set_title("Total Mechanical Energy Components")
@@ -620,9 +628,11 @@ def energy_data(self):
620628
)
621629
ax4.set_xlim(
622630
0,
623-
self.flight.apogee_time
624-
if self.flight.apogee_time != 0.0
625-
else self.flight.t_final,
631+
(
632+
self.flight.apogee_time
633+
if self.flight.apogee_time != 0.0
634+
else self.flight.t_final
635+
),
626636
)
627637
ax3.ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
628638
ax4.set_title("Drag Absolute Power")

rocketpy/rocket/aero_surface.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,10 +1180,7 @@ def evaluate_geometrical_parameters(self):
11801180
* (self.root_chord + 2 * self.tip_chord)
11811181
* self.rocket_radius
11821182
* self.span**2
1183-
+ 6
1184-
* (self.root_chord + self.tip_chord)
1185-
* self.span
1186-
* self.rocket_radius**2
1183+
+ 6 * (self.root_chord + self.tip_chord) * self.span * self.rocket_radius**2
11871184
) / 12
11881185
roll_damping_interference_factor = 1 + (
11891186
((tau - λ) / (tau)) - ((1 - λ) / (tau - 1)) * np.log(tau)
@@ -1506,8 +1503,7 @@ def evaluate_geometrical_parameters(self):
15061503
* self.rocket_radius**2
15071504
* np.sqrt(-self.span**2 + self.rocket_radius**2)
15081505
* np.arctan(
1509-
(self.span)
1510-
/ (np.sqrt(-self.span**2 + self.rocket_radius**2))
1506+
(self.span) / (np.sqrt(-self.span**2 + self.rocket_radius**2))
15111507
)
15121508
- np.pi
15131509
* self.rocket_radius**2

rocketpy/simulation/flight.py

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,9 @@ def __init__(
683683
node.time_bound = phase.TimeNodes[node_index + 1].t
684684
phase.solver.t_bound = node.time_bound
685685
phase.solver._lsoda_solver._integrator.rwork[0] = phase.solver.t_bound
686-
phase.solver._lsoda_solver._integrator.call_args[
687-
4
688-
] = phase.solver._lsoda_solver._integrator.rwork
686+
phase.solver._lsoda_solver._integrator.call_args[4] = (
687+
phase.solver._lsoda_solver._integrator.rwork
688+
)
689689
phase.solver.status = "running"
690690

691691
# Feed required parachute and discrete controller triggers
@@ -1275,9 +1275,7 @@ def udot_rail1(self, t, u, post_processing=False):
12751275
R3 = -0.5 * rho * (free_stream_speed**2) * self.rocket.area * (drag_coeff)
12761276

12771277
# Calculate Linear acceleration
1278-
a3 = (R3 + thrust) / M - (
1279-
e0**2 - e1**2 - e2**2 + e3**2
1280-
) * self.env.gravity(z)
1278+
a3 = (R3 + thrust) / M - (e0**2 - e1**2 - e2**2 + e3**2) * self.env.gravity(z)
12811279
if a3 > 0:
12821280
ax = 2 * (e1 * e3 + e0 * e2) * a3
12831281
ay = 2 * (e2 * e3 - e0 * e1) * a3
@@ -1469,9 +1467,7 @@ def u_dot(self, t, u, post_processing=False):
14691467
0.5 * rho * (comp_stream_speed**2) * reference_area * c_lift
14701468
)
14711469
# component lift force components
1472-
lift_dir_norm = (
1473-
comp_stream_vx_b**2 + comp_stream_vy_b**2
1474-
) ** 0.5
1470+
lift_dir_norm = (comp_stream_vx_b**2 + comp_stream_vy_b**2) ** 0.5
14751471
comp_lift_xb = comp_lift * (comp_stream_vx_b / lift_dir_norm)
14761472
comp_lift_yb = comp_lift * (comp_stream_vy_b / lift_dir_norm)
14771473
# add to total lift force
@@ -1750,9 +1746,7 @@ def u_dot_generalized(self, t, u, post_processing=False):
17501746
0.5 * rho * (comp_stream_speed**2) * reference_area * c_lift
17511747
)
17521748
# Component lift force components
1753-
lift_dir_norm = (
1754-
comp_stream_vx_b**2 + comp_stream_vy_b**2
1755-
) ** 0.5
1749+
lift_dir_norm = (comp_stream_vx_b**2 + comp_stream_vy_b**2) ** 0.5
17561750
comp_lift_xb = comp_lift * (comp_stream_vx_b / lift_dir_norm)
17571751
comp_lift_yb = comp_lift * (comp_stream_vy_b / lift_dir_norm)
17581752
# Add to total lift force
@@ -1896,8 +1890,7 @@ def u_dot_parachute(self, t, u, post_processing=False):
18961890
freestream_z = vz
18971891
# Determine drag force
18981892
pseudoD = (
1899-
-0.5 * rho * cd_s * free_stream_speed
1900-
- ka * rho * 4 * np.pi * (R**2) * Rdot
1893+
-0.5 * rho * cd_s * free_stream_speed - ka * rho * 4 * np.pi * (R**2) * Rdot
19011894
)
19021895
Dx = pseudoD * freestream_x
19031896
Dy = pseudoD * freestream_y
@@ -2486,9 +2479,7 @@ def translational_energy(self):
24862479
# Redefine total_mass time grid to allow for efficient Function algebra
24872480
total_mass = deepcopy(self.rocket.total_mass)
24882481
total_mass.set_discrete_based_on_model(self.vz)
2489-
translational_energy = (
2490-
0.5 * total_mass * (self.vx**2 + self.vy**2 + self.vz**2)
2491-
)
2482+
translational_energy = 0.5 * total_mass * (self.vx**2 + self.vy**2 + self.vz**2)
24922483
return translational_energy
24932484

24942485
@funcify_method("Time (s)", "Kinetic Energy (J)", "spline", "zero")
@@ -3400,29 +3391,31 @@ def add(self, flight_phase, index=None):
34003391
)
34013392
if flight_phase.t == previous_phase.t
34023393
else (
3403-
"Trying to add flight phase starting *together* with the one *proceeding* it. ",
3404-
"This may be caused by multiple parachutes being triggered simultaneously.",
3405-
)
3406-
if flight_phase.t == next_phase.t
3407-
else (
3408-
"Trying to add flight phase starting *before* the one *preceding* it. ",
3409-
"This may be caused by multiple parachutes being triggered simultaneously",
3410-
" or by having a negative parachute lag.",
3411-
)
3412-
if flight_phase.t < previous_phase.t
3413-
else (
3414-
"Trying to add flight phase starting *after* the one *proceeding* it.",
3415-
"This may be caused by multiple parachutes being triggered simultaneously.",
3394+
(
3395+
"Trying to add flight phase starting *together* with the one *proceeding* it. ",
3396+
"This may be caused by multiple parachutes being triggered simultaneously.",
3397+
)
3398+
if flight_phase.t == next_phase.t
3399+
else (
3400+
(
3401+
"Trying to add flight phase starting *before* the one *preceding* it. ",
3402+
"This may be caused by multiple parachutes being triggered simultaneously",
3403+
" or by having a negative parachute lag.",
3404+
)
3405+
if flight_phase.t < previous_phase.t
3406+
else (
3407+
"Trying to add flight phase starting *after* the one *proceeding* it.",
3408+
"This may be caused by multiple parachutes being triggered simultaneously.",
3409+
)
3410+
)
34163411
)
34173412
)
34183413
self.display_warning(*warning_msg)
34193414
adjust = 1e-7 if flight_phase.t in {previous_phase.t, next_phase.t} else 0
34203415
new_index = (
34213416
index - 1
34223417
if flight_phase.t < previous_phase.t
3423-
else index + 1
3424-
if flight_phase.t > next_phase.t
3425-
else index
3418+
else index + 1 if flight_phase.t > next_phase.t else index
34263419
)
34273420
flight_phase.t += adjust
34283421
self.add(flight_phase, new_index)

rocketpy/simulation/flight_data_importer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Starts with .csv or .txt file containing the rocket's collected flight data
22
and build a rocketpy.Flight object from it.
33
"""
4+
45
import warnings
56
from os import listdir
67
from os.path import isfile, join

tests/test_flight_data_importer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests the FlightDataImporter class from rocketpy.simulation module.
22
"""
3+
34
import numpy as np
45

56
from rocketpy.simulation import FlightDataImporter

tests/test_genericmotor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ def test_generic_motor_inertia(generic_motor):
118118
# Tests the inertia formulation from the propellant mass
119119
propellant_mass = generic_motor.propellant_mass.set_discrete(*burn_time, 50).y_array
120120

121-
propellant_I_11 = propellant_mass * (
122-
chamber_radius**2 / 4 + chamber_height**2 / 12
123-
)
121+
propellant_I_11 = propellant_mass * (chamber_radius**2 / 4 + chamber_height**2 / 12)
124122
propellant_I_22 = propellant_I_11
125123
propellant_I_33 = propellant_mass * (chamber_radius**2 / 2)
126124

tests/test_tank.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,11 +631,7 @@ def upper_spherical_cap_centroid(radius, height=None):
631631
"""
632632
if height is None:
633633
height = radius
634-
return (
635-
0.75
636-
* (height**3 - 2 * height * radius**2)
637-
/ (height**2 - 3 * radius**2)
638-
)
634+
return 0.75 * (height**3 - 2 * height * radius**2) / (height**2 - 3 * radius**2)
639635

640636

641637
def tank_centroid_function(tank_radius, tank_height, zero_height=0):
@@ -775,10 +771,7 @@ def lower_spherical_cap_inertia(radius, height=None, reference=0):
775771
)
776772
inertia_y = inertia_x
777773
inertia_z = lower_spherical_cap_volume(radius, height) * (
778-
np.pi
779-
* height**3
780-
* (3 * height**2 - 15 * height * radius + 20 * radius**2)
781-
/ 30
774+
np.pi * height**3 * (3 * height**2 - 15 * height * radius + 20 * radius**2) / 30
782775
)
783776
return np.array([inertia_x, inertia_y, inertia_z])
784777

tests/unit/test_rocket.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ def test_add_fins_assert_cp_cm_plus_fins(calisto, dimensionless_calisto, m):
207207
1
208208
+ np.sqrt(
209209
1
210-
+ (2 * np.sqrt((0.12 / 2 - 0.04 / 2) ** 2 + 0.1**2) / (0.120 + 0.040))
211-
** 2
210+
+ (2 * np.sqrt((0.12 / 2 - 0.04 / 2) ** 2 + 0.1**2) / (0.120 + 0.040)) ** 2
212211
)
213212
)
214213
clalpha *= 1 + calisto.radius / (0.1 + calisto.radius)

tests/unit/test_solidmotor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ def test_evaluate_inertia_33_asserts_extreme_values(cesaroni_m1670):
7070
grain_mass = grain_vol * grain_density
7171

7272
grain_I_33_initial = (
73-
grain_mass
74-
* (1 / 2.0)
75-
* (grain_initial_inner_radius**2 + grain_outer_radius**2)
73+
grain_mass * (1 / 2.0) * (grain_initial_inner_radius**2 + grain_outer_radius**2)
7674
)
7775

7876
# not passing because I_33 is not discrete anymore

0 commit comments

Comments
 (0)