Add types to remaining files; activate mypy's disallow_untyped_defs

This commit is contained in:
2021-04-07 21:25:30 -05:00
parent f5606efb72
commit e9cd6d1715
21 changed files with 102 additions and 64 deletions

View File

@@ -10,7 +10,7 @@ from miplearn.classifiers.counting import CountingClassifier
E = 0.1
def test_counting():
def test_counting() -> None:
clf = CountingClassifier()
n_features = 25
x_train = np.zeros((8, n_features))

View File

@@ -10,7 +10,7 @@ from sklearn.neighbors import KNeighborsClassifier
from miplearn.classifiers.sklearn import ScikitLearnClassifier, ScikitLearnRegressor
def test_constant_prediction():
def test_constant_prediction() -> None:
x_train = np.array([[0.0, 1.0], [1.0, 0.0]])
y_train = np.array([[True, False], [True, False]])
clf = ScikitLearnClassifier(KNeighborsClassifier(n_neighbors=1))
@@ -22,7 +22,7 @@ def test_constant_prediction():
)
def test_regressor():
def test_regressor() -> None:
x_train = np.array([[0.0, 1.0], [1.0, 4.0], [2.0, 2.0]])
y_train = np.array([[1.0], [5.0], [4.0]])
x_test = np.array([[4.0, 4.0], [0.0, 0.0]])

View File

@@ -10,7 +10,7 @@ from miplearn.classifiers import Classifier
from miplearn.classifiers.threshold import MinPrecisionThreshold
def test_threshold_dynamic():
def test_threshold_dynamic() -> None:
clf = Mock(spec=Classifier)
clf.predict_proba = Mock(
return_value=np.array(