@@ -103,13 +103,13 @@ def seterr(all=None, divide=None, over=None, under=None, invalid=None):
103
103
File "<stdin>", line 1, in <module>
104
104
FloatingPointError: overflow encountered in scalar multiply
105
105
106
- >>> old_settings = np.seterr(all='call ')
106
+ >>> old_settings = np.seterr(all='raise ')
107
107
>>> np.geterr()
108
- {'divide': 'call ', 'over': 'call ', 'under': 'call ', 'invalid': 'call '}
108
+ {'divide': 'raise ', 'over': 'raise ', 'under': 'raise ', 'invalid': 'raise '}
109
109
>>> np.int16(32000) * np.int16(3)
110
110
30464
111
111
>>> np.seterr(**orig_settings) # restore original
112
- {'divide': 'call ', 'over': 'call ', 'under': 'call ', 'invalid': 'call '}
112
+ {'divide': 'raise ', 'over': 'raise ', 'under': 'raise ', 'invalid': 'raise '}
113
113
114
114
"""
115
115
@@ -144,9 +144,9 @@ def geterr():
144
144
-------
145
145
res : dict
146
146
A dictionary with keys "divide", "over", "under", and "invalid",
147
- whose values are from the strings "ignore", "print ", "log", "warn ",
148
- "raise", and "call". The keys represent possible floating-point
149
- exceptions, and the values define how these exceptions are handled.
147
+ whose values are from the strings "ignore", "warn ", "raise ",
148
+ and "call". The keys represent possible floating-point exceptions,
149
+ and the values define how these exceptions are handled.
150
150
151
151
See Also
152
152
--------
@@ -231,21 +231,16 @@ def getbufsize():
231
231
@set_module ('numpy' )
232
232
def seterrcall (func ):
233
233
"""
234
- Set the floating-point error callback function or log object .
234
+ Set the floating-point error callback function.
235
235
236
236
There are two ways to capture floating-point error messages. The first
237
237
is to set the error-handler to 'call', using `seterr`. Then, set
238
238
the function to call using this function.
239
239
240
- The second is to set the error-handler to 'log', using `seterr`.
241
- Floating-point errors then trigger a call to the 'write' method of
242
- the provided object.
243
-
244
240
Parameters
245
241
----------
246
242
func : callable f(err, flag) or object with write method
247
- Function to call upon floating-point errors ('call'-mode) or
248
- object whose 'write' method is used to log such message ('log'-mode).
243
+ Function to call upon floating-point errors ('call'-mode).
249
244
250
245
The call function takes two arguments. The first is a string describing
251
246
the type of error (such as "divide by zero", "overflow", "underflow",
@@ -262,7 +257,7 @@ def seterrcall(func):
262
257
263
258
Returns
264
259
-------
265
- h : callable, log instance or None
260
+ h : callable or None
266
261
The old error handler.
267
262
268
263
See Also
@@ -289,26 +284,6 @@ def seterrcall(func):
289
284
>>> np.seterr(**orig_err)
290
285
{'divide': 'call', 'over': 'call', 'under': 'call', 'invalid': 'call'}
291
286
292
- Log error message:
293
-
294
- >>> class Log:
295
- ... def write(self, msg):
296
- ... print("LOG: %s" % msg)
297
- ...
298
-
299
- >>> log = Log()
300
- >>> saved_handler = np.seterrcall(log)
301
- >>> save_err = np.seterr(all='log')
302
-
303
- >>> np.array([1, 2, 3]) / 0.0
304
- LOG: Warning: divide by zero encountered in divide
305
- array([inf, inf, inf])
306
-
307
- >>> np.seterrcall(orig_handler)
308
- <numpy.Log object at 0x...>
309
- >>> np.seterr(**orig_err)
310
- {'divide': 'log', 'over': 'log', 'under': 'log', 'invalid': 'log'}
311
-
312
287
"""
313
288
if func is not None and not isinstance (func , collections .abc .Callable ):
314
289
if (not hasattr (func , 'write' ) or
@@ -327,14 +302,13 @@ def geterrcall():
327
302
Return the current callback function used on floating-point errors.
328
303
329
304
When the error handling for a floating-point error (one of "divide",
330
- "over", "under", or "invalid") is set to 'call' or 'log', the function
331
- that is called or the log instance that is written to is returned by
332
- `geterrcall`. This function or log instance has been set with
333
- `seterrcall`.
305
+ "over", "under", or "invalid") is set to 'call', the function
306
+ that is called is returned by `geterrcall`. This function has been set
307
+ with `seterrcall`.
334
308
335
309
Returns
336
310
-------
337
- errobj : callable, log instance or None
311
+ errobj : callable or None
338
312
The current error handler. If no handler was set through `seterrcall`,
339
313
``None`` is returned.
340
314
@@ -399,7 +373,7 @@ class errstate(contextlib.ContextDecorator):
399
373
Keyword arguments. The valid keywords are the possible floating-point
400
374
exceptions. Each keyword should have a string value that defines the
401
375
treatment for the particular error. Possible values are
402
- {'ignore', 'warn', 'raise', 'call', 'print', 'log' }.
376
+ {'ignore', 'warn', 'raise', 'call'}.
403
377
404
378
See Also
405
379
--------
0 commit comments