Skip to content

Commit 8e88fa8

Browse files
committed
STY: Fix pylint for parachute triggers
1 parent 916b0fc commit 8e88fa8

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

rocketpy/rocket/parachute.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..prints.parachute_prints import _ParachutePrints
99

1010

11-
def detect_motor_burnout(pressure, height, state_vector, u_dot):
11+
def detect_motor_burnout(_pressure, height, state_vector, u_dot):
1212
"""Detect motor burnout by sudden drop in acceleration.
1313
1414
Returns True when vertical acceleration becomes significantly negative
@@ -48,7 +48,7 @@ def detect_motor_burnout(pressure, height, state_vector, u_dot):
4848
return False
4949

5050

51-
def detect_apogee_acceleration(pressure, height, state_vector, u_dot):
51+
def detect_apogee_acceleration(_pressure, _height, state_vector, u_dot):
5252
"""Detect apogee using near-zero vertical velocity and negative vertical accel.
5353
5454
Apogee occurs when the rocket reaches its highest point, characterized by
@@ -71,7 +71,7 @@ def detect_apogee_acceleration(pressure, height, state_vector, u_dot):
7171
return False
7272

7373

74-
def detect_freefall(pressure, height, state_vector, u_dot):
74+
def detect_freefall(_pressure, height, state_vector, u_dot):
7575
"""Detect free-fall when total acceleration magnitude is low.
7676
7777
Free-fall is characterized by acceleration magnitude close to gravitational
@@ -107,7 +107,7 @@ def detect_freefall(pressure, height, state_vector, u_dot):
107107
return False
108108

109109

110-
def detect_liftoff(pressure, height, state_vector, u_dot):
110+
def detect_liftoff(_pressure, _height, _state_vector, u_dot):
111111
"""Detect liftoff by high total acceleration.
112112
113113
Liftoff is characterized by a sudden increase in acceleration as the motor
@@ -139,7 +139,7 @@ def altitude_trigger_factory(target_altitude, require_descent=True):
139139
(descending) to avoid firing during ascent.
140140
"""
141141

142-
def trigger(pressure, height, state_vector, u_dot=None):
142+
def trigger(_pressure, height, state_vector, _u_dot=None):
143143
vz = float(state_vector[5])
144144
if require_descent:
145145
return (height <= target_altitude) and (vz < 0)
@@ -359,7 +359,7 @@ def __init__(
359359

360360
self.__evaluate_trigger_function(trigger)
361361

362-
def __evaluate_trigger_function(self, trigger):
362+
def __evaluate_trigger_function(self, trigger): # pylint: disable=too-many-statements
363363
"""This is used to set the triggerfunc attribute that will be used to
364364
interact with the Flight class.
365365

rocketpy/simulation/flight.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# pylint: disable=too-many-lines
2+
import inspect
23
import math
34
import warnings
45
from copy import deepcopy
56
from functools import cached_property
67

78
import numpy as np
8-
import inspect
99
from scipy.integrate import BDF, DOP853, LSODA, RK23, RK45, OdeSolver, Radau
1010

1111
from rocketpy.simulation.flight_data_exporter import FlightDataExporter
@@ -1236,10 +1236,10 @@ def _evaluate_parachute_trigger(
12361236
if noise.size == 3:
12371237
# u_dot layout: [vx, vy, vz, ax, ay, az, ...]
12381238
u_dot[3:6] = u_dot[3:6] + noise
1239-
except Exception:
1239+
except (ValueError, TypeError):
12401240
# ignore noise errors and continue
12411241
pass
1242-
except Exception:
1242+
except (ValueError, TypeError, RuntimeError):
12431243
# If u_dot computation fails, leave as None
12441244
u_dot = None
12451245

tests/unit/test_parachute_trigger_acceleration.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import numpy as np
2-
import pytest
32

43
from rocketpy.simulation.flight import Flight
54
from rocketpy.rocket.parachute import Parachute
65

76

87
def test_trigger_receives_u_dot_and_noise():
98
# Prepare derivative function that returns known u_dot
10-
def derivative_func(t, y):
9+
def derivative_func(_t, _y):
1110
return np.array([0, 0, 0, 1.0, 2.0, 3.0, 0, 0, 0, 0, 0, 0, 0])
1211

1312
recorded = {}
1413

1514
# User trigger expecting u_dot named exactly 'u_dot'
16-
def user_trigger(p, h, y, u_dot):
15+
def user_trigger(_p, _h, _y, u_dot):
1716
recorded["u_dot"] = np.array(u_dot)
1817
return True
1918

@@ -48,12 +47,12 @@ def user_trigger(p, h, y, u_dot):
4847

4948

5049
def test_trigger_with_sensors_and_u_dot():
51-
def derivative_func(t, y):
50+
def derivative_func(_t, _y):
5251
return np.array([0, 0, 0, -1.0, -2.0, -3.0, 0, 0, 0, 0, 0, 0, 0])
5352

5453
recorded = {}
5554

56-
def user_trigger(p, h, y, sensors, u_dot):
55+
def user_trigger(_p, _h, _y, sensors, u_dot):
5756
recorded["sensors"] = sensors
5857
recorded["u_dot"] = np.array(u_dot)
5958
return False
@@ -86,12 +85,12 @@ def user_trigger(p, h, y, sensors, u_dot):
8685

8786
def test_legacy_trigger_does_not_compute_u_dot():
8887
# derivative function that raises if called
89-
def derivative_func(t, y):
88+
def derivative_func(_t, _y):
9089
raise RuntimeError("derivative should not be called for legacy triggers")
9190

9291
called = {}
9392

94-
def legacy_trigger(p, h, y):
93+
def legacy_trigger(_p, _h, _y):
9594
called["ok"] = True
9695
return True
9796

0 commit comments

Comments
 (0)