

.. _sphx_glr_auto_examples_no_output_plot_raise.py:


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

When scripts fail their gallery thumbnail is replaced with the broken
image stamp. Thus allowing easy identification in the gallery display.

You also get the python traceback of the failed code block



.. code-block:: python
   :lineno-start: 12


    # 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:: /auto_examples/no_output/images/sphx_glr_plot_raise_001.png
    :align: center




This next block will raise a NameError



.. code-block:: python
   :lineno-start: 24


    iae




.. code-block:: pytb

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




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.


Here is another error raising block but will not be executed



.. code-block:: python
   :lineno-start: 35


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

**Total running time of the script:** ( 0 minutes  0.086 seconds)



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :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.readthedocs.io>`_
