-
Notifications
You must be signed in to change notification settings - Fork 366
Allow is_valid
to be called on unfit constraints
#2578
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ def __init__(self, column_names, table_name): | |
self.table_name = table_name | ||
self._joint_column = '#'.join(self.column_names) | ||
self._combinations = None | ||
self._fitted = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need it so we can use the |
||
|
||
def _get_single_table_name(self, metadata): | ||
# Have to define this so that we can re-use existing methods on the constraint | ||
|
@@ -114,6 +115,7 @@ def fit(self, data, metadata): | |
self.metadata = metadata | ||
data = {self.table_name: data} | ||
FixedCombinations._fit(self, data, metadata) | ||
self._fitted = True | ||
|
||
def transform(self, data): | ||
data = {self.table_name: data} | ||
|
@@ -130,7 +132,7 @@ def reverse_transform(self, transformed_data): | |
|
||
def is_valid(self, synthetic_data): | ||
synthetic_data = {self.table_name: synthetic_data} | ||
is_valid = FixedCombinations._is_valid(self, synthetic_data) | ||
is_valid = FixedCombinations._is_valid(self, synthetic_data, self.metadata) | ||
return is_valid[self.table_name] | ||
|
||
return MyConstraint | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, should we update the if condition to be the same as in the base cag class:
if isinstance(data, pd.DataFrame) or self._single_table:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is a different check - the
_is_single_table
attribute on the harness controls whether we expect a single dataframe or a dataframe dict from the programmable constraint (based on whether it's aSingleTableProgrammableConstraint
or aProgrammableConstraint
).