Skip to content

MNT: Place filename save parameter to the end. #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Attention: The newest changes should be on top -->

### Changed

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

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ def plot_1d( # pylint: disable=too-many-statements
force_points=False,
return_object=False,
equal_axis=False,
*,
filename=None,
):
"""Plot 1-Dimensional Function, from a lower limit to an upper limit,
Expand Down Expand Up @@ -1597,6 +1598,7 @@ def plot_2d( # pylint: disable=too-many-statements
disp_type="surface",
alpha=0.6,
cmap="viridis",
*,
filename=None,
):
"""Plot 2-Dimensional Function, from a lower limit to an upper limit,
Expand Down Expand Up @@ -1729,6 +1731,7 @@ def compare_plots( # pylint: disable=too-many-statements
force_points=False,
return_object=False,
show=True,
*,
filename=None,
):
"""Plots N 1-Dimensional Functions in the same plot, from a lower
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/hybrid_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def add_tank(self, tank, position):
)
reset_funcified_methods(self)

def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draws a representation of the HybridMotor.

Parameters
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/liquid_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def add_tank(self, tank, position):
self.positioned_tanks.append({"tank": tank, "position": position})
reset_funcified_methods(self)

def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draw a representation of the LiquidMotor.

Parameters
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ def get_attr_value(obj, attr_name, multiplier=1):
# Write last line
file.write(f"{self.thrust.source[-1, 0]:.4f} {0:.3f}\n")

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

Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/solid_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def propellant_I_13(self):
def propellant_I_23(self):
return 0

def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draw a representation of the SolidMotor.

Parameters
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def underfill_height_exception(param_name, param):
elif (height < bottom_tolerance).any():
underfill_height_exception(name, height)

def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draws the tank geometry.

Parameters
Expand Down
20 changes: 10 additions & 10 deletions rocketpy/plots/aero_surface_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, aero_surface):
self.aero_surface = aero_surface

@abstractmethod
def draw(self, filename=None):
def draw(self, *, filename=None):
pass

def lift(self):
Expand Down Expand Up @@ -54,7 +54,7 @@ class _NoseConePlots(_AeroSurfacePlots):
"""Class that contains all nosecone plots. This class inherits from the
_AeroSurfacePlots class."""

def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draw the nosecone shape along with some important information,
including the center line and the center of pressure position.

Expand Down Expand Up @@ -140,7 +140,7 @@ class _FinsPlots(_AeroSurfacePlots):
_AeroSurfacePlots class."""

@abstractmethod
def draw(self, filename=None):
def draw(self, *, filename=None):
pass

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

# pylint: disable=too-many-statements
def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draw the fin shape along with some important information, including
the center line, the quarter line and the center of pressure position.

Expand Down Expand Up @@ -330,7 +330,7 @@ class _EllipticalFinsPlots(_FinsPlots):
"""Class that contains all elliptical fin plots."""

# pylint: disable=too-many-statements
def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draw the fin shape along with some important information.
These being: the center line and the center of pressure position.

Expand Down Expand Up @@ -409,7 +409,7 @@ class _FreeFormFinsPlots(_FinsPlots):
"""Class that contains all free form fin plots."""

# pylint: disable=too-many-statements
def draw(self, filename=None):
def draw(self, *, filename=None):
"""Draw the fin shape along with some important information.
These being: the center line and the center of pressure position.

Expand Down Expand Up @@ -483,7 +483,7 @@ def draw(self, filename=None):
class _TailPlots(_AeroSurfacePlots):
"""Class that contains all tail plots."""

def draw(self, filename=None):
def draw(self, *, filename=None):
# This will de done in the future
pass

Expand All @@ -498,7 +498,7 @@ def drag_coefficient_curve(self):
else:
return self.aero_surface.drag_coefficient.plot()

def draw(self, filename=None):
def draw(self, *, filename=None):
raise NotImplementedError

def all(self):
Expand All @@ -514,12 +514,12 @@ def all(self):
class _GenericSurfacePlots(_AeroSurfacePlots):
"""Class that contains all generic surface plots."""

def draw(self, filename=None):
def draw(self, *, filename=None):
pass


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

def draw(self, filename=None):
def draw(self, *, filename=None):
pass
2 changes: 2 additions & 0 deletions rocketpy/plots/compare/compare_flights.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from ..plot_helpers import show_or_save_fig, show_or_save_plot
from .compare import Compare

# TODO: needs to refactor this class to use the show_or_save_plot


class CompareFlights(Compare): # pylint: disable=too-many-public-methods
"""A class to compare the results of multiple flights.
Expand Down
34 changes: 20 additions & 14 deletions rocketpy/plots/environment_analysis_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __beaufort_wind_scale(self, units, max_wind_speed=None):

# Surface level plots

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

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

