_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20600 | PyCurlMixin.process_queue | train | def process_queue(self):
"""
Processes all API calls since last invocation, returning a list of data
in the order the API calls were created
"""
m = pycurl.CurlMulti()
m.handles = []
# Loop the queue and create Curl objects for processing
for item in self... | python | {
"resource": ""
} |
q20601 | LeadsClient.camelcase_search_options | train | def camelcase_search_options(self, options):
"""change all underscored variants back to what the API is expecting"""
new_options = {}
for key in options:
value = options[key]
new_key = SEARCH_OPTIONS_DICT.get(key, key)
if new_key == 'sort':
val... | python | {
"resource": ""
} |
q20602 | LeadsClient.get_leads | train | def get_leads(self, *guids, **options):
"""Supports all the search parameters in the API as well as python underscored variants"""
original_options = options
options = self.camelcase_search_options(options.copy())
params = {}
for i in xrange(len(guids)):
params['guids... | python | {
"resource": ""
} |
q20603 | LeadsClient.retrieve_lead | train | def retrieve_lead(self, *guid, **options):
cur_guid = guid or ''
params = {}
for key in options:
params[key] = options[key]
""" Set guid to -1 as default for not finding a user """
lead = {'guid' : '-1'}
""" wrap lead call so that it doesn't error out when no... | python | {
"resource": ""
} |
q20604 | BroadcastClient.get_broadcast | train | def get_broadcast(self, broadcast_guid, **kwargs):
'''
Get a specific broadcast by guid
'''
params = kwargs
broadcast = self._call('broadcasts/%s' % broadcast_guid,
params=params, content_type='application/json')
return Broadcast(broadcast) | python | {
"resource": ""
} |
q20605 | BroadcastClient.get_broadcasts | train | def get_broadcasts(self, type="", page=None,
remote_content_id=None, limit=None, **kwargs):
'''
Get all broadcasts, with optional paging and limits.
Type filter can be 'scheduled', 'published' or 'failed'
'''
if remote_content_id:
return self.get_broadcast... | python | {
"resource": ""
} |
q20606 | BroadcastClient.cancel_broadcast | train | def cancel_broadcast(self, broadcast_guid):
'''
Cancel a broadcast specified by guid
'''
subpath = 'broadcasts/%s/update' % broadcast_guid
broadcast = {'status': 'CANCELED'}
bcast_dict = self._call(subpath, method='POST', data=broadcast,
content_type='applicat... | python | {
"resource": ""
} |
q20607 | BroadcastClient.get_channels | train | def get_channels(self, current=True, publish_only=False, settings=False):
"""
if "current" is false it will return all channels that a user
has published to in the past.
if publish_only is set to true, then return only the channels
that are publishable.
... | python | {
"resource": ""
} |
q20608 | ProspectsClient.get_prospects | train | def get_prospects(self, offset=None, orgoffset=None, limit=None):
""" Return the prospects for the current API key.
Optionally start the result list at the given offset.
Each member of the return list is a prospect element containing
organizational information such as name and location... | python | {
"resource": ""
} |
q20609 | ProspectsClient.search_prospects | train | def search_prospects(self, search_type, query, offset=None, orgoffset=None):
""" Supports doing a search for prospects by city, reion, or country.
search_type should be one of 'city' 'region' 'country'.
This method is intended to be called with one of the outputs from the
get_options_f... | python | {
"resource": ""
} |
q20610 | track_field | train | def track_field(field):
"""
Returns whether the given field should be tracked by Auditlog.
Untracked fields are many-to-many relations and relations to the Auditlog LogEntry model.
:param field: The field to check.
:type field: Field
:return: Whether the given field should be tracked.
:rty... | python | {
"resource": ""
} |
q20611 | get_fields_in_model | train | def get_fields_in_model(instance):
"""
Returns the list of fields in the given model instance. Checks whether to use the official _meta API or use the raw
data. This method excludes many to many fields.
:param instance: The model instance to get the fields for
:type instance: Model
:return: The... | python | {
"resource": ""
} |
q20612 | is_authenticated | train | def is_authenticated(user):
"""Return whether or not a User is authenticated.
Function provides compatibility following deprecation of method call to
`is_authenticated()` in Django 2.0.
This is *only* required to support Django < v1.10 (i.e. v1.9 and earlier),
as `is_authenticated` was introduced ... | python | {
"resource": ""
} |
q20613 | AuditlogModelRegistry.register | train | def register(self, model=None, include_fields=[], exclude_fields=[], mapping_fields={}):
"""
Register a model with auditlog. Auditlog will then track mutations on this model's instances.
:param model: The model to register.
:type model: Model
:param include_fields: The fields to... | python | {
"resource": ""
} |
q20614 | AuditlogModelRegistry._connect_signals | train | def _connect_signals(self, model):
"""
Connect signals for the model.
"""
for signal in self._signals:
receiver = self._signals[signal]
signal.connect(receiver, sender=model, dispatch_uid=self._dispatch_uid(signal, model)) | python | {
"resource": ""
} |
q20615 | AuditlogModelRegistry._disconnect_signals | train | def _disconnect_signals(self, model):
"""
Disconnect signals for the model.
"""
for signal, receiver in self._signals.items():
signal.disconnect(sender=model, dispatch_uid=self._dispatch_uid(signal, model)) | python | {
"resource": ""
} |
q20616 | LogEntryManager.log_create | train | def log_create(self, instance, **kwargs):
"""
Helper method to create a new log entry. This method automatically populates some fields when no explicit value
is given.
:param instance: The model instance to log a change for.
:type instance: Model
:param kwargs: Field ove... | python | {
"resource": ""
} |
q20617 | LogEntryManager.get_for_object | train | def get_for_object(self, instance):
"""
Get log entries for the specified model instance.
:param instance: The model instance to get log entries for.
:type instance: Model
:return: QuerySet of log entries for the given model instance.
:rtype: QuerySet
"""
... | python | {
"resource": ""
} |
q20618 | LogEntryManager.get_for_objects | train | def get_for_objects(self, queryset):
"""
Get log entries for the objects in the specified queryset.
:param queryset: The queryset to get the log entries for.
:type queryset: QuerySet
:return: The LogEntry objects for the objects in the given queryset.
:rtype: QuerySet
... | python | {
"resource": ""
} |
q20619 | LogEntryManager.get_for_model | train | def get_for_model(self, model):
"""
Get log entries for all objects of a specified type.
:param model: The model to get log entries for.
:type model: class
:return: QuerySet of log entries for the given model.
:rtype: QuerySet
"""
# Return empty queryset ... | python | {
"resource": ""
} |
q20620 | LogEntryManager._get_pk_value | train | def _get_pk_value(self, instance):
"""
Get the primary key field value for a model instance.
:param instance: The model instance to get the primary key for.
:type instance: Model
:return: The primary key value of the given model instance.
"""
pk_field = instance.... | python | {
"resource": ""
} |
q20621 | AuditlogHistoryField.bulk_related_objects | train | def bulk_related_objects(self, objs, using=DEFAULT_DB_ALIAS):
"""
Return all objects related to ``objs`` via this ``GenericRelation``.
"""
if self.delete_related:
return super(AuditlogHistoryField, self).bulk_related_objects(objs, using)
# When deleting, Collector.co... | python | {
"resource": ""
} |
q20622 | get_stockprices | train | def get_stockprices(chart_range='1y'):
'''
This is a proxy to the main fetch function to cache
the result based on the chart range parameter.
'''
all_symbols = list_symbols()
@daily_cache(filename='iex_chart_{}'.format(chart_range))
def get_stockprices_cached(all_symbols):
return _... | python | {
"resource": ""
} |
q20623 | LivePipelineEngine._inputs_for_term | train | def _inputs_for_term(term, workspace, graph):
"""
Compute inputs for the given term.
This is mostly complicated by the fact that for each input we store as
many rows as will be necessary to serve **any** computation requiring
that input.
"""
offsets = graph.offse... | python | {
"resource": ""
} |
q20624 | preemphasis | train | def preemphasis(signal, shift=1, cof=0.98):
"""preemphasising on the signal.
Args:
signal (array): The input signal.
shift (int): The shift step.
cof (float): The preemphasising coefficient. 0 equals to no filtering.
Returns:
array: The pre-emphasized signal.
"""
... | python | {
"resource": ""
} |
q20625 | log_power_spectrum | train | def log_power_spectrum(frames, fft_points=512, normalize=True):
"""Log power spectrum of each frame in frames.
Args:
frames (array): The frame array in which each row is a frame.
fft_points (int): The length of FFT. If fft_length is greater than
frame_len, the frames will be zero-pa... | python | {
"resource": ""
} |
q20626 | derivative_extraction | train | def derivative_extraction(feat, DeltaWindows):
"""This function the derivative features.
Args:
feat (array): The main feature vector(For returning the second
order derivative it can be first-order derivative).
DeltaWindows (int): The value of DeltaWindows is set using
... | python | {
"resource": ""
} |
q20627 | cmvnw | train | def cmvnw(vec, win_size=301, variance_normalization=False):
""" This function is aimed to perform local cepstral mean and
variance normalization on a sliding window. The code assumes that
there is one observation per row.
Args:
vec (array): input feature matrix
(size:(num_observatio... | python | {
"resource": ""
} |
q20628 | filterbanks | train | def filterbanks(
num_filter,
coefficients,
sampling_freq,
low_freq=None,
high_freq=None):
"""Compute the Mel-filterbanks. Each filter will be stored in one rows.
The columns correspond to fft bins.
Args:
num_filter (int): the number of filters in the filterba... | python | {
"resource": ""
} |
q20629 | extract_derivative_feature | train | def extract_derivative_feature(feature):
"""
This function extracts temporal derivative features which are
first and second derivatives.
Args:
feature (array): The feature vector which its size is: N x M
Return:
array: The feature cube vector which contains the static, first ... | python | {
"resource": ""
} |
q20630 | remove_umis | train | def remove_umis(adj_list, cluster, nodes):
'''removes the specified nodes from the cluster and returns
the remaining nodes '''
# list incomprehension: for x in nodes: for node in adj_list[x]: yield node
nodes_to_remove = set([node
for x in nodes
for... | python | {
"resource": ""
} |
q20631 | get_substr_slices | train | def get_substr_slices(umi_length, idx_size):
'''
Create slices to split a UMI into approximately equal size substrings
Returns a list of tuples that can be passed to slice function
'''
cs, r = divmod(umi_length, idx_size)
sub_sizes = [cs + 1] * r + [cs] * (idx_size - r)
offset = 0
slices... | python | {
"resource": ""
} |
q20632 | build_substr_idx | train | def build_substr_idx(umis, umi_length, min_edit):
'''
Build a dictionary of nearest neighbours using substrings, can be used
to reduce the number of pairwise comparisons.
'''
substr_idx = collections.defaultdict(
lambda: collections.defaultdict(set))
slices = get_substr_slices(umi_length... | python | {
"resource": ""
} |
q20633 | UMIClusterer._get_best_percentile | train | def _get_best_percentile(self, cluster, counts):
''' return all UMIs with counts >1% of the
median counts in the cluster '''
if len(cluster) == 1:
return list(cluster)
else:
threshold = np.median(list(counts.values()))/100
return [read for read in clu... | python | {
"resource": ""
} |
q20634 | UMIClusterer._get_adj_list_adjacency | train | def _get_adj_list_adjacency(self, umis, counts, threshold):
''' identify all umis within hamming distance threshold'''
adj_list = {umi: [] for umi in umis}
if len(umis) > 25:
umi_length = len(umis[0])
substr_idx = build_substr_idx(umis, umi_length, threshold)
... | python | {
"resource": ""
} |
q20635 | UMIClusterer._group_unique | train | def _group_unique(self, clusters, adj_list, counts):
''' return groups for unique method'''
if len(clusters) == 1:
groups = [clusters]
else:
groups = [[x] for x in clusters]
return groups | python | {
"resource": ""
} |
q20636 | UMIClusterer._group_directional | train | def _group_directional(self, clusters, adj_list, counts):
''' return groups for directional method'''
observed = set()
groups = []
for cluster in clusters:
if len(cluster) == 1:
groups.append(list(cluster))
observed.update(cluster)
... | python | {
"resource": ""
} |
q20637 | UMIClusterer._group_adjacency | train | def _group_adjacency(self, clusters, adj_list, counts):
''' return groups for adjacency method'''
groups = []
for cluster in clusters:
if len(cluster) == 1:
groups.append(list(cluster))
else:
observed = set()
lead_umis =... | python | {
"resource": ""
} |
q20638 | UMIClusterer._group_cluster | train | def _group_cluster(self, clusters, adj_list, counts):
''' return groups for cluster or directional methods'''
groups = []
for cluster in clusters:
groups.append(sorted(cluster, key=lambda x: counts[x],
reverse=True))
return groups | python | {
"resource": ""
} |
q20639 | UMIClusterer._group_percentile | train | def _group_percentile(self, clusters, adj_list, counts):
''' Return "groups" for the the percentile method. Note
that grouping isn't really compatible with the percentile
method. This just returns the retained UMIs in a structure similar
to other methods '''
retained_umis = self... | python | {
"resource": ""
} |
q20640 | CellClusterer._get_connected_components_adjacency | train | def _get_connected_components_adjacency(self, graph, counts):
''' find the connected UMIs within an adjacency dictionary'''
found = set()
components = list()
for node in sorted(graph, key=lambda x: counts[x], reverse=True):
if node not in found:
# component ... | python | {
"resource": ""
} |
q20641 | getHeader | train | def getHeader():
"""return a header string with command line options and timestamp
"""
system, host, release, version, machine = os.uname()
return "# UMI-tools version: %s\n# output generated by %s\n# job started at %s on %s -- %s\n# pid: %i, system: %s %s %s %s" %\
(__version__,
... | python | {
"resource": ""
} |
q20642 | getParams | train | def getParams(options=None):
"""return a string containing script parameters.
Parameters are all variables that start with ``param_``.
"""
result = []
if options:
members = options.__dict__
for k, v in sorted(members.items()):
result.append("# %-40s: %s" % (k, str(v)))
... | python | {
"resource": ""
} |
q20643 | getFooter | train | def getFooter():
"""return a header string with command line options and
timestamp.
"""
return "# job finished in %i seconds at %s -- %s -- %s" %\
(time.time() - global_starting_time,
time.asctime(time.localtime(time.time())),
" ".join(map(lambda x: "%5.2f" % x, os.tim... | python | {
"resource": ""
} |
q20644 | validateExtractOptions | train | def validateExtractOptions(options):
''' Check the validity of the option combinations for barcode extraction'''
if not options.pattern and not options.pattern2:
if not options.read2_in:
U.error("Must supply --bc-pattern for single-end")
else:
U.error("Must supply --bc-p... | python | {
"resource": ""
} |
q20645 | Stop | train | def Stop():
"""stop the experiment.
This method performs final book-keeping, closes the output streams
and writes the final log messages indicating script completion.
"""
if global_options.loglevel >= 1 and global_benchmark:
t = time.time() - global_starting_time
global_options.std... | python | {
"resource": ""
} |
q20646 | getTempFile | train | def getTempFile(dir=None, shared=False, suffix=""):
'''get a temporary file.
The file is created and the caller needs to close and delete
the temporary file once it is not used any more.
Arguments
---------
dir : string
Directory of the temporary file and if not given is set to the
... | python | {
"resource": ""
} |
q20647 | getTempFilename | train | def getTempFilename(dir=None, shared=False, suffix=""):
'''return a temporary filename.
The file is created and the caller needs to delete the temporary
file once it is not used any more.
Arguments
---------
dir : string
Directory of the temporary file and if not given is set to the
... | python | {
"resource": ""
} |
q20648 | get_gene_count_tab | train | def get_gene_count_tab(infile,
bc_getter=None):
''' Yields the counts per umi for each gene
bc_getter: method to get umi (plus optionally, cell barcode) from
read, e.g get_umi_read_id or get_umi_tag
TODO: ADD FOLLOWING OPTION
skip_regex: skip genes matching this regex. Us... | python | {
"resource": ""
} |
q20649 | metafetcher | train | def metafetcher(bamfile, metacontig2contig, metatag):
''' return reads in order of metacontigs'''
for metacontig in metacontig2contig:
for contig in metacontig2contig[metacontig]:
for read in bamfile.fetch(contig):
read.set_tag(metatag, metacontig)
yield read | python | {
"resource": ""
} |
q20650 | TwoPassPairWriter.write | train | def write(self, read, unique_id=None, umi=None, unmapped=False):
'''Check if chromosome has changed since last time. If it has, scan
for mates. Write the read to outfile and save the identity for paired
end retrieval'''
if unmapped or read.mate_is_unmapped:
self.outfile.writ... | python | {
"resource": ""
} |
q20651 | TwoPassPairWriter.write_mates | train | def write_mates(self):
'''Scan the current chromosome for matches to any of the reads stored
in the read1s buffer'''
if self.chrom is not None:
U.debug("Dumping %i mates for contig %s" % (
len(self.read1s), self.chrom))
for read in self.infile.fetch(reference... | python | {
"resource": ""
} |
q20652 | TwoPassPairWriter.close | train | def close(self):
'''Write mates for remaining chromsome. Search for matches to any
unmatched reads'''
self.write_mates()
U.info("Searching for mates for %i unmatched alignments" %
len(self.read1s))
found = 0
for read in self.infile.fetch(until_eof=True, m... | python | {
"resource": ""
} |
q20653 | getErrorCorrectMapping | train | def getErrorCorrectMapping(cell_barcodes, whitelist, threshold=1):
''' Find the mappings between true and false cell barcodes based
on an edit distance threshold.
Any cell barcode within the threshold to more than one whitelist
barcode will be excluded'''
true_to_false = collections.defaultdict(se... | python | {
"resource": ""
} |
q20654 | fastqIterate | train | def fastqIterate(infile):
'''iterate over contents of fastq file.'''
def convert2string(b):
if type(b) == str:
return b
else:
return b.decode("utf-8")
while 1:
line1 = convert2string(infile.readline())
if not line1:
break
if not l... | python | {
"resource": ""
} |
q20655 | Record.guessFormat | train | def guessFormat(self):
'''return quality score format -
might return several if ambiguous.'''
c = [ord(x) for x in self.quals]
mi, ma = min(c), max(c)
r = []
for entry_format, v in iteritems(RANGES):
m1, m2 = v
if mi >= m1 and ma < m2:
... | python | {
"resource": ""
} |
q20656 | random_read_generator.refill_random | train | def refill_random(self):
''' refill the list of random_umis '''
self.random_umis = np.random.choice(
list(self.umis.keys()), self.random_fill_size, p=self.prob)
self.random_ix = 0 | python | {
"resource": ""
} |
q20657 | random_read_generator.fill | train | def fill(self):
''' parse the BAM to obtain the frequency for each UMI'''
self.frequency2umis = collections.defaultdict(list)
for read in self.inbam:
if read.is_unmapped:
continue
if read.is_read2:
continue
self.umis[self.ba... | python | {
"resource": ""
} |
q20658 | random_read_generator.getUmis | train | def getUmis(self, n):
''' return n umis from the random_umis atr.'''
if n < (self.random_fill_size - self.random_ix):
barcodes = self.random_umis[self.random_ix: self.random_ix+n]
else:
# could use the end of the random_umis but
# let's just make a new random_... | python | {
"resource": ""
} |
q20659 | addBarcodesToIdentifier | train | def addBarcodesToIdentifier(read, UMI, cell):
'''extract the identifier from a read and append the UMI and
cell barcode before the first space'''
read_id = read.identifier.split(" ")
if cell == "":
read_id[0] = read_id[0] + "_" + UMI
else:
read_id[0] = read_id[0] + "_" + cell + "_"... | python | {
"resource": ""
} |
q20660 | extractSeqAndQuals | train | def extractSeqAndQuals(seq, quals, umi_bases, cell_bases, discard_bases,
retain_umi=False):
'''Remove selected bases from seq and quals
'''
new_seq = ""
new_quals = ""
umi_quals = ""
cell_quals = ""
ix = 0
for base, qual in zip(seq, quals):
if ((ix not in... | python | {
"resource": ""
} |
q20661 | get_below_threshold | train | def get_below_threshold(umi_quals, quality_encoding, quality_filter_threshold):
'''test whether the umi_quals are below the threshold'''
umi_quals = [x - RANGES[quality_encoding][0] for x in map(ord, umi_quals)]
below_threshold = [x < quality_filter_threshold for x in umi_quals]
return below_threshold | python | {
"resource": ""
} |
q20662 | umi_below_threshold | train | def umi_below_threshold(umi_quals, quality_encoding, quality_filter_threshold):
''' return true if any of the umi quals is below the threshold'''
below_threshold = get_below_threshold(
umi_quals, quality_encoding, quality_filter_threshold)
return any(below_threshold) | python | {
"resource": ""
} |
q20663 | mask_umi | train | def mask_umi(umi, umi_quals, quality_encoding, quality_filter_threshold):
''' Mask all positions where quals < threshold with "N" '''
below_threshold = get_below_threshold(
umi_quals, quality_encoding, quality_filter_threshold)
new_umi = ""
for base, test in zip(umi, below_threshold):
... | python | {
"resource": ""
} |
q20664 | ExtractBarcodes | train | def ExtractBarcodes(read, match,
extract_umi=False,
extract_cell=False,
discard=False,
retain_umi=False):
'''Extract the cell and umi barcodes using a regex.match object
inputs:
- read 1 and read2 = Record objects
- match ... | python | {
"resource": ""
} |
q20665 | ExtractFilterAndUpdate.maskQuality | train | def maskQuality(self, umi, umi_quals):
'''mask low quality bases and return masked umi'''
masked_umi = mask_umi(umi, umi_quals,
self.quality_encoding,
self.quality_filter_mask)
if masked_umi != umi:
self.read_counts['UMI mas... | python | {
"resource": ""
} |
q20666 | ExtractFilterAndUpdate.filterCellBarcode | train | def filterCellBarcode(self, cell):
'''Filter out cell barcodes not in the whitelist, with
optional cell barcode error correction'''
if self.cell_blacklist and cell in self.cell_blacklist:
self.read_counts['Cell barcode in blacklist'] += 1
return None
if cell not... | python | {
"resource": ""
} |
q20667 | detect_bam_features | train | def detect_bam_features(bamfile, n_entries=1000):
''' read the first n entries in the bam file and identify the tags
available detecting multimapping '''
inbam = pysam.Samfile(bamfile)
inbam = inbam.fetch(until_eof=True)
tags = ["NH", "X0", "XT"]
available_tags = {x: 1 for x in tags}
for ... | python | {
"resource": ""
} |
q20668 | aggregateStatsDF | train | def aggregateStatsDF(stats_df):
''' return a dataframe with aggregated counts per UMI'''
grouped = stats_df.groupby("UMI")
agg_dict = {'counts': [np.median, len, np.sum]}
agg_df = grouped.agg(agg_dict)
agg_df.columns = ['median_counts', 'times_observed', 'total_counts']
return agg_df | python | {
"resource": ""
} |
q20669 | mason_morrow | train | def mason_morrow(target, throat_perimeter='throat.perimeter',
throat_area='throat.area'):
r"""
Mason and Morrow relate the capillary pressure to the shaped factor in a
similar way to Mortensen but for triangles.
References
----------
Mason, G. and Morrow, N.R.. Capillary behavi... | python | {
"resource": ""
} |
q20670 | jenkins_rao | train | def jenkins_rao(target, throat_perimeter='throat.perimeter',
throat_area='throat.area',
throat_diameter='throat.indiameter'):
r"""
Jenkins and Rao relate the capillary pressure in an eliptical throat to
the aspect ratio
References
----------
Jenkins, R.G. and Rao... | python | {
"resource": ""
} |
q20671 | AdvectionDiffusion.set_outflow_BC | train | def set_outflow_BC(self, pores, mode='merge'):
r"""
Adds outflow boundary condition to the selected pores.
Outflow condition simply means that the gradient of the solved
quantity does not change, i.e. is 0.
"""
# Hijack the parse_mode function to verify mode/pores argum... | python | {
"resource": ""
} |
q20672 | PETScSparseLinearSolver._create_solver | train | def _create_solver(self):
r"""
This method creates the petsc sparse linear solver.
"""
# http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPType.html#KSPType
iterative_solvers = ['richardson', 'chebyshev', 'cg', 'groppcg',
'pipecg', 'p... | python | {
"resource": ""
} |
q20673 | PETScSparseLinearSolver.solve | train | def solve(self):
r"""
This method solves the sparse linear system, converts the
solution vector from a PETSc.Vec instance to a numpy array,
and finally destroys all the petsc objects to free memory.
Parameters
----------
solver_type : string, optional
... | python | {
"resource": ""
} |
q20674 | StokesFlow.calc_effective_permeability | train | def calc_effective_permeability(self, inlets=None, outlets=None,
domain_area=None, domain_length=None):
r"""
This calculates the effective permeability in this linear transport
algorithm.
Parameters
----------
inlets : array_like
... | python | {
"resource": ""
} |
q20675 | InvasionPercolation.setup | train | def setup(self, phase, entry_pressure='', pore_volume='', throat_volume=''):
r"""
Set up the required parameters for the algorithm
Parameters
----------
phase : OpenPNM Phase object
The phase to be injected into the Network. The Phase must have the
capil... | python | {
"resource": ""
} |
q20676 | Project.extend | train | def extend(self, obj):
r"""
This function is used to add objects to the project. Arguments can
be single OpenPNM objects, an OpenPNM project list, or a plain list of
OpenPNM objects.
"""
if type(obj) is not list:
obj = [obj]
for item in obj:
... | python | {
"resource": ""
} |
q20677 | Project.pop | train | def pop(self, index):
r"""
The object at the given index is removed from the list and returned.
Notes
-----
This method uses ``purge_object`` to perform the actual removal of the
object. It is reommended to just use that directly instead.
See Also
------... | python | {
"resource": ""
} |
q20678 | Project.clear | train | def clear(self, objtype=[]):
r"""
Clears objects from the project entirely or selectively, depdening on
the received arguments.
Parameters
----------
objtype : list of strings
A list containing the object type(s) to be removed. If no types
are sp... | python | {
"resource": ""
} |
q20679 | Project.copy | train | 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 : string
The name to give to the ... | python | {
"resource": ""
} |
q20680 | Project.find_phase | train | def find_phase(self, obj):
r"""
Find the Phase associated with a given object.
Parameters
----------
obj : OpenPNM Object
Can either be a Physics or Algorithm object
Returns
-------
An OpenPNM Phase object.
Raises
------
... | python | {
"resource": ""
} |
q20681 | Project.find_geometry | train | def find_geometry(self, physics):
r"""
Find the Geometry associated with a given Physics
Parameters
----------
physics : OpenPNM Physics Object
Must be a Physics object
Returns
-------
An OpenPNM Geometry object
Raises
------... | python | {
"resource": ""
} |
q20682 | Project.find_full_domain | train | def find_full_domain(self, obj):
r"""
Find the full domain object associated with a given object.
For geometry the network is found, for physics the phase is found and
for all other objects which are defined for for the full domain,
themselves are found.
Parameters
... | python | {
"resource": ""
} |
q20683 | Project.save_object | train | def save_object(self, obj):
r"""
Saves the given object to a file
Parameters
----------
obj : OpenPNM object
The file to be saved. Depending on the object type, the file
extension will be one of 'net', 'geo', 'phase', 'phys' or 'alg'.
"""
... | python | {
"resource": ""
} |
q20684 | Project.load_object | train | def load_object(self, filename):
r"""
Loads a single object from a file
Parameters
----------
"""
p = Path(filename)
with open(p, 'rb') as f:
d = pickle.load(f)
obj = self._new_object(objtype=p.suffix.strip('.'),
... | python | {
"resource": ""
} |
q20685 | Project._dump_data | train | def _dump_data(self, mode=['props']):
r"""
Dump data from all objects in project to an HDF5 file. Note that
'pore.coords', 'throat.conns', 'pore.all', 'throat.all', and all
labels pertaining to the linking of objects are kept.
Parameters
----------
mode : string... | python | {
"resource": ""
} |
q20686 | Project._fetch_data | train | def _fetch_data(self):
r"""
Retrieve data from an HDF5 file and place onto correct objects in the
project
See Also
--------
_dump_data
Notes
-----
In principle, after data is fetched from and HDF5 file, it should
physically stay there unt... | python | {
"resource": ""
} |
q20687 | Project.check_geometry_health | train | def check_geometry_health(self):
r"""
Perform a check to find pores with overlapping or undefined Geometries
Returns
-------
A HealthDict
"""
health = HealthDict()
health['overlapping_pores'] = []
health['undefined_pores'] = []
health['ove... | python | {
"resource": ""
} |
q20688 | Project.check_physics_health | train | def check_physics_health(self, phase):
r"""
Perform a check to find pores which have overlapping or missing Physics
Parameters
----------
phase : OpenPNM Phase object
The Phase whose Physics should be checked
Returns
-------
A HealthDict
... | python | {
"resource": ""
} |
q20689 | Project._regenerate_models | train | def _regenerate_models(self, objs=[], propnames=[]):
r"""
Can be used to regenerate models across all objects in the project.
Parameters
----------
objs : list of OpenPNM objects
Can be used to specify which specific objects to regenerate. The
default is... | python | {
"resource": ""
} |
q20690 | Porosimetry.set_partial_filling | train | def set_partial_filling(self, propname):
r"""
Define which pore filling model to apply.
Parameters
----------
propname : string
Dictionary key on the physics object(s) containing the pore
filling model(s) to apply.
Notes
-----
It ... | python | {
"resource": ""
} |
q20691 | generic_function | train | def generic_function(target, prop, func, **kwargs):
r"""
Runs an arbitrary function on the given data
This allows users to place a customized calculation into the automatated
model regeneration pipeline.
Parameters
----------
target : OpenPNM Object
The object which this model is a... | python | {
"resource": ""
} |
q20692 | product | train | def product(target, prop1, prop2, **kwargs):
r"""
Calculates the product of multiple property values
Parameters
----------
target : OpenPNM Object
The object which this model is associated with. This controls the
length of the calculated array, and also provides access to other
... | python | {
"resource": ""
} |
q20693 | random | train | def random(target, element, seed=None, num_range=[0, 1]):
r"""
Create an array of random numbers of a specified size.
Parameters
----------
target : OpenPNM Object
The object which this model is associated with. This controls the
length of the calculated array, and also provides acc... | python | {
"resource": ""
} |
q20694 | linear | train | def linear(target, m, b, prop):
r"""
Calculates a property as a linear function of a given property
Parameters
----------
target : OpenPNM Object
The object for which these values are being calculated. This
controls the length of the calculated array, and also provides
acce... | python | {
"resource": ""
} |
q20695 | polynomial | train | def polynomial(target, a, prop, **kwargs):
r"""
Calculates a property as a polynomial function of a given property
Parameters
----------
target : OpenPNM Object
The object for which these values are being calculated. This
controls the length of the calculated array, and also provid... | python | {
"resource": ""
} |
q20696 | generic_distribution | train | def generic_distribution(target, seeds, func):
r"""
Accepts an 'rv_frozen' object from the Scipy.stats submodule and returns
values from the distribution for the given seeds
This uses the ``ppf`` method of the stats object
Parameters
----------
target : OpenPNM Object
The object wh... | python | {
"resource": ""
} |
q20697 | from_neighbor_throats | train | def from_neighbor_throats(target, throat_prop='throat.seed', mode='min'):
r"""
Adopt a value from the values found in neighboring throats
Parameters
----------
target : OpenPNM Object
The object which this model is associated with. This controls the
length of the calculated array, a... | python | {
"resource": ""
} |
q20698 | from_neighbor_pores | train | def from_neighbor_pores(target, pore_prop='pore.seed', mode='min'):
r"""
Adopt a value based on the values in neighboring pores
Parameters
----------
target : OpenPNM Object
The object which this model is associated with. This controls the
length of the calculated array, and also pr... | python | {
"resource": ""
} |
q20699 | spatially_correlated | train | def spatially_correlated(target, weights=None, strel=None):
r"""
Generates pore seeds that are spatailly correlated with their neighbors.
Parameters
----------
target : OpenPNM Object
The object which this model is associated with. This controls the
length of the calculated array, a... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.