diff --git a/pyvista/core/composite.py b/pyvista/core/composite.py index f4fcf55997..6a0d656a8b 100644 --- a/pyvista/core/composite.py +++ b/pyvista/core/composite.py @@ -60,13 +60,20 @@ class MultiBlock( Instantiate from a list of objects. - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.plot() Instantiate from a dictionary. - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.plot() @@ -77,7 +84,8 @@ class MultiBlock( ... >>> for block in blocks: - ... surf = block.extract_surface() # Do something with each dataset + ... # Do something with each dataset + ... surf = block.extract_surface() ... """ @@ -147,7 +155,11 @@ def bounds(self) -> BoundsLike: Return the bounds across blocks. >>> import pyvista as pv - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.bounds (-0.5, 2.5, -0.5, 2.5, -0.5, 0.5) @@ -176,7 +188,11 @@ def center(self) -> Any: Examples -------- >>> import pyvista as pv - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.center # doctest:+SKIP array([1., 1., 0.]) @@ -192,7 +208,11 @@ def length(self) -> float: Examples -------- >>> import pyvista as pv - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.length 4.3584 @@ -207,7 +227,11 @@ def n_blocks(self) -> int: Examples -------- >>> import pyvista as pv - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.n_blocks 3 @@ -233,7 +257,11 @@ def volume(self) -> float: Examples -------- >>> import pyvista as pv - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.volume 1.7348 @@ -293,7 +321,10 @@ def get_index_by_name(self, name: str) -> int: Examples -------- >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.get_index_by_name('sphere') 1 @@ -354,7 +385,10 @@ def append(self, dataset: Optional[_TypeMultiBlockLeaf], name: Optional[str] = N -------- >>> import pyvista as pv >>> from pyvista import examples - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.append(pv.Cone()) >>> len(blocks) @@ -392,9 +426,14 @@ def extend(self, datasets: Iterable[_TypeMultiBlockLeaf]) -> None: -------- >>> import pyvista as pv >>> from pyvista import examples - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) - >>> blocks_uniform = pv.MultiBlock({"uniform": examples.load_uniform()}) + >>> blocks_uniform = pv.MultiBlock( + ... {"uniform": examples.load_uniform()} + ... ) >>> blocks.extend(blocks_uniform) >>> len(blocks) 3 @@ -461,7 +500,10 @@ def set_block_name(self, index: int, name: Optional[str]): Examples -------- >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.append(pv.Cone()) >>> blocks.set_block_name(2, 'cone') @@ -491,7 +533,10 @@ def get_block_name(self, index: int) -> Optional[str]: Examples -------- >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.get_block_name(0) 'cube' @@ -514,7 +559,10 @@ def keys(self) -> List[Optional[str]]: Examples -------- >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.keys() ['cube', 'sphere'] @@ -539,7 +587,10 @@ def replace(self, index: int, dataset: Optional[_TypeMultiBlockLeaf]) -> None: -------- >>> import pyvista as pv >>> import numpy as np - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.replace(1, pv.Sphere(center=(10, 10, 10))) >>> blocks.keys() @@ -704,7 +755,10 @@ def insert(self, index: int, dataset: _TypeMultiBlockLeaf, name: Optional[str] = Insert a new :class:`pyvista.PolyData` at the start of the multiblock. >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.keys() ['cube', 'sphere'] @@ -742,7 +796,10 @@ def pop(self, index: Union[int, str] = -1) -> Optional[_TypeMultiBlockLeaf]: Pop the ``"cube"`` multiblock. >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.keys() ['cube', 'sphere'] @@ -765,7 +822,10 @@ def reverse(self): Reverse a multiblock. >>> import pyvista as pv - >>> data = {"cube": pv.Cube(), "sphere": pv.Sphere(center=(2, 2, 0))} + >>> data = { + ... "cube": pv.Cube(), + ... "sphere": pv.Sphere(center=(2, 2, 0)), + ... } >>> blocks = pv.MultiBlock(data) >>> blocks.keys() ['cube', 'sphere'] @@ -907,7 +967,11 @@ def copy(self, deep=True): Examples -------- >>> import pyvista as pv - >>> data = [pv.Sphere(center=(2, 0, 0)), pv.Cube(center=(0, 2, 0)), pv.Cone()] + >>> data = [ + ... pv.Sphere(center=(2, 0, 0)), + ... pv.Cube(center=(0, 2, 0)), + ... pv.Cone(), + ... ] >>> blocks = pv.MultiBlock(data) >>> new_blocks = blocks.copy() >>> len(new_blocks) diff --git a/pyvista/core/dataobject.py b/pyvista/core/dataobject.py index c398a7c92c..10dd57bcd2 100644 --- a/pyvista/core/dataobject.py +++ b/pyvista/core/dataobject.py @@ -366,7 +366,9 @@ def add_field_data(self, array: np.ndarray, name: str, deep=True): Add field data to a UniformGrid dataset. >>> mesh = pyvista.UniformGrid(dimensions=(2, 2, 1)) - >>> mesh.add_field_data(['I could', 'write', 'notes', 'here'], 'my-field-data') + >>> mesh.add_field_data( + ... ['I could', 'write', 'notes', 'here'], 'my-field-data' + ... ) >>> mesh['my-field-data'] pyvista_ndarray(['I could', 'write', 'notes', 'here'], dtype='>> import pyvista - >>> mesh = pyvista.UniformGrid(dimensions=[5, 5, 1], spacing=[1 / 4, 1 / 4, 0]) + >>> mesh = pyvista.UniformGrid( + ... dimensions=[5, 5, 1], spacing=[1 / 4, 1 / 4, 0] + ... ) >>> mesh UniformGrid... >>> mesh.find_containing_cell([0.3, 0.3, 0.0]) @@ -2472,7 +2474,9 @@ def find_cells_within_bounds(self, bounds: Iterable[float]) -> np.ndarray: -------- >>> import pyvista >>> mesh = pyvista.Cube() - >>> index = mesh.find_cells_within_bounds([-2.0, 2.0, -2.0, 2.0, -2.0, 2.0]) + >>> index = mesh.find_cells_within_bounds( + ... [-2.0, 2.0, -2.0, 2.0, -2.0, 2.0] + ... ) """ if np.array(bounds).size != 6: @@ -2573,7 +2577,8 @@ def cell(self) -> Iterator['pyvista.Cell']: Loop over the cells >>> import pyvista as pv - >>> mesh = pv.UniformGrid(dimensions=(3, 3, 1)) # 9 points, 4 cells + >>> # Create a grid with 9 points and 4 cells + >>> mesh = pv.UniformGrid(dimensions=(3, 3, 1)) >>> for cell in mesh.cell: # doctest: +SKIP ... cell ... diff --git a/pyvista/core/datasetattributes.py b/pyvista/core/datasetattributes.py index 568d04c05d..8ade87a1a9 100644 --- a/pyvista/core/datasetattributes.py +++ b/pyvista/core/datasetattributes.py @@ -1096,7 +1096,9 @@ def active_vectors_name(self) -> Optional[str]: >>> import pyvista >>> import numpy as np >>> mesh = pyvista.Sphere() - >>> mesh.point_data.set_vectors(np.random.random((mesh.n_points, 3)), 'my-vectors') + >>> mesh.point_data.set_vectors( + ... np.random.random((mesh.n_points, 3)), 'my-vectors' + ... ) >>> mesh.point_data.active_vectors_name 'my-vectors' diff --git a/pyvista/core/filters/composite.py b/pyvista/core/filters/composite.py index dfe227c21a..0b63721721 100644 --- a/pyvista/core/filters/composite.py +++ b/pyvista/core/filters/composite.py @@ -53,7 +53,10 @@ def combine(self, merge_points=False, tolerance=0.0): >>> import pyvista >>> block = pyvista.MultiBlock( - ... [pyvista.Cube(clean=False), pyvista.Cube(center=(1, 0, 0), clean=False)] + ... [ + ... pyvista.Cube(clean=False), + ... pyvista.Cube(center=(1, 0, 0), clean=False), + ... ] ... ) >>> merged = block.combine() >>> merged.n_points diff --git a/pyvista/core/filters/data_set.py b/pyvista/core/filters/data_set.py index 1c982db4f0..a412ab788f 100644 --- a/pyvista/core/filters/data_set.py +++ b/pyvista/core/filters/data_set.py @@ -324,7 +324,9 @@ def compute_implicit_distance(self, surface, inplace=False): Plot these distances as a heatmap >>> pl = pv.Plotter() - >>> _ = pl.add_mesh(sphere, scalars='implicit_distance', cmap='bwr') + >>> _ = pl.add_mesh( + ... sphere, scalars='implicit_distance', cmap='bwr' + ... ) >>> _ = pl.add_mesh(plane, color='w', style='wireframe') >>> pl.show() @@ -385,7 +387,9 @@ def clip_scalar( >>> import pyvista as pv >>> from pyvista import examples >>> dataset = examples.load_hexbeam() - >>> clipped = dataset.clip_scalar(scalars="sample_point_scalars", value=100) + >>> clipped = dataset.clip_scalar( + ... scalars="sample_point_scalars", value=100 + ... ) >>> clipped.plot() Get clipped meshes corresponding to the portions of the mesh above and below 100. @@ -402,7 +406,9 @@ def clip_scalar( >>> import pyvista as pv >>> from pyvista import examples >>> dataset = examples.load_hexbeam() - >>> clipped = dataset.clip_scalar(scalars="sample_point_scalars", value=100, invert=False) + >>> clipped = dataset.clip_scalar( + ... scalars="sample_point_scalars", value=100, invert=False + ... ) >>> clipped.plot() """ @@ -895,14 +901,21 @@ def slice_along_line(self, line, generate_triangles=False, contour=False, progre >>> center = np.array(hills.center) >>> point_a = center + np.array([5, 0, 0]) >>> point_b = center + np.array([-5, 0, 0]) - >>> arc = pyvista.CircularArc(point_a, point_b, center, resolution=100) + >>> arc = pyvista.CircularArc( + ... point_a, point_b, center, resolution=100 + ... ) >>> line_slice = hills.slice_along_line(arc) Plot the circular arc and the hills mesh. >>> pl = pyvista.Plotter() >>> _ = pl.add_mesh(hills, smooth_shading=True, style='wireframe') - >>> _ = pl.add_mesh(line_slice, line_width=10, render_lines_as_tubes=True, color='k') + >>> _ = pl.add_mesh( + ... line_slice, + ... line_width=10, + ... render_lines_as_tubes=True, + ... color='k', + ... ) >>> _ = pl.add_mesh(arc, line_width=10, color='grey') >>> pl.show() @@ -1052,16 +1065,28 @@ def threshold( >>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (1, 1, 1), (0, 0, 0)) - >>> grid = pyvista.sample_function(noise, [0, 1.0, -0, 1.0, 0, 1.0], dim=(20, 20, 20)) - >>> grid.plot(cmap='gist_earth_r', show_scalar_bar=True, show_edges=False) + >>> grid = pyvista.sample_function( + ... noise, [0, 1.0, -0, 1.0, 0, 1.0], dim=(20, 20, 20) + ... ) + >>> grid.plot( + ... cmap='gist_earth_r', + ... show_scalar_bar=True, + ... show_edges=False, + ... ) Next, apply the threshold. >>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (1, 1, 1), (0, 0, 0)) - >>> grid = pyvista.sample_function(noise, [0, 1.0, -0, 1.0, 0, 1.0], dim=(20, 20, 20)) + >>> grid = pyvista.sample_function( + ... noise, [0, 1.0, -0, 1.0, 0, 1.0], dim=(20, 20, 20) + ... ) >>> threshed = grid.threshold(value=0.02) - >>> threshed.plot(cmap='gist_earth_r', show_scalar_bar=False, show_edges=True) + >>> threshed.plot( + ... cmap='gist_earth_r', + ... show_scalar_bar=False, + ... show_edges=True, + ... ) See :ref:`common_filter_example` for more examples using this filter. @@ -1182,14 +1207,24 @@ def threshold_percent( >>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (2, 2, 2), (0, 0, 0)) - >>> grid = pyvista.sample_function(noise, [0, 1.0, -0, 1.0, 0, 1.0], dim=(30, 30, 30)) + >>> grid = pyvista.sample_function( + ... noise, [0, 1.0, -0, 1.0, 0, 1.0], dim=(30, 30, 30) + ... ) >>> threshed = grid.threshold_percent(0.5) - >>> threshed.plot(cmap='gist_earth_r', show_scalar_bar=False, show_edges=True) + >>> threshed.plot( + ... cmap='gist_earth_r', + ... show_scalar_bar=False, + ... show_edges=True, + ... ) Apply a 80% threshold filter. >>> threshed = grid.threshold_percent(0.8) - >>> threshed.plot(cmap='gist_earth_r', show_scalar_bar=False, show_edges=True) + >>> threshed.plot( + ... cmap='gist_earth_r', + ... show_scalar_bar=False, + ... show_edges=True, + ... ) See :ref:`common_filter_example` for more examples using a similar filter. @@ -1617,7 +1652,11 @@ def contour( >>> x_min, y_min, z_min = -1.35, -1.7, -0.65 >>> grid = pv.UniformGrid( ... dimensions=(n, n, n), - ... spacing=(abs(x_min) / n * 2, abs(y_min) / n * 2, abs(z_min) / n * 2), + ... spacing=( + ... abs(x_min) / n * 2, + ... abs(y_min) / n * 2, + ... abs(z_min) / n * 2, + ... ), ... origin=(x_min, y_min, z_min), ... ) >>> x, y, z = grid.points.T @@ -1947,7 +1986,10 @@ def cell_centers(self, vertex=True, progress_bar=False): >>> pl = pyvista.Plotter() >>> actor = pl.add_mesh(mesh, show_edges=True) >>> actor = pl.add_points( - ... centers, render_points_as_spheres=True, color='red', point_size=20 + ... centers, + ... render_points_as_spheres=True, + ... color='red', + ... point_size=20, ... ) >>> pl.show() @@ -2044,10 +2086,17 @@ def glyph( >>> import pyvista >>> from pyvista import examples >>> mesh = examples.load_random_hills() - >>> arrows = mesh.glyph(scale="Normals", orient="Normals", tolerance=0.05) + >>> arrows = mesh.glyph( + ... scale="Normals", orient="Normals", tolerance=0.05 + ... ) >>> pl = pyvista.Plotter() >>> actor = pl.add_mesh(arrows, color="black") - >>> actor = pl.add_mesh(mesh, scalars="Elevation", cmap="terrain", show_scalar_bar=False) + >>> actor = pl.add_mesh( + ... mesh, + ... scalars="Elevation", + ... cmap="terrain", + ... show_scalar_bar=False, + ... ) >>> pl.show() See :ref:`glyph_example` and :ref:`glyph_table_example` for more @@ -2816,7 +2865,10 @@ def select_enclosed_points( >>> sphere = pyvista.Sphere() >>> plane = pyvista.Plane() >>> selected = plane.select_enclosed_points(sphere) - >>> pts = plane.extract_points(selected['SelectedPoints'].view(bool), adjacent_cells=False) + >>> pts = plane.extract_points( + ... selected['SelectedPoints'].view(bool), + ... adjacent_cells=False, + ... ) >>> pl = pyvista.Plotter() >>> _ = pl.add_mesh(sphere, style='wireframe') >>> _ = pl.add_points(pts, color='r') @@ -3088,7 +3140,9 @@ def interpolate( >>> plane.clear_data() >>> plane = plane.interpolate(pdata, sharpness=3) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(pdata, render_points_as_spheres=True, point_size=50) + >>> _ = pl.add_mesh( + ... pdata, render_points_as_spheres=True, point_size=50 + ... ) >>> _ = pl.add_mesh(plane, style='wireframe', line_width=5) >>> pl.show() @@ -3541,10 +3595,14 @@ def streamlines_evenly_spaced_2D( >>> from pyvista import examples >>> mesh = examples.download_cylinder_crossflow() >>> streams = mesh[0].streamlines_evenly_spaced_2D( - ... start_position=(4, 0.1, 0.0), separating_distance=3, separating_distance_ratio=0.2 + ... start_position=(4, 0.1, 0.0), + ... separating_distance=3, + ... separating_distance_ratio=0.2, ... ) >>> plotter = pyvista.Plotter() - >>> _ = plotter.add_mesh(streams.tube(radius=0.02), scalars="vorticity_mag") + >>> _ = plotter.add_mesh( + ... streams.tube(radius=0.02), scalars="vorticity_mag" + ... ) >>> plotter.view_xy() >>> plotter.show() @@ -3685,7 +3743,9 @@ def sample_over_line(self, pointa, pointb, resolution=None, tolerance=None, prog >>> plane = plane.interpolate(pdata, sharpness=3.5) >>> sample = plane.sample_over_line((-0.5, -0.5, 0), (0.5, 0.5, 0)) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(pdata, render_points_as_spheres=True, point_size=50) + >>> _ = pl.add_mesh( + ... pdata, render_points_as_spheres=True, point_size=50 + ... ) >>> _ = pl.add_mesh(sample, scalars='values', line_width=10) >>> _ = pl.add_mesh(plane, scalars='values', style='wireframe') >>> pl.show() @@ -3846,7 +3906,9 @@ def sample_over_multiple_lines(self, points, tolerance=None, progress_bar=False) ... [[-0.5, -0.5, 0], [0.5, -0.5, 0], [0.5, 0.5, 0]] ... ) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(pdata, render_points_as_spheres=True, point_size=50) + >>> _ = pl.add_mesh( + ... pdata, render_points_as_spheres=True, point_size=50 + ... ) >>> _ = pl.add_mesh(sample, scalars='values', line_width=10) >>> _ = pl.add_mesh(plane, scalars='values', style='wireframe') >>> pl.show() @@ -3901,10 +3963,24 @@ def sample_over_circular_arc( >>> from pyvista import examples >>> uniform = examples.load_uniform() >>> uniform["height"] = uniform.points[:, 2] - >>> pointa = [uniform.bounds[1], uniform.bounds[2], uniform.bounds[5]] - >>> pointb = [uniform.bounds[1], uniform.bounds[3], uniform.bounds[4]] - >>> center = [uniform.bounds[1], uniform.bounds[2], uniform.bounds[4]] - >>> sampled_arc = uniform.sample_over_circular_arc(pointa, pointb, center) + >>> pointa = [ + ... uniform.bounds[1], + ... uniform.bounds[2], + ... uniform.bounds[5], + ... ] + >>> pointb = [ + ... uniform.bounds[1], + ... uniform.bounds[3], + ... uniform.bounds[4], + ... ] + >>> center = [ + ... uniform.bounds[1], + ... uniform.bounds[2], + ... uniform.bounds[4], + ... ] + >>> sampled_arc = uniform.sample_over_circular_arc( + ... pointa, pointb, center + ... ) >>> pl = pyvista.Plotter() >>> _ = pl.add_mesh(uniform, style='wireframe') >>> _ = pl.add_mesh(sampled_arc, line_width=10) @@ -3981,8 +4057,14 @@ def sample_over_circular_arc_normal( >>> uniform["height"] = uniform.points[:, 2] >>> normal = [0, 0, 1] >>> polar = [0, 9, 0] - >>> center = [uniform.bounds[1], uniform.bounds[2], uniform.bounds[5]] - >>> arc = uniform.sample_over_circular_arc_normal(center, normal=normal, polar=polar) + >>> center = [ + ... uniform.bounds[1], + ... uniform.bounds[2], + ... uniform.bounds[5], + ... ] + >>> arc = uniform.sample_over_circular_arc_normal( + ... center, normal=normal, polar=polar + ... ) >>> pl = pyvista.Plotter() >>> _ = pl.add_mesh(uniform, style='wireframe') >>> _ = pl.add_mesh(arc, line_width=10) @@ -4075,7 +4157,9 @@ def plot_over_circular_arc( >>> a = [mesh.bounds[0], mesh.bounds[2], mesh.bounds[5]] >>> b = [mesh.bounds[1], mesh.bounds[2], mesh.bounds[4]] >>> center = [mesh.bounds[0], mesh.bounds[2], mesh.bounds[4]] - >>> mesh.plot_over_circular_arc(a, b, center, resolution=1000, show=False) # doctest:+SKIP + >>> mesh.plot_over_circular_arc( + ... a, b, center, resolution=1000, show=False + ... ) # doctest:+SKIP """ # Ensure matplotlib is available @@ -4205,7 +4289,9 @@ def plot_over_circular_arc_normal( >>> polar = [0, 9, 0] >>> angle = 90 >>> center = [mesh.bounds[0], mesh.bounds[2], mesh.bounds[4]] - >>> mesh.plot_over_circular_arc_normal(center, polar=polar, angle=angle) # doctest:+SKIP + >>> mesh.plot_over_circular_arc_normal( + ... center, polar=polar, angle=angle + ... ) # doctest:+SKIP """ # Ensure matplotlib is available @@ -4275,7 +4361,9 @@ def extract_cells(self, ind, progress_bar=False): >>> subset.n_cells 20 >>> pl = pyvista.Plotter() - >>> actor = pl.add_mesh(grid, style='wireframe', line_width=5, color='black') + >>> actor = pl.add_mesh( + ... grid, style='wireframe', line_width=5, color='black' + ... ) >>> actor = pl.add_mesh(subset, color='grey') >>> pl.show() @@ -5088,7 +5176,12 @@ def transform( accepted. >>> transform_matrix = np.array( - ... [[1, 0, 0, 50], [0, 1, 0, 100], [0, 0, 1, 200], [0, 0, 0, 1]] + ... [ + ... [1, 0, 0, 50], + ... [0, 1, 0, 100], + ... [0, 0, 1, 200], + ... [0, 0, 0, 1], + ... ] ... ) >>> transformed = mesh.transform(transform_matrix) >>> transformed.plot(show_edges=True) @@ -5280,7 +5373,9 @@ def integrate_data(self, progress_bar=False): >>> import pyvista >>> import numpy as np - >>> sphere = pyvista.Sphere(theta_resolution=100, phi_resolution=100) + >>> sphere = pyvista.Sphere( + ... theta_resolution=100, phi_resolution=100 + ... ) >>> sphere.point_data["data"] = 2 * np.ones(sphere.n_points) >>> integrated = sphere.integrate_data() diff --git a/pyvista/core/filters/poly_data.py b/pyvista/core/filters/poly_data.py index 619f6b99d2..d7973382bd 100644 --- a/pyvista/core/filters/poly_data.py +++ b/pyvista/core/filters/poly_data.py @@ -173,8 +173,12 @@ def boolean_union(self, other_mesh, tolerance=1e-5, progress_bar=False): >>> sphere_b = pyvista.Sphere(center=(0.5, 0, 0)) >>> result = sphere_a.boolean_union(sphere_b) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(sphere_a, color='r', style='wireframe', line_width=3) - >>> _ = pl.add_mesh(sphere_b, color='b', style='wireframe', line_width=3) + >>> _ = pl.add_mesh( + ... sphere_a, color='r', style='wireframe', line_width=3 + ... ) + >>> _ = pl.add_mesh( + ... sphere_b, color='b', style='wireframe', line_width=3 + ... ) >>> _ = pl.add_mesh(result, color='tan') >>> pl.camera_position = 'xz' >>> pl.show() @@ -242,8 +246,12 @@ def boolean_intersection(self, other_mesh, tolerance=1e-5, progress_bar=False): >>> sphere_b = pyvista.Sphere(center=(0.5, 0, 0)) >>> result = sphere_a.boolean_intersection(sphere_b) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(sphere_a, color='r', style='wireframe', line_width=3) - >>> _ = pl.add_mesh(sphere_b, color='b', style='wireframe', line_width=3) + >>> _ = pl.add_mesh( + ... sphere_a, color='r', style='wireframe', line_width=3 + ... ) + >>> _ = pl.add_mesh( + ... sphere_b, color='b', style='wireframe', line_width=3 + ... ) >>> _ = pl.add_mesh(result, color='tan') >>> pl.camera_position = 'xz' >>> pl.show() @@ -315,8 +323,12 @@ def boolean_difference(self, other_mesh, tolerance=1e-5, progress_bar=False): >>> sphere_b = pyvista.Sphere(center=(0.5, 0, 0)) >>> result = sphere_a.boolean_difference(sphere_b) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(sphere_a, color='r', style='wireframe', line_width=3) - >>> _ = pl.add_mesh(sphere_b, color='b', style='wireframe', line_width=3) + >>> _ = pl.add_mesh( + ... sphere_a, color='r', style='wireframe', line_width=3 + ... ) + >>> _ = pl.add_mesh( + ... sphere_b, color='b', style='wireframe', line_width=3 + ... ) >>> _ = pl.add_mesh(result, color='tan') >>> pl.camera_position = 'xz' >>> pl.show() @@ -507,7 +519,9 @@ def intersection(self, mesh, split_first=True, split_second=True, progress_bar=F The mesh splitting takes additional time and can be turned off for either mesh individually. - >>> intersection, _, s2_split = s1.intersection(s2, split_first=False, split_second=True) + >>> intersection, _, s2_split = s1.intersection( + ... s2, split_first=False, split_second=True + ... ) """ intfilter = _vtk.vtkIntersectionPolyDataFilter() @@ -614,7 +628,9 @@ def plot_curvature(self, curv_type='mean', **kwargs): >>> from pyvista import examples >>> hills = examples.load_random_hills() - >>> hills.plot_curvature(curv_type='gaussian', smooth_shading=True, clim=[0, 1]) + >>> hills.plot_curvature( + ... curv_type='gaussian', smooth_shading=True, clim=[0, 1] + ... ) """ kwargs.setdefault('scalar_bar_args', {'title': f'{curv_type.capitalize()} Curvature'}) @@ -1661,7 +1677,9 @@ def clip_closed_surface( sphere in the positive Z direction. Shift the clip upwards to leave a smaller mesh behind. - >>> clipped_mesh = sphere.clip_closed_surface('z', origin=[0, 0, 0.3]) + >>> clipped_mesh = sphere.clip_closed_surface( + ... 'z', origin=[0, 0, 0.3] + ... ) >>> clipped_mesh.plot(show_edges=True, line_width=3) """ @@ -1814,7 +1832,9 @@ def clean( >>> import pyvista as pv >>> import numpy as np - >>> points = np.array([[0, 0, 0], [0, 1, 0], [1, 0, 0]], dtype=np.float32) + >>> points = np.array( + ... [[0, 0, 0], [0, 1, 0], [1, 0, 0]], dtype=np.float32 + ... ) >>> faces = np.array([3, 0, 1, 2, 3, 0, 2, 2]) >>> mesh = pv.PolyData(points, faces) >>> mout = mesh.clean() @@ -2036,7 +2056,9 @@ def ray_trace(self, origin, end_point, first_point=False, plot=False, off_screen >>> import pyvista as pv >>> sphere = pv.Sphere() - >>> point, cell = sphere.ray_trace([0, 0, 0], [1, 0, 0], first_point=True) + >>> point, cell = sphere.ray_trace( + ... [0, 0, 0], [1, 0, 0], first_point=True + ... ) >>> f'Intersected at {point[0]:.3f} {point[1]:.3f} {point[2]:.3f}' 'Intersected at 0.499 0.000 0.000' @@ -2131,10 +2153,15 @@ def multi_ray_trace( >>> import pyvista as pv # doctest:+SKIP >>> sphere = pv.Sphere() # doctest:+SKIP >>> points, rays, cells = sphere.multi_ray_trace( - ... [[0, 0, 0]] * 3, [[1, 0, 0], [0, 1, 0], [0, 0, 1]], first_point=True + ... [[0, 0, 0]] * 3, + ... [[1, 0, 0], [0, 1, 0], [0, 0, 1]], + ... first_point=True, ... ) # doctest:+SKIP >>> string = ", ".join( - ... [f"({point[0]:.3f}, {point[1]:.3f}, {point[2]:.3f})" for point in points] + ... [ + ... f"({point[0]:.3f}, {point[1]:.3f}, {point[2]:.3f})" + ... for point in points + ... ] ... ) # doctest:+SKIP >>> f'Rays intersected at {string}' # doctest:+SKIP 'Rays intersected at (0.499, 0.000, 0.000), (0.000, 0.497, 0.000), (0.000, 0.000, 0.500)' @@ -2924,10 +2951,17 @@ def extrude_rotate( >>> import pyvista >>> profile = pyvista.Polygon( - ... center=[1.25, 0.0, 0.0], radius=0.2, normal=(0, 1, 0), n_sides=30 + ... center=[1.25, 0.0, 0.0], + ... radius=0.2, + ... normal=(0, 1, 0), + ... n_sides=30, ... ) >>> extruded = profile.extrude_rotate( - ... resolution=360, translation=4.0, dradius=0.5, angle=1500.0, capping=True + ... resolution=360, + ... translation=4.0, + ... dradius=0.5, + ... angle=1500.0, + ... capping=True, ... ) >>> extruded.plot(smooth_shading=True) @@ -3054,7 +3088,9 @@ def extrude_trim( >>> import pyvista >>> import numpy as np - >>> plane = pyvista.Plane(i_size=2, j_size=2, direction=[0, 0.8, 1]) + >>> plane = pyvista.Plane( + ... i_size=2, j_size=2, direction=[0, 0.8, 1] + ... ) >>> disc = pyvista.Disc(center=(0, 0, -1), c_res=50) >>> direction = [0, 0, 1] >>> extruded_disc = disc.extrude_trim(direction, plane) @@ -3292,14 +3328,27 @@ def collision( >>> scalars = np.zeros(collision.n_cells, dtype=bool) >>> scalars[collision.field_data['ContactCells']] = True >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(collision, scalars=scalars, show_scalar_bar=False, cmap='bwr') - >>> _ = pl.add_mesh(mesh_b, color='tan', line_width=5, opacity=0.7, show_edges=True) + >>> _ = pl.add_mesh( + ... collision, + ... scalars=scalars, + ... show_scalar_bar=False, + ... cmap='bwr', + ... ) + >>> _ = pl.add_mesh( + ... mesh_b, + ... color='tan', + ... line_width=5, + ... opacity=0.7, + ... show_edges=True, + ... ) >>> pl.show() Alternatively, simply plot the collisions using the default ``'collision_rgba'`` array after enabling ``generate_scalars``. - >>> collision, ncol = mesh_a.collision(mesh_b, cell_tolerance=1, generate_scalars=True) + >>> collision, ncol = mesh_a.collision( + ... mesh_b, cell_tolerance=1, generate_scalars=True + ... ) >>> collision.plot() See :ref:`collision_example` for more examples using this filter. @@ -3426,7 +3475,12 @@ def contour_banded( >>> _, edges = mesh.contour_banded(n_contours) >>> pl = pv.Plotter() - >>> _ = pl.add_mesh(edges, line_width=5, render_lines_as_tubes=True, color='k') + >>> _ = pl.add_mesh( + ... edges, + ... line_width=5, + ... render_lines_as_tubes=True, + ... color='k', + ... ) >>> _ = pl.add_mesh(mesh, n_colors=n_contours - 1, cmap='Set3') >>> pl.show() @@ -3440,7 +3494,12 @@ def contour_banded( >>> dargs = dict(n_colors=n_contours - 1, clim=rng) >>> pl = pv.Plotter() - >>> _ = pl.add_mesh(edges, line_width=5, render_lines_as_tubes=True, color='k') + >>> _ = pl.add_mesh( + ... edges, + ... line_width=5, + ... render_lines_as_tubes=True, + ... color='k', + ... ) >>> _ = pl.add_mesh(surf, opacity=0.3, **dargs) >>> _ = pl.add_mesh(output, **dargs) >>> pl.show() diff --git a/pyvista/core/filters/structured_grid.py b/pyvista/core/filters/structured_grid.py index ca8b3dca05..468d8cd75d 100644 --- a/pyvista/core/filters/structured_grid.py +++ b/pyvista/core/filters/structured_grid.py @@ -57,8 +57,12 @@ def extract_subset(self, voi, rate=(1, 1, 1), boundary=False): >>> import pyvista >>> from pyvista import examples >>> grid = examples.load_structured() - >>> voi_1 = grid.extract_subset([0, 80, 0, 40, 0, 1], boundary=True) - >>> voi_2 = grid.extract_subset([0, 80, 40, 80, 0, 1], boundary=True) + >>> voi_1 = grid.extract_subset( + ... [0, 80, 0, 40, 0, 1], boundary=True + ... ) + >>> voi_2 = grid.extract_subset( + ... [0, 80, 40, 80, 0, 1], boundary=True + ... ) For fun, add the two grids back together and show they are identical to the original grid. @@ -107,8 +111,12 @@ def concatenate(self, other, axis, tolerance=0.0): >>> import pyvista >>> from pyvista import examples >>> grid = examples.load_structured() - >>> voi_1 = grid.extract_subset([0, 80, 0, 40, 0, 1], boundary=True) - >>> voi_2 = grid.extract_subset([0, 80, 40, 80, 0, 1], boundary=True) + >>> voi_1 = grid.extract_subset( + ... [0, 80, 0, 40, 0, 1], boundary=True + ... ) + >>> voi_2 = grid.extract_subset( + ... [0, 80, 40, 80, 0, 1], boundary=True + ... ) >>> joined = voi_1.concatenate(voi_2, axis=1) >>> f'{grid.dimensions} same as {joined.dimensions}' '(80, 80, 1) same as (80, 80, 1)' diff --git a/pyvista/core/filters/uniform_grid.py b/pyvista/core/filters/uniform_grid.py index d81488a326..69c1ffeb52 100644 --- a/pyvista/core/filters/uniform_grid.py +++ b/pyvista/core/filters/uniform_grid.py @@ -52,7 +52,9 @@ def gaussian_smooth(self, radius_factor=1.5, std_dev=2.0, scalars=None, progress >>> import numpy as np >>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (2, 5, 8), (0, 0, 0)) - >>> grid = pyvista.sample_function(noise, [0, 1, 0, 1, 0, 1], dim=(20, 20, 20)) + >>> grid = pyvista.sample_function( + ... noise, [0, 1, 0, 1, 0, 1], dim=(20, 20, 20) + ... ) >>> grid.plot(show_scalar_bar=False) Next, smooth the sample data. @@ -141,7 +143,9 @@ def median_smooth( >>> import numpy as np >>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (2, 5, 8), (0, 0, 0)) - >>> grid = pyvista.sample_function(noise, [0, 1, 0, 1, 0, 1], dim=(20, 20, 20)) + >>> grid = pyvista.sample_function( + ... noise, [0, 1, 0, 1, 0, 1], dim=(20, 20, 20) + ... ) >>> grid.plot(show_scalar_bar=False) Next, smooth the sample data. diff --git a/pyvista/core/pointset.py b/pyvista/core/pointset.py index 027e619661..3fa500dc3c 100644 --- a/pyvista/core/pointset.py +++ b/pyvista/core/pointset.py @@ -427,7 +427,9 @@ class PolyData(_vtk.vtkPolyData, _PointSet, PolyDataFilters): Initialize from just vertices. - >>> vertices = np.array([[0, 0, 0], [1, 0, 0], [1, 0.5, 0], [0, 0.5, 0]]) + >>> vertices = np.array( + ... [[0, 0, 0], [1, 0, 0], [1, 0.5, 0], [0, 0.5, 0]] + ... ) >>> mesh = pyvista.PolyData(vertices) Initialize from vertices and faces. @@ -588,9 +590,16 @@ def verts(self) -> np.ndarray: >>> mesh = pyvista.Plane(i_resolution=3, j_resolution=3) >>> mesh.verts = np.vstack( - ... (np.ones(mesh.n_points, dtype=np.int64), np.arange(mesh.n_points)) + ... ( + ... np.ones(mesh.n_points, dtype=np.int64), + ... np.arange(mesh.n_points), + ... ) ... ).T - >>> mesh.plot(color='tan', render_points_as_spheres=True, point_size=60) + >>> mesh.plot( + ... color='tan', + ... render_points_as_spheres=True, + ... point_size=60, + ... ) """ return _vtk.vtk_to_numpy(self.GetVerts().GetData()) @@ -836,7 +845,9 @@ def n_strips(self) -> int: >>> import pyvista >>> import numpy as np - >>> vertices = np.array([[1.0, 0.0, 0.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]) + >>> vertices = np.array( + ... [[1.0, 0.0, 0.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]] + ... ) >>> strip = np.array([3, 0, 1, 2]) >>> mesh = pyvista.PolyData(vertices, strips=strip) >>> mesh.n_strips @@ -929,9 +940,13 @@ def save(self, filename, binary=True, texture=None, recompute_normals=True): >>> import numpy as np >>> sphere = pyvista.Sphere() >>> texture = np.zeros((sphere.n_points, 3), np.uint8) - >>> texture[:, 1] = np.arange(sphere.n_points)[::-1] # just blue channel + >>> # Just the green channel is set as a repeatedly + >>> # decreasing value + >>> texture[:, 1] = np.arange(sphere.n_points)[::-1] >>> sphere.point_data['my_texture'] = texture - >>> sphere.save('my_mesh.ply', texture='my_texture') # doctest:+SKIP + >>> sphere.save( + ... 'my_mesh.ply', texture='my_texture' + ... ) # doctest:+SKIP Alternatively, provide just the texture array. This will be written to the file as ``'RGB'`` since it does not contain an @@ -1370,8 +1385,12 @@ def _from_arrays( >>> import numpy as np >>> from pyvista import CellType >>> import pyvista - >>> cells = np.array([8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]) - >>> cell_type = np.array([CellType.HEXAHEDRON, CellType.HEXAHEDRON], np.int8) + >>> cell0_ids = [8, 0, 1, 2, 3, 4, 5, 6, 7] + >>> cell1_ids = [8, 8, 9, 10, 11, 12, 13, 14, 15] + >>> cells = np.hstack((cell0_ids, cell1_ids)) + >>> cell_type = np.array( + ... [CellType.HEXAHEDRON, CellType.HEXAHEDRON], np.int8 + ... ) >>> cell1 = np.array( ... [ @@ -2149,7 +2168,11 @@ class ExplicitStructuredGrid(_vtk.vtkExplicitStructuredGrid, PointGrid): >>> si, sj, sk = 20, 10, 1 >>> >>> # create raw coordinate grid - >>> grid_ijk = np.mgrid[: (ni + 1) * si : si, : (nj + 1) * sj : sj, : (nk + 1) * sk : sk] + >>> grid_ijk = np.mgrid[ + ... : (ni + 1) * si : si, + ... : (nj + 1) * sj : sj, + ... : (nk + 1) * sk : sk, + ... ] >>> >>> # repeat array along each Cartesian axis for connectivity >>> for axis in range(1, 4): @@ -2274,16 +2297,24 @@ def cast_to_unstructured_grid(self) -> 'UnstructuredGrid': -------- >>> from pyvista import examples >>> grid = examples.load_explicit_structured() # doctest:+SKIP - >>> grid.plot(color='w', show_edges=True, show_bounds=True) # doctest:+SKIP + >>> grid.plot( + ... color='w', show_edges=True, show_bounds=True + ... ) # doctest:+SKIP >>> grid = grid.hide_cells(range(80, 120)) # doctest:+SKIP - >>> grid.plot(color='w', show_edges=True, show_bounds=True) # doctest:+SKIP + >>> grid.plot( + ... color='w', show_edges=True, show_bounds=True + ... ) # doctest:+SKIP >>> grid = grid.cast_to_unstructured_grid() # doctest:+SKIP - >>> grid.plot(color='w', show_edges=True, show_bounds=True) # doctest:+SKIP + >>> grid.plot( + ... color='w', show_edges=True, show_bounds=True + ... ) # doctest:+SKIP >>> grid = grid.cast_to_explicit_structured_grid() # doctest:+SKIP - >>> grid.plot(color='w', show_edges=True, show_bounds=True) # doctest:+SKIP + >>> grid.plot( + ... color='w', show_edges=True, show_bounds=True + ... ) # doctest:+SKIP """ grid = ExplicitStructuredGrid() @@ -2321,10 +2352,14 @@ def save(self, filename, binary=True): >>> grid.save('grid.vtu') # doctest:+SKIP >>> grid = pv.ExplicitStructuredGrid('grid.vtu') # doctest:+SKIP - >>> grid.plot(color='w', show_edges=True, show_bounds=True) # doctest:+SKIP + >>> grid.plot( + ... color='w', show_edges=True, show_bounds=True + ... ) # doctest:+SKIP >>> grid.show_cells() # doctest:+SKIP - >>> grid.plot(color='w', show_edges=True, show_bounds=True) # doctest:+SKIP + >>> grid.plot( + ... color='w', show_edges=True, show_bounds=True + ... ) # doctest:+SKIP """ grid = self.cast_to_unstructured_grid() @@ -2602,8 +2637,12 @@ def neighbors(self, ind, rel='connectivity') -> list: >>> >>> plotter = pv.Plotter() >>> plotter.add_axes() # doctest:+SKIP - >>> plotter.add_mesh(cell, color='r', show_edges=True) # doctest:+SKIP - >>> plotter.add_mesh(neighbors, color='w', show_edges=True) # doctest:+SKIP + >>> plotter.add_mesh( + ... cell, color='r', show_edges=True + ... ) # doctest:+SKIP + >>> plotter.add_mesh( + ... neighbors, color='w', show_edges=True + ... ) # doctest:+SKIP >>> plotter.show() # doctest:+SKIP """ diff --git a/pyvista/demos/demos.py b/pyvista/demos/demos.py index 38dc809b83..d669b0dc0a 100644 --- a/pyvista/demos/demos.py +++ b/pyvista/demos/demos.py @@ -339,7 +339,9 @@ def plot_ants_plane(notebook=None): >>> plane_scalars = airplane.points[:, 1] >>> _ = plotter.add_mesh( - ... airplane, scalars=plane_scalars, scalar_bar_args={'title': 'Plane Y Location'} + ... airplane, + ... scalars=plane_scalars, + ... scalar_bar_args={'title': 'Plane Y Location'}, ... ) >>> _ = plotter.add_text('Ants and Plane Example') >>> plotter.show() diff --git a/pyvista/demos/logo.py b/pyvista/demos/logo.py index 253e0a52ed..a2e757a3af 100644 --- a/pyvista/demos/logo.py +++ b/pyvista/demos/logo.py @@ -98,7 +98,12 @@ def logo_basic(): Add scalars and plot the logo. >>> logo['x_coord'] = logo.points[:, 0] - >>> cpos = logo.plot(scalars='x_coord', cmap='Spectral', smooth_shading=True, cpos='xy') + >>> cpos = logo.plot( + ... scalars='x_coord', + ... cmap='Spectral', + ... smooth_shading=True, + ... cpos='xy', + ... ) """ return logo_letters(merge=True).compute_normals(split_vertices=True) diff --git a/pyvista/examples/downloads.py b/pyvista/examples/downloads.py index 23ac843ad8..42a9d5ef52 100644 --- a/pyvista/examples/downloads.py +++ b/pyvista/examples/downloads.py @@ -621,7 +621,11 @@ def download_head(load=True): # pragma: no cover >>> dataset = examples.download_head() >>> pl = pyvista.Plotter() >>> _ = pl.add_volume(dataset, cmap="cool", opacity="sigmoid_6") - >>> pl.camera_position = [(-228.0, -418.0, -158.0), (94.0, 122.0, 82.0), (-0.2, -0.3, 0.9)] + >>> pl.camera_position = [ + ... (-228.0, -418.0, -158.0), + ... (94.0, 122.0, 82.0), + ... (-0.2, -0.3, 0.9), + ... ] >>> pl.show() See :ref:`volume_rendering_example` for an example using this @@ -686,7 +690,11 @@ def download_bolt_nut(load=True): # pragma: no cover ... opacity="sigmoid_5", ... show_scalar_bar=False, ... ) - >>> pl.camera_position = [(194.6, -141.8, 182.0), (34.5, 61.0, 32.5), (-0.229, 0.45, 0.86)] + >>> pl.camera_position = [ + ... (194.6, -141.8, 182.0), + ... (34.5, 61.0, 32.5), + ... (-0.229, 0.45, 0.86), + ... ] >>> pl.show() See :ref:`volume_rendering_example` for an example using this @@ -772,7 +780,9 @@ def download_topo_land(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_topo_land() - >>> dataset.plot(clim=[-2000, 3000], cmap="gist_earth", show_scalar_bar=False) + >>> dataset.plot( + ... clim=[-2000, 3000], cmap="gist_earth", show_scalar_bar=False + ... ) This dataset is used in the following examples: @@ -855,8 +865,14 @@ def download_knee_full(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_knee_full() - >>> cpos = [(-381.74, -46.02, 216.54), (74.8305, 89.2905, 100.0), (0.23, 0.072, 0.97)] - >>> dataset.plot(volume=True, cmap="bone", cpos=cpos, show_scalar_bar=False) + >>> cpos = [ + ... (-381.74, -46.02, 216.54), + ... (74.8305, 89.2905, 100.0), + ... (0.23, 0.072, 0.97), + ... ] + >>> dataset.plot( + ... volume=True, cmap="bone", cpos=cpos, show_scalar_bar=False + ... ) This dataset is used in the following examples: @@ -1093,7 +1109,9 @@ def download_sparse_points(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_sparse_points() - >>> dataset.plot(scalars="val", render_points_as_spheres=True, point_size=50) + >>> dataset.plot( + ... scalars="val", render_points_as_spheres=True, point_size=50 + ... ) See :ref:`interpolate_example` for an example using this dataset. @@ -2270,7 +2288,11 @@ def download_carotid(load=True): # pragma: no cover Examples -------- >>> from pyvista import examples - >>> cpos = [[220.96, -24.38, -69.96], [135.86, 106.55, 17.72], [-0.25, 0.42, -0.87]] + >>> cpos = [ + ... [220.96, -24.38, -69.96], + ... [135.86, 106.55, 17.72], + ... [-0.25, 0.42, -0.87], + ... ] >>> dataset = examples.download_carotid() >>> dataset.plot(volume=True, cpos=cpos) @@ -2307,7 +2329,11 @@ def download_blow(load=True): # pragma: no cover Examples -------- >>> from pyvista import examples - >>> cpos = [[71.96, 86.1, 28.45], [3.5, 12.0, 1.0], [-0.18, -0.19, 0.96]] + >>> cpos = [ + ... [71.96, 86.1, 28.45], + ... [3.5, 12.0, 1.0], + ... [-0.18, -0.19, 0.96], + ... ] >>> dataset = examples.download_blow() >>> dataset.plot( ... scalars='displacement1', @@ -2400,7 +2426,11 @@ def download_armadillo(load=True): # pragma: no cover Plot the armadillo dataset. Use a custom camera position. >>> from pyvista import examples - >>> cpos = [(161.5, 82.1, -330.2), (-4.3, 24.5, -1.6), (-0.1, 1, 0.12)] + >>> cpos = [ + ... (161.5, 82.1, -330.2), + ... (-4.3, 24.5, -1.6), + ... (-0.1, 1, 0.12), + ... ] >>> dataset = examples.download_armadillo() >>> dataset.plot(cpos=cpos) @@ -2603,7 +2633,9 @@ def download_thermal_probes(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_thermal_probes() - >>> dataset.plot(render_points_as_spheres=True, point_size=5, cpos="xy") + >>> dataset.plot( + ... render_points_as_spheres=True, point_size=5, cpos="xy" + ... ) See :ref:`interpolate_example` for an example using this dataset. @@ -2752,7 +2784,11 @@ def download_crater_imagery(load=True): # pragma: no cover Examples -------- >>> from pyvista import examples - >>> cpos = [[66.0, 73.0, -382.6], [66.0, 73.0, 0.0], [-0.0, -1.0, 0.0]] + >>> cpos = [ + ... [66.0, 73.0, -382.6], + ... [66.0, 73.0, 0.0], + ... [-0.0, -1.0, 0.0], + ... ] >>> dataset = examples.download_crater_imagery() >>> dataset.plot(cpos=cpos) @@ -2809,7 +2845,9 @@ def download_damavand_volcano(load=True): # pragma: no cover ... [4.10000000e-01, -2.90000000e-01, -8.60000000e-01], ... ] >>> dataset = examples.download_damavand_volcano() - >>> dataset.plot(cpos=cpos, cmap="reds", show_scalar_bar=False, volume=True) + >>> dataset.plot( + ... cpos=cpos, cmap="reds", show_scalar_bar=False, volume=True + ... ) See :ref:`volume_rendering_example` for an example using this dataset. @@ -2901,7 +2939,9 @@ def download_antarctica_velocity(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_antarctica_velocity() - >>> dataset.plot(cpos='xy', clim=[1e-3, 1e4], cmap='Blues', log_scale=True) + >>> dataset.plot( + ... cpos='xy', clim=[1e-3, 1e4], cmap='Blues', log_scale=True + ... ) See :ref:`antarctica_example` for an example using this dataset. @@ -3105,7 +3145,9 @@ def download_cubemap_space_4k(): # pragma: no cover >>> _ = pl.add_actor(cubemap.to_skybox()) >>> pl.set_environment_texture(cubemap, True) >>> pl.camera.zoom(0.4) - >>> _ = pl.add_mesh(pv.Sphere(), pbr=True, roughness=0.24, metallic=1.0) + >>> _ = pl.add_mesh( + ... pv.Sphere(), pbr=True, roughness=0.24, metallic=1.0 + ... ) >>> pl.show() """ @@ -3146,7 +3188,9 @@ def download_cubemap_space_16k(): # pragma: no cover >>> _ = pl.add_actor(cubemap.to_skybox()) >>> pl.set_environment_texture(cubemap, True) >>> pl.camera.zoom(0.4) - >>> _ = pl.add_mesh(pv.Sphere(), pbr=True, roughness=0.24, metallic=1.0) + >>> _ = pl.add_mesh( + ... pv.Sphere(), pbr=True, roughness=0.24, metallic=1.0 + ... ) >>> pl.show() """ @@ -3267,7 +3311,11 @@ def download_woman(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_woman() - >>> cpos = [(-2600.0, 1970.6, 1836.9), (48.5, -20.3, 843.9), (0.23, -0.168, 0.958)] + >>> cpos = [ + ... (-2600.0, 1970.6, 1836.9), + ... (48.5, -20.3, 843.9), + ... (0.23, -0.168, 0.958), + ... ] >>> dataset.plot(cpos=cpos) """ @@ -3438,9 +3486,18 @@ def download_action_figure(load=True): # pragma: no cover >>> pl = pyvista.Plotter(lighting=None) >>> pl.add_light(pyvista.Light((30, 10, 10))) >>> _ = pl.add_mesh( - ... dataset, color='w', smooth_shading=True, pbr=True, metallic=0.3, roughness=0.5 + ... dataset, + ... color='w', + ... smooth_shading=True, + ... pbr=True, + ... metallic=0.3, + ... roughness=0.5, ... ) - >>> pl.camera_position = [(32.3, 116.3, 220.6), (-0.05, 3.8, 33.8), (-0.017, 0.86, -0.51)] + >>> pl.camera_position = [ + ... (32.3, 116.3, 220.6), + ... (-0.05, 3.8, 33.8), + ... (-0.017, 0.86, -0.51), + ... ] >>> pl.show() """ @@ -3559,7 +3616,11 @@ def download_louis_louvre(load=True): # pragma: no cover >>> pl = pyvista.Plotter(lighting=None) >>> _ = pl.add_mesh(dataset, smooth_shading=True) >>> pl.add_light(pyvista.Light((10, -10, 10))) - >>> pl.camera_position = [[-6.71, -14.55, 15.17], [1.44, 2.54, 9.84], [0.16, 0.22, 0.96]] + >>> pl.camera_position = [ + ... [-6.71, -14.55, 15.17], + ... [1.44, 2.54, 9.84], + ... [0.16, 0.22, 0.96], + ... ] >>> pl.show() See :ref:`pbr_example` for an example using this dataset. @@ -3781,8 +3842,12 @@ def download_osmnx_graph(): # pragma: no cover >>> import osmnx as ox # doctest:+SKIP >>> address = 'Holzgerlingen DE' # doctest:+SKIP - >>> graph = ox.graph_from_address(address, dist=500, network_type='drive') # doctest:+SKIP - >>> pickle.dump(graph, open('osmnx_graph.p', 'wb')) # doctest:+SKIP + >>> graph = ox.graph_from_address( + ... address, dist=500, network_type='drive' + ... ) # doctest:+SKIP + >>> pickle.dump( + ... graph, open('osmnx_graph.p', 'wb') + ... ) # doctest:+SKIP Returns ------- @@ -4228,7 +4293,12 @@ def download_moonlanding_image(load=True): # pragma: no cover -------- >>> from pyvista import examples >>> dataset = examples.download_moonlanding_image() - >>> dataset.plot(cpos='xy', cmap='gray', background='w', show_scalar_bar=False) + >>> dataset.plot( + ... cpos='xy', + ... cmap='gray', + ... background='w', + ... show_scalar_bar=False, + ... ) See :ref:`image_fft_example` for a full example using this dataset. @@ -4351,11 +4421,23 @@ def download_gif_simple(load=True): # pragma: no cover >>> from pyvista import examples >>> grid = examples.download_gif_simple() - >>> grid.plot(scalars='frame0', rgb=True, background='w', show_scalar_bar=False, cpos='xy') + >>> grid.plot( + ... scalars='frame0', + ... rgb=True, + ... background='w', + ... show_scalar_bar=False, + ... cpos='xy', + ... ) Plot the second frame. - >>> grid.plot(scalars='frame1', rgb=True, background='w', show_scalar_bar=False, cpos='xy') + >>> grid.plot( + ... scalars='frame1', + ... rgb=True, + ... background='w', + ... show_scalar_bar=False, + ... cpos='xy', + ... ) """ return _download_and_read('gifs/sample.gif', load=load) @@ -4704,7 +4786,11 @@ def download_ivan_angel(load=True): # pragma: no cover >>> from pyvista import examples >>> mesh = examples.download_ivan_angel() - >>> cpos = [(-476.14, -393.73, 282.14), (-15.00, 11.25, 44.08), (0.26, 0.24, 0.93)] + >>> cpos = [ + ... (-476.14, -393.73, 282.14), + ... (-15.00, 11.25, 44.08), + ... (0.26, 0.24, 0.93), + ... ] >>> mesh.plot(cpos=cpos) Return the statistics of the dataset. @@ -4809,7 +4895,11 @@ def download_owl(load=True): # pragma: no cover >>> from pyvista import examples >>> mesh = examples.download_owl() - >>> cpos = [(-315.18, -402.21, 230.71), (6.06, -1.74, 101.48), (0.108, 0.226, 0.968)] + >>> cpos = [ + ... (-315.18, -402.21, 230.71), + ... (6.06, -1.74, 101.48), + ... (0.108, 0.226, 0.968), + ... ] >>> mesh.plot(cpos=cpos) Return the statistics of the dataset. diff --git a/pyvista/examples/gltf.py b/pyvista/examples/gltf.py index 0a5a699af1..b4fc000289 100644 --- a/pyvista/examples/gltf.py +++ b/pyvista/examples/gltf.py @@ -32,7 +32,9 @@ def download_damaged_helmet(): # pragma: no cover -------- >>> import pyvista >>> from pyvista import examples # doctest:+SKIP - >>> gltf_file = examples.gltf.download_damaged_helmet() # doctest:+SKIP + >>> gltf_file = ( + ... examples.gltf.download_damaged_helmet() + ... ) # doctest:+SKIP >>> cubemap = examples.download_sky_box_cube_map() # doctest:+SKIP >>> pl = pyvista.Plotter() # doctest:+SKIP >>> pl.import_gltf(gltf_file) # doctest:+SKIP diff --git a/pyvista/examples/planets.py b/pyvista/examples/planets.py index eef832548b..6573864a89 100644 --- a/pyvista/examples/planets.py +++ b/pyvista/examples/planets.py @@ -73,7 +73,9 @@ def load_sun(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: no c >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_sun()) >>> pl.show() @@ -111,7 +113,9 @@ def load_moon(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: no >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_moon()) >>> pl.show() @@ -149,7 +153,9 @@ def load_mercury(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_mercury()) >>> pl.show() @@ -187,7 +193,9 @@ def load_venus(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: no >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_venus()) >>> pl.show() @@ -227,7 +235,9 @@ def load_earth(radius=1.0, lat_resolution=50, lon_resolution=100): >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_earth()) >>> pl.show() @@ -264,7 +274,9 @@ def load_mars(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: no >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_mars()) >>> pl.show() @@ -302,7 +314,9 @@ def load_jupiter(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_jupiter()) >>> pl.show() @@ -340,7 +354,9 @@ def load_saturn(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: n >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_saturn()) >>> pl.show() @@ -380,7 +396,9 @@ def load_saturn_rings(inner=0.25, outer=0.5, c_res=6): # pragma: no cover >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_saturn_rings()) >>> pl.show() @@ -420,7 +438,9 @@ def load_uranus(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: n >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_uranus()) >>> pl.show() @@ -458,7 +478,9 @@ def load_neptune(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_neptune()) >>> pl.show() @@ -496,7 +518,9 @@ def load_pluto(radius=1.0, lat_resolution=50, lon_resolution=100): # pragma: no >>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> _ = pl.add_mesh(examples.planets.load_pluto()) >>> pl.show() @@ -872,7 +896,9 @@ def download_stars_sky_background(texture=False, load=True): # pragma: no cover >>> from pyvista import examples >>> import pyvista as pv >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_stars_sky_background(load=False) + >>> image_path = examples.planets.download_stars_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> pl.show() @@ -909,7 +935,9 @@ def download_milkyway_sky_background(texture=False, load=True): # pragma: no co >>> from pyvista import examples >>> import pyvista as pv >>> pl = pv.Plotter() - >>> image_path = examples.planets.download_milkyway_sky_background(load=False) + >>> image_path = examples.planets.download_milkyway_sky_background( + ... load=False + ... ) >>> pl.add_background_image(image_path) >>> pl.show() diff --git a/pyvista/plotting/_property.py b/pyvista/plotting/_property.py index 428a076c2e..acf1098b7c 100644 --- a/pyvista/plotting/_property.py +++ b/pyvista/plotting/_property.py @@ -634,7 +634,8 @@ def metallic(self) -> float: >>> import pyvista as pv >>> prop = pv.Property() - >>> prop.interpolation = 'pbr' # requires physically based rendering + >>> # requires physically based rendering + >>> prop.interpolation = 'pbr' >>> prop.metallic = 0.1 >>> prop.metallic 0.1 @@ -674,7 +675,8 @@ def roughness(self) -> float: >>> import pyvista as pv >>> prop = pv.Property() - >>> prop.interpolation = 'pbr' # requires physically based rendering + >>> # requires physically based rendering + >>> prop.interpolation = 'pbr' >>> prop.metallic = 0.5 # helps to visualize metallic >>> prop.roughness = 0.1 >>> prop.roughness @@ -1078,7 +1080,8 @@ def anisotropy(self): >>> import pyvista as pv >>> prop = pv.Property() - >>> prop.interpolation = 'pbr' # requires physically based rendering + >>> # requires physically based rendering + >>> prop.interpolation = 'pbr' >>> prop.anisotropy 0.1 @@ -1112,7 +1115,11 @@ def plot(self, **kwargs) -> None: -------- >>> import pyvista as pv >>> prop = pv.Property( - ... show_edges=True, color='brown', edge_color='blue', line_width=4, specular=1.0 + ... show_edges=True, + ... color='brown', + ... edge_color='blue', + ... line_width=4, + ... specular=1.0, ... ) >>> prop.plot() diff --git a/pyvista/plotting/actor.py b/pyvista/plotting/actor.py index ffba3f28c1..2bc0dd923d 100644 --- a/pyvista/plotting/actor.py +++ b/pyvista/plotting/actor.py @@ -363,7 +363,12 @@ def user_matrix(self) -> Optional[np.ndarray]: ... lighting=False, ... ) >>> arr = np.array( - ... [[0.707, -0.707, 0, 0], [0.707, 0.707, 0, 0], [0, 0, 1, 1.500001], [0, 0, 0, 2]] + ... [ + ... [0.707, -0.707, 0, 0], + ... [0.707, 0.707, 0, 0], + ... [0, 0, 1, 1.500001], + ... [0, 0, 0, 2], + ... ] ... ) >>> actor.user_matrix = arr >>> pl.show_axes() diff --git a/pyvista/plotting/camera.py b/pyvista/plotting/camera.py index f5b23c779c..8be883af4d 100644 --- a/pyvista/plotting/camera.py +++ b/pyvista/plotting/camera.py @@ -120,7 +120,9 @@ def from_paraview_pvcc(cls, filename: Union[str, Path]) -> Camera: -------- >>> import pyvista as pv >>> pl = pv.Plotter() - >>> pl.camera = pv.Camera.from_paraview_pvcc("camera.pvcc") # doctest:+SKIP + >>> pl.camera = pv.Camera.from_paraview_pvcc( + ... "camera.pvcc" + ... ) # doctest:+SKIP >>> pl.camera.position (1.0, 1.0, 1.0) """ diff --git a/pyvista/plotting/composite_mapper.py b/pyvista/plotting/composite_mapper.py index eb6fc804ce..79966f9de1 100644 --- a/pyvista/plotting/composite_mapper.py +++ b/pyvista/plotting/composite_mapper.py @@ -110,7 +110,9 @@ def color(self): to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].color = 'r' @@ -142,7 +144,9 @@ def visible(self) -> Optional[bool]: to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].visible = False @@ -180,7 +184,9 @@ def opacity(self) -> Optional[float]: to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[2].opacity = 0.5 @@ -213,7 +219,9 @@ def pickable(self) -> Optional[bool]: to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].pickable = True @@ -319,7 +327,9 @@ def reset_visibilities(self): to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].visible = False @@ -341,13 +351,18 @@ def reset_pickabilities(self): to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].pickable = True >>> mapper.block_attr[2].pickable = False >>> mapper.block_attr.reset_pickabilities() - >>> [mapper.block_attr[1].pickable, mapper.block_attr[2].pickable] + >>> [ + ... mapper.block_attr[1].pickable, + ... mapper.block_attr[2].pickable, + ... ] [None, None] >>> pl.close() @@ -362,7 +377,9 @@ def reset_colors(self): Set individual block colors and then reset them. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset, color='w') >>> mapper.block_attr[1].color = 'r' @@ -385,7 +402,9 @@ def reset_opacities(self): to our indexing to access the right block. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[2].opacity = 0.5 @@ -435,7 +454,9 @@ def get_block(self, index): and ``2`` to access the individual sub-blocks. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr.get_block(0) # doctest:+SKIP @@ -542,7 +563,9 @@ def dataset(self) -> 'pv.MultiBlock': Examples -------- >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.dataset # doctest:+SKIP @@ -582,7 +605,9 @@ def block_attr(self) -> CompositeAttributes: change the visibility and color of the blocks. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].color = 'b' @@ -606,10 +631,14 @@ def color_missing_with_nan(self) -> bool: Enable coloring missing values with NaN. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> dataset[0].point_data['data'] = dataset[0].points[:, 2] >>> pl = pv.Plotter() - >>> actor, mapper = pl.add_composite(dataset, scalars='data', show_scalar_bar=False) + >>> actor, mapper = pl.add_composite( + ... dataset, scalars='data', show_scalar_bar=False + ... ) >>> mapper.nan_color = 'r' >>> mapper.color_missing_with_nan = True >>> pl.show() @@ -631,7 +660,9 @@ def set_unique_colors(self): Set each block of the composite dataset to a unique color. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.set_unique_colors() diff --git a/pyvista/plotting/helpers.py b/pyvista/plotting/helpers.py index aec9012473..adc259e818 100644 --- a/pyvista/plotting/helpers.py +++ b/pyvista/plotting/helpers.py @@ -204,7 +204,9 @@ def plot( UniformGrid. Note ``volume=True`` is passed. >>> import numpy as np - >>> grid = pv.UniformGrid(dimensions=(32, 32, 32), spacing=(0.5, 0.5, 0.5)) + >>> grid = pv.UniformGrid( + ... dimensions=(32, 32, 32), spacing=(0.5, 0.5, 0.5) + ... ) >>> grid['data'] = np.linalg.norm(grid.center - grid.points, axis=1) >>> grid['data'] = np.abs(grid['data'] - grid['data'].max()) ** 3 >>> grid.plot(volume=True) diff --git a/pyvista/plotting/lights.py b/pyvista/plotting/lights.py index 54c285a75e..280a098b4c 100644 --- a/pyvista/plotting/lights.py +++ b/pyvista/plotting/lights.py @@ -115,7 +115,11 @@ class Light(vtkLight): 30, exponent of 20, and a visible actor. >>> light = pv.Light( - ... position=(0, 0, 3), show_actor=True, positional=True, cone_angle=30, exponent=20 + ... position=(0, 0, 3), + ... show_actor=True, + ... positional=True, + ... cone_angle=30, + ... exponent=20, ... ) """ @@ -496,8 +500,12 @@ def intensity(self): >>> import pyvista as pv >>> plotter = pv.Plotter(lighting='none') >>> _ = plotter.add_mesh(pv.Cube(), color='cyan') - >>> light_bright = pv.Light(position=(3, 0, 0), light_type='scene light') - >>> light_dim = pv.Light(position=(0, 3, 0), light_type='scene light') + >>> light_bright = pv.Light( + ... position=(3, 0, 0), light_type='scene light' + ... ) + >>> light_dim = pv.Light( + ... position=(0, 3, 0), light_type='scene light' + ... ) >>> light_dim.intensity = 0.5 >>> for light in light_bright, light_dim: ... light.positional = True @@ -628,8 +636,13 @@ def exponent(self): >>> import pyvista as pv >>> plotter = pv.Plotter(lighting='none') >>> for offset, exponent in zip([0, 1.5, 3], [1, 2, 5]): - ... _ = plotter.add_mesh(pv.Plane((offset, 0, 0)), color='white') - ... light = pv.Light(position=(offset, 0, 0.1), focal_point=(offset, 0, 0)) + ... _ = plotter.add_mesh( + ... pv.Plane((offset, 0, 0)), color='white' + ... ) + ... light = pv.Light( + ... position=(offset, 0, 0.1), + ... focal_point=(offset, 0, 0), + ... ) ... light.exponent = exponent ... light.positional = True ... light.cone_angle = 80 @@ -672,8 +685,12 @@ def cone_angle(self): >>> import pyvista as pv >>> plotter = pv.Plotter(lighting='none') >>> for offset, angle in zip([0, 1.5, 3], [70, 30, 20]): - ... _ = plotter.add_mesh(pv.Plane((offset, 0, 0)), color='white') - ... light = pv.Light(position=(offset, 0, 1), focal_point=(offset, 0, 0)) + ... _ = plotter.add_mesh( + ... pv.Plane((offset, 0, 0)), color='white' + ... ) + ... light = pv.Light( + ... position=(offset, 0, 1), focal_point=(offset, 0, 0) + ... ) ... light.exponent = 15 ... light.positional = True ... light.cone_angle = angle @@ -718,19 +735,22 @@ def attenuation_values(self): >>> import pyvista as pv >>> plotter = pv.Plotter(lighting='none') >>> for offset in 1, 2.5, 4: - ... _ = plotter.add_mesh(pv.Cube(center=(offset, offset, 0)), color='white') + ... _ = plotter.add_mesh( + ... pv.Cube(center=(offset, offset, 0)), color='white' + ... ) ... >>> colors = ['b', 'g'] >>> all_attenuations = [(0, 0.1, 0), (0, 0, 0.1)] >>> centers = [(0, 1, 0), (1, 0, 0)] - >>> for color, attenuation_constants, center in zip(colors, all_attenuations, centers): + >>> for color, attenuation_constants, center in zip( + ... colors, all_attenuations, centers + ... ): ... light = pv.Light(position=center, color=color) ... light.focal_point = (1 + center[0], 1 + center[1], 0) ... light.cone_angle = 90 ... light.positional = True ... light.attenuation_values = attenuation_constants ... plotter.add_light(light) - ... >>> plotter.view_vector((-1, -1, 1)) >>> plotter.show() @@ -1013,7 +1033,12 @@ def copy(self, deep=True): >>> import pyvista as pv >>> light = pv.Light() - >>> light.transform_matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] + >>> light.transform_matrix = [ + ... [1, 0, 0, 0], + ... [0, 1, 0, 0], + ... [0, 0, 1, 0], + ... [0, 0, 0, 1], + ... ] >>> shallow_copied = light.copy(deep=False) >>> shallow_copied == light True diff --git a/pyvista/plotting/lookup_table.py b/pyvista/plotting/lookup_table.py index ea74402cc9..97c0a46476 100644 --- a/pyvista/plotting/lookup_table.py +++ b/pyvista/plotting/lookup_table.py @@ -815,7 +815,10 @@ def apply_opacity(self, opacity, interpolate: bool = True, kind: str = 'quadrati >>> mesh = examples.load_random_hills() >>> lut = pv.LookupTable(cmap='viridis') >>> lut.apply_opacity([1.0, 0.4, 0.0, 0.4, 0.9]) - >>> lut.scalar_range = (mesh.active_scalars.min(), mesh.active_scalars.max()) + >>> lut.scalar_range = ( + ... mesh.active_scalars.min(), + ... mesh.active_scalars.max(), + ... ) >>> pl = pv.Plotter() >>> _ = pl.add_mesh(mesh, cmap=lut) >>> pl.show() diff --git a/pyvista/plotting/mapper.py b/pyvista/plotting/mapper.py index 83454bc59a..35eb4bbd9c 100644 --- a/pyvista/plotting/mapper.py +++ b/pyvista/plotting/mapper.py @@ -100,7 +100,9 @@ def scalar_range(self) -> tuple: set to its default value of ``(0.0, 1.0)``. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.scalar_range @@ -125,7 +127,9 @@ def lookup_table(self) -> 'pv.LookupTable': >>> import pyvista as pv >>> mesh = pv.Sphere() >>> pl = pv.Plotter() - >>> actor = pl.add_mesh(mesh, scalars=mesh.points[:, 2], cmap='bwr') + >>> actor = pl.add_mesh( + ... mesh, scalars=mesh.points[:, 2], cmap='bwr' + ... ) >>> actor.mapper.lookup_table # doctest:+SKIP LookupTable (0x7ff3be8d8c40) Table Range: (-0.5, 0.5) @@ -139,7 +143,9 @@ def lookup_table(self) -> 'pv.LookupTable': Return the lookup table of a composite dataset mapper. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.lookup_table # doctest:+SKIP @@ -191,7 +197,9 @@ def interpolate_before_map(self) -> bool: Disable interpolation before mapping. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> dataset[0].point_data['data'] = dataset[0].points[:, 2] >>> dataset[1].point_data['data'] = dataset[1].points[:, 2] >>> pl = pv.Plotter() @@ -261,11 +269,15 @@ def scalar_map_mode(self) -> str: active scalars to point data. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> dataset[0].point_data['data'] = dataset[0].points[:, 2] >>> dataset[1].point_data['data'] = dataset[1].points[:, 2] >>> pl = pv.Plotter() - >>> actor, mapper = pl.add_composite(dataset, scalars='data', show_scalar_bar=False) + >>> actor, mapper = pl.add_composite( + ... dataset, scalars='data', show_scalar_bar=False + ... ) >>> mapper.scalar_map_mode 'point' >>> pl.close() @@ -324,7 +336,9 @@ def scalar_visibility(self) -> bool: Show that scalar visibility is ``True``. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> dataset[0].point_data['data'] = dataset[0].points[:, 2] >>> dataset[1].point_data['data'] = dataset[1].points[:, 2] >>> pl = pv.Plotter() diff --git a/pyvista/plotting/picking.py b/pyvista/plotting/picking.py index 23c6ab5310..6db8ce2067 100644 --- a/pyvista/plotting/picking.py +++ b/pyvista/plotting/picking.py @@ -1145,7 +1145,9 @@ def enable_block_picking( color. >>> import pyvista as pv - >>> multiblock = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> multiblock = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(multiblock) >>> def turn_blue(index, dataset): diff --git a/pyvista/plotting/plotting.py b/pyvista/plotting/plotting.py index 67c518f7e8..8d094f9a8a 100644 --- a/pyvista/plotting/plotting.py +++ b/pyvista/plotting/plotting.py @@ -407,8 +407,12 @@ def import_gltf(self, filename, set_camera=True): -------- >>> import pyvista >>> from pyvista import examples - >>> helmet_file = examples.gltf.download_damaged_helmet() # doctest:+SKIP - >>> texture = examples.hdr.download_dikhololo_night() # doctest:+SKIP + >>> helmet_file = ( + ... examples.gltf.download_damaged_helmet() + ... ) # doctest:+SKIP + >>> texture = ( + ... examples.hdr.download_dikhololo_night() + ... ) # doctest:+SKIP >>> pl = pyvista.Plotter() # doctest:+SKIP >>> pl.import_gltf(helmet_file) # doctest:+SKIP >>> pl.set_environment_texture(cubemap) # doctest:+SKIP @@ -451,7 +455,9 @@ def import_vrml(self, filename): -------- >>> import pyvista >>> from pyvista import examples - >>> sextant_file = examples.vrml.download_sextant() # doctest:+SKIP + >>> sextant_file = ( + ... examples.vrml.download_sextant() + ... ) # doctest:+SKIP >>> pl = pyvista.Plotter() # doctest:+SKIP >>> pl.import_vrml(sextant_file) # doctest:+SKIP >>> pl.show() # doctest:+SKIP @@ -505,14 +511,20 @@ def export_html(self, filename, backend='pythreejs'): >>> from pyvista import examples >>> mesh = examples.load_uniform() >>> pl = pyvista.Plotter(shape=(1, 2)) - >>> _ = pl.add_mesh(mesh, scalars='Spatial Point Data', show_edges=True) + >>> _ = pl.add_mesh( + ... mesh, scalars='Spatial Point Data', show_edges=True + ... ) >>> pl.subplot(0, 1) - >>> _ = pl.add_mesh(mesh, scalars='Spatial Cell Data', show_edges=True) + >>> _ = pl.add_mesh( + ... mesh, scalars='Spatial Cell Data', show_edges=True + ... ) >>> pl.export_html('pyvista.html') # doctest:+SKIP Export as a vtk.js scene using the panel backend. - >>> pl.export_html('pyvista_panel.html', backend='panel') # doctest:+SKIP + >>> pl.export_html( + ... 'pyvista_panel.html', backend='panel' + ... ) # doctest:+SKIP """ if backend == 'pythreejs': @@ -608,7 +620,12 @@ def export_gltf(self, filename, inline_data=True, rotate_scene=True, save_normal >>> sphere = pyvista.Sphere(radius=0.02) >>> pc = pdata.glyph(scale=False, geom=sphere, orient=False) >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(pc, cmap='reds', smooth_shading=True, show_scalar_bar=False) + >>> _ = pl.add_mesh( + ... pc, + ... cmap='reds', + ... smooth_shading=True, + ... show_scalar_bar=False, + ... ) >>> pl.export_gltf('balls.gltf') # doctest:+SKIP >>> pl.show() @@ -1877,7 +1894,9 @@ def pickable_actors(self): >>> import pyvista as pv >>> pl = pv.Plotter() >>> sphere_actor = pl.add_mesh(pv.Sphere()) - >>> cube_actor = pl.add_mesh(pv.Cube(), pickable=False, style='wireframe') + >>> cube_actor = pl.add_mesh( + ... pv.Cube(), pickable=False, style='wireframe' + ... ) >>> len(pl.pickable_actors) 1 @@ -2495,7 +2514,9 @@ def add_composite( case of multiple nested composite datasets. >>> import pyvista as pv - >>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))]) + >>> dataset = pv.MultiBlock( + ... [pv.Cube(), pv.Sphere(center=(0, 0, 1))] + ... ) >>> pl = pv.Plotter() >>> actor, mapper = pl.add_composite(dataset) >>> mapper.block_attr[1].color = 'b' @@ -3081,7 +3102,9 @@ def add_mesh( >>> sphere = pv.Sphere() >>> sphere['Data'] = sphere.points[:, 2] >>> plotter = pv.Plotter() - >>> _ = plotter.add_mesh(sphere, scalar_bar_args={'title': 'Z Position'}) + >>> _ = plotter.add_mesh( + ... sphere, scalar_bar_args={'title': 'Z Position'} + ... ) >>> plotter.show() Plot using RGB on a single cell. Note that since the number of @@ -3090,13 +3113,31 @@ def add_mesh( >>> import pyvista as pv >>> import numpy as np - >>> vertices = np.array([[0, 0, 0], [1, 0, 0], [0.5, 0.667, 0], [0.5, 0.33, 0.667]]) - >>> faces = np.hstack([[3, 0, 1, 2], [3, 0, 3, 2], [3, 0, 1, 3], [3, 1, 2, 3]]) + >>> vertices = np.array( + ... [ + ... [0, 0, 0], + ... [1, 0, 0], + ... [0.5, 0.667, 0], + ... [0.5, 0.33, 0.667], + ... ] + ... ) + >>> faces = np.hstack( + ... [[3, 0, 1, 2], [3, 0, 3, 2], [3, 0, 1, 3], [3, 1, 2, 3]] + ... ) >>> mesh = pv.PolyData(vertices, faces) - >>> mesh.cell_data['colors'] = [[255, 255, 255], [0, 255, 0], [0, 0, 255], [255, 0, 0]] + >>> mesh.cell_data['colors'] = [ + ... [255, 255, 255], + ... [0, 255, 0], + ... [0, 0, 255], + ... [255, 0, 0], + ... ] >>> plotter = pv.Plotter() >>> _ = plotter.add_mesh( - ... mesh, scalars='colors', lighting=False, rgb=True, preference='cell' + ... mesh, + ... scalars='colors', + ... lighting=False, + ... rgb=True, + ... preference='cell', ... ) >>> plotter.camera_position = 'xy' >>> plotter.show() @@ -3108,7 +3149,11 @@ def add_mesh( >>> plotter = pv.Plotter() >>> _ = plotter.add_mesh( - ... mesh, scalars='colors', lighting=False, rgb=True, preference='point' + ... mesh, + ... scalars='colors', + ... lighting=False, + ... rgb=True, + ... preference='point', ... ) >>> plotter.camera_position = 'xy' >>> plotter.show() @@ -3116,7 +3161,11 @@ def add_mesh( Plot a plane with a constant color and vary its opacity by point. >>> plane = pv.Plane() - >>> plane.plot(color='b', opacity=np.linspace(0, 1, plane.n_points), show_edges=True) + >>> plane.plot( + ... color='b', + ... opacity=np.linspace(0, 1, plane.n_points), + ... show_edges=True, + ... ) Plot the points of a sphere with gaussian smoothing while coloring by z position. @@ -3776,7 +3825,9 @@ def add_volume( >>> grid = pv.UniformGrid(dimensions=(5, 20, 20)) >>> scalars = grid.points - (grid.origin) >>> scalars /= scalars.max() - >>> opacity = np.linalg.norm(grid.points - grid.center, axis=1).reshape(-1, 1) + >>> opacity = np.linalg.norm( + ... grid.points - grid.center, axis=1 + ... ).reshape(-1, 1) >>> opacity /= opacity.max() >>> scalars = np.hstack((scalars, opacity**3)) >>> scalars *= 255 @@ -4655,7 +4706,11 @@ def add_text( >>> import pyvista >>> pl = pyvista.Plotter() >>> actor = pl.add_text( - ... 'Sample Text', position='upper_right', color='blue', shadow=True, font_size=26 + ... 'Sample Text', + ... position='upper_right', + ... color='blue', + ... shadow=True, + ... font_size=26, ... ) >>> pl.show() @@ -4804,7 +4859,9 @@ def open_gif(self, filename, loop=0, fps=10, palettesize=256, subrectangles=Fals >>> import pyvista >>> pl = pyvista.Plotter() - >>> pl.open_gif('movie.gif', fps=8, palettesize=64) # doctest:+SKIP + >>> pl.open_gif( + ... 'movie.gif', fps=8, palettesize=64 + ... ) # doctest:+SKIP See :ref:`gif_movie_example` for a full example using this method. @@ -5127,7 +5184,9 @@ def add_point_labels( >>> import numpy as np >>> import pyvista >>> pl = pyvista.Plotter() - >>> points = np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 0.0], [2.0, 0.0, 0.0]]) + >>> points = np.array( + ... [[0.0, 0.0, 0.0], [1.0, 1.0, 0.0], [2.0, 0.0, 0.0]] + ... ) >>> labels = ['Point A', 'Point B', 'Point C'] >>> actor = pl.add_point_labels( ... points, @@ -5333,7 +5392,9 @@ def add_points(self, points, style='points', **kwargs): >>> import pyvista >>> points = np.random.random((10, 3)) >>> pl = pyvista.Plotter() - >>> actor = pl.add_points(points, render_points_as_spheres=True, point_size=100.0) + >>> actor = pl.add_points( + ... points, render_points_as_spheres=True, point_size=100.0 + ... ) >>> pl.show() Plot using the ``'points_gaussian'`` style @@ -5641,7 +5702,9 @@ def generate_orbital_path(self, factor=3.0, n_points=20, viewup=None, shift=0.0) >>> plotter = pyvista.Plotter() >>> _ = plotter.add_mesh(pyvista.Sphere()) >>> viewup = [0, 0, 1] - >>> orbit = plotter.generate_orbital_path(factor=2.0, n_points=50, shift=0.0, viewup=viewup) + >>> orbit = plotter.generate_orbital_path( + ... factor=2.0, n_points=50, shift=0.0, viewup=viewup + ... ) See :ref:`orbiting_example` for a full example using this method. @@ -5722,11 +5785,17 @@ def orbit_on_path( >>> from pyvista import examples >>> filename = os.path.join(mkdtemp(), 'orbit.gif') >>> plotter = pyvista.Plotter(window_size=[300, 300]) - >>> _ = plotter.add_mesh(examples.load_globe(), smooth_shading=True) + >>> _ = plotter.add_mesh( + ... examples.load_globe(), smooth_shading=True + ... ) >>> plotter.open_gif(filename) >>> viewup = [0, 0, 1] - >>> orbit = plotter.generate_orbital_path(factor=2.0, n_points=24, shift=0.0, viewup=viewup) - >>> plotter.orbit_on_path(orbit, write_frames=True, viewup=viewup, step=0.02) + >>> orbit = plotter.generate_orbital_path( + ... factor=2.0, n_points=24, shift=0.0, viewup=viewup + ... ) + >>> plotter.orbit_on_path( + ... orbit, write_frames=True, viewup=viewup, step=0.02 + ... ) See :ref:`orbiting_example` for a full example using this method. @@ -6119,7 +6188,9 @@ class Plotter(BasePlotter): >>> mesh = pv.Cube() >>> another_mesh = pv.Sphere() >>> pl = pv.Plotter() - >>> actor = pl.add_mesh(mesh, color='red', style='wireframe', line_width=4) + >>> actor = pl.add_mesh( + ... mesh, color='red', style='wireframe', line_width=4 + ... ) >>> actor = pl.add_mesh(another_mesh, color='blue') >>> pl.show() @@ -6414,7 +6485,9 @@ def fun(plotter): Return a ``pythreejs`` scene. - >>> pl.show(jupyter_backend='pythreejs', return_viewer=True) # doctest:+SKIP + >>> pl.show( + ... jupyter_backend='pythreejs', return_viewer=True + ... ) # doctest:+SKIP Obtain the camera position when using ``show``. @@ -6619,7 +6692,9 @@ def add_title(self, title, font_size=18, color=None, font=None, shadow=False): >>> import pyvista >>> pl = pyvista.Plotter() >>> pl.background_color = 'grey' - >>> actor = pl.add_title('Plot Title', font='courier', color='k', font_size=40) + >>> actor = pl.add_title( + ... 'Plot Title', font='courier', color='k', font_size=40 + ... ) >>> pl.show() """ diff --git a/pyvista/plotting/render_window_interactor.py b/pyvista/plotting/render_window_interactor.py index 06042469c1..4299a2a8e9 100644 --- a/pyvista/plotting/render_window_interactor.py +++ b/pyvista/plotting/render_window_interactor.py @@ -113,7 +113,9 @@ def add_observer(self, event, call): >>> import pyvista >>> pl = pyvista.Plotter() - >>> obs_enter = pl.iren.add_observer("EnterEvent", lambda *_: print('Enter!')) + >>> obs_enter = pl.iren.add_observer( + ... "EnterEvent", lambda *_: print('Enter!') + ... ) """ call = partial(try_callback, call) @@ -136,7 +138,9 @@ def remove_observer(self, observer): >>> import pyvista >>> pl = pyvista.Plotter() - >>> obs_enter = pl.iren.add_observer("EnterEvent", lambda *_: print('Enter!')) + >>> obs_enter = pl.iren.add_observer( + ... "EnterEvent", lambda *_: print('Enter!') + ... ) >>> pl.iren.remove_observer(obs_enter) """ @@ -159,8 +163,12 @@ def remove_observers(self, event=None): >>> import pyvista >>> pl = pyvista.Plotter() - >>> obs_enter = pl.iren.add_observer("EnterEvent", lambda *_: print('Enter!')) - >>> obs_leave = pl.iren.add_observer("LeaveEvent", lambda *_: print('Leave!')) + >>> obs_enter = pl.iren.add_observer( + ... "EnterEvent", lambda *_: print('Enter!') + ... ) + >>> obs_leave = pl.iren.add_observer( + ... "LeaveEvent", lambda *_: print('Leave!') + ... ) >>> pl.iren.remove_observers() """ @@ -632,7 +640,9 @@ def enable_terrain_style(self, mouse_wheel_zooms=False, shift_pans=False): >>> _ = plotter.add_mesh(pv.Cube(center=(1, 0, 0))) >>> _ = plotter.add_mesh(pv.Cube(center=(0, 1, 0))) >>> plotter.show_axes() - >>> plotter.enable_terrain_style(mouse_wheel_zooms=True, shift_pans=True) + >>> plotter.enable_terrain_style( + ... mouse_wheel_zooms=True, shift_pans=True + ... ) >>> plotter.show() # doctest:+SKIP """ diff --git a/pyvista/plotting/renderer.py b/pyvista/plotting/renderer.py index c30ff4c70f..fb98f4f823 100644 --- a/pyvista/plotting/renderer.py +++ b/pyvista/plotting/renderer.py @@ -2723,7 +2723,13 @@ def enable_depth_of_field(self, automatic_focal_distance=True): >>> for i in range(5): ... mesh = pv.Sphere(center=(-i * 4, 0, 0)) ... color = [0, 255 - i * 20, 30 + i * 50] - ... _ = pl.add_mesh(mesh, show_edges=False, pbr=True, metallic=1.0, color=color) + ... _ = pl.add_mesh( + ... mesh, + ... show_edges=False, + ... pbr=True, + ... metallic=1.0, + ... color=color, + ... ) ... >>> pl.camera.zoom(1.8) >>> pl.camera_position = [ @@ -2965,7 +2971,9 @@ def set_environment_texture(self, texture, is_srgb=False): >>> import pyvista as pv >>> pl = pv.Plotter(lighting=None) >>> cubemap = examples.download_sky_box_cube_map() - >>> _ = pl.add_mesh(pv.Sphere(), pbr=True, metallic=0.9, roughness=0.4) + >>> _ = pl.add_mesh( + ... pv.Sphere(), pbr=True, metallic=0.9, roughness=0.4 + ... ) >>> pl.set_environment_texture(cubemap) >>> pl.camera_position = 'xy' >>> pl.show() @@ -2991,7 +2999,9 @@ def remove_environment_texture(self): >>> import pyvista as pv >>> pl = pv.Plotter(lighting=None) >>> cubemap = examples.download_sky_box_cube_map() - >>> _ = pl.add_mesh(pv.Sphere(), pbr=True, metallic=0.9, roughness=0.4) + >>> _ = pl.add_mesh( + ... pv.Sphere(), pbr=True, metallic=0.9, roughness=0.4 + ... ) >>> pl.set_environment_texture(cubemap) >>> pl.remove_environment_texture() >>> pl.camera_position = 'xy' @@ -3212,7 +3222,9 @@ def add_legend( >>> sphere = pyvista.Sphere(center=(0, 0, 1)) >>> cube = pyvista.Cube() >>> plotter = pyvista.Plotter() - >>> _ = plotter.add_mesh(sphere, 'grey', smooth_shading=True, label='Sphere') + >>> _ = plotter.add_mesh( + ... sphere, 'grey', smooth_shading=True, label='Sphere' + ... ) >>> _ = plotter.add_mesh(cube, 'r', label='Cube') >>> _ = plotter.add_legend(bcolor='w', face=None) >>> plotter.show() diff --git a/pyvista/plotting/tools.py b/pyvista/plotting/tools.py index c73cd6fb87..3c1f010104 100644 --- a/pyvista/plotting/tools.py +++ b/pyvista/plotting/tools.py @@ -497,7 +497,10 @@ def opacity_transfer_function(mapping, n_colors, interpolate=True, kind='quadrat >>> # Fetch the `sigmoid` mapping between 0 and 255 >>> tf = pv.opacity_transfer_function("sigmoid", 256) >>> # Fetch the `geom_r` mapping between 0 and 1 - >>> tf = pv.opacity_transfer_function("geom_r", 256).astype(float) / 255.0 + >>> tf = ( + ... pv.opacity_transfer_function("geom_r", 256).astype(float) + ... / 255.0 + ... ) >>> # Interpolate a user defined opacity mapping >>> opacity = [0, 0.2, 0.9, 0.6, 0.3] >>> tf = pv.opacity_transfer_function(opacity, 256) diff --git a/pyvista/plotting/volume_property.py b/pyvista/plotting/volume_property.py index 8427712772..c7385594af 100644 --- a/pyvista/plotting/volume_property.py +++ b/pyvista/plotting/volume_property.py @@ -62,7 +62,9 @@ class VolumeProperty(_vtk.vtkVolumeProperty): >>> import pyvista as pv >>> noise = pv.perlin_noise(1, (1, 3, 5), (0, 0, 0)) - >>> grid = pv.sample_function(noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(40, 40, 40)) + >>> grid = pv.sample_function( + ... noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(40, 40, 40) + ... ) >>> grid['scalars'] -= grid['scalars'].min() >>> grid['scalars'] *= 255 / grid['scalars'].max() >>> pl = pv.Plotter() @@ -122,7 +124,9 @@ def apply_lookup_table(self, lookup_table: 'pv.LookupTable'): >>> import pyvista as pv >>> noise = pv.perlin_noise(1, (1, 3, 5), (0, 0, 0)) - >>> grid = pv.sample_function(noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(40, 40, 40)) + >>> grid = pv.sample_function( + ... noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(40, 40, 40) + ... ) >>> grid['scalars'] -= grid['scalars'].min() >>> grid['scalars'] *= 255 / grid['scalars'].max() >>> pl = pv.Plotter() diff --git a/pyvista/plotting/widgets.py b/pyvista/plotting/widgets.py index 47a9e22e10..a42d19cde1 100644 --- a/pyvista/plotting/widgets.py +++ b/pyvista/plotting/widgets.py @@ -1363,7 +1363,9 @@ def add_slider_widget( >>> pl = pv.Plotter() >>> def create_mesh(value): ... res = int(value) - ... sphere = pv.Sphere(phi_resolution=res, theta_resolution=res) + ... sphere = pv.Sphere( + ... phi_resolution=res, theta_resolution=res + ... ) ... pl.add_mesh(sphere, name="sphere", show_edges=True) ... >>> slider = pl.add_slider_widget( @@ -2309,7 +2311,9 @@ def add_camera_orientation_widget(self, animate=True, n_frames=20): >>> import pyvista >>> mesh = pyvista.Cube() >>> plotter = pyvista.Plotter() - >>> _ = plotter.add_mesh(mesh, scalars=range(6), show_scalar_bar=False) + >>> _ = plotter.add_mesh( + ... mesh, scalars=range(6), show_scalar_bar=False + ... ) >>> _ = plotter.add_camera_orientation_widget() >>> plotter.show() diff --git a/pyvista/themes.py b/pyvista/themes.py index 68dc8362e9..4b4e6a49a5 100644 --- a/pyvista/themes.py +++ b/pyvista/themes.py @@ -1163,25 +1163,26 @@ class _SliderConfig(_ThemeConfig): Set the classic slider configuration. >>> import pyvista as pv - >>> pv.global_theme.slider_styles.classic.slider_length = 0.02 - >>> pv.global_theme.slider_styles.classic.slider_width = 0.04 - >>> pv.global_theme.slider_styles.classic.slider_color = (0.5, 0.5, 0.5) - >>> pv.global_theme.slider_styles.classic.tube_width = 0.005 - >>> pv.global_theme.slider_styles.classic.tube_color = (1.0, 1.0, 1.0) - >>> pv.global_theme.slider_styles.classic.cap_opacity = 1 - >>> pv.global_theme.slider_styles.classic.cap_length = 0.01 - >>> pv.global_theme.slider_styles.classic.cap_width = 0.02 + >>> slider_styles = pv.global_theme.slider_styles + >>> slider_styles.classic.slider_length = 0.02 + >>> slider_styles.classic.slider_width = 0.04 + >>> slider_styles.classic.slider_color = (0.5, 0.5, 0.5) + >>> slider_styles.classic.tube_width = 0.005 + >>> slider_styles.classic.tube_color = (1.0, 1.0, 1.0) + >>> slider_styles.classic.cap_opacity = 1 + >>> slider_styles.classic.cap_length = 0.01 + >>> slider_styles.classic.cap_width = 0.02 Set the modern slider configuration. - >>> pv.global_theme.slider_styles.modern.slider_length = 0.02 - >>> pv.global_theme.slider_styles.modern.slider_width = 0.04 - >>> pv.global_theme.slider_styles.modern.slider_color = (0.43, 0.44, 0.45) - >>> pv.global_theme.slider_styles.modern.tube_width = 0.04 - >>> pv.global_theme.slider_styles.modern.tube_color = (0.69, 0.70, 0.709) - >>> pv.global_theme.slider_styles.modern.cap_opacity = 0 - >>> pv.global_theme.slider_styles.modern.cap_length = 0.01 - >>> pv.global_theme.slider_styles.modern.cap_width = 0.02 + >>> slider_styles.modern.slider_length = 0.02 + >>> slider_styles.modern.slider_width = 0.04 + >>> slider_styles.modern.slider_color = (0.43, 0.44, 0.45) + >>> slider_styles.modern.tube_width = 0.04 + >>> slider_styles.modern.tube_color = (0.69, 0.70, 0.709) + >>> slider_styles.modern.cap_opacity = 0 + >>> slider_styles.modern.cap_length = 0.01 + >>> slider_styles.modern.cap_width = 0.02 """ @@ -1603,7 +1604,9 @@ def interpolate_before_map(self) -> bool: Common display argument to make sure all else is constant - >>> dargs = dict(scalars='Elevation', cmap='rainbow', show_edges=True) + >>> dargs = dict( + ... scalars='Elevation', cmap='rainbow', show_edges=True + ... ) >>> p = pv.Plotter(shape=(1, 2)) >>> _ = p.add_mesh( @@ -1620,7 +1623,11 @@ def interpolate_before_map(self) -> bool: ... **dargs ... ) >>> p.link_views() - >>> p.camera_position = [(-1.67, -5.10, 2.06), (0.0, 0.0, 0.0), (0.00, 0.37, 0.93)] + >>> p.camera_position = [ + ... (-1.67, -5.10, 2.06), + ... (0.0, 0.0, 0.0), + ... (0.00, 0.37, 0.93), + ... ] >>> p.show() # doctest: +SKIP """ @@ -1873,7 +1880,10 @@ def camera(self): Set both the position and view of the camera. >>> import pyvista as pv - >>> pv.global_theme.camera = {'position': [1, 1, 1], 'viewup': [0, 0, 1]} + >>> pv.global_theme.camera = { + ... 'position': [1, 1, 1], + ... 'viewup': [0, 0, 1], + ... } Set the default position of the camera. diff --git a/pyvista/utilities/common.py b/pyvista/utilities/common.py index 6810a16a6d..4f99f9f708 100644 --- a/pyvista/utilities/common.py +++ b/pyvista/utilities/common.py @@ -158,8 +158,12 @@ def sample_function( >>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (1, 1, 1), (0, 0, 0)) - >>> grid = pyvista.sample_function(noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(60, 20, 20)) - >>> grid.plot(cmap='gist_earth_r', show_scalar_bar=False, show_edges=True) + >>> grid = pyvista.sample_function( + ... noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(60, 20, 20) + ... ) + >>> grid.plot( + ... cmap='gist_earth_r', show_scalar_bar=False, show_edges=True + ... ) Sample Perlin noise in 2D and plot it. diff --git a/pyvista/utilities/geometric_objects.py b/pyvista/utilities/geometric_objects.py index 33e3eb95c0..4fa94de5d5 100644 --- a/pyvista/utilities/geometric_objects.py +++ b/pyvista/utilities/geometric_objects.py @@ -99,7 +99,9 @@ def Cylinder( -------- >>> import pyvista >>> import numpy as np - >>> cylinder = pyvista.Cylinder(center=[1, 2, 3], direction=[1, 1, 1], radius=1, height=2) + >>> cylinder = pyvista.Cylinder( + ... center=[1, 2, 3], direction=[1, 1, 1], radius=1, height=2 + ... ) >>> cylinder.plot(show_edges=True, line_width=5, cpos='xy') """ cylinderSource = _vtk.vtkCylinderSource() @@ -488,7 +490,9 @@ def MultipleLines(points=[[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]]): Create a multiple lines between ``(0, 0, 0)``, ``(1, 1, 1)`` and ``(0, 0, 1)``. >>> import pyvista - >>> mesh = pyvista.MultipleLines(points=[[0, 0, 0], [1, 1, 1], [0, 0, 1]]) + >>> mesh = pyvista.MultipleLines( + ... points=[[0, 0, 0], [1, 1, 1], [0, 0, 1]] + ... ) >>> mesh.plot(color='k', line_width=10) """ points, _ = _coerce_pointslike_arg(points) @@ -1107,7 +1111,9 @@ def CircularArcFromNormal(center, resolution=100, normal=None, polar=None, angle >>> import pyvista >>> normal = [0, 0, 1] >>> polar = [-1, 0, 0] - >>> arc = pyvista.CircularArcFromNormal([0, 0, 0], normal=normal, polar=polar) + >>> arc = pyvista.CircularArcFromNormal( + ... [0, 0, 0], normal=normal, polar=polar + ... ) >>> pl = pyvista.Plotter() >>> _ = pl.add_mesh(arc, color='k', line_width=10) >>> _ = pl.show_bounds(location='all', font_size=30, use_2d=True) @@ -1418,7 +1424,9 @@ def Superquadric( -------- >>> import pyvista >>> superquadric = pyvista.Superquadric( - ... scale=(3.0, 1.0, 0.5), phi_roundness=0.1, theta_roundness=0.5 + ... scale=(3.0, 1.0, 0.5), + ... phi_roundness=0.1, + ... theta_roundness=0.5, ... ) >>> superquadric.plot(show_edges=True) diff --git a/pyvista/utilities/helpers.py b/pyvista/utilities/helpers.py index 79f727e1b4..795e14b932 100644 --- a/pyvista/utilities/helpers.py +++ b/pyvista/utilities/helpers.py @@ -678,7 +678,16 @@ def make_tri_mesh(points, faces): ... ] ... ) >>> faces = np.array( - ... [[0, 1, 4], [4, 7, 6], [2, 5, 4], [4, 5, 8], [0, 4, 3], [3, 4, 6], [1, 2, 4], [4, 8, 7]] + ... [ + ... [0, 1, 4], + ... [4, 7, 6], + ... [2, 5, 4], + ... [4, 5, 8], + ... [0, 4, 3], + ... [3, 4, 6], + ... [1, 2, 4], + ... [4, 8, 7], + ... ] ... ) >>> tri_mesh = pyvista.make_tri_mesh(points, faces) >>> tri_mesh.plot(show_edges=True, line_width=5) @@ -723,7 +732,9 @@ def vector_poly_data(orig, vec): >>> points = np.vstack((x.ravel(), y.ravel(), np.zeros(x.size))).T >>> u = x / np.sqrt(x**2 + y**2) >>> v = y / np.sqrt(x**2 + y**2) - >>> vectors = np.vstack((u.ravel() ** 3, v.ravel() ** 3, np.zeros(u.size))).T + >>> vectors = np.vstack( + ... (u.ravel() ** 3, v.ravel() ** 3, np.zeros(u.size)) + ... ).T >>> pdata = pyvista.vector_poly_data(points, vectors) >>> pdata.point_data.keys() ['vectors', 'mag'] @@ -1144,13 +1155,22 @@ def fit_plane_to_points(points, return_meta=False): >>> import numpy as np >>> cloud = np.random.random((10, 3)) >>> cloud[:, 2] *= 0.1 - >>> plane, center, normal = pyvista.fit_plane_to_points(cloud, return_meta=True) + >>> plane, center, normal = pyvista.fit_plane_to_points( + ... cloud, return_meta=True + ... ) Plot the fitted plane. >>> pl = pyvista.Plotter() - >>> _ = pl.add_mesh(plane, color='tan', style='wireframe', line_width=4) - >>> _ = pl.add_points(cloud, render_points_as_spheres=True, color='r', point_size=30) + >>> _ = pl.add_mesh( + ... plane, color='tan', style='wireframe', line_width=4 + ... ) + >>> _ = pl.add_points( + ... cloud, + ... render_points_as_spheres=True, + ... color='r', + ... point_size=30, + ... ) >>> pl.show() """ @@ -1526,7 +1546,9 @@ def cubemap(path='', prefix='', ext='.jpg'): Load a skybox given a directory, prefix, and file extension. >>> import pyvista - >>> skybox = pyvista.cubemap('my_directory', 'skybox', '.jpeg') # doctest:+SKIP + >>> skybox = pyvista.cubemap( + ... 'my_directory', 'skybox', '.jpeg' + ... ) # doctest:+SKIP """ sets = ['posx', 'negx', 'posy', 'negy', 'posz', 'negz'] diff --git a/pyvista/utilities/parametric_objects.py b/pyvista/utilities/parametric_objects.py index 54353033f1..7315c526d1 100644 --- a/pyvista/utilities/parametric_objects.py +++ b/pyvista/utilities/parametric_objects.py @@ -42,7 +42,11 @@ def Spline(points, n_points=None): >>> y = r * np.cos(theta) >>> points = np.column_stack((x, y, z)) >>> spline = pv.Spline(points, 1000) - >>> spline.plot(render_lines_as_tubes=True, line_width=10, show_scalar_bar=False) + >>> spline.plot( + ... render_lines_as_tubes=True, + ... line_width=10, + ... show_scalar_bar=False, + ... ) """ spline_function = _vtk.vtkParametricSpline() diff --git a/pyvista/utilities/reader.py b/pyvista/utilities/reader.py index 136186f5e5..605ed90113 100644 --- a/pyvista/utilities/reader.py +++ b/pyvista/utilities/reader.py @@ -153,10 +153,10 @@ def get_reader(filename, force_ext=None): >>> filename.split("/")[-1] # omit the path 'Human.vtp' >>> reader = pyvista.get_reader(filename) - >>> reader # doctest: +ELLIPSIS + >>> reader XMLPolyDataReader('.../Human.vtp') >>> mesh = reader.read() - >>> mesh # doctest: +ELLIPSIS + >>> mesh PolyData ... >>> mesh.plot(color='tan') @@ -384,7 +384,7 @@ class PointCellDataSelection: >>> filename.split("/")[-1] # omit the path 'foam_case_0_0_0_0.case' >>> reader = pyvista.get_reader(filename) - >>> reader # doctest: +ELLIPSIS + >>> reader EnSightReader('.../foam_case_0_0_0_0.case') >>> reader.cell_array_names ['v2', 'nut', 'k', 'nuTilda', 'p', 'omega', 'f', 'epsilon', 'U'] @@ -663,7 +663,11 @@ class XMLRectilinearGridReader(BaseReader, PointCellDataSelection): >>> reader = pyvista.get_reader(filename) >>> mesh = reader.read() >>> sliced_mesh = mesh.slice('y') - >>> sliced_mesh.plot(scalars='Void Volume Fraction', cpos='xz', show_scalar_bar=False) + >>> sliced_mesh.plot( + ... scalars='Void Volume Fraction', + ... cpos='xz', + ... show_scalar_bar=False, + ... ) """ @@ -688,7 +692,12 @@ class XMLUnstructuredGridReader(BaseReader, PointCellDataSelection): 'notch_disp.vtu' >>> reader = pyvista.get_reader(filename) >>> mesh = reader.read() - >>> mesh.plot(scalars="Nodal Displacement", component=0, cpos='xy', show_scalar_bar=False) + >>> mesh.plot( + ... scalars="Nodal Displacement", + ... component=0, + ... cpos='xy', + ... show_scalar_bar=False, + ... ) """ @@ -714,7 +723,9 @@ class XMLPolyDataReader(BaseReader, PointCellDataSelection): >>> reader = pyvista.get_reader(filename) >>> mesh = reader.read() >>> mesh.plot( - ... cpos=((12, 3.5, -4.5), (4.5, 1.6, 0), (0, 1, 0.3)), clim=[0, 100], show_scalar_bar=False + ... cpos=((12, 3.5, -4.5), (4.5, 1.6, 0), (0, 1, 0.3)), + ... clim=[0, 100], + ... show_scalar_bar=False, ... ) """ @@ -1881,7 +1892,7 @@ class PVDReader(BaseReader, TimeReader): >>> filename.split("/")[-1] # omit the path 'wavy.pvd' >>> reader = pyvista.get_reader(filename) - >>> reader.time_values # doctest: +ELLIPSIS + >>> reader.time_values [0.0, 1.0, 2.0, 3.0, ... 12.0, 13.0, 14.0] >>> reader.set_active_time_point(5) >>> reader.active_time_value diff --git a/pyvista/utilities/transformations.py b/pyvista/utilities/transformations.py index 6fb41fc187..585df6518a 100644 --- a/pyvista/utilities/transformations.py +++ b/pyvista/utilities/transformations.py @@ -73,7 +73,9 @@ def axis_angle_rotation(axis, angle, point=None, deg=True): ... [0, 0, 1], ... ] ... ) - >>> rotated = transformations.apply_transformation_to_points(trans, corners) + >>> rotated = transformations.apply_transformation_to_points( + ... trans, corners + ... ) >>> np.allclose(rotated, corners[[1, 2, 0], :]) True @@ -180,7 +182,9 @@ def reflection(normal, point=None): ... [-1, 1, 1], ... ] ... ) - >>> mirrored = transformations.apply_transformation_to_points(trans, verts) + >>> mirrored = transformations.apply_transformation_to_points( + ... trans, verts + ... ) >>> np.allclose(mirrored, verts[[np.r_[4:8, 0:4]], :]) True @@ -244,11 +248,10 @@ def apply_transformation_to_points(transformation, points, inplace=False): >>> points_orig = points.copy() >>> scale_factor = 2 >>> tf = scale_factor * np.eye(4) - >>> tf[ - ... 3, - ... 3, - ... ] = 1 - >>> pyvista.transformations.apply_transformation_to_points(tf, points, inplace=True) + >>> tf[3, 3] = 1 + >>> pyvista.transformations.apply_transformation_to_points( + ... tf, points, inplace=True + ... ) >>> assert np.all(np.isclose(points, scale_factor * points_orig)) """ diff --git a/tests/check_doctest_names.py b/tests/check_doctest_names.py index f7826a51b0..53823ae9cb 100644 --- a/tests/check_doctest_names.py +++ b/tests/check_doctest_names.py @@ -14,8 +14,12 @@ >>> import vtk >>> import pyvista >>> offset = np.array([0, 9]) - >>> cells = np.array([8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]) - >>> cell_type = np.array([vtk.VTK_HEXAHEDRON, vtk.VTK_HEXAHEDRON], np.int8) + >>> cell0_ids = [8, 0, 1, 2, 3, 4, 5, 6, 7] + >>> cell1_ids = [8, 8, 9, 10, 11, 12, 13, 14, 15] + >>> cells = np.hstack((cell0_ids, cell1_ids)) + >>> cell_type = np.array( + ... [vtk.VTK_HEXAHEDRON, vtk.VTK_HEXAHEDRON], np.int8 + ... ) there will be a ``NameError`` when the code block is copied into Python because the ``np`` name is undefined. However, pytest and sphinx test