@@ -511,7 +511,7 @@ There are five levels at which you can emit messages.
511511
512512- `logging.critical ` and `logging.error ` are really only there for errors that
513513 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,
515515 see below.
516516- `logging.info ` is for information that the user may want to know if the
517517 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
527527``logging.WARNING `` to `sys.stderr `.
528528
529529The `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
532532the 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
534534emit a given warning *once * for each line of user code, whereas
535535`logging.warning ` will display the message every time it is called.
536536
537537By default, `warnings.warn ` displays the line of code that has the ``warn ``
538538call. 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 `,
540540but goes up the stack and displays the first line of code outside of
541541Matplotlib. For example, for the module::
542542
@@ -559,13 +559,13 @@ will display::
559559 UserWarning: Attempting to set identical bottom==top
560560 warnings.warn('Attempting to set identical bottom==top')
561561
562- Modifying the module to use `.cbook._warn_external `::
562+ Modifying the module to use `._api.warn_external `::
563563
564- from matplotlib import cbook
564+ from matplotlib import _api
565565
566566 def set_range(bottom, top):
567567 if bottom == top:
568- cbook._warn_external ('Attempting to set identical bottom==top')
568+ _api.warn_external ('Attempting to set identical bottom==top')
569569
570570and running the same script will display::
571571
0 commit comments