Skip to content

Commit

Permalink
Fix demand cloning bug
Browse files Browse the repository at this point in the history
While demand cloning was happening for the `sample` attribute,
the units were left unchanged, leading to missing values down the
line. It only took two lines of code to fix this, using the existing
reindexing operation followed by normalizing the index of `units`.
  • Loading branch information
ioannis-vm committed Apr 10, 2024
1 parent 087e92d commit 8f6d255
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pelicun/model/demand_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,9 @@ def turn_to_tuples(demand_cloning):
self.sample = self.sample.iloc[:, column_index]
# update the column index
self.sample.columns = pd.MultiIndex.from_tuples(column_values)
# update units
self.units = self.units.iloc[column_index]
self.units.index = self.sample.columns

def generate_sample(self, config):
"""
Expand Down

0 comments on commit 8f6d255

Please sign in to comment.