Skip to content

Commit

Permalink
Merge pull request #492 from fast-aircraft-design/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
christophe-david committed May 9, 2023
2 parents 6c57928 + 377e3e4 commit 1345b89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
19 changes: 7 additions & 12 deletions src/fastoad/models/performances/mission/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_first_route_in_sequence(
def compute_from(self, start: FlightPoint) -> pd.DataFrame:
if self.target_fuel_consumption is None:
flight_points = super().compute_from(start)
flight_points.name.loc[flight_points.name.isnull()] = ""
flight_points.loc[flight_points.name.isnull()].name = ""
self._compute_reserve(flight_points)
return flight_points

Expand Down Expand Up @@ -109,17 +109,12 @@ def _compute_reserve(self, flight_points):
base_route_name = self.reserve_base_route_name

reserve_fuel = self.reserve_ratio * self._get_consumed_mass_in_route(base_route_name)
reserve_points = pd.DataFrame(
[
deepcopy(flight_points.iloc[-1]),
deepcopy(flight_points.iloc[-1]),
]
)
last_flight_point = flight_points.iloc[-1]

after_reserve_point = deepcopy(last_flight_point)
after_reserve_point.mass = last_flight_point.mass - reserve_fuel

# We are not using -= here because it would operate last_flight_point.mass can be
# an array. The operator would operate element-wise and would modify the original
# flight point, despite the deepcopy.
reserve_points.mass.iloc[-1] = reserve_points.mass.iloc[0] - reserve_fuel
reserve_points = pd.DataFrame([last_flight_point, after_reserve_point])
reserve_points["name"] = f"{self.name}:reserve"

self.part_flight_points.append(reserve_points)
Expand Down Expand Up @@ -158,7 +153,7 @@ def _compute_flight(self, cruise_distance, start: FlightPoint):
"""
self.first_route.cruise_distance = cruise_distance
flight_points = super().compute_from(start)
flight_points.name.loc[flight_points.name.isnull()] = ""
flight_points.loc[flight_points.name.isnull()].name = ""
self._compute_reserve(flight_points)
self._flight_points = flight_points
return self.target_fuel_consumption - self.consumed_fuel
12 changes: 6 additions & 6 deletions src/fastoad/models/performances/mission/openmdao/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ def initialize(self):
)
self.options.declare(
"compute_TOW",
default=None,
default=False,
types=bool,
deprecation='Option "compute_TOW" is deprecated for mission module. '
'Please use "compute_input_weight" instead.',
deprecation=(
'Option "compute_TOW" is deprecated for mission module. '
'Please use "compute_input_weight" instead.',
"compute_input_weight",
),
desc="If True, TakeOff Weight will be computed from onboard fuel at takeoff and ZFW.\n"
"If False, block fuel will be computed from ramp weight and ZFW.\n"
"Not used (actually forced to True) if adjust_fuel is True.",
Expand All @@ -102,9 +105,6 @@ def initialize(self):
def setup(self):
super().setup()

if self.options["compute_TOW"] is not None:
self.options["compute_input_weight"] = self.options["compute_TOW"]

mission_options = {
key: val for key, val in self.options.items() if key in AdvancedMissionComp().options
}
Expand Down

0 comments on commit 1345b89

Please sign in to comment.