Skip to content

Commit ce655eb

Browse files
authored
MNT: remove workaround for numpy bug fixed in 1.20 (scikit-learn#32577)
1 parent 6195659 commit ce655eb

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

sklearn/preprocessing/_data.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,11 +2811,6 @@ def _dense_fit(self, X, random_state):
28112811
)
28122812

28132813
self.quantiles_ = np.nanpercentile(X, references, axis=0)
2814-
# Due to floating-point precision error in `np.nanpercentile`,
2815-
# make sure that quantiles are monotonically increasing.
2816-
# Upstream issue in numpy:
2817-
# https://github.com/numpy/numpy/issues/14685
2818-
self.quantiles_ = np.maximum.accumulate(self.quantiles_)
28192814

28202815
def _sparse_fit(self, X, random_state):
28212816
"""Compute percentiles for sparse matrices.
@@ -2856,11 +2851,6 @@ def _sparse_fit(self, X, random_state):
28562851
else:
28572852
self.quantiles_.append(np.nanpercentile(column_data, references))
28582853
self.quantiles_ = np.transpose(self.quantiles_)
2859-
# due to floating-point precision error in `np.nanpercentile`,
2860-
# make sure the quantiles are monotonically increasing
2861-
# Upstream issue in numpy:
2862-
# https://github.com/numpy/numpy/issues/14685
2863-
self.quantiles_ = np.maximum.accumulate(self.quantiles_)
28642854

28652855
@_fit_context(prefer_skip_nested_validation=True)
28662856
def fit(self, X, y=None):

sklearn/preprocessing/tests/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ def test_quantile_transformer_sorted_quantiles(array_type):
16141614
# Non-regression test for:
16151615
# https://github.com/scikit-learn/scikit-learn/issues/15733
16161616
# Taken from upstream bug report:
1617-
# https://github.com/numpy/numpy/issues/14685
1617+
# https://github.com/numpy/numpy/issues/14685 (which was resolved in numpy 1.20)
16181618
X = np.array([0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 1, 1, 9, 9, 9, 8, 8, 7] * 10)
16191619
X = 0.1 * X.reshape(-1, 1)
16201620
X = _convert_container(X, array_type)

0 commit comments

Comments
 (0)