code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def is_valid_propname(propname):
r"""
Checks if ``propname`` is a valid OpenPNM propname, i.e. starts with
'pore.' or 'throat.'
Parameters
----------
propname : str
Property name to check whether it's a valid OpenPNM propname.
Returns
-------
bool
Whether or not ``p... |
Checks if ``propname`` is a valid OpenPNM propname, i.e. starts with
'pore.' or 'throat.'
Parameters
----------
propname : str
Property name to check whether it's a valid OpenPNM propname.
Returns
-------
bool
Whether or not ``propname`` is a valid name
| is_valid_propname | python | PMEAL/OpenPNM | openpnm/utils/_misc.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_misc.py | MIT |
def nbr_to_str(nbr, t_precision=12):
r"""
Converts a scalar into a string in scientific (exponential) notation
without the decimal point.
Parameters
----------
nbr : scalar
The number to be converted into a scalar.
t_precision : integer
The time precision (number of decimal ... |
Converts a scalar into a string in scientific (exponential) notation
without the decimal point.
Parameters
----------
nbr : scalar
The number to be converted into a scalar.
t_precision : integer
The time precision (number of decimal places). Default value is 12.
Returns
... | nbr_to_str | python | PMEAL/OpenPNM | openpnm/utils/_misc.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_misc.py | MIT |
def copy(self, name=None):
r"""
Creates a deep copy of the current project
A deep copy means that new, unique versions of all the objects are
created but with identical data and properties.
Parameters
----------
name : str
The name to give to the new... |
Creates a deep copy of the current project
A deep copy means that new, unique versions of all the objects are
created but with identical data and properties.
Parameters
----------
name : str
The name to give to the new project. If not supplied, a name
... | copy | python | PMEAL/OpenPNM | openpnm/utils/_project.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_project.py | MIT |
def _get_locations(self, label):
r"""
Find locations indicated by the given label regardless of which object
it is defined on
Parameters
----------
label : str
The label whose locations are sought, such as 'pore.left'
Returns
-------
... |
Find locations indicated by the given label regardless of which object
it is defined on
Parameters
----------
label : str
The label whose locations are sought, such as 'pore.left'
Returns
-------
locations : ndarray
A boolean arr... | _get_locations | python | PMEAL/OpenPNM | openpnm/utils/_project.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_project.py | MIT |
def _create_console_handles(self, project):
r"""
Adds all objects in the given project to the console as variables
with handle names taken from each object's name.
"""
import __main__
for item in project:
__main__.__dict__[item.name] = item |
Adds all objects in the given project to the console as variables
with handle names taken from each object's name.
| _create_console_handles | python | PMEAL/OpenPNM | openpnm/utils/_workspace.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_workspace.py | MIT |
def save_workspace(self, filename=None):
r"""
Saves all projects in the current workspace as a single file
Parameters
----------
filename : str
The filename to use when saving. If not provided, the present
date and time are used.
Notes
--... |
Saves all projects in the current workspace as a single file
Parameters
----------
filename : str
The filename to use when saving. If not provided, the present
date and time are used.
Notes
-----
The file is actually zip archive containi... | save_workspace | python | PMEAL/OpenPNM | openpnm/utils/_workspace.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_workspace.py | MIT |
def load_workspace(self, filename):
r"""
Loads project(s) from a saved workspace into current workspace
Parameters
----------
filename : str or Path
The filename containing the saved workspace
"""
from zipfile import ZipFile
with ZipFile(file... |
Loads project(s) from a saved workspace into current workspace
Parameters
----------
filename : str or Path
The filename containing the saved workspace
| load_workspace | python | PMEAL/OpenPNM | openpnm/utils/_workspace.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_workspace.py | MIT |
def save_project(self, project, filename=None):
r"""
Saves given Project to a ``pnm`` file
This will include all of associated objects, including algorithms.
Parameters
----------
project : Project
The project to save.
filename : str, optional
... |
Saves given Project to a ``pnm`` file
This will include all of associated objects, including algorithms.
Parameters
----------
project : Project
The project to save.
filename : str, optional
If no filename is given, the given project name is use... | save_project | python | PMEAL/OpenPNM | openpnm/utils/_workspace.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_workspace.py | MIT |
def load_project(self, filename):
r"""
Loads a Project from the specified 'pnm' file
The loaded project is added to the Workspace. This will *not* delete
any existing Projects in the Workspace and will rename any Projects
being loaded if necessary.
Parameters
--... |
Loads a Project from the specified 'pnm' file
The loaded project is added to the Workspace. This will *not* delete
any existing Projects in the Workspace and will rename any Projects
being loaded if necessary.
Parameters
----------
filename : str or Path
... | load_project | python | PMEAL/OpenPNM | openpnm/utils/_workspace.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_workspace.py | MIT |
def new_project(self, name=None):
r"""
Creates a new empty Project object
Parameters
----------
name : str, optional
The unique name to give to the project. If none is given, one
will be automatically generated (e.g. 'proj_01`)
Returns
--... |
Creates a new empty Project object
Parameters
----------
name : str, optional
The unique name to give to the project. If none is given, one
will be automatically generated (e.g. 'proj_01`)
Returns
-------
proj : list
An empty... | new_project | python | PMEAL/OpenPNM | openpnm/utils/_workspace.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/utils/_workspace.py | MIT |
def draw_conduit(network, throat):
"""Draws a subset of a network given throat numbers."""
pn = network
P1, P2 = find_connected_sites(g=pn, bonds=throat)
new_net = Network(coords=pn.coords[[P1, P2], :], conns=np.atleast_2d([0, 1]))
new_net.regenerate_models()
new_net['pore.diameter'] = pn['pore.... | Draws a subset of a network given throat numbers. | draw_conduit | python | PMEAL/OpenPNM | openpnm/visualization/_conduit_visualizer.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_conduit_visualizer.py | MIT |
def plot_connections(network,
throats=None,
ax=None,
size_by=None,
color_by=None,
label_by=None,
cmap='jet',
color='b',
alpha=1.0,
... |
Produce a 3D plot of the network topology.
This shows how throats connect for quick visualization without having
to export data to veiw in Paraview.
Parameters
----------
network : Network
The network whose topological connections to plot
throats : array_like (optional)
Th... | plot_connections | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def plot_coordinates(network,
pores=None,
ax=None,
size_by=None,
color_by=None,
label_by=None,
cmap='jet',
color='r',
alpha=1.0,
ma... |
Produce a 3D plot showing specified pore coordinates as markers.
Parameters
----------
network : Network
The network whose topological connections to plot.
pores : array_like (optional)
The list of pores to plot if only a sub-sample is desired. This is
useful for inspecting... | plot_coordinates | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def plot_networkx(network,
plot_throats=True,
labels=None,
colors=None,
scale=1,
ax=None,
alpha=1.0): # pragma: no cover
r"""
Creates a pretty 2D plot for 2D OpenPNM networks.
Parameters
-------... |
Creates a pretty 2D plot for 2D OpenPNM networks.
Parameters
----------
network : Network
plot_throats : bool, optional
Plots throats as well as pores, if True.
labels : list, optional
List of OpenPNM labels
colors : list, optional
List of corresponding colors to th... | plot_networkx | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def plot_tutorial(network,
pore_labels=None,
throat_labels=None,
font_size=12,
line_width=2,
node_color='b',
edge_color='r',
node_size=500): # pragma: no cover
r"""
Generate a network p... |
Generate a network plot suitable for tutorials and explanations.
Parameters
----------
network : Network
The network to plot, should be 2D, since the z-coordinate will be
ignored.
pore_labels : array_like
A list of values to use for labeling the pores. If not provided then ... | plot_tutorial | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def plot_notebook(network,
node_color=0,
edge_color=0,
node_size=1,
node_scale=20,
edge_scale=5,
colormap='viridis'):
r"""
Visualize a network in 3D using Plotly.
The pores and throats are scaled and... |
Visualize a network in 3D using Plotly.
The pores and throats are scaled and colored by their properties.
The final figure can be rotated and zoomed.
Parameters
----------
network : Network
The network to visualize
node_color : ndarray
An array of values used for coloring ... | plot_notebook | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def _generate_voxel_image(network, pore_shape, throat_shape, max_dim=200):
r"""
Generates a 3d numpy array from an OpenPNM network
Parameters
----------
network : OpenPNM Network
Network from which voxel image is to be generated
pore_shape : str
Shape of pores in the network, va... |
Generates a 3d numpy array from an OpenPNM network
Parameters
----------
network : OpenPNM Network
Network from which voxel image is to be generated
pore_shape : str
Shape of pores in the network, valid choices are "sphere", "cube"
throat_shape : str
Shape of throats in... | _generate_voxel_image | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def generate_voxel_image(network, pore_shape="sphere", throat_shape="cylinder",
max_dim=None, rtol=0.1):
r"""
Generate a voxel image from a Network
Parameters
----------
network : OpenPNM Network
Network from which voxel image is to be generated
pore_shape : str... |
Generate a voxel image from a Network
Parameters
----------
network : OpenPNM Network
Network from which voxel image is to be generated
pore_shape : str
Shape of pores in the network, valid choices are "sphere", "cube"
throat_shape : str
Shape of throats in the network,... | generate_voxel_image | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def plot_vispy(
network,
pore_color=None,
pore_size=None,
throat_color=None,
throat_size=None,
bgcolor='grey',
):
r"""
Creates a pretty network plot using VisPy.
Parameters
----------
network
"""
try:
from vispy import scene
except ModuleNotFoundError:
... |
Creates a pretty network plot using VisPy.
Parameters
----------
network
| plot_vispy | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def set_mpl_style(): # pragma: no cover
r"""
Prettifies matplotlib's output by adjusting fonts, markersize etc.
"""
sfont = 12
mfont = 12
lfont = 12
image_props = {'interpolation': 'none',
'cmap': 'viridis'}
line_props = {'linewidth': 2,
'markersize... |
Prettifies matplotlib's output by adjusting fonts, markersize etc.
| set_mpl_style | python | PMEAL/OpenPNM | openpnm/visualization/_plottools.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/visualization/_plottools.py | MIT |
def info(network):
r"""
Prints an overview of the network dictionary
"""
d = _pdict(network)
d._key = 'Attribute'
d._value = 'Description'
print(d) |
Prints an overview of the network dictionary
| info | python | PMEAL/OpenPNM | openpnm/_skgraph/__init__.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/__init__.py | MIT |
def bcc(shape, spacing=1, mode='kdtree', node_prefix='node', edge_prefix='edge'):
r"""
Generate a body-centered cubic lattice
Parameters
----------
shape : array_like
The number of corner sites in each direction. A cubic lattice of
this size is created and then 'body-centered' node... |
Generate a body-centered cubic lattice
Parameters
----------
shape : array_like
The number of corner sites in each direction. A cubic lattice of
this size is created and then 'body-centered' nodes are added
afterward.
spacing : array_like or float
The size of a uni... | bcc | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_bcc.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_bcc.py | MIT |
def cubic(shape, spacing=1, connectivity=6, node_prefix='node', edge_prefix='edge'):
r"""
Generate a simple cubic lattice
Parameters
----------
shape : array_like
The number of unit cells in each direction. A unit cell has 1 vertex
at its center.
spacing : array_like or float
... |
Generate a simple cubic lattice
Parameters
----------
shape : array_like
The number of unit cells in each direction. A unit cell has 1 vertex
at its center.
spacing : array_like or float
The size of a unit cell in each direction. If an scalar is given it is
applied... | cubic | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_cubic.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_cubic.py | MIT |
def delaunay(
points,
shape=[1, 1, 1],
reflect=False,
f=1,
trim=True,
node_prefix='node',
edge_prefix='edge',
):
r"""
Generate a network based on Delaunay triangulation of random points
Parameters
----------
points : array_like or int
Can either be an N-by-3 arra... |
Generate a network based on Delaunay triangulation of random points
Parameters
----------
points : array_like or int
Can either be an N-by-3 array of point coordinates which will be used,
or a scalar value indicating the number of points to generate
shape : array_like
Indic... | delaunay | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_delaunay.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_delaunay.py | MIT |
def fcc(shape, spacing=1, mode='kdtree', node_prefix='node', edge_prefix='edge'):
r"""
Generate a face-centered cubic lattice
Parameters
----------
shape : array_like
The number of corner sites in each direction. A sipmle cubic lattice
is created then the 'face-sites' are added afte... |
Generate a face-centered cubic lattice
Parameters
----------
shape : array_like
The number of corner sites in each direction. A sipmle cubic lattice
is created then the 'face-sites' are added afterwards.
spacing : array_like or float
The size of a unit cell in each directio... | fcc | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_fcc.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_fcc.py | MIT |
def cubic_template(template, spacing=1, connectivity=6,
node_prefix='node', edge_prefix='edge'):
r"""
Generate a simple cubic lattice matching the shape of the provided tempate
Parameters
----------
templte : ndarray
Each ``True`` value will be treated as a vertex while a... |
Generate a simple cubic lattice matching the shape of the provided tempate
Parameters
----------
templte : ndarray
Each ``True`` value will be treated as a vertex while all others
will be trimmed.
spacing : array_like or float
The size of a unit cell in each direction. If a... | cubic_template | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_template.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_template.py | MIT |
def voronoi(
points,
shape=[1, 1, 1],
trim=True,
reflect=False,
f=1,
relaxation=0,
node_prefix='node',
edge_prefix='edge',
):
r"""
Generate a network based on a Voronoi tessellation of base points
Parameters
----------
points : array_like or int
Can either be... |
Generate a network based on a Voronoi tessellation of base points
Parameters
----------
points : array_like or int
Can either be an N-by-3 array of point coordinates which will be used
directly, or a scalar indicating the number of points to generate.
shape : array_like
The... | voronoi | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_voronoi.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_voronoi.py | MIT |
def voronoi_delaunay_dual(
points,
shape,
trim=True,
reflect=True,
f=1,
relaxation=0,
node_prefix='node',
edge_prefix='edge',
return_tri=False,
):
r"""
Generate a dual Voronoi-Delaunay network from given base points
Parameters
----------
points : array_like or sc... |
Generate a dual Voronoi-Delaunay network from given base points
Parameters
----------
points : array_like or scalar
The points to be tessellated. If a scalar is given a set of points
of that size is generated inside the given ``shape``.
shape : array_like
The size of the d... | voronoi_delaunay_dual | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/_voronoi_delaunay_dual.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/_voronoi_delaunay_dual.py | MIT |
def lloyd_relaxation(vor, mode='rigorous'):
r"""
Computes the center of mass for each polyhedra in a Voronoi tessellaion
Parameters
----------
vor : Scipy Voronoi object
The object returned by ``scipy.spatial.Voronoi``
mode : str
Options are:
=========== ===============... |
Computes the center of mass for each polyhedra in a Voronoi tessellaion
Parameters
----------
vor : Scipy Voronoi object
The object returned by ``scipy.spatial.Voronoi``
mode : str
Options are:
=========== ================================================================
... | lloyd_relaxation | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def get_centroid(pts, mode='rigorous'):
r"""
Finds the centroid of a given set of points
Parameters
----------
pts : ndarray
The points in 2D or 3D
mode : str
Options are:
=========== ================================================================
mode d... |
Finds the centroid of a given set of points
Parameters
----------
pts : ndarray
The points in 2D or 3D
mode : str
Options are:
=========== ================================================================
mode description
=========== =================... | get_centroid | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def parse_points(shape, points, reflect=False, f=1):
r"""
Converts given points argument to consistent format
Parameters
----------
shape : array_like
The shape of the domain
points : int or array_like
If a scalar value then this indicates the number of points to generate. If
... |
Converts given points argument to consistent format
Parameters
----------
shape : array_like
The shape of the domain
points : int or array_like
If a scalar value then this indicates the number of points to generate. If
an array, then these points are used directly.
refl... | parse_points | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def add_all_label(network):
r"""
Add 'node.all' and 'edge.all' to network dictionary
Parameters
----------
network : dict
The network dictionary, containing 'node.coords' and 'edge.conns'
Returns
-------
network : dict
The supplied dictionary with the 'all' labels added... |
Add 'node.all' and 'edge.all' to network dictionary
Parameters
----------
network : dict
The network dictionary, containing 'node.coords' and 'edge.conns'
Returns
-------
network : dict
The supplied dictionary with the 'all' labels added
Notes
-----
This funct... | add_all_label | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def label_faces_cubic(network, rtol=0.0):
r"""
Label the nodes sitting on the faces of the domain assuming the domain
is cubic
Parameters
----------
network : dict
The network dictionary contain 'node.coords'
rtol : float
Controls how closely a node must be to a face to be c... |
Label the nodes sitting on the faces of the domain assuming the domain
is cubic
Parameters
----------
network : dict
The network dictionary contain 'node.coords'
rtol : float
Controls how closely a node must be to a face to be counted. It is
computed relative to the fra... | label_faces_cubic | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def _template_sphere_disc(dim, outer_radius, inner_radius):
r"""
This private method generates an image array of a sphere/shell-disc/ring.
It is useful for passing to Cubic networks as a ``template`` to make
networks with desired shapes.
Parameters
----------
dim : int
Network dime... |
This private method generates an image array of a sphere/shell-disc/ring.
It is useful for passing to Cubic networks as a ``template`` to make
networks with desired shapes.
Parameters
----------
dim : int
Network dimension
outer_radius : int
Number of the nodes in the oute... | _template_sphere_disc | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def template_sphere_shell(r_outer, r_inner=0):
r"""
This method generates an image array of a sphere-shell.
It is useful for passing to Cubic networks as a ``template`` to make
spherical shaped networks.
Parameters
----------
r_outer : int
Number of nodes in the outer radius of the... |
This method generates an image array of a sphere-shell.
It is useful for passing to Cubic networks as a ``template`` to make
spherical shaped networks.
Parameters
----------
r_outer : int
Number of nodes in the outer radius of the sphere
r_inner : int, optional
Number of n... | template_sphere_shell | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def template_cylinder_annulus(z, r_outer, r_inner=0):
r"""
This method generates an image array of a disc-ring.
It is useful for passing to Cubic networks as a ``template`` to make
circular-shaped 2D networks.
Parameters
----------
z : int
The height of the cylinder. A value of 0 w... |
This method generates an image array of a disc-ring.
It is useful for passing to Cubic networks as a ``template`` to make
circular-shaped 2D networks.
Parameters
----------
z : int
The height of the cylinder. A value of 0 will result in a circle
r_outer : int
Number of nod... | template_cylinder_annulus | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def reflect_base_points(points, domain_size, f=1):
r"""
Relects a set of points about the faces of a given domain
Parameters
----------
points : ndarray
The coordinates of the points to be reflected. The points should be
in the coordinate system corresponding to the the domain.
... |
Relects a set of points about the faces of a given domain
Parameters
----------
points : ndarray
The coordinates of the points to be reflected. The points should be
in the coordinate system corresponding to the the domain.
domain_size : list or array
Controls the size and ... | reflect_base_points | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def generate_base_points(num_points, domain_size, reflect=True, f=1):
r"""
Generates a set of randomly distributed points in rectilinear coordinates
for use in spatial tessellations
The points can be distributed in spherical, cylindrical, or rectilinear
domains, as well as 2D and 3D (disks and squa... |
Generates a set of randomly distributed points in rectilinear coordinates
for use in spatial tessellations
The points can be distributed in spherical, cylindrical, or rectilinear
domains, as well as 2D and 3D (disks and squares)
Parameters
----------
num_points : scalar
The number... | generate_base_points | python | PMEAL/OpenPNM | openpnm/_skgraph/generators/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/generators/tools/_funcs.py | MIT |
def join(g1, g2, L_max=0.99):
r"""
Joins two networks together topologically including new connections
Parameters
----------
g1 : dictionary
A dictionary containing 'node.coords' and 'edge.conns'.
g2 : dictionary
A dictionary containing 'node.coords' and 'edge.conns'
L_max :... |
Joins two networks together topologically including new connections
Parameters
----------
g1 : dictionary
A dictionary containing 'node.coords' and 'edge.conns'.
g2 : dictionary
A dictionary containing 'node.coords' and 'edge.conns'
L_max : float
The distance between no... | join | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_binary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_binary.py | MIT |
def add_nodes(network, new_coords):
r"""
Given a list of node coordinates, add them to the network
Parameters
----------
network : dict
A dictionary containing the node and edge attributes as ndarrays
new_coords : ndarray
The N-by-3 array of coordinates of the new nodes
Ret... |
Given a list of node coordinates, add them to the network
Parameters
----------
network : dict
A dictionary containing the node and edge attributes as ndarrays
new_coords : ndarray
The N-by-3 array of coordinates of the new nodes
Returns
-------
network : dict
... | add_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_unary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_unary.py | MIT |
def add_edges(network, new_conns):
r"""
Given a list of edge connections, add them to the network
Parameters
----------
network : dict
A dictionary containing the node and edge attributes as ndarrays
new_conns : ndarray
The N-by-2 array of connections betwween existing nodes
... |
Given a list of edge connections, add them to the network
Parameters
----------
network : dict
A dictionary containing the node and edge attributes as ndarrays
new_conns : ndarray
The N-by-2 array of connections betwween existing nodes
Returns
-------
network : dict
... | add_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_unary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_unary.py | MIT |
def trim_edges(network, inds):
r"""
Removes given edges from a graph or network
Parameters
----------
network : dictionary
A dictionary containing coords, conns and other attributes
inds : array_like
The edge indices to be trimmed in the form of a 1D list or boolean
mask... |
Removes given edges from a graph or network
Parameters
----------
network : dictionary
A dictionary containing coords, conns and other attributes
inds : array_like
The edge indices to be trimmed in the form of a 1D list or boolean
mask with ``True`` values indicating indice... | trim_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_unary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_unary.py | MIT |
def trim_nodes(network, inds):
r"""
Removes given nodes and any connected edges from a graph or network
Parameters
----------
network : dict
A dictionary containing coords, conns and other attributes
inds : array_like
The node indices to be trimmed in the form of a 1D list or bo... |
Removes given nodes and any connected edges from a graph or network
Parameters
----------
network : dict
A dictionary containing coords, conns and other attributes
inds : array_like
The node indices to be trimmed in the form of a 1D list or boolean
mask with ``True`` values... | trim_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_unary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_unary.py | MIT |
def drop_nodes_from_am(am, inds):
r"""
Update adjacency matrix after dropping nodes
Parameters
----------
am : scipy.sparse matrix
The adjacency matrix of the network in COO format.
inds : array_like
A list of which nodes indices to drop. Can either be integer indices
o... |
Update adjacency matrix after dropping nodes
Parameters
----------
am : scipy.sparse matrix
The adjacency matrix of the network in COO format.
inds : array_like
A list of which nodes indices to drop. Can either be integer indices
or a boolean mask with ``True`` indicating ... | drop_nodes_from_am | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_unary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_unary.py | MIT |
def split_edges(network):
r"""
Inserts an new node between each existing node and joins with new edges
Parameters
----------
network : dict
The dictionary containing the network connections and coordinates
Returns
-------
result : tuple
A tuple containing ``new_conns`` ... |
Inserts an new node between each existing node and joins with new edges
Parameters
----------
network : dict
The dictionary containing the network connections and coordinates
Returns
-------
result : tuple
A tuple containing ``new_conns`` and optionally ``new_coords`` if
... | split_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/operations/_unary.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/operations/_unary.py | MIT |
def find_complementary_edges(network, inds, asmask=False):
r"""
Finds the complementary edges to a given set of inputs
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list of edge indices for which the complement is sought
asmask : bool
... |
Finds the complementary edges to a given set of inputs
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list of edge indices for which the complement is sought
asmask : bool
If set to ``True`` the result is returned as a boolean mask of th... | find_complementary_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_complementary_nodes(network, inds, asmask=False):
r"""
Finds the complementary nodes to a given set of inputs
Parameters
----------
network : dict
The network dictionary
inds : array_like (optional)
A list of indices for which the complement is sought
asmask : bool
... |
Finds the complementary nodes to a given set of inputs
Parameters
----------
network : dict
The network dictionary
inds : array_like (optional)
A list of indices for which the complement is sought
asmask : bool
If set to ``True`` the result is returned as a boolean mask... | find_complementary_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_connected_nodes(network, inds, flatten=True, logic='or'):
r"""
Finds which nodes are connected to a given set of edges
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list of edges indices whose connected nodes are sought
flatten : bo... |
Finds which nodes are connected to a given set of edges
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list of edges indices whose connected nodes are sought
flatten : bool (default is ``True``)
Indicates whether the returned result is a... | find_connected_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_neighbor_edges(network, inds, flatten=True, logic='or'):
r"""
Finds all edges that are connected to the given input nodes
Parameters
----------
network : dict
The network dictionary
inds : array_like (optional)
A list of node indices whose neighbor edges are sought
... |
Finds all edges that are connected to the given input nodes
Parameters
----------
network : dict
The network dictionary
inds : array_like (optional)
A list of node indices whose neighbor edges are sought
flatten : bool (default is ``True``)
Indicates whether the returne... | find_neighbor_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_neighbor_nodes(network, inds, flatten=True, include_input=False,
logic='or'):
r"""
Finds all nodes that are directly connected to the input nodes
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list of node indices... |
Finds all nodes that are directly connected to the input nodes
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list of node indices whose neighbors are sought
flatten : bool
If ``True`` (default) the returned result is a compressed array ... | find_neighbor_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_connecting_edges(inds, network=None, am=None):
r"""
Finds the edge that connects each pair of given nodes
Parameters
----------
inds : array_like
A 2-column vector containing pairs of node indices
network : dict, optional
The network dictionary. Either this or ``am`` m... |
Finds the edge that connects each pair of given nodes
Parameters
----------
inds : array_like
A 2-column vector containing pairs of node indices
network : dict, optional
The network dictionary. Either this or ``am`` must be provided
am : scipy.sparse matrix, optional
T... | find_connecting_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_common_edges(network, inds_1, inds_2):
"""
Finds edges shared between two sets of nodes
Parameters
----------
network : dict
The network dictionary
inds_1 : array_like
A list of indices defining the first set of nodes
inds_2 : array_like
A list of indices de... |
Finds edges shared between two sets of nodes
Parameters
----------
network : dict
The network dictionary
inds_1 : array_like
A list of indices defining the first set of nodes
inds_2 : array_like
A list of indices defining the second set of nodes
Returns
-------... | find_common_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def filter_by_z(network, inds, z=1):
r"""
Filters a list of nodes to those with a given number of neighbors
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list containing the indices of the nodes to be filtered
z : int
The coordinatio... |
Filters a list of nodes to those with a given number of neighbors
Parameters
----------
network : dict
The network dictionary
inds : array_like
A list containing the indices of the nodes to be filtered
z : int
The coordination number by which to filter
Returns
... | filter_by_z | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_coordination(network, nodes=None):
r"""
Find the coordination number of nodes
Parameters
----------
network : dict
The network dictionary
nodes : array_like, optional
The nodes for which coordination is sought. If not provided then
coordination for *all* nodes i... |
Find the coordination number of nodes
Parameters
----------
network : dict
The network dictionary
nodes : array_like, optional
The nodes for which coordination is sought. If not provided then
coordination for *all* nodes is returned
Returns
-------
z : ndarray
... | find_coordination | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def find_path(network, pairs, weights=None):
r"""
Find the shortest path between pairs of nodes
Parameters
----------
network : dict
The network dictionary
pairs : array_like
An N x 2 array containing N pairs of nodes between which the shortest
path is sought
weights... |
Find the shortest path between pairs of nodes
Parameters
----------
network : dict
The network dictionary
pairs : array_like
An N x 2 array containing N pairs of nodes between which the shortest
path is sought
weights : ndarray, optional
The edge weights to use ... | find_path | python | PMEAL/OpenPNM | openpnm/_skgraph/queries/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/queries/_funcs.py | MIT |
def bond_percolation(conns, occupied_bonds):
r"""
Assigns cluster numbers to sites and bonds acccording to a bond
percolation process, given a list of occupied bonds.
Parameters
----------
conns : array_like
An N x 2 array connections. Any sites connected to an occupied bond
wil... |
Assigns cluster numbers to sites and bonds acccording to a bond
percolation process, given a list of occupied bonds.
Parameters
----------
conns : array_like
An N x 2 array connections. Any sites connected to an occupied bond
will also be considered occupied and given the same clus... | bond_percolation | python | PMEAL/OpenPNM | openpnm/_skgraph/simulations/_percolation.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/simulations/_percolation.py | MIT |
def site_percolation(conns, occupied_sites):
r"""
Assigns cluster numbers to sites and bonds acccording to a site
percolation process, given a list of occupied sites.
Parameters
----------
conns : array_like
An N x 2 array connections. If two connected sites are both occupied
th... |
Assigns cluster numbers to sites and bonds acccording to a site
percolation process, given a list of occupied sites.
Parameters
----------
conns : array_like
An N x 2 array connections. If two connected sites are both occupied
they are part of the same cluster, as is the bond conne... | site_percolation | python | PMEAL/OpenPNM | openpnm/_skgraph/simulations/_percolation.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/simulations/_percolation.py | MIT |
def trim_disconnected_clusters(b_labels, s_labels, inlets):
r"""
Computes actual node and edge occupancy based on connectivity to the given
inlets
Parameters
----------
b_labels : ndarray
An array of cluster labels assigned to each bond. -1 indicates
unoccupied
s_labels : n... |
Computes actual node and edge occupancy based on connectivity to the given
inlets
Parameters
----------
b_labels : ndarray
An array of cluster labels assigned to each bond. -1 indicates
unoccupied
s_labels : ndarray
An array of cluster labels assigned to each site. -1 ... | trim_disconnected_clusters | python | PMEAL/OpenPNM | openpnm/_skgraph/simulations/_percolation.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/simulations/_percolation.py | MIT |
def remove_isolated_clusters(labels, inlets):
r"""
Finds cluster labels not attached to the inlets, and sets them to
unoccupied (-1)
Parameters
----------
labels : tuple of node and edge labels
This information is provided by the ``site_percolation`` or
``bond_percolation`` func... |
Finds cluster labels not attached to the inlets, and sets them to
unoccupied (-1)
Parameters
----------
labels : tuple of node and edge labels
This information is provided by the ``site_percolation`` or
``bond_percolation`` functions
inlets : array_like
A list of which ... | remove_isolated_clusters | python | PMEAL/OpenPNM | openpnm/_skgraph/simulations/_percolation.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/simulations/_percolation.py | MIT |
def ispercolating(conns, occupied, inlets, outlets):
r"""
Determines if a percolating cluster exists in the network spanning
the given inlet and outlet nodes
Parameters
----------
conns : array_like
An N x 2 array connections. If two connected sites are both occupied
they are pa... |
Determines if a percolating cluster exists in the network spanning
the given inlet and outlet nodes
Parameters
----------
conns : array_like
An N x 2 array connections. If two connected sites are both occupied
they are part of the same cluster, as is the bond connecting them.
o... | ispercolating | python | PMEAL/OpenPNM | openpnm/_skgraph/simulations/_percolation.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/simulations/_percolation.py | MIT |
def rotate_coords(coords, a=0, b=0, c=0, R=None):
r"""
Rotates coordinates a given amount about each axis
Parameters
----------
coords : ndarray
The site coordinates to be transformed. ``coords`` must be in 3D,
but a 2D network can be represented by putting 0's in the missing
... |
Rotates coordinates a given amount about each axis
Parameters
----------
coords : ndarray
The site coordinates to be transformed. ``coords`` must be in 3D,
but a 2D network can be represented by putting 0's in the missing
dimension.
a, b, c : scalar, optional
The a... | rotate_coords | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def shear_coords(coords, ay=0, az=0, bx=0, bz=0, cx=0, cy=0, S=None):
r"""
Shears the coordinates a given amount about along axis
Parameters
----------
coords : ndarray
The coordinates to be transformed
ay : scalar
The factor by which to shear along the x-axis as a function of y... |
Shears the coordinates a given amount about along axis
Parameters
----------
coords : ndarray
The coordinates to be transformed
ay : scalar
The factor by which to shear along the x-axis as a function of y
az : scalar
The factor by which to shear along the x-axis as a fu... | shear_coords | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def generate_points_on_sphere(n=100, r=1):
r"""
Generates approximately equispaced points on the surface of a sphere
Parameters
----------
n : int or [int, int]
If a single ``int`` is provided then this number of points will be
generated using the Fibonacci method to make them appro... |
Generates approximately equispaced points on the surface of a sphere
Parameters
----------
n : int or [int, int]
If a single ``int`` is provided then this number of points will be
generated using the Fibonacci method to make them approximately
equally spaced. If a list of 2 ``... | generate_points_on_sphere | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def generate_points_in_disk(n=100, r=1):
r"""
Generates approximately equally spaced points inside a disk
Parameters
----------
n : int
The number of points to generate
r : scalar
The radius of the disk
Returns
-------
coords : ndarray
An ``n by 2`` array of... |
Generates approximately equally spaced points inside a disk
Parameters
----------
n : int
The number of points to generate
r : scalar
The radius of the disk
Returns
-------
coords : ndarray
An ``n by 2`` array of x, y points (in cartesian coordinates)
| generate_points_in_disk | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def generate_points_on_circle(n=100, r=1):
r"""
Generates equally spaced points on a circle
Parameters
----------
n : int
The number of points to generate
r : scalar
The radius of the disk
Returns
-------
coords : ndarray
An ``n by 2`` array of x, y points (... |
Generates equally spaced points on a circle
Parameters
----------
n : int
The number of points to generate
r : scalar
The radius of the disk
Returns
-------
coords : ndarray
An ``n by 2`` array of x, y points (in cartesian coordinates)
| generate_points_on_circle | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def cart2sph(x, y, z):
r"""
Converts cartesian to spherical coordinates
Parameters
----------
x, y, z : array_like
Arrays containing the x, y and z coordinates to be converted
Returns
-------
r, theta, phi : ndarrays
Three arrays containing the spherical coordinate of e... |
Converts cartesian to spherical coordinates
Parameters
----------
x, y, z : array_like
Arrays containing the x, y and z coordinates to be converted
Returns
-------
r, theta, phi : ndarrays
Three arrays containing the spherical coordinate of each given point
Notes
... | cart2sph | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def sph2cart(r, theta, phi):
r"""
Converts spherical to cartesian coordinates
Parameters
----------
r, theta, phi : array_like
Arrays containing the r, theta and phi coordinates to be transformed
Returns
-------
x, y, z : ndarrays
Three arrays containing the cartesian c... |
Converts spherical to cartesian coordinates
Parameters
----------
r, theta, phi : array_like
Arrays containing the r, theta and phi coordinates to be transformed
Returns
-------
x, y, z : ndarrays
Three arrays containing the cartesian coordinates of the given points
N... | sph2cart | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_coords_transforms.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_coords_transforms.py | MIT |
def get_edge_prefix(network):
r"""
Determines the prefix used for edge arrays from ``<edge_prefix>.conns``
Parameters
----------
network : dict
The network dictionary
Returns
-------
edge_prefix : str
The value of ``<edge_prefix>`` used in ``g``. This is found by
... |
Determines the prefix used for edge arrays from ``<edge_prefix>.conns``
Parameters
----------
network : dict
The network dictionary
Returns
-------
edge_prefix : str
The value of ``<edge_prefix>`` used in ``g``. This is found by
scanning ``g.keys()`` until an arra... | get_edge_prefix | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def get_node_prefix(network):
r"""
Determines the prefix used for node arrays from ``<edge_prefix>.coords``
Parameters
----------
network : dict
The network dictionary
Returns
-------
node_prefix : str
The value of ``<node_prefix>`` used in ``g``. This is found by
... |
Determines the prefix used for node arrays from ``<edge_prefix>.coords``
Parameters
----------
network : dict
The network dictionary
Returns
-------
node_prefix : str
The value of ``<node_prefix>`` used in ``g``. This is found by
scanning ``g.keys()`` until an arr... | get_node_prefix | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def change_prefix(network, old_prefix, new_prefix):
r"""
Changes the prefix used when generating the graph
Parameters
----------
network : dict
The network graph
old_prefix : str
The current prefix to change, can either be a node or an edge prefix
new_prefix : str
Th... |
Changes the prefix used when generating the graph
Parameters
----------
network : dict
The network graph
old_prefix : str
The current prefix to change, can either be a node or an edge prefix
new_prefix : str
The prefix to use instead
Returns
-------
network... | change_prefix | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def isoutside(network, shape, rtol=0.0):
r"""
Identifies sites that lie outside the specified shape
Parameters
----------
network : dict
The network dictionary. For convenience it is also permissible to just
supply an N-by-D array of coordinates.
shape : array_like
The s... |
Identifies sites that lie outside the specified shape
Parameters
----------
network : dict
The network dictionary. For convenience it is also permissible to just
supply an N-by-D array of coordinates.
shape : array_like
The shape of the domain beyond which points are consid... | isoutside | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def dimensionality(network, cache=True):
r"""
Checks the dimensionality of the network
Parameters
----------
network : dict
The network dictionary
cache : boolean, optional (default is True)
If ``False`` then the dimensionality is recalculated even if it has
already been... |
Checks the dimensionality of the network
Parameters
----------
network : dict
The network dictionary
cache : boolean, optional (default is True)
If ``False`` then the dimensionality is recalculated even if it has
already been calculated and stored in the graph dictionary.
... | dimensionality | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def find_surface_nodes_cubic(network):
r"""
Identifies nodes on the outer surface of the domain assuming a cubic domain
to save time
Parameters
----------
network : dict
The graph dictionary
Returns
-------
mask : ndarray
A boolean array of ``True`` values indicatin... |
Identifies nodes on the outer surface of the domain assuming a cubic domain
to save time
Parameters
----------
network : dict
The graph dictionary
Returns
-------
mask : ndarray
A boolean array of ``True`` values indicating which nodes were found
on the surface... | find_surface_nodes_cubic | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def find_coincident_nodes(network):
r"""
Finds nodes with identical coordinates
Parameters
----------
network : dict
The network dictionary
Returns
-------
duplicates : list of ndarrays
A list with each sublist indicating the indices of nodes that share
a common... |
Finds nodes with identical coordinates
Parameters
----------
network : dict
The network dictionary
Returns
-------
duplicates : list of ndarrays
A list with each sublist indicating the indices of nodes that share
a common set of coordinates
Notes
-----
... | find_coincident_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def find_surface_nodes(network):
r"""
Identifies nodes on the outer surface of the domain using a Delaunay
tessellation
Parameters
----------
network : dict
The network dictionary
Returns
-------
mask : ndarray
A boolean array of ``True`` values indicating which nod... |
Identifies nodes on the outer surface of the domain using a Delaunay
tessellation
Parameters
----------
network : dict
The network dictionary
Returns
-------
mask : ndarray
A boolean array of ``True`` values indicating which nodes were found
on the surfaces.
... | find_surface_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def internode_distance(network, inds_1=None, inds_2=None):
r"""
Find the distance between all nodes on set 1 to each node in set 2
Parameters
----------
network : dict
The network dictionary
inds_1 : array_like
A list containing the indices of the first set of nodes
inds_2 :... |
Find the distance between all nodes on set 1 to each node in set 2
Parameters
----------
network : dict
The network dictionary
inds_1 : array_like
A list containing the indices of the first set of nodes
inds_2 : array_Like
A list containing the indices of the first set ... | internode_distance | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def iscoplanar(network):
r"""
Determines if specified nodes are coplanar with each other
Parameters
----------
network : dict
The graph dictionary
Returns
-------
flag : bool
A boolean value of whether given nodes are coplanar (``True``) or
not (``False``)
... |
Determines if specified nodes are coplanar with each other
Parameters
----------
network : dict
The graph dictionary
Returns
-------
flag : bool
A boolean value of whether given nodes are coplanar (``True``) or
not (``False``)
| iscoplanar | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def is_fully_connected(network, inds=None):
r"""
Checks whether graph is fully connected, i.e. not clustered
Parameters
----------
network : dict
The network dictionary
inds : array_like (optional)
The indices of boundary nodes (i.e. inlets/outlets). If this is given
the... |
Checks whether graph is fully connected, i.e. not clustered
Parameters
----------
network : dict
The network dictionary
inds : array_like (optional)
The indices of boundary nodes (i.e. inlets/outlets). If this is given
the multiple sample spanning clusters will count as ful... | is_fully_connected | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def get_cubic_spacing(network):
r"""
Determine spacing of a cubic network
Parameters
----------
network : dict
The network dictionary
Returns
-------
spacing : ndarray
An array containing the spacing between nodes in each direction
"""
node_prefix = get_node_pr... |
Determine spacing of a cubic network
Parameters
----------
network : dict
The network dictionary
Returns
-------
spacing : ndarray
An array containing the spacing between nodes in each direction
| get_cubic_spacing | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def get_cubic_shape(network):
r"""
Determine shape of a cubic network
Parameters
----------
network : dict
The network dictionary
Returns
-------
shape : ndarray
An array containing the shape of the network each direction
"""
node_prefix = get_node_prefix(netwo... |
Determine shape of a cubic network
Parameters
----------
network : dict
The network dictionary
Returns
-------
shape : ndarray
An array containing the shape of the network each direction
| get_cubic_shape | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def get_domain_area(network, inlets=None, outlets=None):
r"""
Determine the cross sectional area relative to the inlets/outlets.
Parameters
----------
network : dict
The network dictionary
inlets : array_like
The indices of the inlets
outlets : array_Like
The indices... |
Determine the cross sectional area relative to the inlets/outlets.
Parameters
----------
network : dict
The network dictionary
inlets : array_like
The indices of the inlets
outlets : array_Like
The indices of the outlets
Returns
-------
area : scalar
... | get_domain_area | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def get_domain_length(network, inlets=None, outlets=None):
r"""
Determine the domain length relative to the inlets/outlets.
Parameters
----------
network : dict
The network dictionary
inlets : array_like
The pore indices of the inlets.
outlets : array_Like
The pore i... |
Determine the domain length relative to the inlets/outlets.
Parameters
----------
network : dict
The network dictionary
inlets : array_like
The pore indices of the inlets.
outlets : array_Like
The pore indices of the outlets.
Returns
-------
area : scalar
... | get_domain_length | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def tri_to_am(tri):
r"""
Given a Delaunay triangulation object from Scipy's ``spatial`` module,
converts to a sparse adjacency matrix network representation.
Parameters
----------
tri : Delaunay Triangulation Object
This object is produced by ``scipy.spatial.Delaunay``
Returns
... |
Given a Delaunay triangulation object from Scipy's ``spatial`` module,
converts to a sparse adjacency matrix network representation.
Parameters
----------
tri : Delaunay Triangulation Object
This object is produced by ``scipy.spatial.Delaunay``
Returns
-------
A sparse adjacen... | tri_to_am | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def vor_to_am(vor):
r"""
Given a Voronoi tessellation object from Scipy's ``spatial`` module,
converts to a sparse adjacency matrix network representation in COO format.
Parameters
----------
vor : Voronoi Tessellation object
This object is produced by ``scipy.spatial.Voronoi``
Ret... |
Given a Voronoi tessellation object from Scipy's ``spatial`` module,
converts to a sparse adjacency matrix network representation in COO format.
Parameters
----------
vor : Voronoi Tessellation object
This object is produced by ``scipy.spatial.Voronoi``
Returns
-------
A spars... | vor_to_am | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def dict_to_am(network, weights=None):
r"""
Convert a graph dictionary into a ``scipy.sparse`` adjacency matrix in
COO format
Parameters
----------
network : dict
A network dictionary
weights : ndarray, optional
The weight values to use for the connections. If not provided
... |
Convert a graph dictionary into a ``scipy.sparse`` adjacency matrix in
COO format
Parameters
----------
network : dict
A network dictionary
weights : ndarray, optional
The weight values to use for the connections. If not provided
then 1's are assumed.
Returns
-... | dict_to_am | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def dict_to_im(network):
r"""
Convert a graph dictionary into a ``scipy.sparse`` incidence matrix in COO
format
Parameters
----------
network : dict
The network dictionary
Returns
-------
im : sparse matrix
The sparse incidence matrix in COO format
Notes
--... |
Convert a graph dictionary into a ``scipy.sparse`` incidence matrix in COO
format
Parameters
----------
network : dict
The network dictionary
Returns
-------
im : sparse matrix
The sparse incidence matrix in COO format
Notes
-----
Rows correspond to nodes ... | dict_to_im | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def ismultigraph(network):
r"""
Checks if graph contains multiple connections between any pair of nodes
Parameters
----------
network : dict
The network dictionary
Returns
-------
flag : bool
Returns ``True`` if any pair of nodes is connected by more than one
ed... |
Checks if graph contains multiple connections between any pair of nodes
Parameters
----------
network : dict
The network dictionary
Returns
-------
flag : bool
Returns ``True`` if any pair of nodes is connected by more than one
edge.
| ismultigraph | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def isgtriu(network):
r"""
Determines if graph connections are in upper triangular format
Parameters
----------
network : dict
The network dictionary
Returns
-------
flag : bool
Returns ``True`` if *all* rows in "conns" are ordered as [lo, hi]
"""
edge_prefix = ... |
Determines if graph connections are in upper triangular format
Parameters
----------
network : dict
The network dictionary
Returns
-------
flag : bool
Returns ``True`` if *all* rows in "conns" are ordered as [lo, hi]
| isgtriu | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def to_triu(network):
r"""
Adjusts conns array to force into upper triangular form
Parameters
----------
network : dict
The network dictionary
Returns
-------
network : dict
The graph dictionary with edge connections updated
Notes
-----
This does not check ... |
Adjusts conns array to force into upper triangular form
Parameters
----------
network : dict
The network dictionary
Returns
-------
network : dict
The graph dictionary with edge connections updated
Notes
-----
This does not check for the creation of duplicate ... | to_triu | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def conns_to_am(conns, shape=None, force_triu=True, drop_diag=True,
drop_dupes=True, drop_negs=True):
r"""
Converts a list of connections into a Scipy sparse adjacency matrix
Parameters
----------
conns : array_like, N x 2
The list of site-to-site connections
shape : lis... |
Converts a list of connections into a Scipy sparse adjacency matrix
Parameters
----------
conns : array_like, N x 2
The list of site-to-site connections
shape : list, optional
The shape of the array. If none is given then it is taken as 1 + the
maximum value in ``conns``.
... | conns_to_am | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def istriu(am):
r"""
Returns ``True`` if the sparse adjacency matrix is upper triangular
"""
if am.shape[0] != am.shape[1]:
print('Matrix is not square, triangularity is irrelevant')
return False
if am.format != 'coo':
am = am.tocoo(copy=False)
return np.all(am.row <= am.... |
Returns ``True`` if the sparse adjacency matrix is upper triangular
| istriu | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def istril(am):
r"""
Returns ``True`` if the sparse adjacency matrix is lower triangular
"""
if am.shape[0] != am.shape[1]:
print('Matrix is not square, triangularity is irrelevant')
return False
if am.format != 'coo':
am = am.tocoo(copy=False)
return np.all(am.row >= am.... |
Returns ``True`` if the sparse adjacency matrix is lower triangular
| istril | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def istriangular(am):
r"""
Returns ``True`` if the sparse adjacency matrix is either upper or lower
triangular
"""
if am.format != 'coo':
am = am.tocoo(copy=False)
return istril(am) or istriu(am) |
Returns ``True`` if the sparse adjacency matrix is either upper or lower
triangular
| istriangular | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def issymmetric(am):
r"""
A method to check if a square matrix is symmetric
Returns ``True`` if the sparse adjacency matrix is symmetric
"""
if am.shape[0] != am.shape[1]:
print('Matrix is not square, symmetrical is irrelevant')
return False
if am.format != 'coo':
am = am... |
A method to check if a square matrix is symmetric
Returns ``True`` if the sparse adjacency matrix is symmetric
| issymmetric | python | PMEAL/OpenPNM | openpnm/_skgraph/tools/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/tools/_funcs.py | MIT |
def plot_edges(network,
edges=None,
ax=None,
size_by=None,
color_by=None,
cmap='jet',
color='b',
alpha=1.0,
linestyle='solid',
linewidth=1,
**kwargs): # pragma: no cover... |
Produce a 3D plot of the network topology
This shows how edges connect for quick visualization without having
to export data to veiw in Paraview.
Parameters
----------
network : dict
The network dictionary
edges : array_like (optional)
The list of edges to plot if only a s... | plot_edges | python | PMEAL/OpenPNM | openpnm/_skgraph/visualization/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/visualization/_funcs.py | MIT |
def plot_nodes(network,
nodes=None,
ax=None,
size_by=None,
color_by=None,
cmap='jet',
color='r',
alpha=1.0,
marker='o',
markersize=10,
**kwargs): # pragma: no cover
... |
Produce a 3D plot showing specified nodecoordinates as markers.
Parameters
----------
network : dict
The network dictionary
nodes : array_like (optional)
The list of nodes to plot if only a sub-sample is desired. This is
useful for inspecting a small region of the network. ... | plot_nodes | python | PMEAL/OpenPNM | openpnm/_skgraph/visualization/_funcs.py | https://github.com/PMEAL/OpenPNM/blob/master/openpnm/_skgraph/visualization/_funcs.py | MIT |
def create_write_and_close_file(fname):
r"""
Putting the following code into it's own function saves a lot of
repitition, but means the assert errors will not come directly from
the offending test. The pytest output gives a traceback which leads
to the correct spot, so this will... |
Putting the following code into it's own function saves a lot of
repitition, but means the assert errors will not come directly from
the offending test. The pytest output gives a traceback which leads
to the correct spot, so this will suffice.
| create_write_and_close_file | python | PMEAL/OpenPNM | tests/unit/io/IOUtilsTest.py | https://github.com/PMEAL/OpenPNM/blob/master/tests/unit/io/IOUtilsTest.py | MIT |
def cleanup(temp_name):
"""Tries to remove temp files by filename wildcard path."""
for filename in iglob(f'{temp_name}*' if temp_name else temp_name):
try:
remove(filename)
except OSError as e:
if e.errno != ENOENT:
raise | Tries to remove temp files by filename wildcard path. | cleanup | python | madmaze/pytesseract | pytesseract/pytesseract.py | https://github.com/madmaze/pytesseract/blob/master/pytesseract/pytesseract.py | Apache-2.0 |
def get_tesseract_version():
"""
Returns Version object of the Tesseract version
"""
try:
output = subprocess.check_output(
[tesseract_cmd, '--version'],
stderr=subprocess.STDOUT,
env=environ,
stdin=subprocess.DEVNULL,
)
except OSError:... |
Returns Version object of the Tesseract version
| get_tesseract_version | python | madmaze/pytesseract | pytesseract/pytesseract.py | https://github.com/madmaze/pytesseract/blob/master/pytesseract/pytesseract.py | Apache-2.0 |
def image_to_string(
image,
lang=None,
config='',
nice=0,
output_type=Output.STRING,
timeout=0,
):
"""
Returns the result of a Tesseract OCR run on the provided image to string
"""
args = [image, 'txt', lang, config, nice, timeout]
return {
Output.BYTES: lambda: run_... |
Returns the result of a Tesseract OCR run on the provided image to string
| image_to_string | python | madmaze/pytesseract | pytesseract/pytesseract.py | https://github.com/madmaze/pytesseract/blob/master/pytesseract/pytesseract.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.