@@ -98,40 +98,55 @@ def set_config(
98
98
99
99
100
100
@contextmanager
101
- def config_context (** new_config ):
102
- """Context manager for global scikit-learn configuration
101
+ def config_context (
102
+ * , assume_finite = None , working_memory = None , print_changed_only = None , display = None
103
+ ):
104
+ """Context manager for global scikit-learn configuration.
103
105
104
106
Parameters
105
107
----------
106
- assume_finite : bool, default=False
108
+ assume_finite : bool, default=None
107
109
If True, validation for finiteness will be skipped,
108
110
saving time, but leading to potential crashes. If
109
111
False, validation for finiteness will be performed,
110
- avoiding error. Global default: False.
112
+ avoiding error. If None, the existing value won't change.
113
+ The default value is False.
111
114
112
- working_memory : int, default=1024
115
+ working_memory : int, default=None
113
116
If set, scikit-learn will attempt to limit the size of temporary arrays
114
117
to this number of MiB (per job when parallelised), often saving both
115
118
computation time and memory on expensive operations that can be
116
- performed in chunks. Global default: 1024.
119
+ performed in chunks. If None, the existing value won't change.
120
+ The default value is 1024.
117
121
118
- print_changed_only : bool, default=True
122
+ print_changed_only : bool, default=None
119
123
If True, only the parameters that were set to non-default
120
124
values will be printed when printing an estimator. For example,
121
125
``print(SVC())`` while True will only print 'SVC()', but would print
122
126
'SVC(C=1.0, cache_size=200, ...)' with all the non-changed parameters
123
- when False. Default is True.
127
+ when False. If None, the existing value won't change.
128
+ The default value is True.
124
129
125
130
.. versionchanged:: 0.23
126
131
Default changed from False to True.
127
132
128
- display : {'text', 'diagram'}, default='text'
133
+ display : {'text', 'diagram'}, default=None
129
134
If 'diagram', estimators will be displayed as a diagram in a Jupyter
130
135
lab or notebook context. If 'text', estimators will be displayed as
131
- text. Default is 'text'.
136
+ text. If None, the existing value won't change.
137
+ The default value is 'text'.
132
138
133
139
.. versionadded:: 0.23
134
140
141
+ Yields
142
+ ------
143
+ None.
144
+
145
+ See Also
146
+ --------
147
+ set_config : Set global scikit-learn configuration.
148
+ get_config : Retrieve current values of the global configuration.
149
+
135
150
Notes
136
151
-----
137
152
All settings, not just those presently modified, will be returned to
@@ -148,15 +163,15 @@ def config_context(**new_config):
148
163
... assert_all_finite([float('nan')])
149
164
Traceback (most recent call last):
150
165
...
151
- ValueError: Input contains NaN, ...
152
-
153
- See Also
154
- --------
155
- set_config : Set global scikit-learn configuration.
156
- get_config : Retrieve current values of the global configuration.
166
+ ValueError: Input contains NaN...
157
167
"""
158
168
old_config = get_config ()
159
- set_config (** new_config )
169
+ set_config (
170
+ assume_finite = assume_finite ,
171
+ working_memory = working_memory ,
172
+ print_changed_only = print_changed_only ,
173
+ display = display ,
174
+ )
160
175
161
176
try :
162
177
yield
0 commit comments