Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(synthesizer): add already_fitted for synthesizer #87

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading