From 4b32621432843e83f42b0ed7f0c21eef36a9b218 Mon Sep 17 00:00:00 2001 From: Plamen Valentinov Kolev Date: Wed, 18 Feb 2026 15:22:52 +0100 Subject: [PATCH 1/2] Reduce the tolerance to 4 digits instead --- tests/unit/multivariate/test_gaussian.py | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/unit/multivariate/test_gaussian.py b/tests/unit/multivariate/test_gaussian.py index c0c2c616..584b13b6 100644 --- a/tests/unit/multivariate/test_gaussian.py +++ b/tests/unit/multivariate/test_gaussian.py @@ -110,7 +110,7 @@ def test__transform_to_normal_numpy_1d(self): ]) returned = gm._transform_to_normal(data) - # Check + # Assert # Failures may occurr on different cpytonn implementations # with different float precision values. # If that happens, atol might need to be increased @@ -147,7 +147,7 @@ def test__transform_to_normal_numpy_2d(self): ]) returned = gm._transform_to_normal(data) - # Check + # Assert # Failures may occurr on different cpytonn implementations # with different float precision values. # If that happens, atol might need to be increased @@ -178,7 +178,7 @@ def test__transform_to_normal_series(self): data = pd.Series({'a': 3, 'b': 5}) returned = gm._transform_to_normal(data) - # Check + # Assert # Failures may occurr on different cpytonn implementations # with different float precision values. # If that happens, atol might need to be increased @@ -211,7 +211,7 @@ def test__transform_to_normal_dataframe(self): data = pd.DataFrame({'a': [3, 4, 5], 'b': [5, 6, 7]}) returned = gm._transform_to_normal(data) - # Check + # Assert # Failures may occurr on different cpytonn implementations # with different float precision values. # If that happens, atol might need to be increased @@ -243,7 +243,7 @@ def test__get_correlation(self): # Run correlation = copula._get_correlation(self.data) - # Check + # Assert assert np.isclose(correlation, expected_correlation).all().all() def test_fit_default_distribution(self): @@ -270,7 +270,7 @@ def test_fit_distribution_arg(self): # Run copula.fit(self.data) - # Check + # Assert assert copula.distribution == 'copulas.univariate.gaussian_kde.GaussianKDE' for i, key in enumerate(self.data.columns): @@ -314,7 +314,7 @@ def test_fit_numpy_array(self): # Run copula.fit(self.data.to_numpy()) - # Check + # Assert for key, (column, univariate) in enumerate(zip(self.data.columns, copula.univariates)): assert univariate._params['loc'] == np.mean(self.data[column]) assert univariate._params['scale'] == np.std(self.data[column]) @@ -336,7 +336,7 @@ def test_fit_broken_distribution(self, logger_mock, truncated_mock): data = self.data['column1'] copula.fit(data) - # Check + # Assert expected_logging_msg = ( 'Unable to fit to a copulas.univariate.truncated_gaussian.TruncatedGaussian ' 'distribution for column column1. Using a Gaussian distribution instead.' @@ -466,7 +466,7 @@ def test_probability_density(self): # Run result = copula.probability_density(X) - # Check + # Assert assert expected_result - 1e-16 < result < expected_result + 1e-16 def test_cumulative_distribution_fit_df_call_np_array(self): @@ -480,7 +480,7 @@ def test_cumulative_distribution_fit_df_call_np_array(self): # Run result = copula.cumulative_distribution(X) - # Check + # Assert assert np.isclose(result, expected_result, atol=1e-5).all().all() def test_cumulative_distribution_fit_call_np_array(self): @@ -494,8 +494,8 @@ def test_cumulative_distribution_fit_call_np_array(self): # Run result = copula.cumulative_distribution(X) - # Check - assert np.isclose(result, expected_result, atol=1e-5).all().all() + # Assert + assert np.isclose(result, expected_result, atol=1e-4).all().all() def test_cumulative_distribution_fit_call_pd(self): """Cumulative_density integrates the probability density along the given values.""" @@ -508,7 +508,7 @@ def test_cumulative_distribution_fit_call_pd(self): # Run result = copula.cumulative_distribution(X) - # Check + # Assert assert np.isclose(result, expected_result, atol=1e-5).all().all() @patch('copulas.multivariate.gaussian.np.random.multivariate_normal') @@ -544,7 +544,7 @@ def test_sample(self, normal_mock): # Run result = instance.sample(5) - # Check + # Assert assert result.equals(expected_result) np.testing.assert_array_equal( @@ -580,7 +580,7 @@ def test_sample_random_state(self): # Run result = instance.sample(5) - # Check + # Assert pd.testing.assert_frame_equal(result, expected_result) def test_to_dict(self): @@ -634,7 +634,7 @@ def test_sample_constant_column(self): # Run result = instance.sample(5) - # Check + # Assert assert result.shape == (5, 2) results = result[~result.isna()].all() assert results.all() From 9e0272e05e12d49e14c47a1f7248887db1fbd30f Mon Sep 17 00:00:00 2001 From: Plamen Valentinov Kolev Date: Wed, 18 Feb 2026 19:04:08 +0100 Subject: [PATCH 2/2] Update other flaky tests --- tests/unit/multivariate/test_gaussian.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/multivariate/test_gaussian.py b/tests/unit/multivariate/test_gaussian.py index 584b13b6..6854c99e 100644 --- a/tests/unit/multivariate/test_gaussian.py +++ b/tests/unit/multivariate/test_gaussian.py @@ -481,7 +481,7 @@ def test_cumulative_distribution_fit_df_call_np_array(self): result = copula.cumulative_distribution(X) # Assert - assert np.isclose(result, expected_result, atol=1e-5).all().all() + assert np.isclose(result, expected_result, atol=1e-4).all().all() def test_cumulative_distribution_fit_call_np_array(self): """Cumulative_density integrates the probability density along the given values.""" @@ -509,7 +509,7 @@ def test_cumulative_distribution_fit_call_pd(self): result = copula.cumulative_distribution(X) # Assert - assert np.isclose(result, expected_result, atol=1e-5).all().all() + assert np.isclose(result, expected_result, atol=1e-4).all().all() @patch('copulas.multivariate.gaussian.np.random.multivariate_normal') def test_sample(self, normal_mock):