Note

Go to the end to download the full example code. or to run this example in your browser via Binder

# Example that fails to execute (with normal thumbnail behaviour)

By default, examples with code blocks that raise an error will have the broken image stamp as their gallery thumbnail. However, this may not be desired, e.g. if only part of the example is expected to fail and it should not look like the entire example fails.

In these cases, the sphinx_gallery_failing_thumbnail variable can be set to `False`, which will change the thumbnail selection to the default behaviour as for non-failing examples.

    15 # Code source: Thomas S. Binns
    16 # License: BSD 3 clause
    17 # sphinx_gallery_line_numbers = True
    18
    19 # sphinx_gallery_failing_thumbnail = False
    20
    21 import matplotlib.pyplot as plt
    22 import numpy as np
    23
    24 plt.pcolormesh(np.random.randn(100, 100))

This block will raise an AssertionError

    29 assert False

    Traceback (most recent call last):
      File "examples/no_output/plot_raise_thumbnail.py", line 29, in <module>
        assert False
               ^^^^^
    AssertionError

Gallery generated by Sphinx-Gallery