Skip to content

Commit bdc51ba

Browse files
committed
BUG: fix dry_mass None check
1 parent 9c0b3e7 commit bdc51ba

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

rocketpy/motors/motor.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,38 @@ def burn_time(self, burn_time):
345345
" argument must be specified."
346346
)
347347

348+
@property
349+
def dry_mass(self):
350+
"""Dry mass of the motor in kg.
351+
352+
Returns
353+
-------
354+
self.dry_mass : float
355+
Motor dry mass in kg.
356+
"""
357+
return self._dry_mass
358+
359+
@dry_mass.setter
360+
def dry_mass(self, dry_mass):
361+
"""Sets dry mass of the motor in kg.
362+
363+
Parameters
364+
----------
365+
dry_mass : float
366+
Motor dry mass in kg.
367+
"""
368+
if dry_mass is not None:
369+
if isinstance(dry_mass, (int, float)):
370+
self._dry_mass = dry_mass
371+
else:
372+
raise ValueError("Dry mass must be a number.")
373+
elif self.description_eng_file:
374+
self._dry_mass = float(self.description_eng_file[-2]) - float(
375+
self.description_eng_file[-3]
376+
)
377+
else:
378+
raise ValueError("Dry mass must be specified.")
379+
348380
@cached_property
349381
def total_impulse(self):
350382
"""Calculates and returns total impulse by numerical integration

0 commit comments

Comments
 (0)