Skip to content

Commit a1709f9

Browse files
MNT: Place filename save parameter to the end. (#739)
* MNT: Place filename save parameter to the end. * DEV: Add TODO for refactoring CompareFlights class to use show_or_save_plot --------- Co-authored-by: Gui-FernandesBR <[email protected]>
1 parent 0fe3d8d commit a1709f9

22 files changed

+85
-69
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Attention: The newest changes should be on top -->
3939

4040
### Changed
4141

42-
-
42+
- MNT: Place filename save parameter to the end. [#739](https://github.com/RocketPy-Team/RocketPy/pull/739)
4343

4444
### Fixed
4545

rocketpy/mathutils/function.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ def plot_1d( # pylint: disable=too-many-statements
14981498
force_points=False,
14991499
return_object=False,
15001500
equal_axis=False,
1501+
*,
15011502
filename=None,
15021503
):
15031504
"""Plot 1-Dimensional Function, from a lower limit to an upper limit,
@@ -1597,6 +1598,7 @@ def plot_2d( # pylint: disable=too-many-statements
15971598
disp_type="surface",
15981599
alpha=0.6,
15991600
cmap="viridis",
1601+
*,
16001602
filename=None,
16011603
):
16021604
"""Plot 2-Dimensional Function, from a lower limit to an upper limit,
@@ -1729,6 +1731,7 @@ def compare_plots( # pylint: disable=too-many-statements
17291731
force_points=False,
17301732
return_object=False,
17311733
show=True,
1734+
*,
17321735
filename=None,
17331736
):
17341737
"""Plots N 1-Dimensional Functions in the same plot, from a lower

rocketpy/motors/hybrid_motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def add_tank(self, tank, position):
601601
)
602602
reset_funcified_methods(self)
603603

604-
def draw(self, filename=None):
604+
def draw(self, *, filename=None):
605605
"""Draws a representation of the HybridMotor.
606606
607607
Parameters

rocketpy/motors/liquid_motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def add_tank(self, tank, position):
463463
self.positioned_tanks.append({"tank": tank, "position": position})
464464
reset_funcified_methods(self)
465465

466-
def draw(self, filename=None):
466+
def draw(self, *, filename=None):
467467
"""Draw a representation of the LiquidMotor.
468468
469469
Parameters

rocketpy/motors/motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ def get_attr_value(obj, attr_name, multiplier=1):
10831083
# Write last line
10841084
file.write(f"{self.thrust.source[-1, 0]:.4f} {0:.3f}\n")
10851085

1086-
def info(self, filename=None):
1086+
def info(self, *, filename=None):
10871087
"""Prints out a summary of the data and graphs available about the
10881088
Motor.
10891089

rocketpy/motors/solid_motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ def propellant_I_13(self):
727727
def propellant_I_23(self):
728728
return 0
729729

730-
def draw(self, filename=None):
730+
def draw(self, *, filename=None):
731731
"""Draw a representation of the SolidMotor.
732732
733733
Parameters

rocketpy/motors/tank.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def underfill_height_exception(param_name, param):
476476
elif (height < bottom_tolerance).any():
477477
underfill_height_exception(name, height)
478478

479-
def draw(self, filename=None):
479+
def draw(self, *, filename=None):
480480
"""Draws the tank geometry.
481481
482482
Parameters

rocketpy/plots/aero_surface_plots.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, aero_surface):
2525
self.aero_surface = aero_surface
2626

2727
@abstractmethod
28-
def draw(self, filename=None):
28+
def draw(self, *, filename=None):
2929
pass
3030

3131
def lift(self):
@@ -54,7 +54,7 @@ class _NoseConePlots(_AeroSurfacePlots):
5454
"""Class that contains all nosecone plots. This class inherits from the
5555
_AeroSurfacePlots class."""
5656

57-
def draw(self, filename=None):
57+
def draw(self, *, filename=None):
5858
"""Draw the nosecone shape along with some important information,
5959
including the center line and the center of pressure position.
6060
@@ -140,7 +140,7 @@ class _FinsPlots(_AeroSurfacePlots):
140140
_AeroSurfacePlots class."""
141141

142142
@abstractmethod
143-
def draw(self, filename=None):
143+
def draw(self, *, filename=None):
144144
pass
145145

146146
def airfoil(self):
@@ -201,7 +201,7 @@ class _TrapezoidalFinsPlots(_FinsPlots):
201201
"""Class that contains all trapezoidal fin plots."""
202202

203203
# pylint: disable=too-many-statements
204-
def draw(self, filename=None):
204+
def draw(self, *, filename=None):
205205
"""Draw the fin shape along with some important information, including
206206
the center line, the quarter line and the center of pressure position.
207207
@@ -330,7 +330,7 @@ class _EllipticalFinsPlots(_FinsPlots):
330330
"""Class that contains all elliptical fin plots."""
331331

332332
# pylint: disable=too-many-statements
333-
def draw(self, filename=None):
333+
def draw(self, *, filename=None):
334334
"""Draw the fin shape along with some important information.
335335
These being: the center line and the center of pressure position.
336336
@@ -409,7 +409,7 @@ class _FreeFormFinsPlots(_FinsPlots):
409409
"""Class that contains all free form fin plots."""
410410

411411
# pylint: disable=too-many-statements
412-
def draw(self, filename=None):
412+
def draw(self, *, filename=None):
413413
"""Draw the fin shape along with some important information.
414414
These being: the center line and the center of pressure position.
415415
@@ -483,7 +483,7 @@ def draw(self, filename=None):
483483
class _TailPlots(_AeroSurfacePlots):
484484
"""Class that contains all tail plots."""
485485

486-
def draw(self, filename=None):
486+
def draw(self, *, filename=None):
487487
# This will de done in the future
488488
pass
489489

@@ -498,7 +498,7 @@ def drag_coefficient_curve(self):
498498
else:
499499
return self.aero_surface.drag_coefficient.plot()
500500

501-
def draw(self, filename=None):
501+
def draw(self, *, filename=None):
502502
raise NotImplementedError
503503

504504
def all(self):
@@ -514,12 +514,12 @@ def all(self):
514514
class _GenericSurfacePlots(_AeroSurfacePlots):
515515
"""Class that contains all generic surface plots."""
516516

517-
def draw(self, filename=None):
517+
def draw(self, *, filename=None):
518518
pass
519519

520520

521521
class _LinearGenericSurfacePlots(_AeroSurfacePlots):
522522
"""Class that contains all linear generic surface plots."""
523523

524-
def draw(self, filename=None):
524+
def draw(self, *, filename=None):
525525
pass

rocketpy/plots/compare/compare_flights.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from ..plot_helpers import show_or_save_fig, show_or_save_plot
77
from .compare import Compare
88

9+
# TODO: needs to refactor this class to use the show_or_save_plot
10+
911

1012
class CompareFlights(Compare): # pylint: disable=too-many-public-methods
1113
"""A class to compare the results of multiple flights.

rocketpy/plots/environment_analysis_plots.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __beaufort_wind_scale(self, units, max_wind_speed=None):
7474

7575
# Surface level plots
7676

77-
def wind_gust_distribution(self, filename=None):
77+
def wind_gust_distribution(self, *, filename=None):
7878
"""Get all values of wind gust speed (for every date and hour available)
7979
and plot a single distribution. Expected result is a Weibull distribution,
8080
however, the result is not always a perfect fit, and sometimes it may
@@ -124,7 +124,9 @@ def wind_gust_distribution(self, filename=None):
124124
plt.legend()
125125
show_or_save_plot(filename)
126126

127-
def surface10m_wind_speed_distribution(self, wind_speed_limit=False, filename=None):
127+
def surface10m_wind_speed_distribution(
128+
self, wind_speed_limit=False, *, filename=None
129+
):
128130
"""Get all values of sustained surface wind speed (for every date and
129131
hour available) and plot a single distribution. Expected result is a
130132
Weibull distribution. The wind speed limit is plotted as a vertical line.
@@ -190,6 +192,7 @@ def surface10m_wind_speed_distribution(self, wind_speed_limit=False, filename=No
190192

191193
def average_surface_temperature_evolution(
192194
self,
195+
*,
193196
filename=None,
194197
): # pylint: disable=too-many-statements
195198
"""Plots average temperature progression throughout the day, including
@@ -265,7 +268,7 @@ def average_surface_temperature_evolution(
265268
show_or_save_plot(filename)
266269

267270
def average_surface10m_wind_speed_evolution(
268-
self, wind_speed_limit=False, filename=None
271+
self, wind_speed_limit=False, *, filename=None
269272
): # pylint: disable=too-many-statements
270273
"""Plots average surface wind speed progression throughout the day,
271274
including sigma contours.
@@ -366,6 +369,7 @@ def average_surface10m_wind_speed_evolution(
366369

367370
def average_surface100m_wind_speed_evolution(
368371
self,
372+
*,
369373
filename=None,
370374
): # pylint: disable=too-many-statements
371375
"""Plots average surface wind speed progression throughout the day, including
@@ -449,7 +453,7 @@ def average_surface100m_wind_speed_evolution(
449453

450454
# Average profiles plots (pressure level data)
451455

452-
def average_wind_speed_profile(self, clear_range_limits=False, filename=None):
456+
def average_wind_speed_profile(self, clear_range_limits=False, *, filename=None):
453457
"""Average wind speed for all datetimes available. The plot also includes
454458
sigma contours.
455459
@@ -554,7 +558,9 @@ def average_wind_speed_profile(self, clear_range_limits=False, filename=None):
554558
)
555559
show_or_save_plot(filename)
556560

557-
def average_wind_velocity_xy_profile(self, clear_range_limits=False, filename=None):
561+
def average_wind_velocity_xy_profile(
562+
self, clear_range_limits=False, *, filename=None
563+
):
558564
"""Average wind X and wind Y for all datetimes available. The X component
559565
is the wind speed in the direction of East, and the Y component is the
560566
wind speed in the direction of North.
@@ -621,7 +627,7 @@ def average_wind_velocity_xy_profile(self, clear_range_limits=False, filename=No
621627
plt.grid()
622628
show_or_save_plot(filename)
623629

624-
def average_wind_heading_profile(self, clear_range_limits=False, filename=None):
630+
def average_wind_heading_profile(self, clear_range_limits=False, *, filename=None):
625631
"""Average wind heading for all datetimes available.
626632
627633
Parameters
@@ -679,7 +685,7 @@ def average_wind_heading_profile(self, clear_range_limits=False, filename=None):
679685
plt.legend()
680686
show_or_save_plot(filename)
681687

682-
def average_pressure_profile(self, clear_range_limits=False, filename=None):
688+
def average_pressure_profile(self, clear_range_limits=False, *, filename=None):
683689
"""Average pressure profile for all datetimes available. The plot also
684690
includes sigma contours.
685691
@@ -772,7 +778,7 @@ def average_pressure_profile(self, clear_range_limits=False, filename=None):
772778
)
773779
show_or_save_plot(filename)
774780

775-
def average_temperature_profile(self, clear_range_limits=False, filename=None):
781+
def average_temperature_profile(self, clear_range_limits=False, *, filename=None):
776782
"""Average temperature profile for all datetimes available. The plot
777783
also includes sigma contours.
778784
@@ -918,7 +924,7 @@ def plot_wind_rose(
918924
ax.yaxis.set_major_formatter(mtick.PercentFormatter(decimals=0))
919925
return ax
920926

921-
def average_wind_rose_specific_hour(self, hour, fig=None, filename=None):
927+
def average_wind_rose_specific_hour(self, hour, fig=None, *, filename=None):
922928
"""Plot a specific hour of the average windrose
923929
924930
Parameters
@@ -952,7 +958,7 @@ def average_wind_rose_specific_hour(self, hour, fig=None, filename=None):
952958
show_or_save_plot(filename)
953959

954960
def average_wind_rose_grid(
955-
self, filename=None
961+
self, *, filename=None
956962
): # pylint: disable=too-many-statements
957963
"""Plot wind roses for all hours of a day, in a grid like plot.
958964
@@ -1088,7 +1094,7 @@ def animate_average_wind_rose(self, figsize=(5, 5), filename="wind_rose.gif"):
10881094
# More plots and animations
10891095

10901096
def wind_gust_distribution_grid(
1091-
self, filename=None
1097+
self, *, filename=None
10921098
): # pylint: disable=too-many-statements
10931099
"""Plots shown in the animation of how the wind gust distribution varies
10941100
throughout the day.
@@ -1264,7 +1270,7 @@ def update(frame):
12641270
return HTML(animation.to_jshtml())
12651271

12661272
def surface_wind_speed_distribution_grid(
1267-
self, wind_speed_limit=False, filename=None
1273+
self, wind_speed_limit=False, *, filename=None
12681274
): # pylint: disable=too-many-statements
12691275
"""Plots shown in the animation of how the sustained surface wind speed
12701276
distribution varies throughout the day. The plots are histograms of the
@@ -1493,7 +1499,7 @@ def update(frame):
14931499
return HTML(animation.to_jshtml())
14941500

14951501
def wind_speed_profile_grid(
1496-
self, clear_range_limits=False, filename=None
1502+
self, clear_range_limits=False, *, filename=None
14971503
): # pylint: disable=too-many-statements
14981504
"""Creates a grid of plots with the wind profile over the average day.
14991505
Each subplot represents a different hour of the day.
@@ -1592,7 +1598,7 @@ def wind_speed_profile_grid(
15921598
show_or_save_plot(filename)
15931599

15941600
def wind_heading_profile_grid(
1595-
self, clear_range_limits=False, filename=None
1601+
self, clear_range_limits=False, *, filename=None
15961602
): # pylint: disable=too-many-statements
15971603
"""Creates a grid of plots with the wind heading profile over the
15981604
average day. Each subplot represents a different hour of the day.

rocketpy/plots/environment_plots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __pressure_temperature(self, ax):
173173

174174
return ax
175175

176-
def gravity_model(self, filename=None):
176+
def gravity_model(self, *, filename=None):
177177
"""Plots the gravity model graph that represents the gravitational
178178
acceleration as a function of height.
179179
@@ -204,7 +204,7 @@ def gravity_model(self, filename=None):
204204

205205
show_or_save_plot(filename)
206206

207-
def atmospheric_model(self, filename=None):
207+
def atmospheric_model(self, *, filename=None):
208208
"""Plots all atmospheric model graphs available. This includes wind
209209
speed and wind direction, density and speed of sound, wind u and wind v,
210210
and pressure and temperature.
@@ -245,7 +245,7 @@ def atmospheric_model(self, filename=None):
245245
show_or_save_plot(filename)
246246

247247
# pylint: disable=too-many-statements
248-
def ensemble_member_comparison(self, filename=None):
248+
def ensemble_member_comparison(self, *, filename=None):
249249
"""Plots ensemble member comparisons. It requires that the environment
250250
model has been set as Ensemble.
251251
@@ -352,7 +352,7 @@ def ensemble_member_comparison(self, filename=None):
352352
# Clean up
353353
self.environment.select_ensemble_member(current_member)
354354

355-
def info(self, filename=None):
355+
def info(self, *, filename=None):
356356
"""Plots a summary of the atmospheric model, including wind speed and
357357
wind direction, density and speed of sound. This is important for the
358358
Environment.info() method.

0 commit comments

Comments
 (0)