Skip to content

Commit

Permalink
MNT: apply isort and simplify statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Jan 26, 2024
1 parent 2a1ab07 commit dd44384
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions rocketpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .control import _Controller
from .environment import Environment, EnvironmentAnalysis
from .mathutils import (
Function,
Expand All @@ -22,7 +23,7 @@
TankGeometry,
UllageBasedTank,
)
from .control import _Controller
from .plots.compare import Compare, CompareFlights
from .rocket import (
AeroSurface,
AirBrakes,
Expand All @@ -37,4 +38,3 @@
TrapezoidalFins,
)
from .simulation import Flight
from .plots.compare import Compare, CompareFlights
39 changes: 16 additions & 23 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,30 +1279,23 @@ def controller_function(
z = state[2]
vz = state[5]
previous_vz = state_history[-1][5]
if time > 3.9:
if z < 1500:
air_brakes.set_deployment_level(0)
if time < 3.9:
return None
if z < 1500:
air_brakes.set_deployment_level(0)
else:
new_deployment_level = (
air_brakes.deployment_level + 0.1 * vz + 0.01 * previous_vz**2
)
if new_deployment_level > air_brakes.deployment_level + 0.2 / sampling_rate:
new_deployment_level = air_brakes.deployment_level + 0.2 / sampling_rate
elif (
new_deployment_level < air_brakes.deployment_level - 0.2 / sampling_rate
):
new_deployment_level = air_brakes.deployment_level - 0.2 / sampling_rate
else:
new_deployment_level = (
air_brakes.deployment_level + 0.1 * vz + 0.01 * previous_vz**2
)
if (
new_deployment_level
> air_brakes.deployment_level + 0.2 / sampling_rate
):
new_deployment_level = (
air_brakes.deployment_level + 0.2 / sampling_rate
)
elif (
new_deployment_level
< air_brakes.deployment_level - 0.2 / sampling_rate
):
new_deployment_level = (
air_brakes.deployment_level - 0.2 / sampling_rate
)
else:
new_deployment_level = air_brakes.deployment_level
air_brakes.set_deployment_level(new_deployment_level)
new_deployment_level = air_brakes.deployment_level
air_brakes.set_deployment_level(new_deployment_level)

return controller_function

Expand Down
4 changes: 2 additions & 2 deletions tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def test_air_brakes_flight(mock_show, flight_calisto_air_brakes):
"""
test_flight = flight_calisto_air_brakes
air_brakes = test_flight.rocket.air_brakes[0]
assert air_brakes.plots.all() == None
assert air_brakes.prints.all() == None
assert air_brakes.plots.all() is None
assert air_brakes.prints.all() is None


@patch("matplotlib.pyplot.show")
Expand Down

0 comments on commit dd44384

Please sign in to comment.