Skip to content

Commit 9ee1563

Browse files
committed
Suppress UserWarning on self.apply()
1 parent 27574fe commit 9ee1563

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

quantile_forest/_quantile_forest.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class calls the ``fit`` method of the ``ForestRegressor`` and creates a
2424

2525
import numbers
2626
import random
27+
import warnings
2728
from math import ceil
2829
from warnings import warn
2930

@@ -190,7 +191,9 @@ def _get_y_train_leaves(self, X, sorter=None, sample_weight=None):
190191
"".format(type(self.max_samples_leaf))
191192
)
192193

193-
X_leaves = self.apply(X)
194+
with warnings.catch_warnings():
195+
warnings.simplefilter("ignore", UserWarning)
196+
X_leaves = self.apply(X)
194197

195198
shape = (n_samples, self.n_estimators)
196199
bootstrap_indices = np.empty(shape, dtype=np.int64)
@@ -473,7 +476,9 @@ def predict(
473476
"to compute any reliable OOB estimates."
474477
)
475478
else:
476-
X_leaves = self.apply(X)
479+
with warnings.catch_warnings():
480+
warnings.simplefilter("ignore", UserWarning)
481+
X_leaves = self.apply(X)
477482
X_indices = None
478483

479484
y_pred = self.forest_.predict(
@@ -579,7 +584,9 @@ def quantile_ranks(
579584
"to compute any reliable OOB estimates."
580585
)
581586
else:
582-
X_leaves = self.apply(X)
587+
with warnings.catch_warnings():
588+
warnings.simplefilter("ignore", UserWarning)
589+
X_leaves = self.apply(X)
583590
X_indices = None
584591

585592
y_ranks = self.forest_.quantile_ranks(
@@ -672,7 +679,9 @@ def proximity_counts(
672679
"to compute any reliable OOB estimates."
673680
)
674681
else:
675-
X_leaves = self.apply(X)
682+
with warnings.catch_warnings():
683+
warnings.simplefilter("ignore", UserWarning)
684+
X_leaves = self.apply(X)
676685
X_indices = None
677686

678687
proximities = self.forest_.proximity_counts(

quantile_forest/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.0.1

0 commit comments

Comments
 (0)