get_example#
- get_example( ) Example[Any, Any][source]#
Look up any example dataset.
Added in version 0.49.
This is a single entry point for every example in
pyvista.examples.examples,pyvista.examples.downloads, andpyvista.examples.planets. It returns the example itself – its files, where they come from, and the readers for them – rather than the dataset, whichExample.load()reads. Reach for it to work with an example by name, or to get at its files or readers. Type checkers resolve the dataset and reader types from the name, soget_example('cow').load()is aPolyDatastatically as well as at runtime.- Parameters:
- name
str|Callable Name of the example, such as
'bunny', or the function which returns it, such asexamples.download_bunny. A'download_'or'load_'prefix on the name is optional.- downloadbool, default:
True Download the example’s files if they are not already present. If
False, aFileNotFoundErroris raised for any example whose files are missing. Files which are already cached, and examples generated in memory, are unaffected.
- name
- Returns:
ExampleThe example, its files, and its readers.
Examples#
Download Python source code | Download Jupyter notebook
Look up an example and read it.
>>> from pyvista import examples
>>> uniform = examples.get_example('uniform')
>>> mesh = uniform.load()
>>> mesh.n_cells
729
Get the reader PyVista resolves for each file that has one. Most examples have exactly one reader.
>>> [type(reader).__name__ for reader in uniform.readers]
['VTKDataSetReader']
See Also#
- Dataset Gallery
Browse every available example.
Used In#
Guides
- Examples & Datasets (1 use)
Docstring Examples
Example(1 use)