Skip to content

Commit 26834dc

Browse files
DEV: add pragma comments to exclude specific lines from coverage
1 parent 9b65393 commit 26834dc

File tree

15 files changed

+82
-86
lines changed

15 files changed

+82
-86
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
"rtol",
263263
"rtype",
264264
"rucsoundings",
265+
"runslow",
265266
"rwork",
266267
"savetxt",
267268
"savgol",

rocketpy/environment/environment.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ def __initialize_utm_coordinates(self):
456456
flattening=self.ellipsoid.flattening,
457457
semi_major_axis=self.ellipsoid.semi_major_axis,
458458
)
459-
else:
460-
# pragma: no cover
459+
else: # pragma: no cover
461460
warnings.warn(
462461
"UTM coordinates are not available for latitudes "
463462
"above 84 or below -80 degrees. The UTM conversions will fail."
@@ -712,8 +711,8 @@ def set_location(self, latitude, longitude):
712711

713712
if not isinstance(latitude, NUMERICAL_TYPES) and isinstance(
714713
longitude, NUMERICAL_TYPES
715-
):
716-
# pragma: no cover
714+
): # pragma: no cover
715+
717716
raise TypeError("Latitude and Longitude must be numbers!")
718717

719718
# Store latitude and longitude
@@ -809,8 +808,8 @@ def max_expected_height(self):
809808

