This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
/
test_create_asv_benchmark_histgbc.py
51 lines (45 loc) · 1.97 KB
/
test_create_asv_benchmark_histgbc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
@brief test log(time=3s)
"""
import os
import unittest
from pyquickhelper.pycode import ExtTestCase, get_temp_folder
from pyquickhelper.texthelper.version_helper import compare_module_version
import sklearn
from mlprodict.asv_benchmark import create_asv_benchmark
import mlprodict
class TestCreateAsvBenchmarkHistGBC(ExtTestCase):
def test_create_asv_benchmark_hist_gbc(self):
self.assertNotEmpty(mlprodict)
temp = get_temp_folder(__file__, "temp_create_asv_benchmark_hist_gbc")
created = create_asv_benchmark(
location=temp, verbose=0,
runtime=('scikit-learn', 'python', 'onnxruntime1'),
exc=False, execute=True,
models={'HistGradientBoostingClassifier'})
self.assertNotEmpty(created)
verif = False
allnames = []
for path, _, files in os.walk(os.path.join(temp, 'benches')):
for zoo in files:
if '__init__' in zoo:
continue
fullname = os.path.join(path, zoo)
if "_hist_gradient_boosting" in fullname:
raise AssertionError(fullname)
with open(fullname, 'r', encoding='utf-8') as f:
content = f.read()
if (zoo.endswith("bench_HGBClas_default_b_cl_mxit100.py") and
compare_module_version(sklearn.__version__, "0.21") >= 0):
if "random_state=42" not in content:
raise AssertionError(content)
if "from sklearn.ensemble._hist_gradient_boosting.gradient_boosting import" not in content:
raise AssertionError(content)
if "par_full_test_name = 'bench" not in content:
raise AssertionError(content)
verif = True
if not verif:
raise AssertionError("Visited files\n{}".format(
"\n".join(allnames)))
if __name__ == "__main__":
unittest.main()