From 9adc5fdd957791d46342100b1a611fe4f5df74c5 Mon Sep 17 00:00:00 2001 From: zuorenchen Date: Tue, 17 Mar 2026 23:45:13 +0000 Subject: [PATCH 1/2] Run formatter --- rocketpy/environment/environment.py | 24 +++++---- rocketpy/rocket/aero_surface/nose_cone.py | 40 +++++++++----- rocketpy/rocket/aero_surface/tail.py | 10 ++-- rocketpy/rocket/parachute.py | 7 +-- rocketpy/rocket/rocket.py | 18 ++++--- rocketpy/simulation/flight.py | 64 +++++++++++++---------- 6 files changed, 98 insertions(+), 65 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index eb2eacd5a..dae2a4976 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -2434,22 +2434,26 @@ def add_wind_gust(self, wind_gust_x, wind_gust_y): # Reset wind heading and velocity magnitude self.wind_heading = Function( - lambda h: (180 / np.pi) - * np.arctan2( - self.wind_velocity_x.get_value_opt(h), - self.wind_velocity_y.get_value_opt(h), - ) - % 360, + lambda h: ( + (180 / np.pi) + * np.arctan2( + self.wind_velocity_x.get_value_opt(h), + self.wind_velocity_y.get_value_opt(h), + ) + % 360 + ), "Height (m)", "Wind Heading (degrees)", extrapolation="constant", ) self.wind_speed = Function( lambda h: ( - self.wind_velocity_x.get_value_opt(h) ** 2 - + self.wind_velocity_y.get_value_opt(h) ** 2 - ) - ** 0.5, + ( + self.wind_velocity_x.get_value_opt(h) ** 2 + + self.wind_velocity_y.get_value_opt(h) ** 2 + ) + ** 0.5 + ), "Height (m)", "Wind Speed (m/s)", extrapolation="constant", diff --git a/rocketpy/rocket/aero_surface/nose_cone.py b/rocketpy/rocket/aero_surface/nose_cone.py index 4e6ea8e95..5ad91062c 100644 --- a/rocketpy/rocket/aero_surface/nose_cone.py +++ b/rocketpy/rocket/aero_surface/nose_cone.py @@ -237,10 +237,16 @@ def theta(x): return np.arccos(1 - 2 * max(min(x / self.length, 1), 0)) self.y_nosecone = Function( - lambda x: self.base_radius - * (theta(x) - np.sin(2 * theta(x)) / 2 + (np.sin(theta(x)) ** 3) / 3) - ** (0.5) - / (np.pi**0.5) + lambda x: ( + self.base_radius + * ( + theta(x) + - np.sin(2 * theta(x)) / 2 + + (np.sin(theta(x)) ** 3) / 3 + ) + ** (0.5) + / (np.pi**0.5) + ) ) elif value in ["tangent", "tangentogive", "ogive"]: @@ -253,15 +259,19 @@ def theta(x): area = np.pi * self.base_radius**2 self.k = 1 - volume / (area * self.length) self.y_nosecone = Function( - lambda x: np.sqrt(rho**2 - (min(x - self.length, 0)) ** 2) - + (self.base_radius - rho) + lambda x: ( + np.sqrt(rho**2 - (min(x - self.length, 0)) ** 2) + + (self.base_radius - rho) + ) ) elif value == "elliptical": self.k = 1 / 3 self.y_nosecone = Function( - lambda x: self.base_radius - * np.sqrt(1 - ((x - self.length) / self.length) ** 2) + lambda x: ( + self.base_radius + * np.sqrt(1 - ((x - self.length) / self.length) ** 2) + ) ) elif value == "vonkarman": @@ -271,15 +281,19 @@ def theta(x): return np.arccos(1 - 2 * max(min(x / self.length, 1), 0)) self.y_nosecone = Function( - lambda x: self.base_radius - * (theta(x) - np.sin(2 * theta(x)) / 2) ** (0.5) - / (np.pi**0.5) + lambda x: ( + self.base_radius + * (theta(x) - np.sin(2 * theta(x)) / 2) ** (0.5) + / (np.pi**0.5) + ) ) elif value == "parabolic": self.k = 0.5 self.y_nosecone = Function( - lambda x: self.base_radius - * ((2 * x / self.length - (x / self.length) ** 2) / (2 - 1)) + lambda x: ( + self.base_radius + * ((2 * x / self.length - (x / self.length) ** 2) / (2 - 1)) + ) ) elif value == "powerseries": self.k = (2 * self.power) / ((2 * self.power) + 1) diff --git a/rocketpy/rocket/aero_surface/tail.py b/rocketpy/rocket/aero_surface/tail.py index b5e4b878a..3e738f99c 100644 --- a/rocketpy/rocket/aero_surface/tail.py +++ b/rocketpy/rocket/aero_surface/tail.py @@ -164,10 +164,12 @@ def evaluate_lift_coefficient(self): """ # Calculate clalpha self.clalpha = Function( - lambda mach: 2 - * ( - (self.bottom_radius / self.rocket_radius) ** 2 - - (self.top_radius / self.rocket_radius) ** 2 + lambda mach: ( + 2 + * ( + (self.bottom_radius / self.rocket_radius) ** 2 + - (self.top_radius / self.rocket_radius) ** 2 + ) ), "Mach", f"Lift coefficient derivative for {self.name}", diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index e27216e26..a080dadd1 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -211,9 +211,10 @@ def __init__( ) alpha, beta = self.noise_corr - self.noise_function = lambda: alpha * self.noise_signal[-1][ - 1 - ] + beta * np.random.normal(noise[0], noise[1]) + self.noise_function = lambda: ( + alpha * self.noise_signal[-1][1] + + beta * np.random.normal(noise[0], noise[1]) + ) self.prints = _ParachutePrints(self) diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 1112a98f3..6fe41a145 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -625,12 +625,14 @@ def evaluate_stability_margin(self): self.stability_margin.set_source( lambda mach, time: ( ( - self.center_of_mass.get_value_opt(time) - - self.cp_position.get_value_opt(mach) + ( + self.center_of_mass.get_value_opt(time) + - self.cp_position.get_value_opt(mach) + ) + / (2 * self.radius) ) - / (2 * self.radius) + * self._csys ) - * self._csys ) return self.stability_margin @@ -647,10 +649,12 @@ def evaluate_static_margin(self): # Calculate static margin self.static_margin.set_source( lambda time: ( - self.center_of_mass.get_value_opt(time) - - self.cp_position.get_value_opt(0) + ( + self.center_of_mass.get_value_opt(time) + - self.cp_position.get_value_opt(0) + ) + / (2 * self.radius) ) - / (2 * self.radius) ) # Change sign if coordinate system is upside down self.static_margin *= self._csys diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index ebe5914d5..cb2ccdfa0 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -772,11 +772,12 @@ def __simulate(self, verbose): lambda self, parachute_porosity=parachute.porosity: setattr( self, "parachute_porosity", parachute_porosity ), - lambda self, - added_mass_coefficient=parachute.added_mass_coefficient: setattr( - self, - "parachute_added_mass_coefficient", - added_mass_coefficient, + lambda self, added_mass_coefficient=parachute.added_mass_coefficient: ( + setattr( + self, + "parachute_added_mass_coefficient", + added_mass_coefficient, + ) ), ] self.flight_phases.add_phase( @@ -1020,33 +1021,40 @@ def __simulate(self, verbose): i += 1 # Create flight phase for time after inflation callbacks = [ - lambda self, - parachute_cd_s=parachute.cd_s: setattr( - self, "parachute_cd_s", parachute_cd_s + lambda self, parachute_cd_s=parachute.cd_s: ( + setattr( + self, + "parachute_cd_s", + parachute_cd_s, + ) ), - lambda self, - parachute_radius=parachute.radius: setattr( - self, - "parachute_radius", - parachute_radius, + lambda self, parachute_radius=parachute.radius: ( + setattr( + self, + "parachute_radius", + parachute_radius, + ) ), - lambda self, - parachute_height=parachute.height: setattr( - self, - "parachute_height", - parachute_height, + lambda self, parachute_height=parachute.height: ( + setattr( + self, + "parachute_height", + parachute_height, + ) ), - lambda self, - parachute_porosity=parachute.porosity: setattr( - self, - "parachute_porosity", - parachute_porosity, + lambda self, parachute_porosity=parachute.porosity: ( + setattr( + self, + "parachute_porosity", + parachute_porosity, + ) ), - lambda self, - added_mass_coefficient=parachute.added_mass_coefficient: setattr( - self, - "parachute_added_mass_coefficient", - added_mass_coefficient, + lambda self, added_mass_coefficient=parachute.added_mass_coefficient: ( + setattr( + self, + "parachute_added_mass_coefficient", + added_mass_coefficient, + ) ), ] self.flight_phases.add_phase( From d324b913e4e52c82bdbc295fab3f6bb2c2ca833d Mon Sep 17 00:00:00 2001 From: zuorenchen Date: Wed, 18 Mar 2026 00:23:34 +0000 Subject: [PATCH 2/2] Fix .pylintrc --- .pylintrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pylintrc b/.pylintrc index e417e0b11..14ff62781 100644 --- a/.pylintrc +++ b/.pylintrc @@ -99,10 +99,6 @@ recursive=no # source root. source-roots= -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no