Skip to content

Commit

Permalink
MNT: linters
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Dec 16, 2024
1 parent 6ef5d3e commit c07b50b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,7 @@ def set_earth_geometry(self, datum):
}
try:
return ellipsoid[datum]
except KeyError as e:
except KeyError as e: # pragma: no cover
available_datums = ', '.join(ellipsoid.keys())
raise AttributeError(
f"The reference system '{datum}' is not recognized. Please use one of "
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/rocket/aero_surface/nose_cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def bluffness(self, value):
raise ValueError(
"Parameter 'bluffness' must be None or 0 when using a nose cone kind 'powerseries'."
)
if value is not None and not (0 <= value <= 1): # pragma: no cover
if value is not None and not 0 <= value <= 1: # pragma: no cover
raise ValueError(
f"Bluffness ratio of {value} is out of range. "
"It must be between 0 and 1."
Expand Down
5 changes: 2 additions & 3 deletions rocketpy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,8 @@ def wrapper(*args, **kwargs):
for i in range(max_attempts):
try:
return func(*args, **kwargs)
except (
Exception
) as e: # pragma: no cover # pylint: disable=broad-except
# pylint: disable=broad-except
except Exception as e: # pragma: no cover
if i == max_attempts - 1:
raise e from None
delay = min(delay * 2, max_delay)
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_aero_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def test_powerseries_nosecones_setters(power, invalid_power, new_power):


@patch("matplotlib.pyplot.show")
def test_elliptical_fins_draw(mock_show, elliptical_fin_set):
def test_elliptical_fins_draw(
mock_show, elliptical_fin_set
): # pylint: disable=unused-argument
assert elliptical_fin_set.plots.draw(filename=None) is None


Expand All @@ -85,7 +87,9 @@ def test_nose_cone_info(calisto_nose_cone):


@patch("matplotlib.pyplot.show")
def test_nose_cone_draw(mock_show, calisto_nose_cone):
def test_nose_cone_draw(
mock_show, calisto_nose_cone
): # pylint: disable=unused-argument
assert calisto_nose_cone.draw(filename=None) is None


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,5 @@ def expected_gas_inertia(t):


@patch("matplotlib.pyplot.show")
def test_tank_geometry_plots_info(mock_show):
def test_tank_geometry_plots_info(mock_show): # pylint: disable=unused-argument
assert TankGeometry({(0, 5): 1}).plots.all() is None
28 changes: 15 additions & 13 deletions tests/unit/test_units.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import pytest

from rocketpy.units import (
conversion_factor,
convert_temperature,
convert_units,
)
from rocketpy.units import conversion_factor, convert_temperature, convert_units


class TestConvertTemperature:
"""Tests for the convert_temperature function."""

def test_convert_temperature_same_unit(self):
assert convert_temperature(300, "K", "K") == 300
assert convert_temperature(27, "degC", "degC") == 27
assert convert_temperature(80, "degF", "degF") == 80

def test_convert_temperature_K_to_degC(self):
def test_convert_temperature_kelvin_to_celsius(self):
assert convert_temperature(300, "K", "degC") == pytest.approx(26.85, rel=1e-2)

def test_convert_temperature_K_to_degF(self):
def test_convert_temperature_kelvin_to_fahrenheit(self):
assert convert_temperature(300, "K", "degF") == pytest.approx(80.33, rel=1e-2)

def test_convert_temperature_degC_to_K(self):
def test_convert_temperature_celsius_to_kelvin(self):
assert convert_temperature(27, "degC", "K") == pytest.approx(300.15, rel=1e-2)

def test_convert_temperature_degC_to_degF(self):
def test_convert_temperature_celsius_to_fahrenheit(self):
assert convert_temperature(27, "degC", "degF") == pytest.approx(80.6, rel=1e-2)

def test_convert_temperature_degF_to_K(self):
def test_convert_temperature_fahrenheit_to_kelvin(self):
assert convert_temperature(80, "degF", "K") == pytest.approx(299.817, rel=1e-2)

def test_convert_temperature_degF_to_degC(self):
def test_convert_temperature_fahrenheit_to_celsius(self):
assert convert_temperature(80, "degF", "degC") == pytest.approx(26.67, rel=1e-2)

def test_convert_temperature_invalid_conversion(self):
Expand All @@ -39,6 +37,8 @@ def test_convert_temperature_invalid_conversion(self):


class TestConversionFactor:
"""Tests for the conversion_factor function."""

def test_conversion_factor_same_unit(self):
assert conversion_factor("m", "m") == 1
assert conversion_factor("ft", "ft") == 1
Expand All @@ -64,15 +64,17 @@ def test_conversion_factor_invalid_conversion(self):


class TestConvertUnits:
"""Tests for the convert_units function."""

def test_convert_units_same_unit(self):
assert convert_units(300, "K", "K") == 300
assert convert_units(27, "degC", "degC") == 27
assert convert_units(80, "degF", "degF") == 80

def test_convert_units_K_to_degC(self):
def test_convert_units_kelvin_to_celsius(self):
assert convert_units(300, "K", "degC") == pytest.approx(26.85, rel=1e-2)

def test_convert_units_K_to_degF(self):
def test_convert_units_kelvin_to_fahrenheit(self):
assert convert_units(300, "K", "degF") == pytest.approx(80.33, rel=1e-2)

def test_convert_units_kilogram_to_pound(self):
Expand Down

0 comments on commit c07b50b

Please sign in to comment.