Skip to content

Commit 28b7639

Browse files
authored
get_constraints for multi-table does not return single-table constraints (#2560)
1 parent 1a7dc82 commit 28b7639

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sdv/multi_table/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ def get_constraints(self):
240240
else:
241241
constraints.append(deepcopy(constraint))
242242

243+
for table_name, synthesizer in self._table_synthesizers.items():
244+
constraints += synthesizer.get_constraints()
245+
243246
return constraints
244247

245248
def validate_constraints(self, synthetic_data):

tests/unit/multi_table/test_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,14 @@ def test_get_constraint(self, copy_mock):
15631563
constraint2 = Mock()
15641564
custom_constraint = Mock()
15651565
constraint3 = ProgrammableConstraintHarness(custom_constraint)
1566+
constraint4 = Mock()
1567+
constraint5 = Mock()
1568+
instance._table_synthesizers = {
1569+
'table1': Mock(),
1570+
'table2': Mock(),
1571+
}
1572+
instance._table_synthesizers['table1'].get_constraints = Mock(return_value=[constraint4])
1573+
instance._table_synthesizers['table2'].get_constraints = Mock(return_value=[constraint5])
15661574

15671575
# Run
15681576
no_constraints = BaseMultiTableSynthesizer.get_constraints(instance)
@@ -1576,6 +1584,8 @@ def test_get_constraint(self, copy_mock):
15761584
copy_mock.return_value,
15771585
copy_mock.return_value,
15781586
copy_mock.return_value,
1587+
constraint4,
1588+
constraint5,
15791589
]
15801590

15811591
def test_get_metadata_original(self):

0 commit comments

Comments
 (0)