8000 DOC: Remove remaining mentions of 'log' error mode (and fix types) · numpy/numpy@cbee123 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbee123

Browse files
committed
DOC: Remove remaining mentions of 'log' error mode (and fix types)
1 parent ed5cfb3 commit cbee123
10000

File tree

3 files changed

+11
-40
lines changed

3 files changed

+11
-40
lines changed

doc/source/user/misc.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ are:
6060
- 'warn' : Print a `RuntimeWarning` (via the Python `warnings` module).
6161
- 'raise' : Raise a `FloatingPointError`.
6262
- 'call' : Call a function specified using the `seterrcall` function.
63-
- 'print' : Print a warning directly to ``stdout``.
64-
- 'log' : Record error in a Log object specified by `seterrcall`.
6563

6664
These behaviors can be set for all kinds of errors or specific ones:
6765

numpy/core/_ufunc_config.py

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def geterr():
144144
-------
145145
res : dict
146146
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.
150150
151151
See Also
152152
--------
@@ -231,21 +231,16 @@ def getbufsize():
231231
@set_module('numpy')
232232
def seterrcall(func):
233233
"""
234-
Set the floating-point error callback function or log object.
234+
Set the floating-point error callback function.
235235
236236
There are two ways to capture floating-point error messages. The first
237237
is to set the error-handler to 'call', using `seterr`. Then, set
238238
the function to call using this function.
239239
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-
244240
Parameters
245241
----------
246242
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).
249244
250245
The call function takes two arguments. The first is a string describing
251246
the type of error (such as "divide by zero", "overflow", "underflow",
@@ -262,7 +257,7 @@ def seterrcall(func):
262257
263258
Returns
264259
-------
265-
h : callable, log instance or None
260+
h : callable or None
266261
The old error handler.
267262
268263
See Also
@@ -289,26 +284,6 @@ def seterrcall(func):
289284
>>> np.seterr(**orig_err)
290285
{'divide': 'call', 'over': 'call', 'under': 'call', 'invalid': 'call'}
291286
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-
312287
"""
313288
if func is not None and not isinstance(func, collections.abc.Callable):
314289
if (not hasattr(func, 'write') or
@@ -327,14 +302,13 @@ def geterrcall():
327302
Return the current callback function used on floating-point errors.
328303
329304
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`.
334308
335309
Returns
336310
-------
337-
errobj : callable, log instance or None
311+
errobj : callable or None
338312
The current error handler. If no handler was set through `seterrcall`,
339313
``None`` is returned.
340314
@@ -399,7 +373,7 @@ class errstate(contextlib.ContextDecorator):
399373
Keyword arguments. The valid keywords are the possible floating-point
400374
exceptions. Each keyword should have a string value that defines the
401375
treatment for the particular error. Possible values are
402-
{'ignore', 'warn', 'raise', 'call', 'print', 'log'}.
376+
{'ignore', 'warn', 'raise', 'call'}.
403377
404378
See Also
405379
--------

numpy/typing/tests/data/reveal/ufunc_config.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ reveal_type(np.seterrcall(Write())) # E: Union[None, def (builtins.str, builtin
2222
reveal_type(np.geterrcall()) # E: Union[None, def (builtins.str, builtins.int) -> Any, _SupportsWrite[builtins.str]]
2323

2424
reveal_type(np.errstate(call=func, all="call")) # E: errstate[def (a: builtins.str, b: builtins.int)]
25-
reveal_type(np.errstate(call=Write(), divide="log", over="log")) # E: errstate[ufunc_config.Write]

0 commit comments

Comments
 (0)
0