Skip to content

Commit 0b1671d

Browse files
Add failure tests for export estimator operations
1 parent 127de4f commit 0b1671d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_sklearn.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
import shutil
1212
import unittest
1313
import warnings
14+
from itertools import product
1415

1516
import numpy as np
17+
from sklearn.exceptions import NotFittedError
1618
from sklearn.utils.estimator_checks import check_estimator
1719
from sklearn.utils.validation import NotFittedError, check_is_fitted
1820

@@ -2704,3 +2706,25 @@ def test_khiops_encoder_no_output_variables_implies_not_fit(self):
27042706

27052707
# Check that the encoder is not fit
27062708
self.assertNotFit(khe)
2709+
2710+
def test_export_operations_raise_when_not_fitted(self):
2711+
"""Test that export functions raise NonFittedError exceptions when non-fitted
2712+
2713+
.. note:
2714+
The standard operations (predict, predict_proba, transform, etc) are
2715+
covered by KhiopsSklearnEstimatorStandardTests.
2716+
"""
2717+
# Prepare the fixtures
2718+
export_operations = ["export_dictionary_file", "export_report_file"]
2719+
estimators = [
2720+
KhiopsClassifier(),
2721+
KhiopsRegressor(),
2722+
KhiopsEncoder(),
2723+
KhiopsCoclustering(),
2724+
]
2725+
2726+
# Execute the tests
2727+
for export_operation, estimator in product(export_operations, estimators):
2728+
with self.subTest(export_operation=export_operation, estimator=estimator):
2729+
with self.assertRaises(NotFittedError):
2730+
getattr(estimator, export_operation)("report.khj")

0 commit comments

Comments
 (0)