From c0029330f7f30b7f9bce508869655d65630314b4 Mon Sep 17 00:00:00 2001 From: John La Date: Thu, 6 Jun 2024 17:35:35 -0500 Subject: [PATCH] override add_custom_constraint_class --- sdv/sequential/par.py | 4 ++++ tests/unit/sequential/test_par.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/sdv/sequential/par.py b/sdv/sequential/par.py index ecd258343..0321cd59d 100644 --- a/sdv/sequential/par.py +++ b/sdv/sequential/par.py @@ -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: diff --git a/tests/unit/sequential/test_par.py b/tests/unit/sequential/test_par.py index b023b3bd4..3fbb889e3 100644 --- a/tests/unit/sequential/test_par.py +++ b/tests/unit/sequential/test_par.py @@ -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