
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/no_output/plot_raise.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_no_output_plot_raise.py>`
        to download the full example code. or to run this example in your browser via Binder

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_no_output_plot_raise.py:


Example that fails to execute
=============================

This example demonstrates a code block that raises an error and how any code
blocks that follow are not executed.

When scripts fail, their gallery thumbnail is replaced with the broken
image stamp. This allows easy identification in the gallery display.

You will also get the python traceback of the failed code block.

.. GENERATED FROM PYTHON SOURCE LINES 13-23

.. code-block:: Python
   :lineno-start: 14


    # Code source: Óscar Nájera
    # License: BSD 3 clause
    # sphinx_gallery_line_numbers = True

    import matplotlib.pyplot as plt
    import numpy as np

    plt.pcolormesh(np.random.randn(100, 100))




.. image-sg:: /auto_examples/no_output/images/sphx_glr_plot_raise_001.png
   :alt: plot raise
   :srcset: /auto_examples/no_output/images/sphx_glr_plot_raise_001.png, /auto_examples/no_output/images/sphx_glr_plot_raise_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 24-25

This next block will raise a NameError

.. GENERATED FROM PYTHON SOURCE LINES 25-28

.. code-block:: Python
   :lineno-start: 26


    iae  # noqa



.. rst-class:: sphx-glr-script-out

.. code-block:: pytb

    Traceback (most recent call last):
      File "examples/no_output/plot_raise.py", line 26, in <module>
        iae  # noqa
        ^^^
    NameError: name 'iae' is not defined




.. GENERATED FROM PYTHON SOURCE LINES 29-33

Sphinx gallery will stop executing the remaining code blocks after
the exception has occurred in the example script. Nevertheless the
html will still render all the example annotated text and
code blocks, but no output will be shown.

.. GENERATED FROM PYTHON SOURCE LINES 35-36

Here is another error raising block but will not be executed

.. GENERATED FROM PYTHON SOURCE LINES 36-38

.. code-block:: Python
   :lineno-start: 37


    plt.plot("Strings are not a valid argument for the plot function")


.. _sphx_glr_download_auto_examples_no_output_plot_raise.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: binder-badge

      .. image:: images/binder_badge_logo.svg
        :target: https://mybinder.org/v2/gh/sphinx-gallery/sphinx-gallery.github.io/master?urlpath=lab/tree/notebooks/auto_examples/no_output/plot_raise.ipynb
        :alt: Launch binder
        :width: 150 px

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_raise.ipynb <plot_raise.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_raise.py <plot_raise.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_raise.zip <plot_raise.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
