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

ConstraintsNotMetError when using GreaterThan constraint with datetime #590

Closed
Manue21 opened this issue Sep 16, 2021 · 1 comment · Fixed by #600
Closed

ConstraintsNotMetError when using GreaterThan constraint with datetime #590

Manue21 opened this issue Sep 16, 2021 · 1 comment · Fixed by #600
Assignees
Labels
bug Something isn't working feature:constraints Related to inputting rules or business logic
Milestone

Comments

@Manue21
Copy link

Manue21 commented Sep 16, 2021

Environment Details

Please indicate the following details about the environment in which you found the bug:

  • SDV version: 0.12.0
  • Python version: 3.8.8
  • Operating System: Windows

Error Description

ConstraintsNotMetError is raised when trying to use GreaterThan constraint with datetime.

Steps to reproduce

I have included a working example using sdv demo dataset

from sdv.demo import load_tabular_demo
from sdv.constraints import GreaterThan

data = load_tabular_demo('student_placements')

start_constraint = GreaterThan(
    low='start_date',
    high='end_date',
    handling_strategy='reject_sampling' )
constraints = [start_constraint]

gc = GaussianCopula(constraints=constraints)
gc.fit(data)`

And the error obtained is pasted below

ConstraintsNotMetError                    Traceback (most recent call last)
<ipython-input-38-bffc85f02fc5> in <module>
     11 
     12 gc = GaussianCopula(constraints=constraints)
---> 13 gc.fit(data)

~\Anaconda3\lib\site-packages\sdv\tabular\base.py in fit(self, data)
    136 
    137         LOGGER.debug('Transforming table %s; shape: %s', self._metadata.name, data.shape)
--> 138         transformed = self._metadata.transform(data)
    139 
    140         if self._metadata.get_dtypes(ids=False):

~\Anaconda3\lib\site-packages\sdv\metadata\table.py in transform(self, data, on_missing_column)
    620         data = self._anonymize(data[fields])
    621 
--> 622         self._validate_data_on_constraints(data)
    623 
    624         LOGGER.debug('Transforming constraints for table %s', self.name)

~\Anaconda3\lib\site-packages\sdv\metadata\table.py in _validate_data_on_constraints(self, data)
    592             if set(constraint.constraint_columns).issubset(data.columns.values):
    593                 if not constraint.is_valid(data).all():
--> 594                     raise ConstraintsNotMetError('Data is not valid for the given constraints')
    595 
    596     def transform(self, data, on_missing_column='error'):

ConstraintsNotMetError: Data is not valid for the given constraints```
@fealho
Copy link
Member

fealho commented Sep 16, 2021

Hi @Manue21, thanks for reporting this issue! I've identified the cause of the problem and our team will be working on it at the earliest opportunity.

@kveerama kveerama added the feature:constraints Related to inputting rules or business logic label Sep 19, 2021
@katxiao katxiao added this to the 0.12.1 milestone Oct 7, 2021
@katxiao katxiao self-assigned this Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:constraints Related to inputting rules or business logic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants