
.. 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

        Click :ref:`here <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 14-24

.. code-block:: python3
   :lineno-start: 15


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

    import numpy as np
    import matplotlib.pyplot as plt

    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_0x.png 2.0x
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f7850f7c730>



.. GENERATED FROM PYTHON SOURCE LINES 25-26

This next block will raise a NameError

.. GENERATED FROM PYTHON SOURCE LINES 26-29

.. code-block:: python3
   :lineno-start: 27


    iae



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

.. code-block:: pytb

    Traceback (most recent call last):
      File "/build/sphinx-gallery-DaI3lO/sphinx-gallery-0.10.1/examples/no_output/plot_raise.py", line 27, in <module>
        iae
    NameError: name 'iae' is not defined




.. GENERATED FROM PYTHON SOURCE LINES 30-34

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 36-37

Here is another error raising block but will not be executed

.. GENERATED FROM PYTHON SOURCE LINES 37-39

.. code-block:: python3
   :lineno-start: 38


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

**Estimated memory usage:**  140 MB


.. _sphx_glr_download_auto_examples_no_output_plot_raise.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: 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-python

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



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

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


.. only:: html

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

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