_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q20800
find_neighbor_sites
train
def find_neighbor_sites(sites, am, flatten=True, include_input=False, logic='or'): r""" Given a symmetric adjacency matrix, finds all sites that are connected to the input sites. Parameters ---------- am : scipy.sparse matrix The adjacency matrix of the network. ...
python
{ "resource": "" }
q20801
find_connected_sites
train
def find_connected_sites(bonds, am, flatten=True, logic='or'): r""" Given an adjacency matrix, finds which sites are connected to the input bonds. Parameters ---------- am : scipy.sparse matrix The adjacency matrix of the network. Must be symmetrical such that if sites *i* and ...
python
{ "resource": "" }
q20802
find_connecting_bonds
train
def find_connecting_bonds(sites, am): r""" Given pairs of sites, finds the bonds which connects each pair. Parameters ---------- sites : array_like A 2-column vector containing pairs of site indices on each row. am : scipy.sparse matrix The adjacency matrix of the network. Mus...
python
{ "resource": "" }
q20803
istriu
train
def istriu(am): r""" Returns ``True`` is 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 sp.all(am.row <= am....
python
{ "resource": "" }
q20804
istriangular
train
def istriangular(am): r""" Returns ``True`` is 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)
python
{ "resource": "" }
q20805
issymmetric
train
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]: logger.warning('Matrix is not square, symmetrical is irrelevant') return False if am.format != 'coo': ...
python
{ "resource": "" }
q20806
am_to_im
train
def am_to_im(am): r""" Convert an adjacency matrix into an incidence matrix """ if am.shape[0] != am.shape[1]: raise Exception('Adjacency matrices must be square') if am.format != 'coo': am = am.tocoo(copy=False) conn = sp.vstack((am.row, am.col)).T row = conn[:, 0] data ...
python
{ "resource": "" }
q20807
im_to_am
train
def im_to_am(im): r""" Convert an incidence matrix into an adjacency matrix """ if im.shape[0] == im.shape[1]: print('Warning: Received matrix is square which is unlikely') if im.shape[0] > im.shape[1]: print('Warning: Received matrix has more sites than bonds') if im.format != '...
python
{ "resource": "" }
q20808
tri_to_am
train
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 ...
python
{ "resource": "" }
q20809
vor_to_am
train
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...
python
{ "resource": "" }
q20810
conns_to_am
train
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 : li...
python
{ "resource": "" }
q20811
isoutside
train
def isoutside(coords, shape): r""" Identifies points that lie outside the specified region. Parameters ---------- domain_size : array_like The size and shape of the domain beyond which points should be trimmed. The argument is treated as follows: **sphere** : If a scalar or...
python
{ "resource": "" }
q20812
ispercolating
train
def ispercolating(am, inlets, outlets, mode='site'): r""" Determines if a percolating clusters exists in the network spanning the given inlet and outlet sites Parameters ---------- am : adjacency_matrix The adjacency matrix with the ``data`` attribute indicating if a bond is occ...
python
{ "resource": "" }
q20813
site_percolation
train
def site_percolation(ij, occupied_sites): r""" Calculates the site and bond occupancy status for a site percolation process given a list of occupied sites. Parameters ---------- ij : array_like An N x 2 array of [site_A, site_B] connections. If two connected sites are both occu...
python
{ "resource": "" }
q20814
bond_percolation
train
def bond_percolation(ij, occupied_bonds): r""" Calculates the site and bond occupancy status for a bond percolation process given a list of occupied bonds. Parameters ---------- ij : array_like An N x 2 array of [site_A, site_B] connections. A site is considered occupied if any...
python
{ "resource": "" }
q20815
trim
train
def trim(network, pores=[], throats=[]): ''' Remove pores or throats from the network. Parameters ---------- network : OpenPNM Network Object The Network from which pores or throats should be removed pores (or throats) : array_like The indices of the of the pores or throats to ...
python
{ "resource": "" }
q20816
find_surface_pores
train
def find_surface_pores(network, markers=None, label='surface'): r""" Find the pores on the surface of the domain by performing a Delaunay triangulation between the network pores and some external ``markers``. All pores connected to these external marker points are considered surface pores. Para...
python
{ "resource": "" }
q20817
clone_pores
train
def clone_pores(network, pores, labels=['clone'], mode='parents'): r''' Clones the specified pores and adds them to the network Parameters ---------- network : OpenPNM Network Object The Network object to which the new pores are to be added pores : array_like List of pores to c...
python
{ "resource": "" }
q20818
stitch
train
def stitch(network, donor, P_network, P_donor, method='nearest', len_max=sp.inf, len_min=0, label_suffix=''): r''' Stitches a second a network to the current network. Parameters ---------- networK : OpenPNM Network Object The Network to which to donor Network will be attached ...
python
{ "resource": "" }
q20819
connect_pores
train
def connect_pores(network, pores1, pores2, labels=[], add_conns=True): r''' Returns the possible connections between two group of pores, and optionally makes the connections. See ``Notes`` for advanced usage. Parameters ---------- network : OpenPNM Network Object pores1 : array_like ...
python
{ "resource": "" }
q20820
find_pore_to_pore_distance
train
def find_pore_to_pore_distance(network, pores1=None, pores2=None): r''' Find the distance between all pores on set one to each pore in set 2 Parameters ---------- network : OpenPNM Network Object The network object containing the pore coordinates pores1 : array_like The pore in...
python
{ "resource": "" }
q20821
merge_pores
train
def merge_pores(network, pores, labels=['merged']): r""" Combines a selection of pores into a new single pore located at the centroid of the selected pores and connected to all of their neighbors. Parameters ---------- network : OpenPNM Network Object pores : array_like The list of...
python
{ "resource": "" }
q20822
template_sphere_shell
train
def template_sphere_shell(outer_radius, inner_radius=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 ---------- outer_radius : int Number of nodes in the outer...
python
{ "resource": "" }
q20823
template_cylinder_annulus
train
def template_cylinder_annulus(height, outer_radius, inner_radius=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 ---------- height : int The height of the cyli...
python
{ "resource": "" }
q20824
plot_connections
train
def plot_connections(network, throats=None, fig=None, **kwargs): r""" Produces a 3D plot of the network topology showing how throats connect for quick visualization without having to export data to veiw in Paraview. Parameters ---------- network : OpenPNM Network Object The network whos...
python
{ "resource": "" }
q20825
plot_coordinates
train
def plot_coordinates(network, pores=None, fig=None, **kwargs): r""" Produces a 3D plot showing specified pore coordinates as markers Parameters ---------- network : OpenPNM Network Object The network whose topological connections to plot pores : array_like (optional) The list o...
python
{ "resource": "" }
q20826
plot_networkx
train
def plot_networkx(network, plot_throats=True, labels=None, colors=None, scale=10): r''' Returns a pretty 2d plot for 2d OpenPNM networks. Parameters ---------- network : OpenPNM Network object plot_throats : boolean Plots throats as well as pores, if True. labels...
python
{ "resource": "" }
q20827
reflect_base_points
train
def reflect_base_points(base_pts, domain_size): r''' Helper function for relecting a set of points about the faces of a given domain. Parameters ---------- base_pts : array_like The coordinates of the base_pts to be reflected in the coordinate system corresponding to the the dom...
python
{ "resource": "" }
q20828
find_clusters
train
def find_clusters(network, mask=[], t_labels=False): r""" Identify connected clusters of pores in the network. This method can also return a list of throat cluster numbers, which correspond to the cluster numbers of the pores to which the throat is connected. Either site and bond percolation can b...
python
{ "resource": "" }
q20829
add_boundary_pores
train
def add_boundary_pores(network, pores, offset, apply_label='boundary'): r""" This method uses ``clone_pores`` to clone the input pores, then shifts them the specified amount and direction, then applies the given label. Parameters ---------- pores : array_like List of pores to offset. I...
python
{ "resource": "" }
q20830
find_path
train
def find_path(network, pore_pairs, weights=None): r""" Find the shortest path between pairs of pores. Parameters ---------- network : OpenPNM Network Object The Network object on which the search should be performed pore_pairs : array_like An N x 2 array containing N pairs of p...
python
{ "resource": "" }
q20831
iscoplanar
train
def iscoplanar(coords): r''' Determines if given pores are coplanar with each other Parameters ---------- coords : array_like List of pore coords to check for coplanarity. At least 3 pores are required. Returns ------- A boolean value of whether given points are coplan...
python
{ "resource": "" }
q20832
OhmicConduction.calc_effective_conductivity
train
def calc_effective_conductivity(self, inlets=None, outlets=None, domain_area=None, domain_length=None): r""" This calculates the effective electrical conductivity. Parameters ---------- inlets : array_like The pores where the inlet...
python
{ "resource": "" }
q20833
washburn
train
def washburn(target, surface_tension='pore.surface_tension', contact_angle='pore.contact_angle', diameter='throat.diameter'): r""" Computes the capillary entry pressure assuming the throat in a cylindrical tube. Parameters ---------- target : OpenPNM Object The...
python
{ "resource": "" }
q20834
purcell
train
def purcell(target, r_toroid, surface_tension='pore.surface_tension', contact_angle='pore.contact_angle', diameter='throat.diameter'): r""" Computes the throat capillary entry pressure assuming the throat is a toroid. Parameters ---------- target : OpenPNM Object ...
python
{ "resource": "" }
q20835
ransohoff_snap_off
train
def ransohoff_snap_off(target, shape_factor=2.0, wavelength=5e-6, require_pair=False, surface_tension='pore.surface_tension', contact_angle='pore.contact_angle', diameter='throat.dia...
python
{ "resource": "" }
q20836
purcell_bidirectional
train
def purcell_bidirectional(target, r_toroid, num_points=1e2, surface_tension='pore.surface_tension', contact_angle='pore.contact_angle', throat_diameter='throat.diameter', pore_diameter='pore...
python
{ "resource": "" }
q20837
sinusoidal_bidirectional
train
def sinusoidal_bidirectional(target, num_points=1e2, surface_tension='pore.surface_tension', contact_angle='pore.contact_angle', throat_diameter='throat.diameter', throat_ampl...
python
{ "resource": "" }
q20838
NetworkX.to_networkx
train
def to_networkx(cls, network): r""" Write OpenPNM Network to a NetworkX object. Parameters ---------- network : OpenPNM Network Object The OpenPNM Network to be converted to a NetworkX object Returns ------- A NetworkX object with all pore/th...
python
{ "resource": "" }
q20839
conduit_conductance
train
def conduit_conductance(target, throat_conductance, throat_occupancy='throat.occupancy', pore_occupancy='pore.occupancy', mode='strict', factor=1e-6): r""" Determines the conductance of a pore-throat-pore conduit based on the invaded st...
python
{ "resource": "" }
q20840
pore_coords
train
def pore_coords(target): r""" The average of the pore coords """ network = target.project.network Ts = network.throats(target.name) conns = network['throat.conns'] coords = network['pore.coords'] return _sp.mean(coords[conns], axis=1)[Ts]
python
{ "resource": "" }
q20841
ModelsDict.dependency_list
train
def dependency_list(self): r''' Returns a list of dependencies in the order with which they should be called to ensure data is calculated by one model before it's asked for by another. Notes ----- This raises an exception if the graph has cycles which means the ...
python
{ "resource": "" }
q20842
ModelsDict.dependency_graph
train
def dependency_graph(self): r""" Returns a NetworkX graph object of the dependencies See Also -------- dependency_list dependency_map Notes ----- To visualize the dependencies, the following NetworkX function and settings is helpful: ...
python
{ "resource": "" }
q20843
ModelsDict.dependency_map
train
def dependency_map(self): r""" Create a graph of the dependency graph in a decent format See Also -------- dependency_graph dependency_list """ dtree = self.dependency_graph() fig = nx.draw_spectral(dtree, with_labe...
python
{ "resource": "" }
q20844
ModelsMixin.regenerate_models
train
def regenerate_models(self, propnames=None, exclude=[], deep=False): r""" Re-runs the specified model or models. Parameters ---------- propnames : string or list of strings The list of property names to be regenerated. If None are given then ALL models a...
python
{ "resource": "" }
q20845
ModelsMixin.remove_model
train
def remove_model(self, propname=None, mode=['model', 'data']): r""" Removes model and data from object. Parameters ---------- propname : string or list of strings The property or list of properties to remove mode : list of strings Controls what i...
python
{ "resource": "" }
q20846
equivalent_diameter
train
def equivalent_diameter(target, throat_area='throat.area', throat_shape='circle'): r""" Calculates the diameter of a cirlce or edge-length of a sqaure with same area as the throat. Parameters ---------- target : OpenPNM Object The object which this model is assoc...
python
{ "resource": "" }
q20847
TransientReactiveTransport.set_IC
train
def set_IC(self, values): r""" A method to set simulation initial conditions Parameters ---------- values : ND-array or scalar Set the initial conditions using an 'Np' long array. 'Np' being the number of pores. If a scalar is given, the same value is ...
python
{ "resource": "" }
q20848
TransientReactiveTransport._t_update_A
train
def _t_update_A(self): r""" A method to update 'A' matrix at each time step according to 't_scheme' """ network = self.project.network Vi = network['pore.volume'] dt = self.settings['t_step'] s = self.settings['t_scheme'] if (s == 'implicit'): ...
python
{ "resource": "" }
q20849
TransientReactiveTransport._t_update_b
train
def _t_update_b(self): r""" A method to update 'b' array at each time step according to 't_scheme' and the source term value """ network = self.project.network phase = self.project.phases()[self.settings['phase']] Vi = network['pore.volume'] dt = self.sett...
python
{ "resource": "" }
q20850
TransientReactiveTransport._t_run_reactive
train
def _t_run_reactive(self, x): """r Repeatedly updates transient 'A', 'b', and the solution guess within each time step according to the applied source term then calls '_solve' to solve the resulting system of linear equations. Stops when the residual falls below 'r_tolerance'. ...
python
{ "resource": "" }
q20851
general_symbolic
train
def general_symbolic(target, eqn=None, arg_map=None): r''' A general function to interpret a sympy equation and evaluate the linear components of the source term. Parameters ---------- target : OpenPNM object The OpenPNM object where the result will be applied. eqn : sympy symbolic...
python
{ "resource": "" }
q20852
toc
train
def toc(quiet=False): r""" Homemade version of matlab tic and toc function, tic starts or resets the clock, toc reports the time since the last call of tic. Parameters ---------- quiet : Boolean If False (default) then a message is output to the console. If True the message is ...
python
{ "resource": "" }
q20853
flat_list
train
def flat_list(input_list): r""" Given a list of nested lists of arbitrary depth, returns a single level or 'flat' list. """ x = input_list if isinstance(x, list): return [a for i in x for a in flat_list(i)] else: return [x]
python
{ "resource": "" }
q20854
sanitize_dict
train
def sanitize_dict(input_dict): r""" Given a nested dictionary, ensures that all nested dicts are normal Python dicts. This is necessary for pickling, or just converting an 'auto-vivifying' dict to something that acts normal. """ plain_dict = dict() for key in input_dict.keys(): valu...
python
{ "resource": "" }
q20855
models_to_table
train
def models_to_table(obj, params=True): r""" Converts a ModelsDict object to a ReST compatible table Parameters ---------- obj : OpenPNM object Any object that has a ``models`` attribute params : boolean Indicates whether or not to include a list of parameter values in t...
python
{ "resource": "" }
q20856
conduit_lengths
train
def conduit_lengths(network, throats=None, mode='pore'): r""" Return the respective lengths of the conduit components defined by the throat conns P1 T P2 mode = 'pore' - uses pore coordinates mode = 'centroid' uses pore and throat centroids """ if throats is None: throats = network.t...
python
{ "resource": "" }
q20857
FickianDiffusion.calc_effective_diffusivity
train
def calc_effective_diffusivity(self, inlets=None, outlets=None, domain_area=None, domain_length=None): r""" This calculates the effective diffusivity in this linear transport algorithm. Parameters ---------- inlets : array_like ...
python
{ "resource": "" }
q20858
Subdomain._set_locations
train
def _set_locations(self, element, indices, mode, complete=False): r""" This private method is called by ``set_locations`` and ``remove_locations`` as needed. """ boss = self.project.find_full_domain(self) element = self._parse_element(element=element, single=True) ...
python
{ "resource": "" }
q20859
ctc
train
def ctc(target, pore_diameter='pore.diameter'): r""" Calculate throat length assuming point-like pores, i.e. center-to-center distance between pores. Also, this models assumes that pores and throat centroids are colinear. Parameters ---------- target : OpenPNM Object The object whic...
python
{ "resource": "" }
q20860
piecewise
train
def piecewise(target, throat_endpoints='throat.endpoints', throat_centroid='throat.centroid'): r""" Calculate throat length from end points and optionally a centroid Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the...
python
{ "resource": "" }
q20861
conduit_lengths
train
def conduit_lengths(target, throat_endpoints='throat.endpoints', throat_length='throat.length'): r""" Calculate conduit lengths. A conduit is defined as half pore + throat + half pore. Parameters ---------- target : OpenPNM Object The object which this model is assoc...
python
{ "resource": "" }
q20862
standard
train
def standard(target, mol_weight='pore.molecular_weight', molar_density='pore.molar_density'): r""" Calculates the mass density from the molecular weight and molar density Parameters ---------- mol_weight : string The dictionary key containing the molecular weight values mo...
python
{ "resource": "" }
q20863
Dict.save
train
def save(cls, dct, filename): r""" Saves data from the given dictionary into the specified file. Parameters ---------- dct : dictionary A dictionary to save to file, presumably obtained from the ``to_dict`` method of this class. filename : string...
python
{ "resource": "" }
q20864
Dict.load
train
def load(cls, filename): r""" Load data from the specified file into a Python dictionary Parameters ---------- filename : string The path to the file to be opened Notes ----- This returns a Python dictionary which can be converted into OpenPN...
python
{ "resource": "" }
q20865
OrdinaryPercolation.set_inlets
train
def set_inlets(self, pores=[], overwrite=False): r""" Set the locations from which the invader enters the network Parameters ---------- pores : array_like Locations that are initially filled with invader, from which clusters grow and invade into the netwo...
python
{ "resource": "" }
q20866
OrdinaryPercolation.set_residual
train
def set_residual(self, pores=[], throats=[], overwrite=False): r""" Specify locations of any residual invader. These locations are set to invaded at the start of the simulation. Parameters ---------- pores : array_like The pores locations that are to be fill...
python
{ "resource": "" }
q20867
OrdinaryPercolation.get_percolation_threshold
train
def get_percolation_threshold(self): r""" Find the invasion threshold at which a cluster spans from the inlet to the outlet sites """ if np.sum(self['pore.inlets']) == 0: raise Exception('Inlet pores must be specified first') if np.sum(self['pore.outlets']) =...
python
{ "resource": "" }
q20868
OrdinaryPercolation.is_percolating
train
def is_percolating(self, applied_pressure): r""" Returns a True or False value to indicate if a percolating cluster spans between the inlet and outlet pores that were specified at the given applied pressure. Parameters ---------- applied_pressure : scalar, float ...
python
{ "resource": "" }
q20869
OrdinaryPercolation.run
train
def run(self, points=25, start=None, stop=None): r""" Runs the percolation algorithm to determine which pores and throats will be invaded at each given pressure point. Parameters ---------- points: int or array_like An array containing the pressure points to ...
python
{ "resource": "" }
q20870
OrdinaryPercolation.get_intrusion_data
train
def get_intrusion_data(self, Pc=None): r""" Obtain the numerical values of the calculated intrusion curve Returns ------- A named-tuple containing arrays of applied capillary pressures and invading phase saturation. """ net = self.project.network ...
python
{ "resource": "" }
q20871
OrdinaryPercolation.plot_intrusion_curve
train
def plot_intrusion_curve(self, fig=None): r""" Plot the percolation curve as the invader volume or number fraction vs the applied capillary pressure. """ # Begin creating nicely formatted plot x, y = self.get_intrusion_data() if fig is None: fig = plt...
python
{ "resource": "" }
q20872
OrdinaryPercolation.results
train
def results(self, Pc): r""" This method determines which pores and throats are filled with invading phase at the specified capillary pressure, and creates several arrays indicating the occupancy status of each pore and throat for the given pressure. Parameters --...
python
{ "resource": "" }
q20873
percolating_continua
train
def percolating_continua(target, phi_crit, tau, volume_fraction='pore.volume_fraction', bulk_property='pore.intrinsic_conductivity'): r''' Calculates the effective property of a continua using percolation theory Parameters ---------- target : OpenPN...
python
{ "resource": "" }
q20874
ReactiveTransport.set_source
train
def set_source(self, propname, pores): r""" Applies a given source term to the specified pores Parameters ---------- propname : string The property name of the source term model to be applied pores : array_like The pore indices where the source t...
python
{ "resource": "" }
q20875
ReactiveTransport._set_BC
train
def _set_BC(self, pores, bctype, bcvalues=None, mode='merge'): r""" Apply boundary conditions to specified pores if no source terms are already assigned to these pores. Otherwise, raise an error. Parameters ---------- pores : array_like The pores where the bo...
python
{ "resource": "" }
q20876
ReactiveTransport._update_physics
train
def _update_physics(self): """r Update physics using the current value of 'quantity' Notes ----- The algorithm directly writes the value of 'quantity' into the phase. This method was implemented relaxing one of the OpenPNM rules of algorithms not being able to wr...
python
{ "resource": "" }
q20877
ReactiveTransport._apply_sources
train
def _apply_sources(self): """r Update 'A' and 'b' applying source terms to specified pores Notes ----- Applying source terms to 'A' and 'b' is performed after (optionally) under-relaxing the source term to improve numerical stability. Physics are also updated bef...
python
{ "resource": "" }
q20878
ReactiveTransport.run
train
def run(self, x=None): r""" Builds the A and b matrices, and calls the solver specified in the ``settings`` attribute. Parameters ---------- x : ND-array Initial guess of unknown variable """ logger.info('Running ReactiveTransport') #...
python
{ "resource": "" }
q20879
ReactiveTransport._run_reactive
train
def _run_reactive(self, x): """r Repeatedly updates 'A', 'b', and the solution guess within according to the applied source term then calls '_solve' to solve the resulting system of linear equations. Stops when the residual falls below 'r_tolerance' or when the maximum nu...
python
{ "resource": "" }
q20880
sphere
train
def sphere(target, pore_diameter='pore.diameter'): r""" Calculate pore volume from diameter assuming a spherical pore body Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the length of the calculated array, and also provide...
python
{ "resource": "" }
q20881
cylinder
train
def cylinder(target, throat_length='throat.length', throat_diameter='throat.diameter'): r""" Calculate throat volume assuing a cylindrical shape Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the length of the...
python
{ "resource": "" }
q20882
cuboid
train
def cuboid(target, throat_length='throat.length', throat_diameter='throat.diameter'): r""" Calculate throat volume assuing a square cross-section Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the length of the ...
python
{ "resource": "" }
q20883
extrusion
train
def extrusion(target, throat_length='throat.length', throat_area='throat.area'): r""" Calculate throat volume from the throat area and the throat length. This method is useful for abnormal shaped throats. Parameters ---------- target : OpenPNM Object The object which this ...
python
{ "resource": "" }
q20884
HDF5.to_hdf5
train
def to_hdf5(cls, network=None, phases=[], element=['pore', 'throat'], filename='', interleave=True, flatten=False, categorize_by=[]): r""" Creates an HDF5 file containing data from the specified objects, and categorized according to the given arguments. Parameters ...
python
{ "resource": "" }
q20885
get_objects_in_sequence
train
def get_objects_in_sequence(brain_or_object, ctype, cref): """Return a list of items """ obj = api.get_object(brain_or_object) if ctype == "backreference": return get_backreferences(obj, cref) if ctype == "contained": return get_contained_items(obj, cref) raise ValueError("Refere...
python
{ "resource": "" }
q20886
get_backreferences
train
def get_backreferences(obj, relationship): """Returns the backreferences """ refs = get_backuidreferences(obj, relationship) # TODO remove after all ReferenceField get ported to UIDReferenceField # At this moment, there are still some content types that are using the # ReferenceField, so we nee...
python
{ "resource": "" }
q20887
get_type_id
train
def get_type_id(context, **kw): """Returns the type id for the context passed in """ portal_type = kw.get("portal_type", None) if portal_type: return portal_type # Override by provided marker interface if IAnalysisRequestPartition.providedBy(context): return "AnalysisRequestPart...
python
{ "resource": "" }
q20888
strip_suffix
train
def strip_suffix(id): """Split off any suffix from ID This mimics the old behavior of the Sample ID. """ suffix = get_suffix(id) if not suffix: return id return re.split(suffix, id)[0]
python
{ "resource": "" }
q20889
get_partition_count
train
def get_partition_count(context, default=0): """Returns the number of partitions of this AR """ if not is_ar(context): return default parent = context.getParentAnalysisRequest() if not parent: return default return len(parent.getDescendants())
python
{ "resource": "" }
q20890
get_secondary_count
train
def get_secondary_count(context, default=0): """Returns the number of secondary ARs of this AR """ if not is_ar(context): return default primary = context.getPrimaryAnalysisRequest() if not primary: return default return len(primary.getSecondaryAnalysisRequests())
python
{ "resource": "" }
q20891
get_config
train
def get_config(context, **kw): """Fetch the config dict from the Bika Setup for the given portal_type """ # get the ID formatting config config_map = api.get_bika_setup().getIDFormatting() # allow portal_type override portal_type = get_type_id(context, **kw) # check if we have a config for...
python
{ "resource": "" }
q20892
get_variables
train
def get_variables(context, **kw): """Prepares a dictionary of key->value pairs usable for ID formatting """ # allow portal_type override portal_type = get_type_id(context, **kw) # The variables map hold the values that might get into the constructed id variables = { "context": context, ...
python
{ "resource": "" }
q20893
slice
train
def slice(string, separator="-", start=None, end=None): """Slice out a segment of a string, which is splitted on both the wildcards and the separator passed in, if any """ # split by wildcards/keywords first # AR-{sampleType}-{parentId}{alpha:3a2d} segments = filter(None, re.split('(\{.+?\})', s...
python
{ "resource": "" }
q20894
search_by_prefix
train
def search_by_prefix(portal_type, prefix): """Returns brains which share the same portal_type and ID prefix """ catalog = api.get_tool("uid_catalog") brains = catalog({"portal_type": portal_type}) # Filter brains with the same ID prefix return filter(lambda brain: api.get_id(brain).startswith(pr...
python
{ "resource": "" }
q20895
get_ids_with_prefix
train
def get_ids_with_prefix(portal_type, prefix): """Return a list of ids sharing the same portal type and prefix """ brains = search_by_prefix(portal_type, prefix) ids = map(api.get_id, brains) return ids
python
{ "resource": "" }
q20896
get_seq_number_from_id
train
def get_seq_number_from_id(id, id_template, prefix, **kw): """Return the sequence number of the given ID """ separator = kw.get("separator", "-") postfix = id.replace(prefix, "").strip(separator) postfix_segments = postfix.split(separator) seq_number = 0 possible_seq_nums = filter(lambda n: ...
python
{ "resource": "" }
q20897
get_alpha_or_number
train
def get_alpha_or_number(number, template): """Returns an Alphanumber that represents the number passed in, expressed as defined in the template. Otherwise, returns the number """ match = re.match(r".*\{alpha:(\d+a\d+d)\}$", template.strip()) if match and match.groups(): format = match.groups...
python
{ "resource": "" }
q20898
get_counted_number
train
def get_counted_number(context, config, variables, **kw): """Compute the number for the sequence type "Counter" """ # This "context" is defined by the user in the Setup and can be actually # anything. However, we assume it is something like "sample" or similar ctx = config.get("context") # get ...
python
{ "resource": "" }
q20899
get_generated_number
train
def get_generated_number(context, config, variables, **kw): """Generate a new persistent number with the number generator for the sequence type "Generated" """ # separator where to split the ID separator = kw.get('separator', '-') # allow portal_type override portal_type = get_type_id(conte...
python
{ "resource": "" }