Skip to content

Commit

Permalink
override add_custom_constraint_class
Browse files Browse the repository at this point in the history
  • Loading branch information
lajohn4747 committed Jun 6, 2024
1 parent 0fed269 commit c002933
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sdv/sequential/par.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ def load_custom_constraint_classes(self, filepath, class_names):
"""Error that tells the user custom constraints can't be used in the ``PARSynthesizer``."""
raise SynthesizerInputError('The PARSynthesizer cannot accommodate custom constraints.')

def add_custom_constraint_class(self, class_object, class_name):
"""Error that tells the user custom constraints can't be used in the ``PARSynthesizer``."""
raise SynthesizerInputError('The PARSynthesizer cannot accommodate custom constraints.')

def _validate_context_columns(self, data):
errors = []
if self.context_columns:
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/sequential/test_par.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ def test_load_custom_constraint_classes(self):
with pytest.raises(SynthesizerInputError, match=error_message):
synthesizer.load_custom_constraint_classes(filepath='test', class_names=[])

def test_add_custom_constraint_class(self):
"""Test that if custom constraint is being added, an error is raised."""
# Setup
metadata = self.get_metadata()
synthesizer = PARSynthesizer(metadata=metadata)

# Run and Assert
error_message = re.escape(
'The PARSynthesizer cannot accommodate custom constraints.'
)
with pytest.raises(SynthesizerInputError, match=error_message):
synthesizer.add_custom_constraint_class(Mock(), class_name='Mock')

def test_get_parameters(self):
"""Test that it returns every ``init`` parameter without the ``metadata``."""
# Setup
Expand Down

0 comments on commit c002933

Please sign in to comment.