id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
46,200
kgori/treeCl
treeCl/collection.py
Collection.permuted_copy
def permuted_copy(self, partition=None): """ Return a copy of the collection with all alignment columns permuted """ def take(n, iterable): return [next(iterable) for _ in range(n)] if partition is None: partition = Partition([1] * len(self)) index_tuple...
python
def permuted_copy(self, partition=None): """ Return a copy of the collection with all alignment columns permuted """ def take(n, iterable): return [next(iterable) for _ in range(n)] if partition is None: partition = Partition([1] * len(self)) index_tuple...
[ "def", "permuted_copy", "(", "self", ",", "partition", "=", "None", ")", ":", "def", "take", "(", "n", ",", "iterable", ")", ":", "return", "[", "next", "(", "iterable", ")", "for", "_", "in", "range", "(", "n", ")", "]", "if", "partition", "is", ...
Return a copy of the collection with all alignment columns permuted
[ "Return", "a", "copy", "of", "the", "collection", "with", "all", "alignment", "columns", "permuted" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L489-L513
46,201
kgori/treeCl
treeCl/collection.py
Scorer.get_id
def get_id(self, grp): """ Return a hash of the tuple of indices that specify the group """ thehash = hex(hash(grp)) if ISPY3: # use default encoding to get bytes thehash = thehash.encode() return self.cache.get(grp, hashlib.sha1(thehash).hexdigest())
python
def get_id(self, grp): """ Return a hash of the tuple of indices that specify the group """ thehash = hex(hash(grp)) if ISPY3: # use default encoding to get bytes thehash = thehash.encode() return self.cache.get(grp, hashlib.sha1(thehash).hexdigest())
[ "def", "get_id", "(", "self", ",", "grp", ")", ":", "thehash", "=", "hex", "(", "hash", "(", "grp", ")", ")", "if", "ISPY3", ":", "# use default encoding to get bytes", "thehash", "=", "thehash", ".", "encode", "(", ")", "return", "self", ".", "cache", ...
Return a hash of the tuple of indices that specify the group
[ "Return", "a", "hash", "of", "the", "tuple", "of", "indices", "that", "specify", "the", "group" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L534-L541
46,202
kgori/treeCl
treeCl/collection.py
Scorer.check_work_done
def check_work_done(self, grp): """ Check for the existence of alignment and result files. """ id_ = self.get_id(grp) concat_file = os.path.join(self.cache_dir, '{}.phy'.format(id_)) result_file = os.path.join(self.cache_dir, '{}.{}.json'.format(id_, self.task_interface.n...
python
def check_work_done(self, grp): """ Check for the existence of alignment and result files. """ id_ = self.get_id(grp) concat_file = os.path.join(self.cache_dir, '{}.phy'.format(id_)) result_file = os.path.join(self.cache_dir, '{}.{}.json'.format(id_, self.task_interface.n...
[ "def", "check_work_done", "(", "self", ",", "grp", ")", ":", "id_", "=", "self", ".", "get_id", "(", "grp", ")", "concat_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "cache_dir", ",", "'{}.phy'", ".", "format", "(", "id_", ")", ")"...
Check for the existence of alignment and result files.
[ "Check", "for", "the", "existence", "of", "alignment", "and", "result", "files", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L543-L550
46,203
kgori/treeCl
treeCl/collection.py
Scorer.write_group
def write_group(self, grp, overwrite=False, **kwargs): """ Write the concatenated alignment to disk in the location specified by self.cache_dir """ id_ = self.get_id(grp) alignment_done, result_done = self.check_work_done(grp) self.cache[grp] = id_ al_file...
python
def write_group(self, grp, overwrite=False, **kwargs): """ Write the concatenated alignment to disk in the location specified by self.cache_dir """ id_ = self.get_id(grp) alignment_done, result_done = self.check_work_done(grp) self.cache[grp] = id_ al_file...
[ "def", "write_group", "(", "self", ",", "grp", ",", "overwrite", "=", "False", ",", "*", "*", "kwargs", ")", ":", "id_", "=", "self", ".", "get_id", "(", "grp", ")", "alignment_done", ",", "result_done", "=", "self", ".", "check_work_done", "(", "grp",...
Write the concatenated alignment to disk in the location specified by self.cache_dir
[ "Write", "the", "concatenated", "alignment", "to", "disk", "in", "the", "location", "specified", "by", "self", ".", "cache_dir" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L552-L568
46,204
kgori/treeCl
treeCl/collection.py
Scorer.get_group_result
def get_group_result(self, grp, **kwargs): """ Retrieve the results for a group. Needs this to already be calculated - errors out if result not available. """ id_ = self.get_id(grp) self.cache[grp] = id_ # Check if this file is already processed alignment...
python
def get_group_result(self, grp, **kwargs): """ Retrieve the results for a group. Needs this to already be calculated - errors out if result not available. """ id_ = self.get_id(grp) self.cache[grp] = id_ # Check if this file is already processed alignment...
[ "def", "get_group_result", "(", "self", ",", "grp", ",", "*", "*", "kwargs", ")", ":", "id_", "=", "self", ".", "get_id", "(", "grp", ")", "self", ".", "cache", "[", "grp", "]", "=", "id_", "# Check if this file is already processed", "alignment_written", ...
Retrieve the results for a group. Needs this to already be calculated - errors out if result not available.
[ "Retrieve", "the", "results", "for", "a", "group", ".", "Needs", "this", "to", "already", "be", "calculated", "-", "errors", "out", "if", "result", "not", "available", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L570-L588
46,205
kgori/treeCl
treeCl/collection.py
Scorer.get_partition_score
def get_partition_score(self, p): """ Assumes analysis is done and written to id.json! """ scores = [] for grp in p.get_membership(): try: result = self.get_group_result(grp) scores.append(result['likelihood']) except ValueE...
python
def get_partition_score(self, p): """ Assumes analysis is done and written to id.json! """ scores = [] for grp in p.get_membership(): try: result = self.get_group_result(grp) scores.append(result['likelihood']) except ValueE...
[ "def", "get_partition_score", "(", "self", ",", "p", ")", ":", "scores", "=", "[", "]", "for", "grp", "in", "p", ".", "get_membership", "(", ")", ":", "try", ":", "result", "=", "self", ".", "get_group_result", "(", "grp", ")", "scores", ".", "append...
Assumes analysis is done and written to id.json!
[ "Assumes", "analysis", "is", "done", "and", "written", "to", "id", ".", "json!" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L640-L651
46,206
kgori/treeCl
treeCl/collection.py
Scorer.get_partition_trees
def get_partition_trees(self, p): """ Return the trees associated with a partition, p """ trees = [] for grp in p.get_membership(): try: result = self.get_group_result(grp) trees.append(result['ml_tree']) except ValueError: ...
python
def get_partition_trees(self, p): """ Return the trees associated with a partition, p """ trees = [] for grp in p.get_membership(): try: result = self.get_group_result(grp) trees.append(result['ml_tree']) except ValueError: ...
[ "def", "get_partition_trees", "(", "self", ",", "p", ")", ":", "trees", "=", "[", "]", "for", "grp", "in", "p", ".", "get_membership", "(", ")", ":", "try", ":", "result", "=", "self", ".", "get_group_result", "(", "grp", ")", "trees", ".", "append",...
Return the trees associated with a partition, p
[ "Return", "the", "trees", "associated", "with", "a", "partition", "p" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L653-L665
46,207
kgori/treeCl
treeCl/collection.py
Optimiser.expect
def expect(self, use_proportions=True): """ The Expectation step of the CEM algorithm """ changed = self.get_changed(self.partition, self.prev_partition) lk_table = self.generate_lktable(self.partition, changed, use_proportions) self.table = self.likelihood_table_to_probs(lk_table)
python
def expect(self, use_proportions=True): """ The Expectation step of the CEM algorithm """ changed = self.get_changed(self.partition, self.prev_partition) lk_table = self.generate_lktable(self.partition, changed, use_proportions) self.table = self.likelihood_table_to_probs(lk_table)
[ "def", "expect", "(", "self", ",", "use_proportions", "=", "True", ")", ":", "changed", "=", "self", ".", "get_changed", "(", "self", ".", "partition", ",", "self", ".", "prev_partition", ")", "lk_table", "=", "self", ".", "generate_lktable", "(", "self", ...
The Expectation step of the CEM algorithm
[ "The", "Expectation", "step", "of", "the", "CEM", "algorithm" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L791-L795
46,208
kgori/treeCl
treeCl/collection.py
Optimiser.classify
def classify(self, table, weighted_choice=False, transform=None): """ The Classification step of the CEM algorithm """ assert table.shape[1] == self.numgrp if weighted_choice: if transform is not None: probs = transform_fn(table.copy(), transform) # else:...
python
def classify(self, table, weighted_choice=False, transform=None): """ The Classification step of the CEM algorithm """ assert table.shape[1] == self.numgrp if weighted_choice: if transform is not None: probs = transform_fn(table.copy(), transform) # else:...
[ "def", "classify", "(", "self", ",", "table", ",", "weighted_choice", "=", "False", ",", "transform", "=", "None", ")", ":", "assert", "table", ".", "shape", "[", "1", "]", "==", "self", ".", "numgrp", "if", "weighted_choice", ":", "if", "transform", "...
The Classification step of the CEM algorithm
[ "The", "Classification", "step", "of", "the", "CEM", "algorithm" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L797-L816
46,209
kgori/treeCl
treeCl/collection.py
Optimiser.maximise
def maximise(self, **kwargs): """ The Maximisation step of the CEM algorithm """ self.scorer.write_partition(self.partition) self.scorer.analyse_cache_dir(**kwargs) self.likelihood = self.scorer.get_partition_score(self.partition) self.scorer.clean_cache() changed = self....
python
def maximise(self, **kwargs): """ The Maximisation step of the CEM algorithm """ self.scorer.write_partition(self.partition) self.scorer.analyse_cache_dir(**kwargs) self.likelihood = self.scorer.get_partition_score(self.partition) self.scorer.clean_cache() changed = self....
[ "def", "maximise", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "scorer", ".", "write_partition", "(", "self", ".", "partition", ")", "self", ".", "scorer", ".", "analyse_cache_dir", "(", "*", "*", "kwargs", ")", "self", ".", "likelihoo...
The Maximisation step of the CEM algorithm
[ "The", "Maximisation", "step", "of", "the", "CEM", "algorithm" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L818-L826
46,210
kgori/treeCl
treeCl/collection.py
Optimiser.set_partition
def set_partition(self, partition): """ Store the partition in self.partition, and move the old self.partition into self.prev_partition """ assert len(partition) == self.numgrp self.partition, self.prev_partition = partition, self.partition
python
def set_partition(self, partition): """ Store the partition in self.partition, and move the old self.partition into self.prev_partition """ assert len(partition) == self.numgrp self.partition, self.prev_partition = partition, self.partition
[ "def", "set_partition", "(", "self", ",", "partition", ")", ":", "assert", "len", "(", "partition", ")", "==", "self", ".", "numgrp", "self", ".", "partition", ",", "self", ".", "prev_partition", "=", "partition", ",", "self", ".", "partition" ]
Store the partition in self.partition, and move the old self.partition into self.prev_partition
[ "Store", "the", "partition", "in", "self", ".", "partition", "and", "move", "the", "old", "self", ".", "partition", "into", "self", ".", "prev_partition" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L844-L850
46,211
kgori/treeCl
treeCl/collection.py
Optimiser.get_changed
def get_changed(self, p1, p2): """ Return the loci that are in clusters that have changed between partitions p1 and p2 """ if p1 is None or p2 is None: return list(range(len(self.insts))) return set(flatten_list(set(p1) - set(p2)))
python
def get_changed(self, p1, p2): """ Return the loci that are in clusters that have changed between partitions p1 and p2 """ if p1 is None or p2 is None: return list(range(len(self.insts))) return set(flatten_list(set(p1) - set(p2)))
[ "def", "get_changed", "(", "self", ",", "p1", ",", "p2", ")", ":", "if", "p1", "is", "None", "or", "p2", "is", "None", ":", "return", "list", "(", "range", "(", "len", "(", "self", ".", "insts", ")", ")", ")", "return", "set", "(", "flatten_list"...
Return the loci that are in clusters that have changed between partitions p1 and p2
[ "Return", "the", "loci", "that", "are", "in", "clusters", "that", "have", "changed", "between", "partitions", "p1", "and", "p2" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L868-L875
46,212
kgori/treeCl
treeCl/collection.py
Optimiser._update_likelihood_model
def _update_likelihood_model(self, inst, partition_parameters, tree): """ Set parameters of likelihood model - inst - using values in dictionary - partition_parameters -, and - tree - """ # Build transition matrix from dict model = partition_parameters['model'] ...
python
def _update_likelihood_model(self, inst, partition_parameters, tree): """ Set parameters of likelihood model - inst - using values in dictionary - partition_parameters -, and - tree - """ # Build transition matrix from dict model = partition_parameters['model'] ...
[ "def", "_update_likelihood_model", "(", "self", ",", "inst", ",", "partition_parameters", ",", "tree", ")", ":", "# Build transition matrix from dict", "model", "=", "partition_parameters", "[", "'model'", "]", "freqs", "=", "partition_parameters", ".", "get", "(", ...
Set parameters of likelihood model - inst - using values in dictionary - partition_parameters -, and - tree -
[ "Set", "parameters", "of", "likelihood", "model", "-", "inst", "-", "using", "values", "in", "dictionary", "-", "partition_parameters", "-", "and", "-", "tree", "-" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L911-L935
46,213
kgori/treeCl
treeCl/collection.py
Optimiser._fill_empty_groups_old
def _fill_empty_groups_old(self, probs, assignment): """ Does the simple thing - if any group is empty, but needs to have at least one member, assign the data point with highest probability of membership """ new_assignment = np.array(assignment.tolist()) for k in range(self.numgr...
python
def _fill_empty_groups_old(self, probs, assignment): """ Does the simple thing - if any group is empty, but needs to have at least one member, assign the data point with highest probability of membership """ new_assignment = np.array(assignment.tolist()) for k in range(self.numgr...
[ "def", "_fill_empty_groups_old", "(", "self", ",", "probs", ",", "assignment", ")", ":", "new_assignment", "=", "np", ".", "array", "(", "assignment", ".", "tolist", "(", ")", ")", "for", "k", "in", "range", "(", "self", ".", "numgrp", ")", ":", "if", ...
Does the simple thing - if any group is empty, but needs to have at least one member, assign the data point with highest probability of membership
[ "Does", "the", "simple", "thing", "-", "if", "any", "group", "is", "empty", "but", "needs", "to", "have", "at", "least", "one", "member", "assign", "the", "data", "point", "with", "highest", "probability", "of", "membership" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L1005-L1016
46,214
kgori/treeCl
treeCl/bootstrap.py
jac
def jac(x,a): """ Jacobian matrix given Christophe's suggestion of f """ return (x-a) / np.sqrt(((x-a)**2).sum(1))[:,np.newaxis]
python
def jac(x,a): """ Jacobian matrix given Christophe's suggestion of f """ return (x-a) / np.sqrt(((x-a)**2).sum(1))[:,np.newaxis]
[ "def", "jac", "(", "x", ",", "a", ")", ":", "return", "(", "x", "-", "a", ")", "/", "np", ".", "sqrt", "(", "(", "(", "x", "-", "a", ")", "**", "2", ")", ".", "sum", "(", "1", ")", ")", "[", ":", ",", "np", ".", "newaxis", "]" ]
Jacobian matrix given Christophe's suggestion of f
[ "Jacobian", "matrix", "given", "Christophe", "s", "suggestion", "of", "f" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L70-L72
46,215
kgori/treeCl
treeCl/bootstrap.py
gradient
def gradient(x, a, c): """ J'.G """ return jac(x, a).T.dot(g(x, a, c))
python
def gradient(x, a, c): """ J'.G """ return jac(x, a).T.dot(g(x, a, c))
[ "def", "gradient", "(", "x", ",", "a", ",", "c", ")", ":", "return", "jac", "(", "x", ",", "a", ")", ".", "T", ".", "dot", "(", "g", "(", "x", ",", "a", ",", "c", ")", ")" ]
J'.G
[ "J", ".", "G" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L74-L76
46,216
kgori/treeCl
treeCl/bootstrap.py
hessian
def hessian(x, a): """ J'.J """ j = jac(x, a) return j.T.dot(j)
python
def hessian(x, a): """ J'.J """ j = jac(x, a) return j.T.dot(j)
[ "def", "hessian", "(", "x", ",", "a", ")", ":", "j", "=", "jac", "(", "x", ",", "a", ")", "return", "j", ".", "T", ".", "dot", "(", "j", ")" ]
J'.J
[ "J", ".", "J" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L78-L81
46,217
kgori/treeCl
treeCl/bootstrap.py
grad_desc_update
def grad_desc_update(x, a, c, step=0.01): """ Given a value of x, return a better x using gradient descent """ return x - step * gradient(x,a,c)
python
def grad_desc_update(x, a, c, step=0.01): """ Given a value of x, return a better x using gradient descent """ return x - step * gradient(x,a,c)
[ "def", "grad_desc_update", "(", "x", ",", "a", ",", "c", ",", "step", "=", "0.01", ")", ":", "return", "x", "-", "step", "*", "gradient", "(", "x", ",", "a", ",", "c", ")" ]
Given a value of x, return a better x using gradient descent
[ "Given", "a", "value", "of", "x", "return", "a", "better", "x", "using", "gradient", "descent" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L83-L88
46,218
kgori/treeCl
treeCl/bootstrap.py
optimise_levenberg_marquardt
def optimise_levenberg_marquardt(x, a, c, damping=0.001, tolerance=0.001): """ Optimise value of x using levenberg-marquardt """ x_new = x x_old = x-1 # dummy value f_old = f(x_new, a, c) while np.abs(x_new - x_old).sum() > tolerance: x_old = x_new x_tmp = levenberg_marquardt...
python
def optimise_levenberg_marquardt(x, a, c, damping=0.001, tolerance=0.001): """ Optimise value of x using levenberg-marquardt """ x_new = x x_old = x-1 # dummy value f_old = f(x_new, a, c) while np.abs(x_new - x_old).sum() > tolerance: x_old = x_new x_tmp = levenberg_marquardt...
[ "def", "optimise_levenberg_marquardt", "(", "x", ",", "a", ",", "c", ",", "damping", "=", "0.001", ",", "tolerance", "=", "0.001", ")", ":", "x_new", "=", "x", "x_old", "=", "x", "-", "1", "# dummy value", "f_old", "=", "f", "(", "x_new", ",", "a", ...
Optimise value of x using levenberg-marquardt
[ "Optimise", "value", "of", "x", "using", "levenberg", "-", "marquardt" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L143-L160
46,219
kgori/treeCl
treeCl/bootstrap.py
run_out_of_sample_mds
def run_out_of_sample_mds(boot_collection, ref_collection, ref_distance_matrix, index, dimensions, task=_fast_geo, rooted=False, **kwargs): """ index = index of the locus the bootstrap sample corresponds to - only important if using recalc=True in kwargs """ fit = np.empty((len(boot_collecti...
python
def run_out_of_sample_mds(boot_collection, ref_collection, ref_distance_matrix, index, dimensions, task=_fast_geo, rooted=False, **kwargs): """ index = index of the locus the bootstrap sample corresponds to - only important if using recalc=True in kwargs """ fit = np.empty((len(boot_collecti...
[ "def", "run_out_of_sample_mds", "(", "boot_collection", ",", "ref_collection", ",", "ref_distance_matrix", ",", "index", ",", "dimensions", ",", "task", "=", "_fast_geo", ",", "rooted", "=", "False", ",", "*", "*", "kwargs", ")", ":", "fit", "=", "np", ".", ...
index = index of the locus the bootstrap sample corresponds to - only important if using recalc=True in kwargs
[ "index", "=", "index", "of", "the", "locus", "the", "bootstrap", "sample", "corresponds", "to", "-", "only", "important", "if", "using", "recalc", "=", "True", "in", "kwargs" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L190-L206
46,220
kgori/treeCl
treeCl/bootstrap.py
stress
def stress(ref_cds, est_cds): """ Kruskal's stress """ ref_dists = pdist(ref_cds) est_dists = pdist(est_cds) return np.sqrt(((ref_dists - est_dists)**2).sum() / (ref_dists**2).sum())
python
def stress(ref_cds, est_cds): """ Kruskal's stress """ ref_dists = pdist(ref_cds) est_dists = pdist(est_cds) return np.sqrt(((ref_dists - est_dists)**2).sum() / (ref_dists**2).sum())
[ "def", "stress", "(", "ref_cds", ",", "est_cds", ")", ":", "ref_dists", "=", "pdist", "(", "ref_cds", ")", "est_dists", "=", "pdist", "(", "est_cds", ")", "return", "np", ".", "sqrt", "(", "(", "(", "ref_dists", "-", "est_dists", ")", "**", "2", ")",...
Kruskal's stress
[ "Kruskal", "s", "stress" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L224-L230
46,221
kgori/treeCl
treeCl/bootstrap.py
rmsd
def rmsd(ref_cds, est_cds): """ Root-mean-squared-difference """ ref_dists = pdist(ref_cds) est_dists = pdist(est_cds) return np.sqrt(((ref_dists - est_dists)**2).mean())
python
def rmsd(ref_cds, est_cds): """ Root-mean-squared-difference """ ref_dists = pdist(ref_cds) est_dists = pdist(est_cds) return np.sqrt(((ref_dists - est_dists)**2).mean())
[ "def", "rmsd", "(", "ref_cds", ",", "est_cds", ")", ":", "ref_dists", "=", "pdist", "(", "ref_cds", ")", "est_dists", "=", "pdist", "(", "est_cds", ")", "return", "np", ".", "sqrt", "(", "(", "(", "ref_dists", "-", "est_dists", ")", "**", "2", ")", ...
Root-mean-squared-difference
[ "Root", "-", "mean", "-", "squared", "-", "difference" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L237-L243
46,222
kgori/treeCl
treeCl/bootstrap.py
OptimiseDistanceFit.levenberg_marquardt
def levenberg_marquardt(self, start_x=None, damping=1.0e-3, tolerance=1.0e-6): """ Optimise value of x using levenberg marquardt """ if start_x is None: start_x = self._analytical_fitter.fit(self._c) return optimise_levenberg_marquardt(start_x, self._a, self._c, toler...
python
def levenberg_marquardt(self, start_x=None, damping=1.0e-3, tolerance=1.0e-6): """ Optimise value of x using levenberg marquardt """ if start_x is None: start_x = self._analytical_fitter.fit(self._c) return optimise_levenberg_marquardt(start_x, self._a, self._c, toler...
[ "def", "levenberg_marquardt", "(", "self", ",", "start_x", "=", "None", ",", "damping", "=", "1.0e-3", ",", "tolerance", "=", "1.0e-6", ")", ":", "if", "start_x", "is", "None", ":", "start_x", "=", "self", ".", "_analytical_fitter", ".", "fit", "(", "sel...
Optimise value of x using levenberg marquardt
[ "Optimise", "value", "of", "x", "using", "levenberg", "marquardt" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L316-L322
46,223
kgori/treeCl
treeCl/bootstrap.py
AnalyticalFit._make_A_and_part_of_b_adjacent
def _make_A_and_part_of_b_adjacent(self, ref_crds): """ Make A and part of b. See docstring of this class for answer to "What are A and b?" """ rot = self._rotate_rows(ref_crds) A = 2*(rot - ref_crds) partial_b = (rot**2 - ref_crds**2).sum(1) return A, par...
python
def _make_A_and_part_of_b_adjacent(self, ref_crds): """ Make A and part of b. See docstring of this class for answer to "What are A and b?" """ rot = self._rotate_rows(ref_crds) A = 2*(rot - ref_crds) partial_b = (rot**2 - ref_crds**2).sum(1) return A, par...
[ "def", "_make_A_and_part_of_b_adjacent", "(", "self", ",", "ref_crds", ")", ":", "rot", "=", "self", ".", "_rotate_rows", "(", "ref_crds", ")", "A", "=", "2", "*", "(", "rot", "-", "ref_crds", ")", "partial_b", "=", "(", "rot", "**", "2", "-", "ref_crd...
Make A and part of b. See docstring of this class for answer to "What are A and b?"
[ "Make", "A", "and", "part", "of", "b", ".", "See", "docstring", "of", "this", "class", "for", "answer", "to", "What", "are", "A", "and", "b?" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L442-L450
46,224
pudo/jsonmapping
jsonmapping/elastic.py
generate_schema_mapping
def generate_schema_mapping(resolver, schema_uri, depth=1): """ Try and recursively iterate a JSON schema and to generate an ES mapping that encasulates it. """ visitor = SchemaVisitor({'$ref': schema_uri}, resolver) return _generate_schema_mapping(visitor, set(), depth)
python
def generate_schema_mapping(resolver, schema_uri, depth=1): """ Try and recursively iterate a JSON schema and to generate an ES mapping that encasulates it. """ visitor = SchemaVisitor({'$ref': schema_uri}, resolver) return _generate_schema_mapping(visitor, set(), depth)
[ "def", "generate_schema_mapping", "(", "resolver", ",", "schema_uri", ",", "depth", "=", "1", ")", ":", "visitor", "=", "SchemaVisitor", "(", "{", "'$ref'", ":", "schema_uri", "}", ",", "resolver", ")", "return", "_generate_schema_mapping", "(", "visitor", ","...
Try and recursively iterate a JSON schema and to generate an ES mapping that encasulates it.
[ "Try", "and", "recursively", "iterate", "a", "JSON", "schema", "and", "to", "generate", "an", "ES", "mapping", "that", "encasulates", "it", "." ]
4cf0a20a393ba82e00651c6fd39522a67a0155de
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/elastic.py#L6-L10
46,225
kgori/treeCl
treeCl/tasks.py
phyml_task
def phyml_task(alignment_file, model, **kwargs): """ Kwargs are passed to the Phyml process command line """ import re fl = os.path.abspath(alignment_file) ph = Phyml(verbose=False) if model in ['JC69', 'K80', 'F81', 'F84', 'HKY85', 'TN93', 'GTR']: datatype = 'nt' elif re.search(...
python
def phyml_task(alignment_file, model, **kwargs): """ Kwargs are passed to the Phyml process command line """ import re fl = os.path.abspath(alignment_file) ph = Phyml(verbose=False) if model in ['JC69', 'K80', 'F81', 'F84', 'HKY85', 'TN93', 'GTR']: datatype = 'nt' elif re.search(...
[ "def", "phyml_task", "(", "alignment_file", ",", "model", ",", "*", "*", "kwargs", ")", ":", "import", "re", "fl", "=", "os", ".", "path", ".", "abspath", "(", "alignment_file", ")", "ph", "=", "Phyml", "(", "verbose", "=", "False", ")", "if", "model...
Kwargs are passed to the Phyml process command line
[ "Kwargs", "are", "passed", "to", "the", "Phyml", "process", "command", "line" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tasks.py#L111-L145
46,226
pudo/jsonmapping
jsonmapping/util.py
validate_mapping
def validate_mapping(mapping): """ Validate a mapping configuration file against the relevant schema. """ file_path = os.path.join(os.path.dirname(__file__), 'schemas', 'mapping.json') with open(file_path, 'r') as fh: validator = Draft4Validator(json.load(fh)) va...
python
def validate_mapping(mapping): """ Validate a mapping configuration file against the relevant schema. """ file_path = os.path.join(os.path.dirname(__file__), 'schemas', 'mapping.json') with open(file_path, 'r') as fh: validator = Draft4Validator(json.load(fh)) va...
[ "def", "validate_mapping", "(", "mapping", ")", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'schemas'", ",", "'mapping.json'", ")", "with", "open", "(", "file_path", ",", "'...
Validate a mapping configuration file against the relevant schema.
[ "Validate", "a", "mapping", "configuration", "file", "against", "the", "relevant", "schema", "." ]
4cf0a20a393ba82e00651c6fd39522a67a0155de
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/util.py#L7-L14
46,227
kgori/treeCl
treeCl/plotter.py
Plotter.heatmap
def heatmap(self, partition=None, cmap=CM.Blues): """ Plots a visual representation of a distance matrix """ if isinstance(self.dm, DistanceMatrix): length = self.dm.values.shape[0] else: length = self.dm.shape[0] datamax = float(np.abs(self.dm).max()) fi...
python
def heatmap(self, partition=None, cmap=CM.Blues): """ Plots a visual representation of a distance matrix """ if isinstance(self.dm, DistanceMatrix): length = self.dm.values.shape[0] else: length = self.dm.shape[0] datamax = float(np.abs(self.dm).max()) fi...
[ "def", "heatmap", "(", "self", ",", "partition", "=", "None", ",", "cmap", "=", "CM", ".", "Blues", ")", ":", "if", "isinstance", "(", "self", ".", "dm", ",", "DistanceMatrix", ")", ":", "length", "=", "self", ".", "dm", ".", "values", ".", "shape"...
Plots a visual representation of a distance matrix
[ "Plots", "a", "visual", "representation", "of", "a", "distance", "matrix" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/plotter.py#L249-L274
46,228
kgori/treeCl
treeCl/concatenation.py
Concatenation.get_tree_collection_strings
def get_tree_collection_strings(self, scale=1, guide_tree=None): """ Function to get input strings for tree_collection tree_collection needs distvar, genome_map and labels - these are returned in the order above """ records = [self.collection[i] for i in self.indices] ret...
python
def get_tree_collection_strings(self, scale=1, guide_tree=None): """ Function to get input strings for tree_collection tree_collection needs distvar, genome_map and labels - these are returned in the order above """ records = [self.collection[i] for i in self.indices] ret...
[ "def", "get_tree_collection_strings", "(", "self", ",", "scale", "=", "1", ",", "guide_tree", "=", "None", ")", ":", "records", "=", "[", "self", ".", "collection", "[", "i", "]", "for", "i", "in", "self", ".", "indices", "]", "return", "TreeCollectionTa...
Function to get input strings for tree_collection tree_collection needs distvar, genome_map and labels - these are returned in the order above
[ "Function", "to", "get", "input", "strings", "for", "tree_collection", "tree_collection", "needs", "distvar", "genome_map", "and", "labels", "-", "these", "are", "returned", "in", "the", "order", "above" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/concatenation.py#L90-L96
46,229
getsentry/libsourcemap
libsourcemap/highlevel.py
from_json
def from_json(buffer, auto_flatten=True, raise_for_index=True): """Parses a JSON string into either a view or an index. If auto flatten is enabled a sourcemap index that does not contain external references is automatically flattened into a view. By default if an index would be returned an `IndexedSou...
python
def from_json(buffer, auto_flatten=True, raise_for_index=True): """Parses a JSON string into either a view or an index. If auto flatten is enabled a sourcemap index that does not contain external references is automatically flattened into a view. By default if an index would be returned an `IndexedSou...
[ "def", "from_json", "(", "buffer", ",", "auto_flatten", "=", "True", ",", "raise_for_index", "=", "True", ")", ":", "buffer", "=", "to_bytes", "(", "buffer", ")", "view_out", "=", "_ffi", ".", "new", "(", "'lsm_view_t **'", ")", "index_out", "=", "_ffi", ...
Parses a JSON string into either a view or an index. If auto flatten is enabled a sourcemap index that does not contain external references is automatically flattened into a view. By default if an index would be returned an `IndexedSourceMap` error is raised instead which holds the index.
[ "Parses", "a", "JSON", "string", "into", "either", "a", "view", "or", "an", "index", ".", "If", "auto", "flatten", "is", "enabled", "a", "sourcemap", "index", "that", "does", "not", "contain", "external", "references", "is", "automatically", "flattened", "in...
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L62-L89
46,230
getsentry/libsourcemap
libsourcemap/highlevel.py
View.from_memdb
def from_memdb(buffer): """Creates a sourcemap view from MemDB bytes.""" buffer = to_bytes(buffer) return View._from_ptr(rustcall( _lib.lsm_view_from_memdb, buffer, len(buffer)))
python
def from_memdb(buffer): """Creates a sourcemap view from MemDB bytes.""" buffer = to_bytes(buffer) return View._from_ptr(rustcall( _lib.lsm_view_from_memdb, buffer, len(buffer)))
[ "def", "from_memdb", "(", "buffer", ")", ":", "buffer", "=", "to_bytes", "(", "buffer", ")", "return", "View", ".", "_from_ptr", "(", "rustcall", "(", "_lib", ".", "lsm_view_from_memdb", ",", "buffer", ",", "len", "(", "buffer", ")", ")", ")" ]
Creates a sourcemap view from MemDB bytes.
[ "Creates", "a", "sourcemap", "view", "from", "MemDB", "bytes", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L114-L119
46,231
getsentry/libsourcemap
libsourcemap/highlevel.py
View.from_memdb_file
def from_memdb_file(path): """Creates a sourcemap view from MemDB at a given file.""" path = to_bytes(path) return View._from_ptr(rustcall(_lib.lsm_view_from_memdb_file, path))
python
def from_memdb_file(path): """Creates a sourcemap view from MemDB at a given file.""" path = to_bytes(path) return View._from_ptr(rustcall(_lib.lsm_view_from_memdb_file, path))
[ "def", "from_memdb_file", "(", "path", ")", ":", "path", "=", "to_bytes", "(", "path", ")", "return", "View", ".", "_from_ptr", "(", "rustcall", "(", "_lib", ".", "lsm_view_from_memdb_file", ",", "path", ")", ")" ]
Creates a sourcemap view from MemDB at a given file.
[ "Creates", "a", "sourcemap", "view", "from", "MemDB", "at", "a", "given", "file", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L122-L125
46,232
getsentry/libsourcemap
libsourcemap/highlevel.py
View.dump_memdb
def dump_memdb(self, with_source_contents=True, with_names=True): """Dumps a sourcemap in MemDB format into bytes.""" len_out = _ffi.new('unsigned int *') buf = rustcall( _lib.lsm_view_dump_memdb, self._get_ptr(), len_out, with_source_contents, with_names) ...
python
def dump_memdb(self, with_source_contents=True, with_names=True): """Dumps a sourcemap in MemDB format into bytes.""" len_out = _ffi.new('unsigned int *') buf = rustcall( _lib.lsm_view_dump_memdb, self._get_ptr(), len_out, with_source_contents, with_names) ...
[ "def", "dump_memdb", "(", "self", ",", "with_source_contents", "=", "True", ",", "with_names", "=", "True", ")", ":", "len_out", "=", "_ffi", ".", "new", "(", "'unsigned int *'", ")", "buf", "=", "rustcall", "(", "_lib", ".", "lsm_view_dump_memdb", ",", "s...
Dumps a sourcemap in MemDB format into bytes.
[ "Dumps", "a", "sourcemap", "in", "MemDB", "format", "into", "bytes", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L138-L149
46,233
getsentry/libsourcemap
libsourcemap/highlevel.py
View.lookup_token
def lookup_token(self, line, col): """Given a minified location, this tries to locate the closest token that is a match. Returns `None` if no match can be found. """ # Silently ignore underflows if line < 0 or col < 0: return None tok_out = _ffi.new('lsm_toke...
python
def lookup_token(self, line, col): """Given a minified location, this tries to locate the closest token that is a match. Returns `None` if no match can be found. """ # Silently ignore underflows if line < 0 or col < 0: return None tok_out = _ffi.new('lsm_toke...
[ "def", "lookup_token", "(", "self", ",", "line", ",", "col", ")", ":", "# Silently ignore underflows", "if", "line", "<", "0", "or", "col", "<", "0", ":", "return", "None", "tok_out", "=", "_ffi", ".", "new", "(", "'lsm_token_t *'", ")", "if", "rustcall"...
Given a minified location, this tries to locate the closest token that is a match. Returns `None` if no match can be found.
[ "Given", "a", "minified", "location", "this", "tries", "to", "locate", "the", "closest", "token", "that", "is", "a", "match", ".", "Returns", "None", "if", "no", "match", "can", "be", "found", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L151-L161
46,234
getsentry/libsourcemap
libsourcemap/highlevel.py
View.get_original_function_name
def get_original_function_name(self, line, col, minified_name, minified_source): """Given a token location and a minified function name and the minified source file this returns the original function name if it can be found of the minified function in scope. ...
python
def get_original_function_name(self, line, col, minified_name, minified_source): """Given a token location and a minified function name and the minified source file this returns the original function name if it can be found of the minified function in scope. ...
[ "def", "get_original_function_name", "(", "self", ",", "line", ",", "col", ",", "minified_name", ",", "minified_source", ")", ":", "# Silently ignore underflows", "if", "line", "<", "0", "or", "col", "<", "0", ":", "return", "None", "minified_name", "=", "mini...
Given a token location and a minified function name and the minified source file this returns the original function name if it can be found of the minified function in scope.
[ "Given", "a", "token", "location", "and", "a", "minified", "function", "name", "and", "the", "minified", "source", "file", "this", "returns", "the", "original", "function", "name", "if", "it", "can", "be", "found", "of", "the", "minified", "function", "in", ...
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L163-L185
46,235
getsentry/libsourcemap
libsourcemap/highlevel.py
View.get_source_contents
def get_source_contents(self, src_id): """Given a source ID this returns the embedded sourcecode if there is. The sourcecode is returned as UTF-8 bytes for more efficient processing. """ len_out = _ffi.new('unsigned int *') must_free = _ffi.new('int *') rv = rust...
python
def get_source_contents(self, src_id): """Given a source ID this returns the embedded sourcecode if there is. The sourcecode is returned as UTF-8 bytes for more efficient processing. """ len_out = _ffi.new('unsigned int *') must_free = _ffi.new('int *') rv = rust...
[ "def", "get_source_contents", "(", "self", ",", "src_id", ")", ":", "len_out", "=", "_ffi", ".", "new", "(", "'unsigned int *'", ")", "must_free", "=", "_ffi", ".", "new", "(", "'int *'", ")", "rv", "=", "rustcall", "(", "_lib", ".", "lsm_view_get_source_c...
Given a source ID this returns the embedded sourcecode if there is. The sourcecode is returned as UTF-8 bytes for more efficient processing.
[ "Given", "a", "source", "ID", "this", "returns", "the", "embedded", "sourcecode", "if", "there", "is", ".", "The", "sourcecode", "is", "returned", "as", "UTF", "-", "8", "bytes", "for", "more", "efficient", "processing", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L187-L201
46,236
getsentry/libsourcemap
libsourcemap/highlevel.py
View.has_source_contents
def has_source_contents(self, src_id): """Checks if some sources exist.""" return bool(rustcall(_lib.lsm_view_has_source_contents, self._get_ptr(), src_id))
python
def has_source_contents(self, src_id): """Checks if some sources exist.""" return bool(rustcall(_lib.lsm_view_has_source_contents, self._get_ptr(), src_id))
[ "def", "has_source_contents", "(", "self", ",", "src_id", ")", ":", "return", "bool", "(", "rustcall", "(", "_lib", ".", "lsm_view_has_source_contents", ",", "self", ".", "_get_ptr", "(", ")", ",", "src_id", ")", ")" ]
Checks if some sources exist.
[ "Checks", "if", "some", "sources", "exist", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L203-L206
46,237
getsentry/libsourcemap
libsourcemap/highlevel.py
View.get_source_name
def get_source_name(self, src_id): """Returns the name of the given source.""" len_out = _ffi.new('unsigned int *') rv = rustcall(_lib.lsm_view_get_source_name, self._get_ptr(), src_id, len_out) if rv: return decode_rust_str(rv, len_out[0])
python
def get_source_name(self, src_id): """Returns the name of the given source.""" len_out = _ffi.new('unsigned int *') rv = rustcall(_lib.lsm_view_get_source_name, self._get_ptr(), src_id, len_out) if rv: return decode_rust_str(rv, len_out[0])
[ "def", "get_source_name", "(", "self", ",", "src_id", ")", ":", "len_out", "=", "_ffi", ".", "new", "(", "'unsigned int *'", ")", "rv", "=", "rustcall", "(", "_lib", ".", "lsm_view_get_source_name", ",", "self", ".", "_get_ptr", "(", ")", ",", "src_id", ...
Returns the name of the given source.
[ "Returns", "the", "name", "of", "the", "given", "source", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L208-L214
46,238
getsentry/libsourcemap
libsourcemap/highlevel.py
View.iter_sources
def iter_sources(self): """Iterates over all source names and IDs.""" for src_id in xrange(self.get_source_count()): yield src_id, self.get_source_name(src_id)
python
def iter_sources(self): """Iterates over all source names and IDs.""" for src_id in xrange(self.get_source_count()): yield src_id, self.get_source_name(src_id)
[ "def", "iter_sources", "(", "self", ")", ":", "for", "src_id", "in", "xrange", "(", "self", ".", "get_source_count", "(", ")", ")", ":", "yield", "src_id", ",", "self", ".", "get_source_name", "(", "src_id", ")" ]
Iterates over all source names and IDs.
[ "Iterates", "over", "all", "source", "names", "and", "IDs", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L221-L224
46,239
getsentry/libsourcemap
libsourcemap/highlevel.py
Index.from_json
def from_json(buffer): """Creates an index from a JSON string.""" buffer = to_bytes(buffer) return Index._from_ptr(rustcall( _lib.lsm_index_from_json, buffer, len(buffer)))
python
def from_json(buffer): """Creates an index from a JSON string.""" buffer = to_bytes(buffer) return Index._from_ptr(rustcall( _lib.lsm_index_from_json, buffer, len(buffer)))
[ "def", "from_json", "(", "buffer", ")", ":", "buffer", "=", "to_bytes", "(", "buffer", ")", "return", "Index", ".", "_from_ptr", "(", "rustcall", "(", "_lib", ".", "lsm_index_from_json", ",", "buffer", ",", "len", "(", "buffer", ")", ")", ")" ]
Creates an index from a JSON string.
[ "Creates", "an", "index", "from", "a", "JSON", "string", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L253-L258
46,240
getsentry/libsourcemap
libsourcemap/highlevel.py
Index.into_view
def into_view(self): """Converts the index into a view""" try: return View._from_ptr(rustcall( _lib.lsm_index_into_view, self._get_ptr())) finally: self._ptr = None
python
def into_view(self): """Converts the index into a view""" try: return View._from_ptr(rustcall( _lib.lsm_index_into_view, self._get_ptr())) finally: self._ptr = None
[ "def", "into_view", "(", "self", ")", ":", "try", ":", "return", "View", ".", "_from_ptr", "(", "rustcall", "(", "_lib", ".", "lsm_index_into_view", ",", "self", ".", "_get_ptr", "(", ")", ")", ")", "finally", ":", "self", ".", "_ptr", "=", "None" ]
Converts the index into a view
[ "Converts", "the", "index", "into", "a", "view" ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L276-L283
46,241
getsentry/libsourcemap
libsourcemap/highlevel.py
ProguardView.from_path
def from_path(filename): """Creates a sourcemap view from a file path.""" filename = to_bytes(filename) if NULL_BYTE in filename: raise ValueError('null byte in path') return ProguardView._from_ptr(rustcall( _lib.lsm_proguard_mapping_from_path, filenam...
python
def from_path(filename): """Creates a sourcemap view from a file path.""" filename = to_bytes(filename) if NULL_BYTE in filename: raise ValueError('null byte in path') return ProguardView._from_ptr(rustcall( _lib.lsm_proguard_mapping_from_path, filenam...
[ "def", "from_path", "(", "filename", ")", ":", "filename", "=", "to_bytes", "(", "filename", ")", "if", "NULL_BYTE", "in", "filename", ":", "raise", "ValueError", "(", "'null byte in path'", ")", "return", "ProguardView", ".", "_from_ptr", "(", "rustcall", "("...
Creates a sourcemap view from a file path.
[ "Creates", "a", "sourcemap", "view", "from", "a", "file", "path", "." ]
94b5a34814fafee9dc23da8ec0ccca77f30e3370
https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L311-L318
46,242
pudo/jsonmapping
jsonmapping/mapper.py
Mapper.apply
def apply(self, data): """ Apply the given mapping to ``data``, recursively. The return type is a tuple of a boolean and the resulting data element. The boolean indicates whether any values were mapped in the child nodes of the mapping. It is used to skip optional branches of the object ...
python
def apply(self, data): """ Apply the given mapping to ``data``, recursively. The return type is a tuple of a boolean and the resulting data element. The boolean indicates whether any values were mapped in the child nodes of the mapping. It is used to skip optional branches of the object ...
[ "def", "apply", "(", "self", ",", "data", ")", ":", "if", "self", ".", "visitor", ".", "is_object", ":", "obj", "=", "{", "}", "if", "self", ".", "visitor", ".", "parent", "is", "None", ":", "obj", "[", "'$schema'", "]", "=", "self", ".", "visito...
Apply the given mapping to ``data``, recursively. The return type is a tuple of a boolean and the resulting data element. The boolean indicates whether any values were mapped in the child nodes of the mapping. It is used to skip optional branches of the object graph.
[ "Apply", "the", "given", "mapping", "to", "data", "recursively", ".", "The", "return", "type", "is", "a", "tuple", "of", "a", "boolean", "and", "the", "resulting", "data", "element", ".", "The", "boolean", "indicates", "whether", "any", "values", "were", "...
4cf0a20a393ba82e00651c6fd39522a67a0155de
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/mapper.py#L52-L79
46,243
kgori/treeCl
treeCl/utils/translator.py
Translator.translate
def translate(self, text): """ Translate text, returns the modified text. """ # Reset substitution counter self.count = 0 # Process text return self._make_regex().sub(self, text)
python
def translate(self, text): """ Translate text, returns the modified text. """ # Reset substitution counter self.count = 0 # Process text return self._make_regex().sub(self, text)
[ "def", "translate", "(", "self", ",", "text", ")", ":", "# Reset substitution counter", "self", ".", "count", "=", "0", "# Process text", "return", "self", ".", "_make_regex", "(", ")", ".", "sub", "(", "self", ",", "text", ")" ]
Translate text, returns the modified text.
[ "Translate", "text", "returns", "the", "modified", "text", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/utils/translator.py#L25-L32
46,244
kgori/treeCl
treeCl/clustering.py
Spectral.cluster
def cluster(self, n, embed_dim=None, algo=spectral.SPECTRAL, method=methods.KMEANS): """ Cluster the embedded coordinates using spectral clustering Parameters ---------- n: int The number of clusters to return embed_dim: ...
python
def cluster(self, n, embed_dim=None, algo=spectral.SPECTRAL, method=methods.KMEANS): """ Cluster the embedded coordinates using spectral clustering Parameters ---------- n: int The number of clusters to return embed_dim: ...
[ "def", "cluster", "(", "self", ",", "n", ",", "embed_dim", "=", "None", ",", "algo", "=", "spectral", ".", "SPECTRAL", ",", "method", "=", "methods", ".", "KMEANS", ")", ":", "if", "n", "==", "1", ":", "return", "Partition", "(", "[", "1", "]", "...
Cluster the embedded coordinates using spectral clustering Parameters ---------- n: int The number of clusters to return embed_dim: int The dimensionality of the underlying coordinates ...
[ "Cluster", "the", "embedded", "coordinates", "using", "spectral", "clustering" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/clustering.py#L234-L279
46,245
kgori/treeCl
treeCl/clustering.py
Spectral.spectral_embedding
def spectral_embedding(self, n): """ Embed the points using spectral decomposition of the laplacian of the affinity matrix Parameters ---------- n: int The number of dimensions """ coords = spectral_embedding(self._affinity, n) ...
python
def spectral_embedding(self, n): """ Embed the points using spectral decomposition of the laplacian of the affinity matrix Parameters ---------- n: int The number of dimensions """ coords = spectral_embedding(self._affinity, n) ...
[ "def", "spectral_embedding", "(", "self", ",", "n", ")", ":", "coords", "=", "spectral_embedding", "(", "self", ".", "_affinity", ",", "n", ")", "return", "CoordinateMatrix", "(", "normalise_rows", "(", "coords", ")", ")" ]
Embed the points using spectral decomposition of the laplacian of the affinity matrix Parameters ---------- n: int The number of dimensions
[ "Embed", "the", "points", "using", "spectral", "decomposition", "of", "the", "laplacian", "of", "the", "affinity", "matrix" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/clustering.py#L281-L292
46,246
kgori/treeCl
treeCl/clustering.py
Spectral.kpca_embedding
def kpca_embedding(self, n): """ Embed the points using kernel PCA of the affinity matrix Parameters ---------- n: int The number of dimensions """ return self.dm.embedding(n, 'kpca', affinity_matrix=self._affinity)
python
def kpca_embedding(self, n): """ Embed the points using kernel PCA of the affinity matrix Parameters ---------- n: int The number of dimensions """ return self.dm.embedding(n, 'kpca', affinity_matrix=self._affinity)
[ "def", "kpca_embedding", "(", "self", ",", "n", ")", ":", "return", "self", ".", "dm", ".", "embedding", "(", "n", ",", "'kpca'", ",", "affinity_matrix", "=", "self", ".", "_affinity", ")" ]
Embed the points using kernel PCA of the affinity matrix Parameters ---------- n: int The number of dimensions
[ "Embed", "the", "points", "using", "kernel", "PCA", "of", "the", "affinity", "matrix" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/clustering.py#L309-L318
46,247
kgori/treeCl
treeCl/clustering.py
MultidimensionalScaling.cluster
def cluster(self, n, embed_dim=None, algo=mds.CLASSICAL, method=methods.KMEANS): """ Cluster the embedded coordinates using multidimensional scaling Parameters ---------- n: int The number of clusters to return embed_dim ...
python
def cluster(self, n, embed_dim=None, algo=mds.CLASSICAL, method=methods.KMEANS): """ Cluster the embedded coordinates using multidimensional scaling Parameters ---------- n: int The number of clusters to return embed_dim ...
[ "def", "cluster", "(", "self", ",", "n", ",", "embed_dim", "=", "None", ",", "algo", "=", "mds", ".", "CLASSICAL", ",", "method", "=", "methods", ".", "KMEANS", ")", ":", "if", "n", "==", "1", ":", "return", "Partition", "(", "[", "1", "]", "*", ...
Cluster the embedded coordinates using multidimensional scaling Parameters ---------- n: int The number of clusters to return embed_dim int The dimensionality of the underlying coordinates ...
[ "Cluster", "the", "embedded", "coordinates", "using", "multidimensional", "scaling" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/clustering.py#L329-L371
46,248
kgori/treeCl
treeCl/wrappers/abstract_wrapper.py
AbstractWrapper._log_thread
def _log_thread(self, pipe, queue): """ Start a thread logging output from pipe """ # thread function to log subprocess output (LOG is a queue) def enqueue_output(out, q): for line in iter(out.readline, b''): q.put(line.rstrip()) out.close...
python
def _log_thread(self, pipe, queue): """ Start a thread logging output from pipe """ # thread function to log subprocess output (LOG is a queue) def enqueue_output(out, q): for line in iter(out.readline, b''): q.put(line.rstrip()) out.close...
[ "def", "_log_thread", "(", "self", ",", "pipe", ",", "queue", ")", ":", "# thread function to log subprocess output (LOG is a queue)", "def", "enqueue_output", "(", "out", ",", "q", ")", ":", "for", "line", "in", "iter", "(", "out", ".", "readline", ",", "b''"...
Start a thread logging output from pipe
[ "Start", "a", "thread", "logging", "output", "from", "pipe" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/wrappers/abstract_wrapper.py#L143-L159
46,249
kgori/treeCl
treeCl/wrappers/abstract_wrapper.py
AbstractWrapper._search_for_executable
def _search_for_executable(self, executable): """ Search for file give in "executable". If it is not found, we try the environment PATH. Returns either the absolute path to the found executable, or None if the executable couldn't be found. """ if os.path.isfile(executable...
python
def _search_for_executable(self, executable): """ Search for file give in "executable". If it is not found, we try the environment PATH. Returns either the absolute path to the found executable, or None if the executable couldn't be found. """ if os.path.isfile(executable...
[ "def", "_search_for_executable", "(", "self", ",", "executable", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "executable", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "executable", ")", "else", ":", "envpath", "=", "os", ".",...
Search for file give in "executable". If it is not found, we try the environment PATH. Returns either the absolute path to the found executable, or None if the executable couldn't be found.
[ "Search", "for", "file", "give", "in", "executable", ".", "If", "it", "is", "not", "found", "we", "try", "the", "environment", "PATH", ".", "Returns", "either", "the", "absolute", "path", "to", "the", "found", "executable", "or", "None", "if", "the", "ex...
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/wrappers/abstract_wrapper.py#L161-L176
46,250
fedelemantuano/tika-app-python
tikapp/tikapp.py
TikaApp._command_template
def _command_template(self, switches, objectInput=None): """Template for Tika app commands Args: switches (list): list of switches to Tika app Jar objectInput (object): file object/standard input to analyze Return: Standard output data (unicode Python 2, str...
python
def _command_template(self, switches, objectInput=None): """Template for Tika app commands Args: switches (list): list of switches to Tika app Jar objectInput (object): file object/standard input to analyze Return: Standard output data (unicode Python 2, str...
[ "def", "_command_template", "(", "self", ",", "switches", ",", "objectInput", "=", "None", ")", ":", "command", "=", "[", "\"java\"", ",", "\"-jar\"", ",", "self", ".", "file_jar", ",", "\"-eUTF-8\"", "]", "if", "self", ".", "memory_allocation", ":", "comm...
Template for Tika app commands Args: switches (list): list of switches to Tika app Jar objectInput (object): file object/standard input to analyze Return: Standard output data (unicode Python 2, str Python 3)
[ "Template", "for", "Tika", "app", "commands" ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/tikapp.py#L76-L112
46,251
fedelemantuano/tika-app-python
tikapp/tikapp.py
TikaApp.detect_content_type
def detect_content_type(self, path=None, payload=None, objectInput=None): """ Return the content type of passed file or payload. Args: path (string): Path of file to analyze payload (string): Payload base64 to analyze objectInput (object): file object/standar...
python
def detect_content_type(self, path=None, payload=None, objectInput=None): """ Return the content type of passed file or payload. Args: path (string): Path of file to analyze payload (string): Payload base64 to analyze objectInput (object): file object/standar...
[ "def", "detect_content_type", "(", "self", ",", "path", "=", "None", ",", "payload", "=", "None", ",", "objectInput", "=", "None", ")", ":", "# From Python detection content type from stdin doesn't work TO FIX", "if", "objectInput", ":", "message", "=", "\"Detection c...
Return the content type of passed file or payload. Args: path (string): Path of file to analyze payload (string): Payload base64 to analyze objectInput (object): file object/standard input to analyze Returns: content type of file (string)
[ "Return", "the", "content", "type", "of", "passed", "file", "or", "payload", "." ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/tikapp.py#L119-L140
46,252
fedelemantuano/tika-app-python
tikapp/tikapp.py
TikaApp.extract_only_content
def extract_only_content(self, path=None, payload=None, objectInput=None): """ Return only the text content of passed file. These parameters are in OR. Only one of them can be analyzed. Args: path (string): Path of file to analyze payload (string): Payload base64...
python
def extract_only_content(self, path=None, payload=None, objectInput=None): """ Return only the text content of passed file. These parameters are in OR. Only one of them can be analyzed. Args: path (string): Path of file to analyze payload (string): Payload base64...
[ "def", "extract_only_content", "(", "self", ",", "path", "=", "None", ",", "payload", "=", "None", ",", "objectInput", "=", "None", ")", ":", "if", "objectInput", ":", "switches", "=", "[", "\"-t\"", "]", "result", "=", "self", ".", "_command_template", ...
Return only the text content of passed file. These parameters are in OR. Only one of them can be analyzed. Args: path (string): Path of file to analyze payload (string): Payload base64 to analyze objectInput (object): file object/standard input to analyze Re...
[ "Return", "only", "the", "text", "content", "of", "passed", "file", ".", "These", "parameters", "are", "in", "OR", ".", "Only", "one", "of", "them", "can", "be", "analyzed", "." ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/tikapp.py#L143-L164
46,253
fedelemantuano/tika-app-python
tikapp/tikapp.py
TikaApp.extract_all_content
def extract_all_content( self, path=None, payload=None, objectInput=None, pretty_print=False, convert_to_obj=False, ): """ This function returns a JSON of all contents and metadata of passed file Args: path (string): Path o...
python
def extract_all_content( self, path=None, payload=None, objectInput=None, pretty_print=False, convert_to_obj=False, ): """ This function returns a JSON of all contents and metadata of passed file Args: path (string): Path o...
[ "def", "extract_all_content", "(", "self", ",", "path", "=", "None", ",", "payload", "=", "None", ",", "objectInput", "=", "None", ",", "pretty_print", "=", "False", ",", "convert_to_obj", "=", "False", ",", ")", ":", "f", "=", "file_path", "(", "path", ...
This function returns a JSON of all contents and metadata of passed file Args: path (string): Path of file to analyze payload (string): Payload base64 to analyze objectInput (object): file object/standard input to analyze pretty_print (boolean): If True a...
[ "This", "function", "returns", "a", "JSON", "of", "all", "contents", "and", "metadata", "of", "passed", "file" ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/tikapp.py#L190-L219
46,254
fedelemantuano/tika-app-python
tikapp/utils.py
clean
def clean(func): """ This decorator removes the temp file from disk. This is the case where you want to analyze from a payload. """ def wrapper(*args, **kwargs): # tuple: output command, path given from command line, # path of templ file when you give the payload out, given_p...
python
def clean(func): """ This decorator removes the temp file from disk. This is the case where you want to analyze from a payload. """ def wrapper(*args, **kwargs): # tuple: output command, path given from command line, # path of templ file when you give the payload out, given_p...
[ "def", "clean", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# tuple: output command, path given from command line,", "# path of templ file when you give the payload", "out", ",", "given_path", ",", "path", "=", "fun...
This decorator removes the temp file from disk. This is the case where you want to analyze from a payload.
[ "This", "decorator", "removes", "the", "temp", "file", "from", "disk", ".", "This", "is", "the", "case", "where", "you", "want", "to", "analyze", "from", "a", "payload", "." ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/utils.py#L43-L61
46,255
fedelemantuano/tika-app-python
tikapp/utils.py
file_path
def file_path(path=None, payload=None, objectInput=None): """ Given a file path, payload or file object, it writes file on disk and returns the temp path. Args: path (string): path of real file payload(string): payload in base64 of file objectInput (object): file object/standard...
python
def file_path(path=None, payload=None, objectInput=None): """ Given a file path, payload or file object, it writes file on disk and returns the temp path. Args: path (string): path of real file payload(string): payload in base64 of file objectInput (object): file object/standard...
[ "def", "file_path", "(", "path", "=", "None", ",", "payload", "=", "None", ",", "objectInput", "=", "None", ")", ":", "f", "=", "path", "if", "path", "else", "write_payload", "(", "payload", ",", "objectInput", ")", "if", "not", "os", ".", "path", "....
Given a file path, payload or file object, it writes file on disk and returns the temp path. Args: path (string): path of real file payload(string): payload in base64 of file objectInput (object): file object/standard input to analyze Returns: Path of file
[ "Given", "a", "file", "path", "payload", "or", "file", "object", "it", "writes", "file", "on", "disk", "and", "returns", "the", "temp", "path", "." ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/utils.py#L64-L84
46,256
fedelemantuano/tika-app-python
tikapp/utils.py
write_payload
def write_payload(payload=None, objectInput=None): """ This function writes a base64 payload or file object on disk. Args: payload (string): payload in base64 objectInput (object): file object/standard input to analyze Returns: Path of file """ temp = tempfile.mkstemp(...
python
def write_payload(payload=None, objectInput=None): """ This function writes a base64 payload or file object on disk. Args: payload (string): payload in base64 objectInput (object): file object/standard input to analyze Returns: Path of file """ temp = tempfile.mkstemp(...
[ "def", "write_payload", "(", "payload", "=", "None", ",", "objectInput", "=", "None", ")", ":", "temp", "=", "tempfile", ".", "mkstemp", "(", ")", "[", "1", "]", "log", ".", "debug", "(", "\"Write payload in temp file {!r}\"", ".", "format", "(", "temp", ...
This function writes a base64 payload or file object on disk. Args: payload (string): payload in base64 objectInput (object): file object/standard input to analyze Returns: Path of file
[ "This", "function", "writes", "a", "base64", "payload", "or", "file", "object", "on", "disk", "." ]
9a462aa611af2032306c78a9c996c8545288c212
https://github.com/fedelemantuano/tika-app-python/blob/9a462aa611af2032306c78a9c996c8545288c212/tikapp/utils.py#L87-L113
46,257
pudo/jsonmapping
jsonmapping/statements.py
StatementsVisitor.get_subject
def get_subject(self, data): """ Try to get a unique ID from the object. By default, this will be the 'id' field of any given object, or a field specified by the 'rdfSubject' property. If no other option is available, a UUID will be generated. """ if not isinstance(data, Mapping)...
python
def get_subject(self, data): """ Try to get a unique ID from the object. By default, this will be the 'id' field of any given object, or a field specified by the 'rdfSubject' property. If no other option is available, a UUID will be generated. """ if not isinstance(data, Mapping)...
[ "def", "get_subject", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "Mapping", ")", ":", "return", "None", "if", "data", ".", "get", "(", "self", ".", "subject", ")", ":", "return", "data", ".", "get", "(", "self"...
Try to get a unique ID from the object. By default, this will be the 'id' field of any given object, or a field specified by the 'rdfSubject' property. If no other option is available, a UUID will be generated.
[ "Try", "to", "get", "a", "unique", "ID", "from", "the", "object", ".", "By", "default", "this", "will", "be", "the", "id", "field", "of", "any", "given", "object", "or", "a", "field", "specified", "by", "the", "rdfSubject", "property", ".", "If", "no",...
4cf0a20a393ba82e00651c6fd39522a67a0155de
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/statements.py#L22-L31
46,258
pudo/jsonmapping
jsonmapping/statements.py
StatementsVisitor.triplify
def triplify(self, data, parent=None): """ Recursively generate statements from the data supplied. """ if data is None: return if self.is_object: for res in self._triplify_object(data, parent): yield res elif self.is_array: for item in...
python
def triplify(self, data, parent=None): """ Recursively generate statements from the data supplied. """ if data is None: return if self.is_object: for res in self._triplify_object(data, parent): yield res elif self.is_array: for item in...
[ "def", "triplify", "(", "self", ",", "data", ",", "parent", "=", "None", ")", ":", "if", "data", "is", "None", ":", "return", "if", "self", ".", "is_object", ":", "for", "res", "in", "self", ".", "_triplify_object", "(", "data", ",", "parent", ")", ...
Recursively generate statements from the data supplied.
[ "Recursively", "generate", "statements", "from", "the", "data", "supplied", "." ]
4cf0a20a393ba82e00651c6fd39522a67a0155de
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/statements.py#L53-L71
46,259
pudo/jsonmapping
jsonmapping/statements.py
StatementsVisitor._triplify_object
def _triplify_object(self, data, parent): """ Create bi-directional statements for object relationships. """ subject = self.get_subject(data) if self.path: yield (subject, TYPE_SCHEMA, self.path, TYPE_SCHEMA) if parent is not None: yield (parent, self.predicate, ...
python
def _triplify_object(self, data, parent): """ Create bi-directional statements for object relationships. """ subject = self.get_subject(data) if self.path: yield (subject, TYPE_SCHEMA, self.path, TYPE_SCHEMA) if parent is not None: yield (parent, self.predicate, ...
[ "def", "_triplify_object", "(", "self", ",", "data", ",", "parent", ")", ":", "subject", "=", "self", ".", "get_subject", "(", "data", ")", "if", "self", ".", "path", ":", "yield", "(", "subject", ",", "TYPE_SCHEMA", ",", "self", ".", "path", ",", "T...
Create bi-directional statements for object relationships.
[ "Create", "bi", "-", "directional", "statements", "for", "object", "relationships", "." ]
4cf0a20a393ba82e00651c6fd39522a67a0155de
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/statements.py#L73-L86
46,260
praekelt/django-simple-autocomplete
simple_autocomplete/views.py
get_json
def get_json(request, token): """Return matching results as JSON""" result = [] searchtext = request.GET['q'] if len(searchtext) >= 3: pickled = _simple_autocomplete_queryset_cache.get(token, None) if pickled is not None: app_label, model_name, query = pickle.loads(pickled) ...
python
def get_json(request, token): """Return matching results as JSON""" result = [] searchtext = request.GET['q'] if len(searchtext) >= 3: pickled = _simple_autocomplete_queryset_cache.get(token, None) if pickled is not None: app_label, model_name, query = pickle.loads(pickled) ...
[ "def", "get_json", "(", "request", ",", "token", ")", ":", "result", "=", "[", "]", "searchtext", "=", "request", ".", "GET", "[", "'q'", "]", "if", "len", "(", "searchtext", ")", ">=", "3", ":", "pickled", "=", "_simple_autocomplete_queryset_cache", "."...
Return matching results as JSON
[ "Return", "matching", "results", "as", "JSON" ]
925b639a6a7fac2350dda9656845d8bd9aa2e748
https://github.com/praekelt/django-simple-autocomplete/blob/925b639a6a7fac2350dda9656845d8bd9aa2e748/simple_autocomplete/views.py#L14-L62
46,261
kgori/treeCl
treeCl/parsers.py
RaxmlParser._dash_f_e_to_dict
def _dash_f_e_to_dict(self, info_filename, tree_filename): """ Raxml provides an option to fit model params to a tree, selected with -f e. The output is different and needs a different parser. """ with open(info_filename) as fl: models, likelihood, partition_p...
python
def _dash_f_e_to_dict(self, info_filename, tree_filename): """ Raxml provides an option to fit model params to a tree, selected with -f e. The output is different and needs a different parser. """ with open(info_filename) as fl: models, likelihood, partition_p...
[ "def", "_dash_f_e_to_dict", "(", "self", ",", "info_filename", ",", "tree_filename", ")", ":", "with", "open", "(", "info_filename", ")", "as", "fl", ":", "models", ",", "likelihood", ",", "partition_params", "=", "self", ".", "_dash_f_e_parser", ".", "parseFi...
Raxml provides an option to fit model params to a tree, selected with -f e. The output is different and needs a different parser.
[ "Raxml", "provides", "an", "option", "to", "fit", "model", "params", "to", "a", "tree", "selected", "with", "-", "f", "e", ".", "The", "output", "is", "different", "and", "needs", "a", "different", "parser", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/parsers.py#L222-L246
46,262
kgori/treeCl
treeCl/parsers.py
RaxmlParser.to_dict
def to_dict(self, info_filename, tree_filename, dash_f_e=False): """ Parse raxml output and return a dict Option dash_f_e=True will parse the output of a raxml -f e run, which has different output """ logger.debug('info_filename: {} {}' .format(info_f...
python
def to_dict(self, info_filename, tree_filename, dash_f_e=False): """ Parse raxml output and return a dict Option dash_f_e=True will parse the output of a raxml -f e run, which has different output """ logger.debug('info_filename: {} {}' .format(info_f...
[ "def", "to_dict", "(", "self", ",", "info_filename", ",", "tree_filename", ",", "dash_f_e", "=", "False", ")", ":", "logger", ".", "debug", "(", "'info_filename: {} {}'", ".", "format", "(", "info_filename", ",", "'(FOUND)'", "if", "os", ".", "path", ".", ...
Parse raxml output and return a dict Option dash_f_e=True will parse the output of a raxml -f e run, which has different output
[ "Parse", "raxml", "output", "and", "return", "a", "dict", "Option", "dash_f_e", "=", "True", "will", "parse", "the", "output", "of", "a", "raxml", "-", "f", "e", "run", "which", "has", "different", "output" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/parsers.py#L248-L261
46,263
kgori/treeCl
treeCl/utils/fileIO.py
freader
def freader(filename, gz=False, bz=False): """ Returns a filereader object that can handle gzipped input """ filecheck(filename) if filename.endswith('.gz'): gz = True elif filename.endswith('.bz2'): bz = True if gz: return gzip.open(filename, 'rb') elif bz: ret...
python
def freader(filename, gz=False, bz=False): """ Returns a filereader object that can handle gzipped input """ filecheck(filename) if filename.endswith('.gz'): gz = True elif filename.endswith('.bz2'): bz = True if gz: return gzip.open(filename, 'rb') elif bz: ret...
[ "def", "freader", "(", "filename", ",", "gz", "=", "False", ",", "bz", "=", "False", ")", ":", "filecheck", "(", "filename", ")", "if", "filename", ".", "endswith", "(", "'.gz'", ")", ":", "gz", "=", "True", "elif", "filename", ".", "endswith", "(", ...
Returns a filereader object that can handle gzipped input
[ "Returns", "a", "filereader", "object", "that", "can", "handle", "gzipped", "input" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/utils/fileIO.py#L132-L146
46,264
kgori/treeCl
treeCl/utils/fileIO.py
fwriter
def fwriter(filename, gz=False, bz=False): """ Returns a filewriter object that can write plain or gzipped output. If gzip or bzip2 compression is asked for then the usual filename extension will be added.""" if filename.endswith('.gz'): gz = True elif filename.endswith('.bz2'): bz = Tr...
python
def fwriter(filename, gz=False, bz=False): """ Returns a filewriter object that can write plain or gzipped output. If gzip or bzip2 compression is asked for then the usual filename extension will be added.""" if filename.endswith('.gz'): gz = True elif filename.endswith('.bz2'): bz = Tr...
[ "def", "fwriter", "(", "filename", ",", "gz", "=", "False", ",", "bz", "=", "False", ")", ":", "if", "filename", ".", "endswith", "(", "'.gz'", ")", ":", "gz", "=", "True", "elif", "filename", ".", "endswith", "(", "'.bz2'", ")", ":", "bz", "=", ...
Returns a filewriter object that can write plain or gzipped output. If gzip or bzip2 compression is asked for then the usual filename extension will be added.
[ "Returns", "a", "filewriter", "object", "that", "can", "write", "plain", "or", "gzipped", "output", ".", "If", "gzip", "or", "bzip2", "compression", "is", "asked", "for", "then", "the", "usual", "filename", "extension", "will", "be", "added", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/utils/fileIO.py#L149-L167
46,265
kgori/treeCl
treeCl/utils/fileIO.py
glob_by_extensions
def glob_by_extensions(directory, extensions): """ Returns files matched by all extensions in the extensions list """ directorycheck(directory) files = [] xt = files.extend for ex in extensions: xt(glob.glob('{0}/*.{1}'.format(directory, ex))) return files
python
def glob_by_extensions(directory, extensions): """ Returns files matched by all extensions in the extensions list """ directorycheck(directory) files = [] xt = files.extend for ex in extensions: xt(glob.glob('{0}/*.{1}'.format(directory, ex))) return files
[ "def", "glob_by_extensions", "(", "directory", ",", "extensions", ")", ":", "directorycheck", "(", "directory", ")", "files", "=", "[", "]", "xt", "=", "files", ".", "extend", "for", "ex", "in", "extensions", ":", "xt", "(", "glob", ".", "glob", "(", "...
Returns files matched by all extensions in the extensions list
[ "Returns", "files", "matched", "by", "all", "extensions", "in", "the", "extensions", "list" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/utils/fileIO.py#L170-L177
46,266
kgori/treeCl
treeCl/utils/fileIO.py
head
def head(filename, n=10): """ prints the top `n` lines of a file """ with freader(filename) as fr: for _ in range(n): print(fr.readline().strip())
python
def head(filename, n=10): """ prints the top `n` lines of a file """ with freader(filename) as fr: for _ in range(n): print(fr.readline().strip())
[ "def", "head", "(", "filename", ",", "n", "=", "10", ")", ":", "with", "freader", "(", "filename", ")", "as", "fr", ":", "for", "_", "in", "range", "(", "n", ")", ":", "print", "(", "fr", ".", "readline", "(", ")", ".", "strip", "(", ")", ")"...
prints the top `n` lines of a file
[ "prints", "the", "top", "n", "lines", "of", "a", "file" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/utils/fileIO.py#L190-L194
46,267
synw/django-instant
instant/utils.py
channels_for_role
def channels_for_role(role): """ Get the channels for a role """ chans = [] chans_names = [] # default channels if role == "public": if ENABLE_PUBLIC_CHANNEL is True: chan = dict(slug=PUBLIC_CHANNEL, path=None) chans.append(chan) chans_names.append...
python
def channels_for_role(role): """ Get the channels for a role """ chans = [] chans_names = [] # default channels if role == "public": if ENABLE_PUBLIC_CHANNEL is True: chan = dict(slug=PUBLIC_CHANNEL, path=None) chans.append(chan) chans_names.append...
[ "def", "channels_for_role", "(", "role", ")", ":", "chans", "=", "[", "]", "chans_names", "=", "[", "]", "# default channels", "if", "role", "==", "\"public\"", ":", "if", "ENABLE_PUBLIC_CHANNEL", "is", "True", ":", "chan", "=", "dict", "(", "slug", "=", ...
Get the channels for a role
[ "Get", "the", "channels", "for", "a", "role" ]
784ab068a7e83f76723763437ecbcc9294ab029a
https://github.com/synw/django-instant/blob/784ab068a7e83f76723763437ecbcc9294ab029a/instant/utils.py#L41-L96
46,268
kgori/treeCl
treeCl/tree.py
ILS.ils
def ils(self, node, sorting_times=None, force_topology_change=True): """ A constrained and approximation of ILS using nearest-neighbour interchange Process ------- A node with at least three descendents is selected from an ultrametric tree (node '2', below) ...
python
def ils(self, node, sorting_times=None, force_topology_change=True): """ A constrained and approximation of ILS using nearest-neighbour interchange Process ------- A node with at least three descendents is selected from an ultrametric tree (node '2', below) ...
[ "def", "ils", "(", "self", ",", "node", ",", "sorting_times", "=", "None", ",", "force_topology_change", "=", "True", ")", ":", "# node = '2', par = '1', gpar = '0' -- in above diagram", "n_2", "=", "node", "n_1", "=", "n_2", ".", "parent_node", "if", "n_1", "==...
A constrained and approximation of ILS using nearest-neighbour interchange Process ------- A node with at least three descendents is selected from an ultrametric tree (node '2', below) ---0--... ---0--... ---0--... | | ...
[ "A", "constrained", "and", "approximation", "of", "ILS", "using", "nearest", "-", "neighbour", "interchange" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L464-L581
46,269
kgori/treeCl
treeCl/tree.py
Tree.get_inner_edges
def get_inner_edges(self): """ Returns a list of the internal edges of the tree. """ inner_edges = [e for e in self._tree.preorder_edge_iter() if e.is_internal() and e.head_node and e.tail_node] return inner_edges
python
def get_inner_edges(self): """ Returns a list of the internal edges of the tree. """ inner_edges = [e for e in self._tree.preorder_edge_iter() if e.is_internal() and e.head_node and e.tail_node] return inner_edges
[ "def", "get_inner_edges", "(", "self", ")", ":", "inner_edges", "=", "[", "e", "for", "e", "in", "self", ".", "_tree", ".", "preorder_edge_iter", "(", ")", "if", "e", ".", "is_internal", "(", ")", "and", "e", ".", "head_node", "and", "e", ".", "tail_...
Returns a list of the internal edges of the tree.
[ "Returns", "a", "list", "of", "the", "internal", "edges", "of", "the", "tree", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L897-L901
46,270
kgori/treeCl
treeCl/tree.py
Tree.intersection
def intersection(self, other): """ Returns the intersection of the taxon sets of two Trees """ taxa1 = self.labels taxa2 = other.labels return taxa1 & taxa2
python
def intersection(self, other): """ Returns the intersection of the taxon sets of two Trees """ taxa1 = self.labels taxa2 = other.labels return taxa1 & taxa2
[ "def", "intersection", "(", "self", ",", "other", ")", ":", "taxa1", "=", "self", ".", "labels", "taxa2", "=", "other", ".", "labels", "return", "taxa1", "&", "taxa2" ]
Returns the intersection of the taxon sets of two Trees
[ "Returns", "the", "intersection", "of", "the", "taxon", "sets", "of", "two", "Trees" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L907-L911
46,271
kgori/treeCl
treeCl/tree.py
Tree.postorder
def postorder(self, skip_seed=False): """ Return a generator that yields the nodes of the tree in postorder. If skip_seed=True then the root node is not included. """ for node in self._tree.postorder_node_iter(): if skip_seed and node is self._tree.seed_node: ...
python
def postorder(self, skip_seed=False): """ Return a generator that yields the nodes of the tree in postorder. If skip_seed=True then the root node is not included. """ for node in self._tree.postorder_node_iter(): if skip_seed and node is self._tree.seed_node: ...
[ "def", "postorder", "(", "self", ",", "skip_seed", "=", "False", ")", ":", "for", "node", "in", "self", ".", "_tree", ".", "postorder_node_iter", "(", ")", ":", "if", "skip_seed", "and", "node", "is", "self", ".", "_tree", ".", "seed_node", ":", "conti...
Return a generator that yields the nodes of the tree in postorder. If skip_seed=True then the root node is not included.
[ "Return", "a", "generator", "that", "yields", "the", "nodes", "of", "the", "tree", "in", "postorder", ".", "If", "skip_seed", "=", "True", "then", "the", "root", "node", "is", "not", "included", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L978-L986
46,272
kgori/treeCl
treeCl/tree.py
Tree.preorder
def preorder(self, skip_seed=False): """ Return a generator that yields the nodes of the tree in preorder. If skip_seed=True then the root node is not included. """ for node in self._tree.preorder_node_iter(): if skip_seed and node is self._tree.seed_node: ...
python
def preorder(self, skip_seed=False): """ Return a generator that yields the nodes of the tree in preorder. If skip_seed=True then the root node is not included. """ for node in self._tree.preorder_node_iter(): if skip_seed and node is self._tree.seed_node: ...
[ "def", "preorder", "(", "self", ",", "skip_seed", "=", "False", ")", ":", "for", "node", "in", "self", ".", "_tree", ".", "preorder_node_iter", "(", ")", ":", "if", "skip_seed", "and", "node", "is", "self", ".", "_tree", ".", "seed_node", ":", "continu...
Return a generator that yields the nodes of the tree in preorder. If skip_seed=True then the root node is not included.
[ "Return", "a", "generator", "that", "yields", "the", "nodes", "of", "the", "tree", "in", "preorder", ".", "If", "skip_seed", "=", "True", "then", "the", "root", "node", "is", "not", "included", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L988-L996
46,273
kgori/treeCl
treeCl/tree.py
Tree.prune_to_subset
def prune_to_subset(self, subset, inplace=False): """ Prunes the Tree to just the taxon set given in `subset` """ if not subset.issubset(self.labels): print('"subset" is not a subset') return if not inplace: t = self.copy() else: t = self ...
python
def prune_to_subset(self, subset, inplace=False): """ Prunes the Tree to just the taxon set given in `subset` """ if not subset.issubset(self.labels): print('"subset" is not a subset') return if not inplace: t = self.copy() else: t = self ...
[ "def", "prune_to_subset", "(", "self", ",", "subset", ",", "inplace", "=", "False", ")", ":", "if", "not", "subset", ".", "issubset", "(", "self", ".", "labels", ")", ":", "print", "(", "'\"subset\" is not a subset'", ")", "return", "if", "not", "inplace",...
Prunes the Tree to just the taxon set given in `subset`
[ "Prunes", "the", "Tree", "to", "just", "the", "taxon", "set", "given", "in", "subset" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L998-L1010
46,274
kgori/treeCl
treeCl/tree.py
Tree.randomise_branch_lengths
def randomise_branch_lengths( self, i=(1, 1), l=(1, 1), distribution_func=random.gammavariate, inplace=False, ): """ Replaces branch lengths with values drawn from the specified distribution_func. Parameters of the distribution are given in...
python
def randomise_branch_lengths( self, i=(1, 1), l=(1, 1), distribution_func=random.gammavariate, inplace=False, ): """ Replaces branch lengths with values drawn from the specified distribution_func. Parameters of the distribution are given in...
[ "def", "randomise_branch_lengths", "(", "self", ",", "i", "=", "(", "1", ",", "1", ")", ",", "l", "=", "(", "1", ",", "1", ")", ",", "distribution_func", "=", "random", ".", "gammavariate", ",", "inplace", "=", "False", ",", ")", ":", "if", "not", ...
Replaces branch lengths with values drawn from the specified distribution_func. Parameters of the distribution are given in the tuples i and l, for interior and leaf nodes respectively.
[ "Replaces", "branch", "lengths", "with", "values", "drawn", "from", "the", "specified", "distribution_func", ".", "Parameters", "of", "the", "distribution", "are", "given", "in", "the", "tuples", "i", "and", "l", "for", "interior", "and", "leaf", "nodes", "res...
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1012-L1034
46,275
kgori/treeCl
treeCl/tree.py
Tree.randomise_labels
def randomise_labels( self, inplace=False, ): """ Shuffles the leaf labels, but doesn't alter the tree structure """ if not inplace: t = self.copy() else: t = self names = list(t.labels) random.shuffle(names) for l in ...
python
def randomise_labels( self, inplace=False, ): """ Shuffles the leaf labels, but doesn't alter the tree structure """ if not inplace: t = self.copy() else: t = self names = list(t.labels) random.shuffle(names) for l in ...
[ "def", "randomise_labels", "(", "self", ",", "inplace", "=", "False", ",", ")", ":", "if", "not", "inplace", ":", "t", "=", "self", ".", "copy", "(", ")", "else", ":", "t", "=", "self", "names", "=", "list", "(", "t", ".", "labels", ")", "random"...
Shuffles the leaf labels, but doesn't alter the tree structure
[ "Shuffles", "the", "leaf", "labels", "but", "doesn", "t", "alter", "the", "tree", "structure" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1036-L1052
46,276
kgori/treeCl
treeCl/tree.py
Tree.reversible_deroot
def reversible_deroot(self): """ Stores info required to restore rootedness to derooted Tree. Returns the edge that was originally rooted, the length of e1, and the length of e2. Dendropy Derooting Process: In a rooted tree the root node is bifurcating. Derooting makes it ...
python
def reversible_deroot(self): """ Stores info required to restore rootedness to derooted Tree. Returns the edge that was originally rooted, the length of e1, and the length of e2. Dendropy Derooting Process: In a rooted tree the root node is bifurcating. Derooting makes it ...
[ "def", "reversible_deroot", "(", "self", ")", ":", "root_edge", "=", "self", ".", "_tree", ".", "seed_node", ".", "edge", "lengths", "=", "dict", "(", "[", "(", "edge", ",", "edge", ".", "length", ")", "for", "edge", "in", "self", ".", "_tree", ".", ...
Stores info required to restore rootedness to derooted Tree. Returns the edge that was originally rooted, the length of e1, and the length of e2. Dendropy Derooting Process: In a rooted tree the root node is bifurcating. Derooting makes it trifurcating. Call the two edg...
[ "Stores", "info", "required", "to", "restore", "rootedness", "to", "derooted", "Tree", ".", "Returns", "the", "edge", "that", "was", "originally", "rooted", "the", "length", "of", "e1", "and", "the", "length", "of", "e2", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1054-L1089
46,277
kgori/treeCl
treeCl/tree.py
Tree.rlgt
def rlgt(self, time=None, times=1, disallow_sibling_lgts=False): """ Uses class LGT to perform random lateral gene transfer on ultrametric tree """ lgt = LGT(self.copy()) for _ in range(times): lgt.rlgt(time, disallow_sibling_lgts) return lgt.tree
python
def rlgt(self, time=None, times=1, disallow_sibling_lgts=False): """ Uses class LGT to perform random lateral gene transfer on ultrametric tree """ lgt = LGT(self.copy()) for _ in range(times): lgt.rlgt(time, disallow_sibling_lgts) return lgt.tree
[ "def", "rlgt", "(", "self", ",", "time", "=", "None", ",", "times", "=", "1", ",", "disallow_sibling_lgts", "=", "False", ")", ":", "lgt", "=", "LGT", "(", "self", ".", "copy", "(", ")", ")", "for", "_", "in", "range", "(", "times", ")", ":", "...
Uses class LGT to perform random lateral gene transfer on ultrametric tree
[ "Uses", "class", "LGT", "to", "perform", "random", "lateral", "gene", "transfer", "on", "ultrametric", "tree" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1130-L1138
46,278
kgori/treeCl
treeCl/tree.py
Tree.scale
def scale(self, factor, inplace=True): """ Multiplies all branch lengths by factor. """ if not inplace: t = self.copy() else: t = self t._tree.scale_edges(factor) t._dirty = True return t
python
def scale(self, factor, inplace=True): """ Multiplies all branch lengths by factor. """ if not inplace: t = self.copy() else: t = self t._tree.scale_edges(factor) t._dirty = True return t
[ "def", "scale", "(", "self", ",", "factor", ",", "inplace", "=", "True", ")", ":", "if", "not", "inplace", ":", "t", "=", "self", ".", "copy", "(", ")", "else", ":", "t", "=", "self", "t", ".", "_tree", ".", "scale_edges", "(", "factor", ")", "...
Multiplies all branch lengths by factor.
[ "Multiplies", "all", "branch", "lengths", "by", "factor", "." ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1164-L1172
46,279
kgori/treeCl
treeCl/tree.py
Tree.strip
def strip(self, inplace=False): """ Sets all edge lengths to None """ if not inplace: t = self.copy() else: t = self for e in t._tree.preorder_edge_iter(): e.length = None t._dirty = True return t
python
def strip(self, inplace=False): """ Sets all edge lengths to None """ if not inplace: t = self.copy() else: t = self for e in t._tree.preorder_edge_iter(): e.length = None t._dirty = True return t
[ "def", "strip", "(", "self", ",", "inplace", "=", "False", ")", ":", "if", "not", "inplace", ":", "t", "=", "self", ".", "copy", "(", ")", "else", ":", "t", "=", "self", "for", "e", "in", "t", ".", "_tree", ".", "preorder_edge_iter", "(", ")", ...
Sets all edge lengths to None
[ "Sets", "all", "edge", "lengths", "to", "None" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1174-L1183
46,280
kgori/treeCl
treeCl/tree.py
Tree._name_things
def _name_things(self): """ Easy names for debugging """ edges = {} nodes = {None: 'root'} for n in self._tree.postorder_node_iter(): nodes[n] = '.'.join([str(x.taxon) for x in n.leaf_nodes()]) for e in self._tree.preorder_edge_iter(): edges[e] = ' ---> '....
python
def _name_things(self): """ Easy names for debugging """ edges = {} nodes = {None: 'root'} for n in self._tree.postorder_node_iter(): nodes[n] = '.'.join([str(x.taxon) for x in n.leaf_nodes()]) for e in self._tree.preorder_edge_iter(): edges[e] = ' ---> '....
[ "def", "_name_things", "(", "self", ")", ":", "edges", "=", "{", "}", "nodes", "=", "{", "None", ":", "'root'", "}", "for", "n", "in", "self", ".", "_tree", ".", "postorder_node_iter", "(", ")", ":", "nodes", "[", "n", "]", "=", "'.'", ".", "join...
Easy names for debugging
[ "Easy", "names", "for", "debugging" ]
fed624b3db1c19cc07175ca04e3eda6905a8d305
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1197-L1208
46,281
pysal/spglm
spglm/glm.py
GLM.fit
def fit(self, ini_betas=None, tol=1.0e-6, max_iter=200, solve='iwls'): """ Method that fits a model with a particular estimation routine. Parameters ---------- ini_betas : array k*1, initial coefficient values, including constant. ...
python
def fit(self, ini_betas=None, tol=1.0e-6, max_iter=200, solve='iwls'): """ Method that fits a model with a particular estimation routine. Parameters ---------- ini_betas : array k*1, initial coefficient values, including constant. ...
[ "def", "fit", "(", "self", ",", "ini_betas", "=", "None", ",", "tol", "=", "1.0e-6", ",", "max_iter", "=", "200", ",", "solve", "=", "'iwls'", ")", ":", "self", ".", "fit_params", "[", "'ini_betas'", "]", "=", "ini_betas", "self", ".", "fit_params", ...
Method that fits a model with a particular estimation routine. Parameters ---------- ini_betas : array k*1, initial coefficient values, including constant. Default is None, which calculates initial values during estima...
[ "Method", "that", "fits", "a", "model", "with", "a", "particular", "estimation", "routine", "." ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/glm.py#L107-L135
46,282
pysal/spglm
spglm/links.py
Logit.inverse
def inverse(self, z): """ Inverse of the logit transform Parameters ---------- z : array-like The value of the logit transform at `p` Returns ------- p : array Probabilities Notes ----- g^(-1)(z) = exp(z)/...
python
def inverse(self, z): """ Inverse of the logit transform Parameters ---------- z : array-like The value of the logit transform at `p` Returns ------- p : array Probabilities Notes ----- g^(-1)(z) = exp(z)/...
[ "def", "inverse", "(", "self", ",", "z", ")", ":", "z", "=", "np", ".", "asarray", "(", "z", ")", "t", "=", "np", ".", "exp", "(", "-", "z", ")", "return", "1.", "/", "(", "1.", "+", "t", ")" ]
Inverse of the logit transform Parameters ---------- z : array-like The value of the logit transform at `p` Returns ------- p : array Probabilities Notes ----- g^(-1)(z) = exp(z)/(1+exp(z))
[ "Inverse", "of", "the", "logit", "transform" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L149-L169
46,283
pysal/spglm
spglm/links.py
Power.inverse
def inverse(self, z): """ Inverse of the power transform link function Parameters ---------- `z` : array-like Value of the transformed mean parameters at `p` Returns ------- `p` : array Mean parameters Notes -----...
python
def inverse(self, z): """ Inverse of the power transform link function Parameters ---------- `z` : array-like Value of the transformed mean parameters at `p` Returns ------- `p` : array Mean parameters Notes -----...
[ "def", "inverse", "(", "self", ",", "z", ")", ":", "p", "=", "np", ".", "power", "(", "z", ",", "1.", "/", "self", ".", "power", ")", "return", "p" ]
Inverse of the power transform link function Parameters ---------- `z` : array-like Value of the transformed mean parameters at `p` Returns ------- `p` : array Mean parameters Notes ----- g^(-1)(z`) = `z`**(1/`power`)
[ "Inverse", "of", "the", "power", "transform", "link", "function" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L279-L299
46,284
pysal/spglm
spglm/links.py
Power.deriv
def deriv(self, p): """ Derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g'(p) : array Derivative of power transform of `p` Notes ----- g'(`p`) = `pow...
python
def deriv(self, p): """ Derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g'(p) : array Derivative of power transform of `p` Notes ----- g'(`p`) = `pow...
[ "def", "deriv", "(", "self", ",", "p", ")", ":", "return", "self", ".", "power", "*", "np", ".", "power", "(", "p", ",", "self", ".", "power", "-", "1", ")" ]
Derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g'(p) : array Derivative of power transform of `p` Notes ----- g'(`p`) = `power` * `p`**(`power` - 1)
[ "Derivative", "of", "the", "power", "transform" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L301-L319
46,285
pysal/spglm
spglm/links.py
Power.deriv2
def deriv2(self, p): """ Second derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g''(p) : array Second derivative of the power transform of `p` Notes ----- ...
python
def deriv2(self, p): """ Second derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g''(p) : array Second derivative of the power transform of `p` Notes ----- ...
[ "def", "deriv2", "(", "self", ",", "p", ")", ":", "return", "self", ".", "power", "*", "(", "self", ".", "power", "-", "1", ")", "*", "np", ".", "power", "(", "p", ",", "self", ".", "power", "-", "2", ")" ]
Second derivative of the power transform Parameters ---------- p : array-like Mean parameters Returns -------- g''(p) : array Second derivative of the power transform of `p` Notes ----- g''(`p`) = `power` * (`power` - 1) ...
[ "Second", "derivative", "of", "the", "power", "transform" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L321-L339
46,286
pysal/spglm
spglm/links.py
Power.inverse_deriv
def inverse_deriv(self, z): """ Derivative of the inverse of the power transform Parameters ---------- z : array-like `z` is usually the linear predictor for a GLM or GEE model. Returns ------- g^(-1)'(z) : array The value of the ...
python
def inverse_deriv(self, z): """ Derivative of the inverse of the power transform Parameters ---------- z : array-like `z` is usually the linear predictor for a GLM or GEE model. Returns ------- g^(-1)'(z) : array The value of the ...
[ "def", "inverse_deriv", "(", "self", ",", "z", ")", ":", "return", "np", ".", "power", "(", "z", ",", "(", "1", "-", "self", ".", "power", ")", "/", "self", ".", "power", ")", "/", "self", ".", "power" ]
Derivative of the inverse of the power transform Parameters ---------- z : array-like `z` is usually the linear predictor for a GLM or GEE model. Returns ------- g^(-1)'(z) : array The value of the derivative of the inverse of the power transform...
[ "Derivative", "of", "the", "inverse", "of", "the", "power", "transform" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L341-L356
46,287
pysal/spglm
spglm/links.py
CDFLink.deriv
def deriv(self, p): """ Derivative of CDF link Parameters ---------- p : array-like mean parameters Returns ------- g'(p) : array The derivative of CDF transform at `p` Notes ----- g'(`p`) = 1./ `dbn`.pdf(...
python
def deriv(self, p): """ Derivative of CDF link Parameters ---------- p : array-like mean parameters Returns ------- g'(p) : array The derivative of CDF transform at `p` Notes ----- g'(`p`) = 1./ `dbn`.pdf(...
[ "def", "deriv", "(", "self", ",", "p", ")", ":", "p", "=", "self", ".", "_clean", "(", "p", ")", "return", "1.", "/", "self", ".", "dbn", ".", "pdf", "(", "self", ".", "dbn", ".", "ppf", "(", "p", ")", ")" ]
Derivative of CDF link Parameters ---------- p : array-like mean parameters Returns ------- g'(p) : array The derivative of CDF transform at `p` Notes ----- g'(`p`) = 1./ `dbn`.pdf(`dbn`.ppf(`p`))
[ "Derivative", "of", "CDF", "link" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L602-L621
46,288
pysal/spglm
spglm/links.py
cauchy.deriv2
def deriv2(self, p): """ Second derivative of the Cauchy link function. Parameters ---------- p: array-like Probabilities Returns ------- g''(p) : array Value of the second derivative of Cauchy link function at `p` """ ...
python
def deriv2(self, p): """ Second derivative of the Cauchy link function. Parameters ---------- p: array-like Probabilities Returns ------- g''(p) : array Value of the second derivative of Cauchy link function at `p` """ ...
[ "def", "deriv2", "(", "self", ",", "p", ")", ":", "a", "=", "np", ".", "pi", "*", "(", "p", "-", "0.5", ")", "d2", "=", "2", "*", "np", ".", "pi", "**", "2", "*", "np", ".", "sin", "(", "a", ")", "/", "np", ".", "cos", "(", "a", ")", ...
Second derivative of the Cauchy link function. Parameters ---------- p: array-like Probabilities Returns ------- g''(p) : array Value of the second derivative of Cauchy link function at `p`
[ "Second", "derivative", "of", "the", "Cauchy", "link", "function", "." ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L678-L694
46,289
pysal/spglm
spglm/links.py
CLogLog.deriv
def deriv(self, p): """ Derivative of C-Log-Log transform link function Parameters ---------- p : array-like Mean parameters Returns ------- g'(p) : array The derivative of the CLogLog transform link function Notes ...
python
def deriv(self, p): """ Derivative of C-Log-Log transform link function Parameters ---------- p : array-like Mean parameters Returns ------- g'(p) : array The derivative of the CLogLog transform link function Notes ...
[ "def", "deriv", "(", "self", ",", "p", ")", ":", "p", "=", "self", ".", "_clean", "(", "p", ")", "return", "1.", "/", "(", "(", "p", "-", "1", ")", "*", "(", "np", ".", "log", "(", "1", "-", "p", ")", ")", ")" ]
Derivative of C-Log-Log transform link function Parameters ---------- p : array-like Mean parameters Returns ------- g'(p) : array The derivative of the CLogLog transform link function Notes ----- g'(p) = - 1 / ((p-1)*log...
[ "Derivative", "of", "C", "-", "Log", "-", "Log", "transform", "link", "function" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L749-L768
46,290
pysal/spglm
spglm/links.py
CLogLog.deriv2
def deriv2(self, p): """ Second derivative of the C-Log-Log ink function Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the CLogLog link function """ p ...
python
def deriv2(self, p): """ Second derivative of the C-Log-Log ink function Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the CLogLog link function """ p ...
[ "def", "deriv2", "(", "self", ",", "p", ")", ":", "p", "=", "self", ".", "_clean", "(", "p", ")", "fl", "=", "np", ".", "log", "(", "1", "-", "p", ")", "d2", "=", "-", "1", "/", "(", "(", "1", "-", "p", ")", "**", "2", "*", "fl", ")",...
Second derivative of the C-Log-Log ink function Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the CLogLog link function
[ "Second", "derivative", "of", "the", "C", "-", "Log", "-", "Log", "ink", "function" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L770-L788
46,291
pysal/spglm
spglm/links.py
NegativeBinomial.deriv2
def deriv2(self,p): ''' Second derivative of the negative binomial link function. Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the negative binomial transform link ...
python
def deriv2(self,p): ''' Second derivative of the negative binomial link function. Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the negative binomial transform link ...
[ "def", "deriv2", "(", "self", ",", "p", ")", ":", "numer", "=", "-", "(", "1", "+", "2", "*", "self", ".", "alpha", "*", "p", ")", "denom", "=", "(", "p", "+", "self", ".", "alpha", "*", "p", "**", "2", ")", "**", "2", "return", "numer", ...
Second derivative of the negative binomial link function. Parameters ---------- p : array-like Mean parameters Returns ------- g''(p) : array The second derivative of the negative binomial transform link function Notes ...
[ "Second", "derivative", "of", "the", "negative", "binomial", "link", "function", "." ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L900-L921
46,292
pysal/spglm
spglm/links.py
NegativeBinomial.inverse_deriv
def inverse_deriv(self, z): ''' Derivative of the inverse of the negative binomial transform Parameters ----------- z : array-like Usually the linear predictor for a GLM or GEE model Returns ------- g^(-1)'(z) : array The value of...
python
def inverse_deriv(self, z): ''' Derivative of the inverse of the negative binomial transform Parameters ----------- z : array-like Usually the linear predictor for a GLM or GEE model Returns ------- g^(-1)'(z) : array The value of...
[ "def", "inverse_deriv", "(", "self", ",", "z", ")", ":", "t", "=", "np", ".", "exp", "(", "z", ")", "return", "t", "/", "(", "self", ".", "alpha", "*", "(", "1", "-", "t", ")", "**", "2", ")" ]
Derivative of the inverse of the negative binomial transform Parameters ----------- z : array-like Usually the linear predictor for a GLM or GEE model Returns ------- g^(-1)'(z) : array The value of the derivative of the inverse of the negative ...
[ "Derivative", "of", "the", "inverse", "of", "the", "negative", "binomial", "transform" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/links.py#L923-L939
46,293
biocommons/eutils
eutils/client.py
Client.einfo
def einfo(self, db=None): """query the einfo endpoint :param db: string (optional) :rtype: EInfo or EInfoDB object If db is None, the reply is a list of databases, which is returned in an EInfo object (which has a databases() method). If db is not None, the reply is in...
python
def einfo(self, db=None): """query the einfo endpoint :param db: string (optional) :rtype: EInfo or EInfoDB object If db is None, the reply is a list of databases, which is returned in an EInfo object (which has a databases() method). If db is not None, the reply is in...
[ "def", "einfo", "(", "self", ",", "db", "=", "None", ")", ":", "if", "db", "is", "None", ":", "return", "EInfoResult", "(", "self", ".", "_qs", ".", "einfo", "(", ")", ")", ".", "dblist", "return", "EInfoResult", "(", "self", ".", "_qs", ".", "ei...
query the einfo endpoint :param db: string (optional) :rtype: EInfo or EInfoDB object If db is None, the reply is a list of databases, which is returned in an EInfo object (which has a databases() method). If db is not None, the reply is information about the specified ...
[ "query", "the", "einfo", "endpoint" ]
0ec7444fd520d2af56114122442ff8f60952db0b
https://github.com/biocommons/eutils/blob/0ec7444fd520d2af56114122442ff8f60952db0b/eutils/client.py#L52-L68
46,294
biocommons/eutils
eutils/client.py
Client.esearch
def esearch(self, db, term): """query the esearch endpoint """ esr = ESearchResult(self._qs.esearch({'db': db, 'term': term})) if esr.count > esr.retmax: logger.warning("NCBI found {esr.count} results, but we truncated the reply at {esr.retmax}" " resu...
python
def esearch(self, db, term): """query the esearch endpoint """ esr = ESearchResult(self._qs.esearch({'db': db, 'term': term})) if esr.count > esr.retmax: logger.warning("NCBI found {esr.count} results, but we truncated the reply at {esr.retmax}" " resu...
[ "def", "esearch", "(", "self", ",", "db", ",", "term", ")", ":", "esr", "=", "ESearchResult", "(", "self", ".", "_qs", ".", "esearch", "(", "{", "'db'", ":", "db", ",", "'term'", ":", "term", "}", ")", ")", "if", "esr", ".", "count", ">", "esr"...
query the esearch endpoint
[ "query", "the", "esearch", "endpoint" ]
0ec7444fd520d2af56114122442ff8f60952db0b
https://github.com/biocommons/eutils/blob/0ec7444fd520d2af56114122442ff8f60952db0b/eutils/client.py#L70-L77
46,295
biocommons/eutils
eutils/client.py
Client.efetch
def efetch(self, db, id): """query the efetch endpoint """ db = db.lower() xml = self._qs.efetch({'db': db, 'id': str(id)}) doc = le.XML(xml) if db in ['gene']: return EntrezgeneSet(doc) if db in ['nuccore', 'nucest', 'protein']: # TODO: GB...
python
def efetch(self, db, id): """query the efetch endpoint """ db = db.lower() xml = self._qs.efetch({'db': db, 'id': str(id)}) doc = le.XML(xml) if db in ['gene']: return EntrezgeneSet(doc) if db in ['nuccore', 'nucest', 'protein']: # TODO: GB...
[ "def", "efetch", "(", "self", ",", "db", ",", "id", ")", ":", "db", "=", "db", ".", "lower", "(", ")", "xml", "=", "self", ".", "_qs", ".", "efetch", "(", "{", "'db'", ":", "db", ",", "'id'", ":", "str", "(", "id", ")", "}", ")", "doc", "...
query the efetch endpoint
[ "query", "the", "efetch", "endpoint" ]
0ec7444fd520d2af56114122442ff8f60952db0b
https://github.com/biocommons/eutils/blob/0ec7444fd520d2af56114122442ff8f60952db0b/eutils/client.py#L79-L96
46,296
asweigart/pygbutton
pygbutton/__init__.py
PygButton.draw
def draw(self, surfaceObj): """Blit the current button's appearance to the surface object.""" if self._visible: if self.buttonDown: surfaceObj.blit(self.surfaceDown, self._rect) elif self.mouseOverButton: surfaceObj.blit(self.surfaceHighlight, self...
python
def draw(self, surfaceObj): """Blit the current button's appearance to the surface object.""" if self._visible: if self.buttonDown: surfaceObj.blit(self.surfaceDown, self._rect) elif self.mouseOverButton: surfaceObj.blit(self.surfaceHighlight, self...
[ "def", "draw", "(", "self", ",", "surfaceObj", ")", ":", "if", "self", ".", "_visible", ":", "if", "self", ".", "buttonDown", ":", "surfaceObj", ".", "blit", "(", "self", ".", "surfaceDown", ",", "self", ".", "_rect", ")", "elif", "self", ".", "mouse...
Blit the current button's appearance to the surface object.
[ "Blit", "the", "current", "button", "s", "appearance", "to", "the", "surface", "object", "." ]
7fab6a0d53f2b1d2d1d83768464eb2bf2a24802b
https://github.com/asweigart/pygbutton/blob/7fab6a0d53f2b1d2d1d83768464eb2bf2a24802b/pygbutton/__init__.py#L182-L190
46,297
pysal/spglm
spglm/family.py
Family._setlink
def _setlink(self, link): """ Helper method to set the link for a family. Raises a ValueError exception if the link is not available. Note that the error message might not be that informative because it tells you that the link should be in the base class for the link function. ...
python
def _setlink(self, link): """ Helper method to set the link for a family. Raises a ValueError exception if the link is not available. Note that the error message might not be that informative because it tells you that the link should be in the base class for the link function. ...
[ "def", "_setlink", "(", "self", ",", "link", ")", ":", "# TODO: change the links class attribute in the families to hold", "# meaningful information instead of a list of links instances such as", "# [<statsmodels.family.links.Log object at 0x9a4240c>,", "# <statsmodels.family.links.Power obje...
Helper method to set the link for a family. Raises a ValueError exception if the link is not available. Note that the error message might not be that informative because it tells you that the link should be in the base class for the link function. See glm.GLM for a list of appropriate...
[ "Helper", "method", "to", "set", "the", "link", "for", "a", "family", "." ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/family.py#L39-L64
46,298
pysal/spglm
spglm/family.py
Family.weights
def weights(self, mu): r""" Weights for IRLS steps Parameters ---------- mu : array-like The transformed mean response variable in the exponential family Returns ------- w : array The weights for the IRLS steps """ ...
python
def weights(self, mu): r""" Weights for IRLS steps Parameters ---------- mu : array-like The transformed mean response variable in the exponential family Returns ------- w : array The weights for the IRLS steps """ ...
[ "def", "weights", "(", "self", ",", "mu", ")", ":", "return", "1.", "/", "(", "self", ".", "link", ".", "deriv", "(", "mu", ")", "**", "2", "*", "self", ".", "variance", "(", "mu", ")", ")" ]
r""" Weights for IRLS steps Parameters ---------- mu : array-like The transformed mean response variable in the exponential family Returns ------- w : array The weights for the IRLS steps
[ "r", "Weights", "for", "IRLS", "steps" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/family.py#L96-L111
46,299
pysal/spglm
spglm/family.py
Gaussian.resid_dev
def resid_dev(self, endog, mu, scale=1.): """ Gaussian deviance residuals Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable scale : float, optional An optional ...
python
def resid_dev(self, endog, mu, scale=1.): """ Gaussian deviance residuals Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable scale : float, optional An optional ...
[ "def", "resid_dev", "(", "self", ",", "endog", ",", "mu", ",", "scale", "=", "1.", ")", ":", "return", "(", "endog", "-", "mu", ")", "/", "np", ".", "sqrt", "(", "self", ".", "variance", "(", "mu", ")", ")", "/", "scale" ]
Gaussian deviance residuals Parameters ----------- endog : array-like Endogenous response variable mu : array-like Fitted mean response variable scale : float, optional An optional argument to divide the residuals by scale. The default ...
[ "Gaussian", "deviance", "residuals" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/family.py#L500-L521