Skip to content

Commit 769fc67

Browse files
committed
Fix coverage
1 parent c9ec2cc commit 769fc67

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/unit/synthesizer/test_ctgan.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,21 @@ def test__cond_loss(self):
286286

287287
assert (result - expected).abs() < 1e-3
288288

289+
@patch('ctgan.synthesizers.ctgan._format_score')
290+
def test_fit_verbose_calls_format_score(self, format_score_mock):
291+
"""Test that ``_format_score`` is called during verbose fitting."""
292+
# Setup
293+
format_score_mock.side_effect = lambda x: f'+{abs(x):05.2f}'
294+
data = pd.DataFrame({'col1': [0, 1, 2, 3, 4], 'col2': ['a', 'b', 'c', 'a', 'b']})
295+
296+
# Run
297+
ctgan = CTGAN(epochs=1, verbose=True)
298+
ctgan.fit(data, discrete_columns=['col2'])
299+
300+
# Assert
301+
assert format_score_mock.call_count == 4
302+
format_score_mock.assert_any_call(0)
303+
289304
def test__validate_discrete_columns(self):
290305
"""Test `_validate_discrete_columns` if the discrete column doesn't exist.
291306

0 commit comments

Comments
 (0)