Skip to content

Commit

Permalink
Fixed unnecessary column creation during variable init.
Browse files Browse the repository at this point in the history
  • Loading branch information
pineapple-cat committed Jan 27, 2025
1 parent 7df7ca8 commit 20d4665
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/hivpy/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ def init_variable(self, name: str, init_val, n_prev_steps=0, data_type=None):
to be stored (default 0).
"""
self.variable_history[name] = n_prev_steps + 1
if data_type is not None:
self.data[name] = pd.Series([init_val]*self.size, dtype=data_type)
if (n_prev_steps == 0):
if data_type is not None:
self.data[name] = pd.Series([init_val]*self.size, dtype=data_type)
else:
self.data[name] = init_val
else:
self.data[name] = init_val
if (n_prev_steps > 0):
for i in range(0, n_prev_steps + 1):
if data_type is not None:
self.data[self.constructParamColumn(name, i)] = pd.Series([init_val]*self.size, dtype=data_type)
Expand Down

0 comments on commit 20d4665

Please sign in to comment.