Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mpvanderschelling committed Feb 7, 2024
1 parent dca4c69 commit 56da418
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/f3dasm/_src/experimentdata/experimentdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def __init__(self,

def __len__(self):
"""The len() method returns the number of datapoints"""
if self._input_data.is_empty():
return len(self._output_data)

return len(self._input_data)

def __iter__(self) -> Iterator[Tuple[Dict[str, Any]]]:
Expand Down Expand Up @@ -235,6 +238,9 @@ def index(self) -> pd.Index:
pd.Index
The job number of all the experiments in pandas Index format
"""
if self._input_data.is_empty():
return self._output_data.indices

return self._input_data.indices

# Alternative Constructors
Expand Down Expand Up @@ -795,7 +801,11 @@ def _reset_index(self) -> None:
Reset the index of the ExperimentData object.
"""
self._input_data.reset_index()
self._output_data.reset_index(self._input_data.indices)

if self._input_data.is_empty():
self._output_data.reset_index()
else:
self._output_data.reset_index(self._input_data.indices)
self._jobs.reset_index()

# ExperimentSample
Expand Down Expand Up @@ -1466,6 +1476,7 @@ def _iterate_scipy(self, optimizer: Optimizer,
ValueError
Raised when invalid x0_selection is specified
"""
last_index = self.index[-1] if not self.index.empty else -1
n_data_before_iterate = len(self)

if isinstance(x0_selection, str):
Expand All @@ -1491,6 +1502,16 @@ def _iterate_scipy(self, optimizer: Optimizer,
if callback is not None:
callback(init_samples)

if overwrite:
_indices = init_samples.index + last_index + 1
self._overwrite_experiments(
experiment_sample=init_samples,
indices=_indices,
add_if_not_exist=True)

else:
self.add_experiments(init_samples)

x0_selection = 'last'

x0 = x0_factory(experiment_data=self, mode=x0_selection,
Expand Down

0 comments on commit 56da418

Please sign in to comment.