Skip to content

Commit 2dcc367

Browse files
committed
[free-threaded] [azure parallel] fix for when category is a tuple
1 parent 69c47eb commit 2dcc367

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sklearn/utils/parallel.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,19 @@ def __call__(self, *args, **kwargs):
173173
if this_value is not None and not isinstance(this_value, str):
174174
this_warning_filter_dict[special_key] = this_value.pattern
175175

176-
warnings.filterwarnings(**this_warning_filter_dict, append=True)
176+
category = this_warning_filter_dict.get("category", None)
177+
# For some reason sometimes category is a tuple (maybe from
178+
# warnings.simplefilter or pytest.warns) but filterwarnings
179+
# does not support it
180+
if isinstance(category, tuple):
181+
for this_category in category:
182+
this_warning_filter_dict_copy = this_warning_filter_dict.copy()
183+
this_warning_filter_dict_copy["category"] = this_category
184+
warnings.filterwarnings(
185+
**this_warning_filter_dict_copy, append=True
186+
)
187+
else:
188+
warnings.filterwarnings(**this_warning_filter_dict, append=True)
177189

178190
return self.function(*args, **kwargs)
179191

0 commit comments

Comments
 (0)