def average_surface_temperature_evolution(
self,
*,
filename=None,
): # pylint: disable=too-many-statements
"""Plots average temperature progression throughout the day, including
Expand Down Expand Up @@ -265,7 +268,7 @@ def average_surface_temperature_evolution(
show_or_save_plot(filename)

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

def average_surface100m_wind_speed_evolution(
self,
*,
filename=None,
): # pylint: disable=too-many-statements
"""Plots average surface wind speed progression throughout the day, including
Expand Down Expand Up @@ -449,7 +453,7 @@ def average_surface100m_wind_speed_evolution(

# Average profiles plots (pressure level data)

def average_wind_speed_profile(self, clear_range_limits=False, filename=None):
def average_wind_speed_profile(self, clear_range_limits=False, *, filename=None):
"""Average wind speed for all datetimes available. The plot also includes
sigma contours.

Expand Down Expand Up @@ -554,7 +558,9 @@ def average_wind_speed_profile(self, clear_range_limits=False, filename=None):
)
show_or_save_plot(filename)

def average_wind_velocity_xy_profile(self, clear_range_limits=False, filename=None):
def average_wind_velocity_xy_profile(
self, clear_range_limits=False, *, filename=None
):
"""Average wind X and wind Y for all datetimes available. The X component
is the wind speed in the direction of East, and the Y component is the
wind speed in the direction of North.
Expand Down Expand Up @@ -621,7 +627,7 @@ def average_wind_velocity_xy_profile(self, clear_range_limits=False, filename=No
plt.grid()
show_or_save_plot(filename)

def average_wind_heading_profile(self, clear_range_limits=False, filename=None):
def average_wind_heading_profile(self, clear_range_limits=False, *, filename=None):
"""Average wind heading for all datetimes available.

Parameters
Expand Down Expand Up @@ -679,7 +685,7 @@ def average_wind_heading_profile(self, clear_range_limits=False, filename=None):
plt.legend()
show_or_save_plot(filename)

def average_pressure_profile(self, clear_range_limits=False, filename=None):
def average_pressure_profile(self, clear_range_limits=False, *, filename=None):
"""Average pressure profile for all datetimes available. The plot also
includes sigma contours.

Expand Down Expand Up @@ -772,7 +778,7 @@ def average_pressure_profile(self, clear_range_limits=False, filename=None):
)
show_or_save_plot(filename)

def average_temperature_profile(self, clear_range_limits=False, filename=None):
def average_temperature_profile(self, clear_range_limits=False, *, filename=None):
"""Average temperature profile for all datetimes available. The plot
also includes sigma contours.

Expand Down Expand Up @@ -918,7 +924,7 @@ def plot_wind_rose(
ax.yaxis.set_major_formatter(mtick.PercentFormatter(decimals=0))
return ax

def average_wind_rose_specific_hour(self, hour, fig=None, filename=None):
def average_wind_rose_specific_hour(self, hour, fig=None, *, filename=None):
"""Plot a specific hour of the average windrose

Parameters
Expand Down Expand Up @@ -952,7 +958,7 @@ def average_wind_rose_specific_hour(self, hour, fig=None, filename=None):
show_or_save_plot(filename)

def average_wind_rose_grid(
self, filename=None
self, *, filename=None
): # pylint: disable=too-many-statements
"""Plot wind roses for all hours of a day, in a grid like plot.

Expand Down Expand Up @@ -1088,7 +1094,7 @@ def animate_average_wind_rose(self, figsize=(5, 5), filename="wind_rose.gif"):
# More plots and animations

def wind_gust_distribution_grid(
self, filename=None
self, *, filename=None
): # pylint: disable=too-many-statements
"""Plots shown in the animation of how the wind gust distribution varies
throughout the day.
Expand Down Expand Up @@ -1264,7 +1270,7 @@ def update(frame):
return HTML(animation.to_jshtml())

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

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

def wind_heading_profile_grid(
self, clear_range_limits=False, filename=None
self, clear_range_limits=False, *, filename=None
): # pylint: disable=too-many-statements
"""Creates a grid of plots with the wind heading profile over the
average day. Each subplot represents a different hour of the day.
Expand Down
8 changes: 4 additions & 4 deletions rocketpy/plots/environment_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __pressure_temperature(self, ax):

return ax

def gravity_model(self, filename=None):
def gravity_model(self, *, filename=None):
"""Plots the gravity model graph that represents the gravitational
acceleration as a function of height.

Expand Down Expand Up @@ -204,7 +204,7 @@ def gravity_model(self, filename=None):

show_or_save_plot(filename)

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

# pylint: disable=too-many-statements
def ensemble_member_comparison(self, filename=None):
def ensemble_member_comparison(self, *, filename=None):
"""Plots ensemble member comparisons. It requires that the environment
model has been set as Ensemble.

Expand Down Expand Up @@ -352,7 +352,7 @@ def ensemble_member_comparison(self, filename=None):
# Clean up
self.environment.select_ensemble_member(current_member)

def info(self, filename=None):
def info(self, *, filename=None):
"""Plots a summary of the atmospheric model, including wind speed and
wind direction, density and speed of sound. This is important for the
Environment.info() method.
Expand Down
Loading