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

Add _validate_inputs class method to constraints #914

Merged
merged 6 commits into from
Jul 25, 2022

Conversation

fealho
Copy link
Member

@fealho fealho commented Jul 20, 2022

Resolve #878.

@fealho fealho changed the base branch from master to V1.0.0.dev July 21, 2022 13:50
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2022

Codecov Report

Merging #914 (116ab0a) into V1.0.0.dev (1d6dc06) will increase coverage by 2.13%.
The diff coverage is 100.00%.

@@              Coverage Diff               @@
##           V1.0.0.dev     #914      +/-   ##
==============================================
+ Coverage       68.59%   70.73%   +2.13%     
==============================================
  Files              38       39       +1     
  Lines            2866     3075     +209     
==============================================
+ Hits             1966     2175     +209     
  Misses            900      900              
Impacted Files Coverage Δ
sdv/constraints/base.py 97.23% <100.00%> (+0.34%) ⬆️
sdv/constraints/tabular.py 99.75% <100.00%> (+0.01%) ⬆️
sdv/lite/tabular.py 100.00% <0.00%> (ø)
sdv/relational/hma.py 11.48% <0.00%> (ø)
sdv/timeseries/base.py 0.00% <0.00%> (ø)
sdv/metadata/__init__.py 100.00% <0.00%> (ø)
sdv/metadata/single_table.py 98.70% <0.00%> (ø)
sdv/tabular/base.py 83.85% <0.00%> (+1.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d6dc06...116ab0a. Read the comment docs.

@fealho fealho marked this pull request as ready for review July 21, 2022 16:45
@fealho fealho requested a review from a team as a code owner July 21, 2022 16:45
@fealho fealho requested review from katxiao, amontanez24 and pvk-developer and removed request for a team and katxiao July 21, 2022 16:45
Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a lot of the classes can just use the base method if we make the base method use introspection to get the parameters names from __init__

sdv/constraints/tabular.py Outdated Show resolved Hide resolved
if missing_values:
if constraint_name == 'Inequality':
errors.append(ValueError(
f'Missing required values {missing_values} in an {constraint_name} constraint.'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like these if statements. @amontanez24 @pvk-developer what do you guys think of deleting it, so the error would just say a Inequality constraint instead of an Inequality constraint. It doesn't sound too wrong to me, and I'd rather the code be cleaner than a very minor grammatical thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing the ifs we can just ake a variable ccalled article and use that in the f-string. eg.

article = 'an' if constraint_name == 'Inequality' else 'a'
errors.append(ValueError(f'Missing required values {missing_values} in {article} {constraint_name} constraint.'))

Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment about removing the ifs for the Inequality cases. Once that change is done this should be good to go!

sdv/constraints/base.py Outdated Show resolved Hide resolved
sdv/constraints/tabular.py Show resolved Hide resolved
sdv/constraints/tabular.py Show resolved Hide resolved
sdv/constraints/tabular.py Show resolved Hide resolved
sdv/constraints/base.py Outdated Show resolved Hide resolved
@fealho fealho merged commit 38dca14 into V1.0.0.dev Jul 25, 2022
@fealho fealho deleted the issue-878-validate-inputs branch July 25, 2022 22:28
pvk-developer pushed a commit that referenced this pull request Aug 9, 2022
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
pvk-developer pushed a commit that referenced this pull request Aug 10, 2022
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
amontanez24 pushed a commit that referenced this pull request Sep 13, 2022
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
amontanez24 pushed a commit that referenced this pull request Nov 22, 2022
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
amontanez24 pushed a commit that referenced this pull request Dec 21, 2022
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
amontanez24 pushed a commit that referenced this pull request Feb 17, 2023
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
amontanez24 pushed a commit that referenced this pull request Mar 23, 2023
* Add functionality and tests

* Update tests

* Switch tests to using regex

* Trigger Build

* Address feedback

* Change Inequality if statements to one liner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add _validate_inputs class method to each constraint
4 participants