-
Notifications
You must be signed in to change notification settings - Fork 320
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
Add create_custom_constraint
method
#848
Conversation
1d6cef1
to
05cd96e
Compare
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.
Could we also add an integration test with a CustomConstraint
?
sdv/constraints/tabular.py
Outdated
|
||
return table_data | ||
TYPE = 'CUSTOM_CONSTRAINT' # this lets us know how to handle it |
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.
Can we either make this a boolean flag like is_custom
or create an enum class for this? The reason would be that whenever someone is doing logic around this attribute, they would have to know the string value for custom constraints and any other type. It would be easier if they could see all the possible values. Here is an example of enums: https://docs.python.org/3/library/enum.html
Personally though, I think this can just be a boolean
Codecov Report
@@ Coverage Diff @@
## master #848 +/- ##
==========================================
+ Coverage 68.04% 70.65% +2.60%
==========================================
Files 38 38
Lines 2857 3196 +339
==========================================
+ Hits 1944 2258 +314
- Misses 913 938 +25
Continue to review full report at Codecov.
|
65741a0
to
86f01bc
Compare
cd28d99
to
fdff66a
Compare
Andrew Montanez seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
fdff66a
to
1cdda5c
Compare
sdv/constraints/base.py
Outdated
@@ -245,30 +245,6 @@ def filter_valid(self, table_data): | |||
|
|||
return table_data[valid] | |||
|
|||
@classmethod | |||
def from_dict(cls, constraint_dict): |
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.
This is not used anywhere else right now (and it causes problems for the changes introduced by this PR), which is why it's been deleted.
sdv/constraints/tabular.py
Outdated
|
||
return np.logical_and.reduce(valid) | ||
def _transform(self, data): |
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.
I thought we were going to override the transform
method and do something to catch errors so that it is possible to fall back on reject sampling. Currently, the logic only falls back if the constraint raises a MissingConstraintColumnError
, but that can't happen with a custom constraint. We either need to catch most/all errors and surface it as a MissingConstraintColumnError
, or provide some special logic to handle that
commit 04d1549 Author: Felipe Alex Hofmann <fealho@gmail.com> Date: Tue Jun 28 19:49:25 2022 -0700 Move `data.copy` to base class of constraints (#849) * changing logic for handling constraints * fixing a lot of tests * removing handling_strategy attribute * removing handling_strategy from docs and code * fixing tests, docs and tutorials * adding unit tests * only calling reverse_transform if custom constraint * ignoring sre_parse during isort * pr comments * raising all errors except missing column erros * adding integration test and tracking if reverse transform should use reject sampling * refactoring how constraint transforms happen * adding unit tests * Rebase + move copy to base * Fix test cases * fix rebase * Test resulting data is a copy for transform/reverse_transform Co-authored-by: Andrew Montanez <amontanez2424@gmail.com> Co-authored-by: Andrew Montanez <andrewmontanez@Andrews-MBP.hsd1.ma.comcast.net> Co-authored-by: Andrew Montanez <andrew@datacebo.com> Co-authored-by: Andrew Montanez <andrew@sdv.dev>
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.
This is looking good! 2 comments
- We may want to rebase off of this branch after it gets merged to make sure nothing weird happens with the loading of the constraints: Update handling constraints doc #856
- We should add a custom constraint to the
integration/test_constraints.py
file
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.
One small comment but besides that
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.
LGTM!
Resolve #836.