Skip to content

Commit

Permalink
fix(synthesizer): add already_fitted for synthesizer (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa authored Feb 6, 2024
1 parent acfcddd commit 6f271e1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ydata/sdk/synthesizers/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def fit(self, X: Union[DataSource, pdDataFrame],
anonymize (Optional[str]): (optional) fields to anonymize and the anonymization strategy
condition_on: (Optional[List[str]]): (optional) list of features to condition upon
"""
if self._is_initialized():
if self._already_fitted():
raise AlreadyFittedError()

_datatype = DataSourceType(datatype) if isinstance(
Expand Down Expand Up @@ -383,6 +383,16 @@ def _is_initialized(self) -> bool:
"""
return self._model is not None

def _already_fitted(self) -> bool:
"""Determine if a synthesizer is already fitted.
Returns:
True if the synthesizer is instanciated
"""

return self._is_initialized() and (self._model.status and self._model.status.training and
self._model.status.training.state is not [TrainingState.PREPARING])

@staticmethod
def _resolve_api_status(api_status: Dict) -> Status:
"""Determine the status of the Synthesizer.
Expand Down

0 comments on commit 6f271e1

Please sign in to comment.