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

Modularize validate method for multi-table synthesizers #2292

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 14 additions & 10 deletions sdv/multi_table/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,8 @@ def _validate_all_tables(self, data):

return errors

def validate(self, data):
"""Validate the data.

Validate that the metadata matches the data and thta every table's constraints are valid.

Args:
data (dict):
A dictionary of table names to pd.DataFrames.
"""
def _validate(self, data):
"""Validate metadata, constraints, and data."""
errors = []
constraints_errors = []
self.metadata.validate_data(data)
Expand All @@ -268,6 +261,17 @@ def validate(self, data):
elif errors:
raise InvalidDataError(errors)

def validate(self, data):
"""Validate the data.

Validate that the metadata matches the data and thta every table's constraints are valid.

Args:
data (dict):
A dictionary of table names to pd.DataFrames.
"""
self._validate(data)

def _validate_table_name(self, table_name):
if table_name not in self._table_synthesizers:
raise ValueError(
Expand Down Expand Up @@ -368,8 +372,8 @@ def preprocess(self, data):
"""
list_of_changed_tables = self._store_and_convert_original_cols(data)

data = self._transform_helper(data)
self.validate(data)
data = self._transform_helper(data)
if self._fitted:
warnings.warn(
'This model has already been fitted. To use the new preprocessed data, '
Expand Down
Loading