Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_multi_block_io(extension, binary, tmpdir):
filename = str(tmpdir.mkdir("tmpdir").join('tmp.%s' % extension))
multi = pyvista.MultiBlock()
# Add examples
multi.append(ex.load_ant())
multi.append(ex.load_sphere())
multi.append(ex.load_uniform())
multi.append(ex.load_airplane())
multi.append(ex.load_globe())
# Now check everything
assert multi.n_blocks == 5
# Save it out
multi.save(filename, binary)
foo = pyvista.MultiBlock(filename)
assert foo.n_blocks == multi.n_blocks
foo = pyvista.read(filename)
assert foo.n_blocks == multi.n_blocks
def test_read_uniform_grid_from_file():
grid = pyvista.read(examples.uniformfile)
assert grid.n_cells == 729
assert grid.n_points == 1000
assert grid.bounds == [0.0,9.0, 0.0,9.0, 0.0,9.0]
assert grid.n_arrays == 2
assert grid.dimensions == [10, 10, 10]
def test_read_rectilinear_grid_from_file():
grid = pyvista.read(examples.rectfile)
assert grid.n_cells == 16146
assert grid.n_points == 18144
assert grid.bounds == [-350.0,1350.0, -400.0,1350.0, -850.0,0.0]
assert grid.n_arrays == 1
def test_vertice_cells_on_read(tmpdir):
point_cloud = pyvista.PolyData(np.random.rand(100, 3))
filename = str(tmpdir.mkdir("tmpdir").join('foo.ply'))
point_cloud.save(filename)
recovered = pyvista.read(filename)
assert recovered.n_cells == 100
recovered = pyvista.PolyData(filename)
assert recovered.n_cells == 100
def test_save_uniform(extension, binary, tmpdir):
filename = str(tmpdir.mkdir("tmpdir").join('tmp.%s' % extension))
ogrid = examples.load_uniform()
ogrid.save(filename, binary)
grid = pyvista.UniformGrid(filename)
assert grid.n_cells == ogrid.n_cells
assert grid.origin == ogrid.origin
assert grid.spacing == ogrid.spacing
assert grid.dimensions == ogrid.dimensions
grid = pyvista.read(filename)
assert isinstance(grid, pyvista.UniformGrid)
assert grid.n_cells == ogrid.n_cells
assert grid.origin == ogrid.origin
assert grid.spacing == ogrid.spacing
assert grid.dimensions == ogrid.dimensions
def download_lobster():
"""Scan of a lobster from
https://www.laserdesign.com/lobster-scan-data
"""
url = "http://3dgallery.gks.com/2016/lobster/index2.php"
filename, _ = _retrieve_file(url, 'lobster.ply')
return pyvista.read(filename)
def download_blood_vessels():
"""data representing the bifurcation of blood vessels."""
local_path, _ = _download_file('pvtu_blood_vessels/blood_vessels.zip')
filename = os.path.join(local_path, 'T0000000500.pvtu')
mesh = pyvista.read(filename)
mesh.set_active_vectors('velocity')
return mesh
# of files.
#
# Let's inspect where this downloaded our dataset:
path = os.path.join(pv.EXAMPLES_PATH, "blood_vessels")
print(os.listdir(path))
###############################################################################
print(os.listdir(os.path.join(path, "T0000000500")))
###############################################################################
# Note that a ``.pvtu`` file is available along side a directory. This
# directory contains all the parallel files or pieces that make the whole mesh.
# We can simply read the ``.pvtu`` file and VTK will handle putting the mesh
# together.
filename = os.path.join(path, "T0000000500.pvtu")
mesh = pv.read(filename)
print(mesh)
###############################################################################
# Plot the pieced together mesh
mesh.plot(scalars="node_value", categories=True)
###############################################################################
mesh.plot(scalars="density")
def download_face2():
"""Scan of a man's face from
https://www.laserdesign.com/sample-files/mans-face/
"""
url = "http://3dgallery.gks.com/2012/face/"
filename, _ = _retrieve_file(url, 'man_face.stl')
return pyvista.read(filename)