Skip to content

Commit 47a08f6

Browse files
committed
code coverage
1 parent 93bf2c2 commit 47a08f6

8 files changed

Lines changed: 22 additions & 16 deletions

mlinsights/mlmodel/_kmeans_022.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from sklearn.utils.sparsefuncs_fast import assign_rows_csr # pylint: disable=W0611,E0611
1010
try:
1111
from sklearn.cluster._kmeans import _check_sample_weight
12-
except ImportError:
12+
except ImportError: # pragma: no cover
1313
from sklearn.cluster._kmeans import (
1414
_check_normalize_sample_weight as _check_sample_weight)
1515
from sklearn.metrics.pairwise import pairwise_distances_argmin_min

mlinsights/mlmodel/_kmeans_constraint_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def _compute_strategy_coefficient(distances, strategy, labels):
234234
ar = numpy.arange(distances.shape[0])
235235
dist = distances[ar, labels]
236236
return distances - dist[:, numpy.newaxis]
237-
raise ValueError("Unknwon strategy '{0}'.".format(strategy))
237+
raise ValueError( # pragma: no cover
238+
"Unknwon strategy '{0}'.".format(strategy))
238239

239240

240241
def _randomize_index(index, weights):

mlinsights/mlmodel/decision_tree_logreg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def _fit_parallel(self, X, y, sample_weight):
422422

423423
def _fit_perpendicular(self, X, y, sample_weight):
424424
"Implements the perpendicular strategy."
425-
raise NotImplementedError()
425+
raise NotImplementedError() # pragma: no cover
426426

427427
def predict(self, X):
428428
"""

mlinsights/mlmodel/extended_features.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _get_feature_names_poly(self, input_features=None):
7171
input_features = ["x%d" %
7272
i for i in range(0, self.n_input_features_)]
7373
elif len(input_features) != self.n_input_features_:
74-
raise ValueError(
74+
raise ValueError( # pragma: no cover
7575
"input_features should contain {} strings.".format(
7676
self.n_input_features_))
7777

@@ -125,7 +125,7 @@ def fit(self, X, y=None):
125125
return self._fit_poly(X, y)
126126
elif self.kind == 'poly-slow':
127127
return self._fit_poly(X, y)
128-
raise ValueError(
128+
raise ValueError( # pragma: no cover
129129
"Unknown extended features '{}'.".format(self.kind))
130130

131131
def _fit_poly(self, X, y=None):
@@ -148,7 +148,8 @@ def transform(self, X):
148148
"""
149149
n_features = X.shape[1]
150150
if n_features != self.n_input_features_:
151-
raise ValueError("X shape does not match training shape")
151+
raise ValueError( # pragma: no cover
152+
"X shape does not match training shape")
152153
if self.kind == 'poly':
153154
return self._transform_poly(X)
154155
if self.kind == 'poly-slow':

mlinsights/mlmodel/piecewise_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from sklearn.utils.fixes import _joblib_parallel_args
1414
try:
1515
from tqdm import tqdm
16-
except ImportError:
16+
except ImportError: # pragma: no cover
1717
pass
1818

1919

mlinsights/mlmodel/sklearn_transform_inv_fct.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ def __init__(self, fct, fct_inv=None):
4646
BaseReciprocalTransformer.__init__(self)
4747
if isinstance(fct, str):
4848
if fct_inv is not None:
49-
raise ValueError(
49+
raise ValueError( # pragma: no cover
5050
"If fct is a function name, fct_inv must not be specified.")
5151
opts = self.__class__.available_fcts()
5252
if fct not in opts:
53-
raise ValueError("Unknown fct '{}', it should in {}.".format(
54-
fct, list(sorted(opts))))
53+
raise ValueError( # pragma: no cover
54+
"Unknown fct '{}', it should in {}.".format(
55+
fct, list(sorted(opts))))
5556
else:
5657
if fct_inv is None:
5758
raise ValueError(
@@ -117,7 +118,8 @@ def fit(self, X=None, y=None, sample_weight=None):
117118
Defines a random permutation over the targets.
118119
"""
119120
if y is None:
120-
raise RuntimeError("targets cannot be empty.")
121+
raise RuntimeError( # pragma: no cover
122+
"targets cannot be empty.")
121123
num = numpy.issubdtype(y.dtype, numpy.floating)
122124
perm = {}
123125
for u in y.ravel():
@@ -141,7 +143,7 @@ def fit(self, X=None, y=None, sample_weight=None):
141143

142144
def _check_is_fitted(self):
143145
if not hasattr(self, 'permutation_'):
144-
raise NotFittedError(
146+
raise NotFittedError( # pragma: no cover
145147
"This instance {} is not fitted yet. Call 'fit' with "
146148
"appropriate arguments before using this method.".format(
147149
type(self)))
@@ -169,8 +171,9 @@ def _find_closest(self, cl):
169171
return float(res)
170172
if self.knn_perm_.dtype in (numpy.int32, numpy.int64):
171173
return int(res)
172-
raise NotImplementedError("The function does not work for type {}.".format(
173-
self.knn_perm_.dtype))
174+
raise NotImplementedError( # pragma: no cover
175+
"The function does not work for type {}.".format(
176+
self.knn_perm_.dtype))
174177

175178
def transform(self, X, y):
176179
"""

mlinsights/mlmodel/target_predictors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def predict(self, X):
109109
Predicted values.
110110
"""
111111
if not hasattr(self, 'regressor_'):
112-
raise NotFittedError(
112+
raise NotFittedError( # pragma: no cover
113113
"This instance {} is not fitted yet. Call 'fit' with "
114114
"appropriate arguments before using this method.".format(
115115
type(self)))

mlinsights/mltree/tree_structure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def _get_tree(obj):
1414
return obj
1515
if hasattr(obj, "tree_"):
1616
return obj.tree_
17-
raise AttributeError("obj is no tree: {}".format(type(obj)))
17+
raise AttributeError( # pragma: no cover
18+
"obj is no tree: {}".format(type(obj)))
1819

1920

2021
def tree_leave_index(model):

0 commit comments

Comments
 (0)