810809
@max_expected_height.setter
811810
def max_expected_height(self, value):
812-
if value < self.elevation:
813-
raise ValueError( # pragma: no cover
811+
if value < self.elevation: # pragma: no cover
812+
raise ValueError(
814813
"Max expected height cannot be lower than the surface elevation"
815814
)
816815
self._max_expected_height = value
@@ -949,8 +948,8 @@ def get_elevation_from_topographic_profile(self, lat, lon):
949948
Elevation provided by the topographic data, in meters.
950949
"""
951950
# TODO: refactor this method. pylint: disable=too-many-statements
952-
if self.topographic_profile_activated is False:
953-
raise ValueError( # pragma: no cover
951+
if self.topographic_profile_activated is False: # pragma: no cover
952+
raise ValueError(
954953
"You must define a Topographic profile first, please use the "
955954
"Environment.set_topographic_profile() method first."
956955
)
@@ -1279,8 +1278,8 @@ def set_atmospheric_model( # pylint: disable=too-many-statements
12791278
self.process_forecast_reanalysis(dataset, dictionary)
12801279
else:
12811280
self.process_ensemble(dataset, dictionary)
1282-
else:
1283-
raise ValueError(f"Unknown model type '{type}'.") # pragma: no cover
1281+
else: # pragma: no cover
1282+
raise ValueError(f"Unknown model type '{type}'.")
12841283

12851284
if type not in ["ensemble"]:
12861285
# Ensemble already computed these values
@@ -2749,7 +2748,7 @@ def decimal_degrees_to_arc_seconds(angle):
27492748
return degrees, arc_minutes, arc_seconds
27502749

27512750

2752-
if __name__ == "__main__":
2751+
if __name__ == "__main__": # pragma: no cover
27532752
import doctest
27542753

27552754
results = doctest.testmod()

rocketpy/environment/fetchers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ def fetch_atmospheric_data_from_windy(lat, lon, model):
7979

8080
try:
8181
response = requests.get(url).json()
82-
if "data" not in response.keys():
82+
if "data" not in response.keys(): # pragma: no cover
8383
raise ValueError(
8484
f"Could not get a valid response for '{model}' from Windy. "
8585
"Check if the coordinates are set inside the model's domain."
8686
)
87-
except requests.exceptions.RequestException as e:
87+
except requests.exceptions.RequestException as e: # pragma: no cover
8888
if model == "iconEu":
8989
raise ValueError(
9090
"Could not get a valid response for Icon-EU from Windy. "
@@ -315,8 +315,8 @@ def fetch_wyoming_sounding(file):
315315
If the response indicates the output format is invalid.
316316
"""
317317
response = requests.get(file)
318-
if response.status_code != 200:
319-
raise ImportError(f"Unable to load {file}.") # pragma: no cover
318+
if response.status_code != 200: # pragma: no cover
319+
raise ImportError(f"Unable to load {file}.")
320320
if len(re.findall("Can't get .+ Observations at", response.text)):
321321
raise ValueError(
322322
re.findall("Can't get .+ Observations at .+", response.text)[0]
@@ -330,7 +330,7 @@ def fetch_wyoming_sounding(file):
330330

331331

332332
@exponential_backoff(max_attempts=5, base_delay=2, max_delay=60)
333-
def fetch_noaaruc_sounding(file):
333+
def fetch_noaaruc_sounding(file): # pragma: no cover
334334
"""Fetches sounding data from a specified file using the NOAA RUC soundings.
335335
336336
Parameters

rocketpy/environment/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def utm_to_geodesic( # pylint: disable=too-many-locals,too-many-statements
590590
return lat, lon
591591

592592

593-
if __name__ == "__main__":
593+
if __name__ == "__main__": # pragma: no cover
594594
import doctest
595595

596596
results = doctest.testmod()

rocketpy/mathutils/function.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ def plot(self, *args, **kwargs):
14791479
else:
14801480
print("Error: Only functions with 1D or 2D domains can be plotted.")
14811481

1482-
def plot1D(self, *args, **kwargs):
1482+
def plot1D(self, *args, **kwargs): # pragma: no cover
14831483
"""Deprecated method, use Function.plot_1d instead."""
14841484
warnings.warn(
14851485
"The `Function.plot1D` method is set to be deprecated and fully "
@@ -1579,7 +1579,7 @@ def plot_1d( # pylint: disable=too-many-statements
15791579
if return_object:
15801580
return fig, ax
15811581

1582-
def plot2D(self, *args, **kwargs):
1582+
def plot2D(self, *args, **kwargs): # pragma: no cover
15831583
"""Deprecated method, use Function.plot_2d instead."""
15841584
warnings.warn(
15851585
"The `Function.plot2D` method is set to be deprecated and fully "
@@ -2770,7 +2770,7 @@ def differentiate_complex_step(self, x, dx=1e-200, order=1):
27702770
"""
27712771
if order == 1:
27722772
return float(self.get_value_opt(x + dx * 1j).imag / dx)
2773-
else:
2773+
else: # pragma: no cover
27742774
raise NotImplementedError(
27752775
"Only 1st order derivatives are supported yet. Set order=1."
27762776
)
@@ -3262,7 +3262,7 @@ def __validate_source(self, source): # pylint: disable=too-many-statements
32623262
self.__inputs__ = header[:-1]
32633263
if self.__outputs__ is None:
32643264
self.__outputs__ = [header[-1]]
3265-
except Exception as e:
3265+
except Exception as e: # pragma: no cover
32663266
raise ValueError(
32673267
"Could not read the csv or txt file to create Function source."
32683268
) from e
@@ -3668,7 +3668,7 @@ def reset_funcified_methods(instance):
36683668
instance.__dict__.pop(key)
36693669

36703670

3671-
if __name__ == "__main__":
3671+
if __name__ == "__main__": # pragma: no cover
36723672
import doctest
36733673

36743674
results = doctest.testmod()

rocketpy/mathutils/vector_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ def transformation_euler_angles(roll, pitch, roll2):
10931093
return Matrix.transformation(euler313_to_quaternions(roll, pitch, roll2))
10941094

10951095

1096-
if __name__ == "__main__":
1096+
if __name__ == "__main__": # pragma: no cover
10971097
import doctest
10981098

10991099
results = doctest.testmod()

rocketpy/motors/fluid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def __post_init__(self):
3030
If the density is not a positive number.
3131
"""
3232

33-
if not isinstance(self.name, str):
33+
if not isinstance(self.name, str): # pragma: no cover
3434
raise ValueError("The name must be a string.")
35-
if self.density < 0:
35+
if self.density < 0: # pragma: no cover
3636
raise ValueError("The density must be a positive number.")
3737

3838
# Initialize plots and prints object

rocketpy/motors/motor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class Function. Thrust units are Newtons.
247247
self._csys = 1
248248
elif coordinate_system_orientation == "combustion_chamber_to_nozzle":
249249
self._csys = -1
250-
else:
250+
else: # pragma: no cover
251251
raise ValueError(
252252
"Invalid coordinate system orientation. Options are "
253253
"'nozzle_to_combustion_chamber' and 'combustion_chamber_to_nozzle'."
@@ -346,7 +346,7 @@ def burn_time(self, burn_time):
346346
else:
347347
if not callable(self.thrust.source):
348348
self._burn_time = (self.thrust.x_array[0], self.thrust.x_array[-1])
349-
else:
349+
else: # pragma: no cover
350350
raise ValueError(
351351
"When using a float or callable as thrust source, a burn_time"
352352
" argument must be specified."

rocketpy/plots/rocket_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def _draw_generic_surface(
385385
x_pos = position[2]
386386
# y position of the surface is the y position in the plot
387387
y_pos = position[1]
388-
else:
388+
else: # pragma: no cover
389389
raise ValueError("Plane must be 'xz' or 'yz'.")
390390

391391
ax.scatter(
@@ -633,7 +633,7 @@ def _draw_sensors(self, ax, sensors, plane):
633633
# y position of the sensor is the y position in the plot
634634
y_pos = pos[1]
635635
normal_y = sensor.normal_vector.y
636-
else:
636+
else: # pragma: no cover
637637
raise ValueError("Plane must be 'xz' or 'yz'.")
638638

639639
# line length is 2/5 of the rocket radius

rocketpy/prints/compare_prints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
class _ComparePrints:
1+
class _ComparePrints: # pragma: no cover
22
def __init__(self) -> None:
33
pass

0 commit comments

Comments
 (0)