Skip to content

Commit

Permalink
MNT Small check sample weight refactor (#16324)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjpfan committed Jan 30, 2020
1 parent e05b9e1 commit 70829b3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sklearn/utils/validation.py
Expand Up @@ -1205,12 +1205,10 @@ def _check_sample_weight(sample_weight, X, dtype=None):
if dtype is not None and dtype not in [np.float32, np.float64]:
dtype = np.float64

if sample_weight is None or isinstance(sample_weight, numbers.Number):
if sample_weight is None:
sample_weight = np.ones(n_samples, dtype=dtype)
else:
sample_weight = np.full(n_samples, sample_weight,
dtype=dtype)
if sample_weight is None:
sample_weight = np.ones(n_samples, dtype=dtype)
elif isinstance(sample_weight, numbers.Number):
sample_weight = np.full(n_samples, sample_weight, dtype=dtype)
else:
if dtype is None:
dtype = [np.float64, np.float32]
Expand Down

0 comments on commit 70829b3

Please sign in to comment.