Skip to content

Commit

Permalink
Update preprocess_data
Browse files Browse the repository at this point in the history
  • Loading branch information
fealho committed Aug 2, 2023
1 parent c4a5230 commit 8372027
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sdv/single_table/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,9 @@ def fit_processed_data(self, processed_data):
processed_data (pandas.DataFrame):
The transformed data used to fit the model to.
"""
self._fit(processed_data)
if not processed_data.empty:
self._fit(processed_data)

self._fitted = True
self._fitted_date = datetime.datetime.today().strftime('%Y-%m-%d')
self._fitted_sdv_version = pkg_resources.get_distribution('sdv').version
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/multi_table/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,20 @@ def test_fit_processed_data(self):
instance._augment_tables.assert_called_once_with(data)
instance._model_tables.assert_called_once_with(instance._augment_tables.return_value)
assert instance._fitted

def test_fit_processed_data_empty_table(self):
"""Test the fit attributes are properly set when data is empty."""
# Setup
instance = Mock()
data = pd.DataFrame()

# Run
BaseMultiTableSynthesizer.fit_processed_data(instance, data)

# Assert
assert instance._fitted
assert instance._fitted_date
assert instance._fitted_sdv_version

def test_fit(self):
"""Test that ``fit`` calls ``preprocess`` and then ``fit_processed_data``."""
Expand Down

0 comments on commit 8372027

Please sign in to comment.