File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1111import shutil
1212import unittest
1313import warnings
14+ from itertools import product
1415
1516import numpy as np
17+ from sklearn .exceptions import NotFittedError
1618from sklearn .utils .estimator_checks import check_estimator
1719from 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" )
You can’t perform that action at this time.
0 commit comments