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

Better error message if I provide an incompatible sdtype/locale combo #1653

Closed
npatki opened this issue Oct 25, 2023 · 0 comments · Fixed by #1660
Closed

Better error message if I provide an incompatible sdtype/locale combo #1653

npatki opened this issue Oct 25, 2023 · 0 comments · Fixed by #1660
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Oct 25, 2023

Environment Details

  • SDV version: 1.5.0
  • Python version: 3.10
  • Operating System: Linux (Colab Notebook)

Error Description

Certain sdtypes are not compatible with certain locales. For example the state_abbr sdtype is supposed to indicate a 2-digit code for a state. But not all countries have states -- for example in Great Britain doesn't have states. In this case, the synthesizer crashes with an AttributeError.

Expected Behavior

I expect a more easy-to-parse error such as:

SynthesizerInputError: The sdtype 'state_abbr' is not compatible with any of the locales. To continue, 
try changing the locales or adding 'en_US' as possible option.

Steps to reproduce

from sdv.metadata import SingleTableMetadata
from sdv.single_table import GaussianCopulaSynthesizer
import pandas as pd

metadata = SingleTableMetadata.load_from_dict({
    'columns': {
        'A': { 'sdtype': 'numerical' },
        'B': { 'sdtype': 'state_abbr' }
    }
})

data = pd.DataFrame(data={
    'A': [23.34, 12.40, 14.27, 19.40, 21.40],
    'B': ['CA', 'CA', 'MA', 'MA', 'NY']
})

synth = GaussianCopulaSynthesizer(metadata, locales=['en_GB'])
synth.fit(data)

Output:

AttributeError: 'Generator' object has no attribute 'state_abbr'

Stack Trace:
stack_trace.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants