@@ -511,7 +511,7 @@ There are five levels at which you can emit messages.
511
511
512
512
- `logging.critical ` and `logging.error ` are really only there for errors that
513
513
will end the use of the library but not kill the interpreter.
514
- - `logging.warning ` and `.cbook._warn_external ` are used to warn the user,
514
+ - `logging.warning ` and `._api.warn_external ` are used to warn the user,
515
515
see below.
516
516
- `logging.info ` is for information that the user may want to know if the
517
517
program behaves oddly. They are not displayed by default. For instance, if
@@ -527,16 +527,16 @@ By default, `logging` displays all log messages at levels higher than
527
527
``logging.WARNING `` to `sys.stderr `.
528
528
529
529
The `logging tutorial `_ suggests that the difference between `logging.warning `
530
- and `.cbook._warn_external ` (which uses `warnings.warn `) is that
531
- `.cbook._warn_external ` should be used for things the user must change to stop
530
+ and `._api.warn_external ` (which uses `warnings.warn `) is that
531
+ `._api.warn_external ` should be used for things the user must change to stop
532
532
the warning (typically in the source), whereas `logging.warning ` can be more
533
- persistent. Moreover, note that `.cbook._warn_external ` will by default only
533
+ persistent. Moreover, note that `._api.warn_external ` will by default only
534
534
emit a given warning *once * for each line of user code, whereas
535
535
`logging.warning ` will display the message every time it is called.
536
536
537
537
By default, `warnings.warn ` displays the line of code that has the ``warn ``
538
538
call. This usually isn't more informative than the warning message itself.
539
- Therefore, Matplotlib uses `.cbook._warn_external ` which uses `warnings.warn `,
539
+ Therefore, Matplotlib uses `._api.warn_external ` which uses `warnings.warn `,
540
540
but goes up the stack and displays the first line of code outside of
541
541
Matplotlib. For example, for the module::
542
542
@@ -559,13 +559,13 @@ will display::
559
559
UserWarning: Attempting to set identical bottom==top
560
560
warnings.warn('Attempting to set identical bottom==top')
561
561
562
- Modifying the module to use `.cbook._warn_external `::
562
+ Modifying the module to use `._api.warn_external `::
563
563
564
- from matplotlib import cbook
564
+ from matplotlib import _api
565
565
566
566
def set_range(bottom, top):
567
567
if bottom == top:
568
- cbook._warn_external ('Attempting to set identical bottom==top')
568
+ _api.warn_external ('Attempting to set identical bottom==top')
569
569
570
570
and running the same script will display::
571
571
0 commit comments