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

Improve error message for ColumnFormula constraint when constraint column used in formula #508

Closed
fealho opened this issue Jul 12, 2021 · 1 comment · Fixed by #531
Closed
Assignees
Labels
feature request Request for a new feature
Milestone

Comments

@fealho
Copy link
Member

fealho commented Jul 12, 2021

Using the ColumnFormula constraint where the constraint column is used in the constraint formula crashes with a KeyError. While this is expected, the error message could be improved to provide a more meaningful explanation of what's causing the issue.

Below is some code to produce this error:

import pandas as pd
from sdv.constraints import *
from sdv.tabular import *

ones = [1 for i in range(10)]
data = pd.DataFrame({
    'a': ones,
    'b': ones,
    'c': ones
})

def formula(data):
    return data['a']

constraint = ColumnFormula(
    column='a',
    formula=formula
)

model = GaussianCopula(constraints=[constraint])
model.fit(data)
samples = model.sample(10)
@fealho fealho added feature request Request for a new feature pending review labels Jul 12, 2021
@katxiao katxiao self-assigned this Jul 28, 2021
@katxiao
Copy link
Contributor

katxiao commented Jul 28, 2021

Instead of updating the comment, we will add an argument to optionally keep the original column instead of always dropping it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants