Skip to content

Commit

Permalink
move indexing out from add_data to not overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
roussel-ryan committed Oct 31, 2024
1 parent 8e54995 commit 9109752
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xopt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ def evaluate_data(
# explode any list like results if all the output names exist
output_data = explode_all_columns(output_data)

# add correct indexes
if self.data is not None:
output_data.index = np.arange(len(self.data), len(self.data) + len(output_data))

self.add_data(output_data)

# dump data to file if specified
Expand All @@ -356,8 +360,6 @@ def add_data(self, new_data: pd.DataFrame):
# Set internal dataframe.
if self.data is not None:
new_data = pd.DataFrame(new_data, copy=True) # copy for reindexing
new_data.index = np.arange(len(self.data), len(self.data) + len(new_data))

self.data = pd.concat([self.data, new_data], axis=0)
else:
if new_data.index.dtype != np.int64:
Expand Down

0 comments on commit 9109752

Please sign in to comment.