hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
9128b26f8e8f7eb2ad29120c8222d0d0e282cb47
mqtlam/dcgan-tfslim
train.py
[ "MIT" ]
Python
generate_z
<not_specific>
def generate_z(sample_size, z_dim): """Helper function to generate noise vector. Can replace this with a different noise function. Args: sample_size: sample/batch size z_dim: dimensionality of z noise Returns: random noise, dimensionality is (sample_size, z_dim) """ ret...
Helper function to generate noise vector. Can replace this with a different noise function. Args: sample_size: sample/batch size z_dim: dimensionality of z noise Returns: random noise, dimensionality is (sample_size, z_dim)
Helper function to generate noise vector. Can replace this with a different noise function.
[ "Helper", "function", "to", "generate", "noise", "vector", ".", "Can", "replace", "this", "with", "a", "different", "noise", "function", "." ]
def generate_z(sample_size, z_dim): return np.random.uniform(-1, 1, size=(sample_size, z_dim)).astype(np.float32)
[ "def", "generate_z", "(", "sample_size", ",", "z_dim", ")", ":", "return", "np", ".", "random", ".", "uniform", "(", "-", "1", ",", "1", ",", "size", "=", "(", "sample_size", ",", "z_dim", ")", ")", ".", "astype", "(", "np", ".", "float32", ")" ]
Helper function to generate noise vector.
[ "Helper", "function", "to", "generate", "noise", "vector", "." ]
[ "\"\"\"Helper function to generate noise vector.\n Can replace this with a different noise function.\n\n Args:\n sample_size: sample/batch size\n z_dim: dimensionality of z noise\n\n Returns:\n random noise, dimensionality is (sample_size, z_dim)\n \"\"\"" ]
[ { "param": "sample_size", "type": null }, { "param": "z_dim", "type": null } ]
{ "returns": [ { "docstring": "random noise, dimensionality is (sample_size, z_dim)", "docstring_tokens": [ "random", "noise", "dimensionality", "is", "(", "sample_size", "z_dim", ")" ], "type": null } ], "raises": [],...
9128b26f8e8f7eb2ad29120c8222d0d0e282cb47
mqtlam/dcgan-tfslim
train.py
[ "MIT" ]
Python
train
null
def train(dcgan): """Train DCGAN. Preconditions: checkpoint, data, logs directories exist Postconditions: checkpoints are saved logs are written Args: dcgan: DCGAN object """ sess = dcgan.sess FLAGS = dcgan.f # load dataset list_file = os.path.join...
Train DCGAN. Preconditions: checkpoint, data, logs directories exist Postconditions: checkpoints are saved logs are written Args: dcgan: DCGAN object
Train DCGAN. Preconditions: checkpoint, data, logs directories exist checkpoints are saved logs are written
[ "Train", "DCGAN", ".", "Preconditions", ":", "checkpoint", "data", "logs", "directories", "exist", "checkpoints", "are", "saved", "logs", "are", "written" ]
def train(dcgan): sess = dcgan.sess FLAGS = dcgan.f list_file = os.path.join(FLAGS.data_dir, '{0}.txt'.format(FLAGS.dataset)) if os.path.exists(list_file): print "Using training list: {0}".format(list_file) with open(list_file, 'r') as f: data = [os.path.join(FLAGS.data_dir, ...
[ "def", "train", "(", "dcgan", ")", ":", "sess", "=", "dcgan", ".", "sess", "FLAGS", "=", "dcgan", ".", "f", "list_file", "=", "os", ".", "path", ".", "join", "(", "FLAGS", ".", "data_dir", ",", "'{0}.txt'", ".", "format", "(", "FLAGS", ".", "datase...
Train DCGAN.
[ "Train", "DCGAN", "." ]
[ "\"\"\"Train DCGAN.\n\n Preconditions:\n checkpoint, data, logs directories exist\n\n Postconditions:\n checkpoints are saved\n logs are written\n\n Args:\n dcgan: DCGAN object\n \"\"\"", "# load dataset", "# load from file when found", "# recursively walk dataset direc...
[ { "param": "dcgan", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dcgan", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb96625504fecb0a1f9069aced14dea147e893bd
mqtlam/dcgan-tfslim
dcgan.py
[ "MIT" ]
Python
save
null
def save(self, step): """Save model. Postconditions: checkpoint directory is created if not found checkpoint directory is updated with new saved model Args: step: step of training to save """ model_name = "DCGAN.model" model_dir = sel...
Save model. Postconditions: checkpoint directory is created if not found checkpoint directory is updated with new saved model Args: step: step of training to save
Save model. Postconditions: checkpoint directory is created if not found checkpoint directory is updated with new saved model
[ "Save", "model", ".", "Postconditions", ":", "checkpoint", "directory", "is", "created", "if", "not", "found", "checkpoint", "directory", "is", "updated", "with", "new", "saved", "model" ]
def save(self, step): model_name = "DCGAN.model" model_dir = self.get_model_dir() checkpoint_dir = os.path.join(self.f.checkpoint_dir, model_dir) if not os.path.exists(checkpoint_dir): os.makedirs(checkpoint_dir) model_file_prefix = model_dir self.saver.save(s...
[ "def", "save", "(", "self", ",", "step", ")", ":", "model_name", "=", "\"DCGAN.model\"", "model_dir", "=", "self", ".", "get_model_dir", "(", ")", "checkpoint_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "f", ".", "checkpoint_dir", ",", ...
Save model.
[ "Save", "model", "." ]
[ "\"\"\"Save model.\n\n Postconditions:\n checkpoint directory is created if not found\n checkpoint directory is updated with new saved model\n\n Args:\n step: step of training to save\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "step", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "step", "type": null, "docstring": "step of training to save", ...
cb96625504fecb0a1f9069aced14dea147e893bd
mqtlam/dcgan-tfslim
dcgan.py
[ "MIT" ]
Python
checkpoint_exists
<not_specific>
def checkpoint_exists(self): """Check if any checkpoints exist. Returns: True if any checkpoints exist """ model_dir = self.get_model_dir() checkpoint_dir = os.path.join(self.f.checkpoint_dir, model_dir) return os.path.exists(checkpoint_dir)
Check if any checkpoints exist. Returns: True if any checkpoints exist
Check if any checkpoints exist.
[ "Check", "if", "any", "checkpoints", "exist", "." ]
def checkpoint_exists(self): model_dir = self.get_model_dir() checkpoint_dir = os.path.join(self.f.checkpoint_dir, model_dir) return os.path.exists(checkpoint_dir)
[ "def", "checkpoint_exists", "(", "self", ")", ":", "model_dir", "=", "self", ".", "get_model_dir", "(", ")", "checkpoint_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "f", ".", "checkpoint_dir", ",", "model_dir", ")", "return", "os", ".", ...
Check if any checkpoints exist.
[ "Check", "if", "any", "checkpoints", "exist", "." ]
[ "\"\"\"Check if any checkpoints exist.\n\n Returns:\n True if any checkpoints exist\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "True if any checkpoints exist", "docstring_tokens": [ "True", "if", "any", "checkpoints", "exist" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "doc...
cb96625504fecb0a1f9069aced14dea147e893bd
mqtlam/dcgan-tfslim
dcgan.py
[ "MIT" ]
Python
__create_summaries
null
def __create_summaries(self): """Helper function to create summaries. """ # histogram summaries self.z_sum = tf.summary.histogram("z", self.z) self.d_real_sum = tf.summary.histogram("d/output/real", self.D_real) self.d_fake_sum = tf.summary.histogram("d/output/fake", self...
Helper function to create summaries.
Helper function to create summaries.
[ "Helper", "function", "to", "create", "summaries", "." ]
def __create_summaries(self): self.z_sum = tf.summary.histogram("z", self.z) self.d_real_sum = tf.summary.histogram("d/output/real", self.D_real) self.d_fake_sum = tf.summary.histogram("d/output/fake", self.D_fake) self.g_sum = tf.summary.image("generated", ...
[ "def", "__create_summaries", "(", "self", ")", ":", "self", ".", "z_sum", "=", "tf", ".", "summary", ".", "histogram", "(", "\"z\"", ",", "self", ".", "z", ")", "self", ".", "d_real_sum", "=", "tf", ".", "summary", ".", "histogram", "(", "\"d/output/re...
Helper function to create summaries.
[ "Helper", "function", "to", "create", "summaries", "." ]
[ "\"\"\"Helper function to create summaries.\n \"\"\"", "# histogram summaries", "# image summaries", "# scalar summaries" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c8d0e4e63ce94d76ab1a16c49c36d3bb3d88d20b
mattk7/netrd
netrd/reconstruction/partial_correlation_matrix.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, TS, index=None, drop_index=True, of_residuals=False, cutoffs=[(-1, 1)]): """ Reconstruct a network from time series data using a regularized form of the precision matrix. After [this tutorial]( https://bwlewis.gith...
Reconstruct a network from time series data using a regularized form of the precision matrix. After [this tutorial]( https://bwlewis.github.io/correlation-regularization/) in R. Params ------ index (int, array of ints, or None): Take the partial correlations of ...
Reconstruct a network from time series data using a regularized form of the precision matrix. Params index (int, array of ints, or None): Take the partial correlations of each pair of elements holding constant an index variable or set of index variables. If None, take the partial correlations of the variables holding...
[ "Reconstruct", "a", "network", "from", "time", "series", "data", "using", "a", "regularized", "form", "of", "the", "precision", "matrix", ".", "Params", "index", "(", "int", "array", "of", "ints", "or", "None", ")", ":", "Take", "the", "partial", "correlat...
def fit(self, TS, index=None, drop_index=True, of_residuals=False, cutoffs=[(-1, 1)]): p_cor = partial_corr(TS, index=index) if drop_index and index is not None: p_cor = np.delete(p_cor, index, axis=0) p_cor = np.delete(...
[ "def", "fit", "(", "self", ",", "TS", ",", "index", "=", "None", ",", "drop_index", "=", "True", ",", "of_residuals", "=", "False", ",", "cutoffs", "=", "[", "(", "-", "1", ",", "1", ")", "]", ")", ":", "p_cor", "=", "partial_corr", "(", "TS", ...
Reconstruct a network from time series data using a regularized form of the precision matrix.
[ "Reconstruct", "a", "network", "from", "time", "series", "data", "using", "a", "regularized", "form", "of", "the", "precision", "matrix", "." ]
[ "\"\"\"\n Reconstruct a network from time series data using a regularized\n form of the precision matrix. After [this tutorial](\n https://bwlewis.github.io/correlation-regularization/) in R.\n\n Params\n ------\n index (int, array of ints, or None): Take the partial correl...
[ { "param": "self", "type": null }, { "param": "TS", "type": null }, { "param": "index", "type": null }, { "param": "drop_index", "type": null }, { "param": "of_residuals", "type": null }, { "param": "cutoffs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [],...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, TS, deg=15, nbins=10): """ Reconstruct a network by calculating the mutual information between the probability distributions of the (binned) values of the time series of pairs of nodes, i and j. First, the mutual information is computed between each pair of vertice...
Reconstruct a network by calculating the mutual information between the probability distributions of the (binned) values of the time series of pairs of nodes, i and j. First, the mutual information is computed between each pair of vertices. Then, a thresholding condition is app...
Reconstruct a network by calculating the mutual information between the probability distributions of the (binned) values of the time series of pairs of nodes, i and j. First, the mutual information is computed between each pair of vertices. Then, a thresholding condition is applied to obtain edges. Params TS (np.nda...
[ "Reconstruct", "a", "network", "by", "calculating", "the", "mutual", "information", "between", "the", "probability", "distributions", "of", "the", "(", "binned", ")", "values", "of", "the", "time", "series", "of", "pairs", "of", "nodes", "i", "and", "j", "."...
def fit(self, TS, deg=15, nbins=10): N = TS.shape[0] rang = [np.min(TS), np.max(TS)] IndivP = find_individual_probability_distribution(TS, rang, nbins) ProduP = find_product_probability_distribution(IndivP, N) JointP = find_joint_probability_distribution(TS, rang, nbins) ...
[ "def", "fit", "(", "self", ",", "TS", ",", "deg", "=", "15", ",", "nbins", "=", "10", ")", ":", "N", "=", "TS", ".", "shape", "[", "0", "]", "rang", "=", "[", "np", ".", "min", "(", "TS", ")", ",", "np", ".", "max", "(", "TS", ")", "]",...
Reconstruct a network by calculating the mutual information between the probability distributions of the (binned) values of the time series of pairs of nodes, i and j.
[ "Reconstruct", "a", "network", "by", "calculating", "the", "mutual", "information", "between", "the", "probability", "distributions", "of", "the", "(", "binned", ")", "values", "of", "the", "time", "series", "of", "pairs", "of", "nodes", "i", "and", "j", "."...
[ "\"\"\"\n Reconstruct a network by calculating the mutual information between the\n probability distributions of the (binned) values of the time series of\n pairs of nodes, i and j.\n\n First, the mutual information is computed between each pair of vertices.\n Then, a thresholding...
[ { "param": "self", "type": null }, { "param": "TS", "type": null }, { "param": "deg", "type": null }, { "param": "nbins", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [],...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
find_individual_probability_distribution
<not_specific>
def find_individual_probability_distribution(TS, rang, nbins): """ Assign each node to a vector of length nbins where each element is the probability of the node in the time series being in that binned "state" Params ------ TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors....
Assign each node to a vector of length nbins where each element is the probability of the node in the time series being in that binned "state" Params ------ TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors. rang (list): list of the minimum and maximum value in the time se...
Assign each node to a vector of length nbins where each element is the probability of the node in the time series being in that binned "state" Params TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors. rang (list): list of the minimum and maximum value in the time series nbins (int): number of bin...
[ "Assign", "each", "node", "to", "a", "vector", "of", "length", "nbins", "where", "each", "element", "is", "the", "probability", "of", "the", "node", "in", "the", "time", "series", "being", "in", "that", "binned", "\"", "state", "\"", "Params", "TS", "(",...
def find_individual_probability_distribution(TS, rang, nbins): N, L = TS.shape IndivP = dict() for j in range(N): P, _ = np.histogram(TS[j], bins=nbins, range=rang) IndivP[j] = P / L return IndivP
[ "def", "find_individual_probability_distribution", "(", "TS", ",", "rang", ",", "nbins", ")", ":", "N", ",", "L", "=", "TS", ".", "shape", "IndivP", "=", "dict", "(", ")", "for", "j", "in", "range", "(", "N", ")", ":", "P", ",", "_", "=", "np", "...
Assign each node to a vector of length nbins where each element is the probability of the node in the time series being in that binned "state"
[ "Assign", "each", "node", "to", "a", "vector", "of", "length", "nbins", "where", "each", "element", "is", "the", "probability", "of", "the", "node", "in", "the", "time", "series", "being", "in", "that", "binned", "\"", "state", "\"" ]
[ "\"\"\"\n Assign each node to a vector of length nbins where each element is the probability of the\n node in the time series being in that binned \"state\"\n\n Params\n ------\n TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors.\n rang (list): list of the minimum and maximum ...
[ { "param": "TS", "type": null }, { "param": "rang", "type": null }, { "param": "nbins", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rang", "type": null, "docstring": null, "docstring_tokens": [],...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
find_product_probability_distribution
<not_specific>
def find_product_probability_distribution(IndivP, N): """ Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'. P(x) * P(y) <-- as opposed to P(x,y) Params ------ IndivP (dict): dictionary that gets ou...
Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'. P(x) * P(y) <-- as opposed to P(x,y) Params ------ IndivP (dict): dictionary that gets output by find_individual_probability_distribution() N (int...
Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'. Params IndivP (dict): dictionary that gets output by find_individual_probability_distribution() N (int): number of nodes in the graph Returns ProduP (dict): a dictionar...
[ "Assign", "each", "node", "j", "to", "a", "vector", "of", "length", "nbins", "where", "each", "element", "is", "the", "product", "of", "its", "own", "individual_probability_distribution", "and", "its", "neighbors", "'", ".", "Params", "IndivP", "(", "dict", ...
def find_product_probability_distribution(IndivP, N): ProduP = dict() for l in range(N): for j in range(l): ProduP[(j,l)] = np.outer(IndivP[j], IndivP[l]) return ProduP
[ "def", "find_product_probability_distribution", "(", "IndivP", ",", "N", ")", ":", "ProduP", "=", "dict", "(", ")", "for", "l", "in", "range", "(", "N", ")", ":", "for", "j", "in", "range", "(", "l", ")", ":", "ProduP", "[", "(", "j", ",", "l", "...
Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'.
[ "Assign", "each", "node", "j", "to", "a", "vector", "of", "length", "nbins", "where", "each", "element", "is", "the", "product", "of", "its", "own", "individual_probability_distribution", "and", "its", "neighbors", "'", "." ]
[ "\"\"\"\n Assign each node j to a vector of length nbins where each element is the product of its own\n individual_probability_distribution and its neighbors'. P(x) * P(y) <-- as opposed to P(x,y)\n\n Params\n ------\n IndivP (dict): dictionary that gets output by find_individual_probability_distribu...
[ { "param": "IndivP", "type": null }, { "param": "N", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "IndivP", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "N", "type": null, "docstring": null, "docstring_tokens": []...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
find_joint_probability_distribution
<not_specific>
def find_joint_probability_distribution(TS, rang, nbins): """ Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'. P(x) * P(y) <-- as opposed to P(x,y) Params ------ TS (np.ndarray): Array consisting ...
Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'. P(x) * P(y) <-- as opposed to P(x,y) Params ------ TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors. rang (list): list of th...
Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'. Params TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors. rang (list): list of the minimum and maximum value in the time series nbins (int): number o...
[ "Assign", "each", "node", "j", "to", "a", "vector", "of", "length", "nbins", "where", "each", "element", "is", "the", "product", "of", "its", "own", "individual_probability_distribution", "and", "its", "neighbors", "'", ".", "Params", "TS", "(", "np", ".", ...
def find_joint_probability_distribution(TS, rang, nbins): N, L = TS.shape JointP = dict() for l in range(N): for j in range(l): P, _, _ = np.histogram2d(TS[j], TS[l], bins=nbins, range=np.array([rang,rang])) JointP[(j,l)] = P / L return JointP
[ "def", "find_joint_probability_distribution", "(", "TS", ",", "rang", ",", "nbins", ")", ":", "N", ",", "L", "=", "TS", ".", "shape", "JointP", "=", "dict", "(", ")", "for", "l", "in", "range", "(", "N", ")", ":", "for", "j", "in", "range", "(", ...
Assign each node j to a vector of length nbins where each element is the product of its own individual_probability_distribution and its neighbors'.
[ "Assign", "each", "node", "j", "to", "a", "vector", "of", "length", "nbins", "where", "each", "element", "is", "the", "product", "of", "its", "own", "individual_probability_distribution", "and", "its", "neighbors", "'", "." ]
[ "\"\"\"\n Assign each node j to a vector of length nbins where each element is the product of its own\n individual_probability_distribution and its neighbors'. P(x) * P(y) <-- as opposed to P(x,y)\n\n Params\n ------\n TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors.\n rang ...
[ { "param": "TS", "type": null }, { "param": "rang", "type": null }, { "param": "nbins", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rang", "type": null, "docstring": null, "docstring_tokens": [],...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
mutual_info_node_pair
<not_specific>
def mutual_info_node_pair(JointP_jl, ProduP_jl): """ Calculate the mutual information between two nodes. Params ------ JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distribu...
Calculate the mutual information between two nodes. Params ------ JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions Returns ------- I_jl (float): the mut...
Calculate the mutual information between two nodes. Params JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions Returns I_jl (float): the mutual information between j and l, or the (j,l)'t...
[ "Calculate", "the", "mutual", "information", "between", "two", "nodes", ".", "Params", "JointP_jl", "(", "np", ".", "ndarray", ")", ":", "nbins", "x", "nbins", "array", "of", "two", "nodes", "'", "joint", "probability", "distributions", "ProduP_jl", "(", "np...
def mutual_info_node_pair(JointP_jl, ProduP_jl): I_jl = 0 for q,p in zip(JointP_jl.flatten(), ProduP_jl.flatten()): if q > 0 and p > 0: I_jl += q * np.log( q / p ) return I_jl
[ "def", "mutual_info_node_pair", "(", "JointP_jl", ",", "ProduP_jl", ")", ":", "I_jl", "=", "0", "for", "q", ",", "p", "in", "zip", "(", "JointP_jl", ".", "flatten", "(", ")", ",", "ProduP_jl", ".", "flatten", "(", ")", ")", ":", "if", "q", ">", "0"...
Calculate the mutual information between two nodes.
[ "Calculate", "the", "mutual", "information", "between", "two", "nodes", "." ]
[ "\"\"\"\n Calculate the mutual information between two nodes.\n\n Params\n ------\n JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions\n ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions\n\n Returns\n -------\n ...
[ { "param": "JointP_jl", "type": null }, { "param": "ProduP_jl", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "JointP_jl", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ProduP_jl", "type": null, "docstring": null, "docstring_...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
mutual_info_all_pairs
<not_specific>
def mutual_info_all_pairs(JointP, ProduP, N): """ Calculate the mutual information between all pairs of nodes. Params ------ JointP (dict): a dictionary where the keys are pairs of nodes in the graph and the are nbins x nbins arrays corresponding to joint probability vectors ...
Calculate the mutual information between all pairs of nodes. Params ------ JointP (dict): a dictionary where the keys are pairs of nodes in the graph and the are nbins x nbins arrays corresponding to joint probability vectors ProduP (dict): a dictionary where the keys are pairs ...
Calculate the mutual information between all pairs of nodes. Params JointP (dict): a dictionary where the keys are pairs of nodes in the graph and the are nbins x nbins arrays corresponding to joint probability vectors ProduP (dict): a dictionary where the keys are pairs of nodes in the graph and the values are nbins ...
[ "Calculate", "the", "mutual", "information", "between", "all", "pairs", "of", "nodes", ".", "Params", "JointP", "(", "dict", ")", ":", "a", "dictionary", "where", "the", "keys", "are", "pairs", "of", "nodes", "in", "the", "graph", "and", "the", "are", "n...
def mutual_info_all_pairs(JointP, ProduP, N): I = np.zeros((N, N)) for l in range(N): for j in range(l): JointP_jl = JointP[(j,l)] ProduP_jl = ProduP[(j,l)] I[j,l] = mutual_info_node_pair(JointP_jl, ProduP_jl) I[l,j] = I[j,l] return I
[ "def", "mutual_info_all_pairs", "(", "JointP", ",", "ProduP", ",", "N", ")", ":", "I", "=", "np", ".", "zeros", "(", "(", "N", ",", "N", ")", ")", "for", "l", "in", "range", "(", "N", ")", ":", "for", "j", "in", "range", "(", "l", ")", ":", ...
Calculate the mutual information between all pairs of nodes.
[ "Calculate", "the", "mutual", "information", "between", "all", "pairs", "of", "nodes", "." ]
[ "\"\"\"\n Calculate the mutual information between all pairs of nodes.\n\n Params\n ------\n JointP (dict): a dictionary where the keys are pairs of nodes in the graph and the\n are nbins x nbins arrays corresponding to joint probability vectors\n ProduP (dict): a dictionary where t...
[ { "param": "JointP", "type": null }, { "param": "ProduP", "type": null }, { "param": "N", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "JointP", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ProduP", "type": null, "docstring": null, "docstring_tokens...
76015edfb788a7bf5b11e9be1f3377a696b927e1
mattk7/netrd
netrd/reconstruction/mutual_information_matrix.py
[ "MIT" ]
Python
threshold_from_degree
<not_specific>
def threshold_from_degree(deg,M): """ Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg. Params ------ deg (int): Target degree for which the appropriate threshold will be computed M (np.ndarray): Pre-thresholded NxN array Returns ------ ...
Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg. Params ------ deg (int): Target degree for which the appropriate threshold will be computed M (np.ndarray): Pre-thresholded NxN array Returns ------ tau (float): Required threshold for A=np....
Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg. Params deg (int): Target degree for which the appropriate threshold will be computed M (np.ndarray): Pre-thresholded NxN array Returns tau (float): Required threshold for A=np.array(I<tau,dtype=int) to have an average of ...
[ "Compute", "the", "required", "threshold", "(", "tau", ")", "in", "order", "to", "yield", "a", "reconstructed", "graph", "of", "mean", "degree", "deg", ".", "Params", "deg", "(", "int", ")", ":", "Target", "degree", "for", "which", "the", "appropriate", ...
def threshold_from_degree(deg,M): N=len(M) A=np.ones((N,N)) for tau in sorted(M.flatten()): A[M==tau]=0 if np.mean(np.sum(A,1))<deg: break return tau
[ "def", "threshold_from_degree", "(", "deg", ",", "M", ")", ":", "N", "=", "len", "(", "M", ")", "A", "=", "np", ".", "ones", "(", "(", "N", ",", "N", ")", ")", "for", "tau", "in", "sorted", "(", "M", ".", "flatten", "(", ")", ")", ":", "A",...
Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.
[ "Compute", "the", "required", "threshold", "(", "tau", ")", "in", "order", "to", "yield", "a", "reconstructed", "graph", "of", "mean", "degree", "deg", "." ]
[ "\"\"\"\n Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.\n Params\n ------\n deg (int): Target degree for which the appropriate threshold will be computed\n M (np.ndarray): Pre-thresholded NxN array\n Returns\n ------\n tau (float): Required ...
[ { "param": "deg", "type": null }, { "param": "M", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "deg", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "M", "type": null, "docstring": null, "docstring_tokens": [], ...
60df341b653ec62323b645c0636c8cb28aca2289
mattk7/netrd
netrd/reconstruction/convergent_cross_mapping.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, TS, tau=1, alpha=0.05): """Infer causal relation applying Takens Theorem of dynamical systems. Convergent cross-mapping infers dynamical causal relation between vairiables from time series data. Time series data portray an attractor manifold of the dynamical system of inte...
Infer causal relation applying Takens Theorem of dynamical systems. Convergent cross-mapping infers dynamical causal relation between vairiables from time series data. Time series data portray an attractor manifold of the dynamical system of interests. Existing approaches of attractor r...
Infer causal relation applying Takens Theorem of dynamical systems. Convergent cross-mapping infers dynamical causal relation between vairiables from time series data. Time series data portray an attractor manifold of the dynamical system of interests. The convergent cross-mapping algorithm first constructs the shadow...
[ "Infer", "causal", "relation", "applying", "Takens", "Theorem", "of", "dynamical", "systems", ".", "Convergent", "cross", "-", "mapping", "infers", "dynamical", "causal", "relation", "between", "vairiables", "from", "time", "series", "data", ".", "Time", "series",...
def fit(self, TS, tau=1, alpha=0.05): data = TS.T L, N = data.shape if L < 3 + (N-1) * (1+tau): message = 'Need more data.' message += ' L must be not less than 3+(N-1)*(1+tau).' raise ValueError(message) shadows = [shadow_data_cloud(data[:, i], N, t...
[ "def", "fit", "(", "self", ",", "TS", ",", "tau", "=", "1", ",", "alpha", "=", "0.05", ")", ":", "data", "=", "TS", ".", "T", "L", ",", "N", "=", "data", ".", "shape", "if", "L", "<", "3", "+", "(", "N", "-", "1", ")", "*", "(", "1", ...
Infer causal relation applying Takens Theorem of dynamical systems.
[ "Infer", "causal", "relation", "applying", "Takens", "Theorem", "of", "dynamical", "systems", "." ]
[ "\"\"\"Infer causal relation applying Takens Theorem of dynamical systems.\n\n Convergent cross-mapping infers dynamical causal relation between\n vairiables from time series data. Time series data portray an attractor\n manifold of the dynamical system of interests. Existing approaches of\n ...
[ { "param": "self", "type": null }, { "param": "TS", "type": null }, { "param": "tau", "type": null }, { "param": "alpha", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [],...
60df341b653ec62323b645c0636c8cb28aca2289
mattk7/netrd
netrd/reconstruction/convergent_cross_mapping.py
[ "MIT" ]
Python
nearest_neighbors
<not_specific>
def nearest_neighbors(shadow, L): """ Return time indices of the N+1 nearest neighbors for every point in the shadow data cloud and their corresponding Euclidean distances. Params ------ shadow (np.ndarray): Array of the shadow data cloud. L (int): Number of observations in the time series...
Return time indices of the N+1 nearest neighbors for every point in the shadow data cloud and their corresponding Euclidean distances. Params ------ shadow (np.ndarray): Array of the shadow data cloud. L (int): Number of observations in the time series. Returns ------- nei (np.nd...
Return time indices of the N+1 nearest neighbors for every point in the shadow data cloud and their corresponding Euclidean distances. Params shadow (np.ndarray): Array of the shadow data cloud. L (int): Number of observations in the time series. Returns nei (np.ndarray): $M \times (N+1)$ array of time indices of ...
[ "Return", "time", "indices", "of", "the", "N", "+", "1", "nearest", "neighbors", "for", "every", "point", "in", "the", "shadow", "data", "cloud", "and", "their", "corresponding", "Euclidean", "distances", ".", "Params", "shadow", "(", "np", ".", "ndarray", ...
def nearest_neighbors(shadow, L): M, N = shadow.shape k = N + 2 method = 'ball_tree' if k < M/2 else 'brute' nbrs = NearestNeighbors(n_neighbors=k, algorithm=method).fit(shadow) dist, nei = nbrs.kneighbors(shadow) nei = np.delete(nei, 0, axis=1) dist = np.delete(dist, 0, axis=1) nei +=...
[ "def", "nearest_neighbors", "(", "shadow", ",", "L", ")", ":", "M", ",", "N", "=", "shadow", ".", "shape", "k", "=", "N", "+", "2", "method", "=", "'ball_tree'", "if", "k", "<", "M", "/", "2", "else", "'brute'", "nbrs", "=", "NearestNeighbors", "("...
Return time indices of the N+1 nearest neighbors for every point in the shadow data cloud and their corresponding Euclidean distances.
[ "Return", "time", "indices", "of", "the", "N", "+", "1", "nearest", "neighbors", "for", "every", "point", "in", "the", "shadow", "data", "cloud", "and", "their", "corresponding", "Euclidean", "distances", "." ]
[ "\"\"\"\n Return time indices of the N+1 nearest neighbors for every point in the\n shadow data cloud and their corresponding Euclidean distances.\n\n Params\n ------\n shadow (np.ndarray): Array of the shadow data cloud.\n\n L (int): Number of observations in the time series.\n\n Returns\n ...
[ { "param": "shadow", "type": null }, { "param": "L", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "shadow", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "L", "type": null, "docstring": null, "docstring_tokens": []...
9c3c998aeb274da2f7a10185644ecddca1a1a7b7
mattk7/netrd
netrd/utilities/threshold.py
[ "MIT" ]
Python
threshold_in_range
<not_specific>
def threshold_in_range(mat, cutoffs=[(-1, 1)]): """ Threshold a numpy array by setting values not within a list of ranges to zero. Params ------ mat: (np.ndarray): A numpy array. cutoffs (list of tuples): When thresholding, include only edges whose correlations fall within a given range or ...
Threshold a numpy array by setting values not within a list of ranges to zero. Params ------ mat: (np.ndarray): A numpy array. cutoffs (list of tuples): When thresholding, include only edges whose correlations fall within a given range or set of ranges. The lower value must come first in e...
Threshold a numpy array by setting values not within a list of ranges to zero. Params Returns the thresholded numpy array
[ "Threshold", "a", "numpy", "array", "by", "setting", "values", "not", "within", "a", "list", "of", "ranges", "to", "zero", ".", "Params", "Returns", "the", "thresholded", "numpy", "array" ]
def threshold_in_range(mat, cutoffs=[(-1, 1)]): mask_function = np.vectorize(lambda x: any([x>=cutoff[0] and x<=cutoff[1] for cutoff in cutoffs])) mask = mask_function(mat) thresholded_mat = mat * mask return thresholded_mat
[ "def", "threshold_in_range", "(", "mat", ",", "cutoffs", "=", "[", "(", "-", "1", ",", "1", ")", "]", ")", ":", "mask_function", "=", "np", ".", "vectorize", "(", "lambda", "x", ":", "any", "(", "[", "x", ">=", "cutoff", "[", "0", "]", "and", "...
Threshold a numpy array by setting values not within a list of ranges to zero.
[ "Threshold", "a", "numpy", "array", "by", "setting", "values", "not", "within", "a", "list", "of", "ranges", "to", "zero", "." ]
[ "\"\"\"\n Threshold a numpy array by setting values not within a list of ranges to zero.\n\n Params\n ------\n mat: (np.ndarray): A numpy array.\n cutoffs (list of tuples): When thresholding, include only edges whose\n correlations fall within a given range or set of ranges. The lower\n value m...
[ { "param": "mat", "type": null }, { "param": "cutoffs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mat", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cutoffs", "type": null, "docstring": null, "docstring_tokens":...
9c3c998aeb274da2f7a10185644ecddca1a1a7b7
mattk7/netrd
netrd/utilities/threshold.py
[ "MIT" ]
Python
threshold_on_quantile
<not_specific>
def threshold_on_quantile(mat, quantile=0.9): """ Threshold a numpy array by setting values below a given quantile to zero. Params ------ mat: (np.ndarray): A numpy array. quantile (float): The threshold above which to keep an element of the array, e.g., set to zero elements below the 90th ...
Threshold a numpy array by setting values below a given quantile to zero. Params ------ mat: (np.ndarray): A numpy array. quantile (float): The threshold above which to keep an element of the array, e.g., set to zero elements below the 90th quantile of the array. Returns ------- t...
Threshold a numpy array by setting values below a given quantile to zero. Params Returns the thresholded numpy array
[ "Threshold", "a", "numpy", "array", "by", "setting", "values", "below", "a", "given", "quantile", "to", "zero", ".", "Params", "Returns", "the", "thresholded", "numpy", "array" ]
def threshold_on_quantile(mat, quantile=0.9): return mat * (mat > np.percentile(mat, quantile * 100))
[ "def", "threshold_on_quantile", "(", "mat", ",", "quantile", "=", "0.9", ")", ":", "return", "mat", "*", "(", "mat", ">", "np", ".", "percentile", "(", "mat", ",", "quantile", "*", "100", ")", ")" ]
Threshold a numpy array by setting values below a given quantile to zero.
[ "Threshold", "a", "numpy", "array", "by", "setting", "values", "below", "a", "given", "quantile", "to", "zero", "." ]
[ "\"\"\"\n Threshold a numpy array by setting values below a given quantile to zero.\n\n Params\n ------\n mat: (np.ndarray): A numpy array.\n quantile (float): The threshold above which to keep an element of the array,\n e.g., set to zero elements below the 90th quantile of the array.\n\n Retur...
[ { "param": "mat", "type": null }, { "param": "quantile", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mat", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "quantile", "type": null, "docstring": null, "docstring_tokens"...
9c3c998aeb274da2f7a10185644ecddca1a1a7b7
mattk7/netrd
netrd/utilities/threshold.py
[ "MIT" ]
Python
threshold_on_degree
<not_specific>
def threshold_on_degree(mat, avg_k=1): """ Threshold a numpy array by setting values below a given quantile to zero. Params ------ mat: (np.ndarray): A numpy array. avg_k (float): The average degree to target when thresholding the matrix. Returns ------- thresholded_mat: the thresh...
Threshold a numpy array by setting values below a given quantile to zero. Params ------ mat: (np.ndarray): A numpy array. avg_k (float): The average degree to target when thresholding the matrix. Returns ------- thresholded_mat: the thresholded numpy array
Threshold a numpy array by setting values below a given quantile to zero. Params Returns the thresholded numpy array
[ "Threshold", "a", "numpy", "array", "by", "setting", "values", "below", "a", "given", "quantile", "to", "zero", ".", "Params", "Returns", "the", "thresholded", "numpy", "array" ]
def threshold_on_degree(mat, avg_k=1): n = len(mat) A = np.ones((n, n)) for m in sorted(mat.flatten()): A[mat == m] = 0 if np.mean(np.sum(A, 1)) <= avg_k: break return mat * (mat >= m)
[ "def", "threshold_on_degree", "(", "mat", ",", "avg_k", "=", "1", ")", ":", "n", "=", "len", "(", "mat", ")", "A", "=", "np", ".", "ones", "(", "(", "n", ",", "n", ")", ")", "for", "m", "in", "sorted", "(", "mat", ".", "flatten", "(", ")", ...
Threshold a numpy array by setting values below a given quantile to zero.
[ "Threshold", "a", "numpy", "array", "by", "setting", "values", "below", "a", "given", "quantile", "to", "zero", "." ]
[ "\"\"\"\n Threshold a numpy array by setting values below a given quantile to zero.\n\n Params\n ------\n mat: (np.ndarray): A numpy array.\n avg_k (float): The average degree to target when thresholding the matrix.\n\n Returns\n -------\n thresholded_mat: the thresholded numpy array\n\n ...
[ { "param": "mat", "type": null }, { "param": "avg_k", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mat", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "avg_k", "type": null, "docstring": null, "docstring_tokens": [...
0c78e23f09dc8f59a5d65398ba0628b386777b83
mattk7/netrd
netrd/reconstruction/ou_inference.py
[ "MIT" ]
Python
inverse_method
<not_specific>
def inverse_method(covariance, temperatures): """This function finds the weights of an heterogenous Ornstein-Uhlenbeck process covariance = covariance matrix of the zero-mean signal Params ------ covariance (np.ndarray): Covariance matrix of the zero-mean signal. temperatures (np.ndarr...
This function finds the weights of an heterogenous Ornstein-Uhlenbeck process covariance = covariance matrix of the zero-mean signal Params ------ covariance (np.ndarray): Covariance matrix of the zero-mean signal. temperatures (np.ndarray): Diffusion coefficient of each of the signals. ...
This function finds the weights of an heterogenous Ornstein-Uhlenbeck process covariance = covariance matrix of the zero-mean signal Params covariance (np.ndarray): Covariance matrix of the zero-mean signal. temperatures (np.ndarray): Diffusion coefficient of each of the signals. Returns weights (np.ndarray): Cou...
[ "This", "function", "finds", "the", "weights", "of", "an", "heterogenous", "Ornstein", "-", "Uhlenbeck", "process", "covariance", "=", "covariance", "matrix", "of", "the", "zero", "-", "mean", "signal", "Params", "covariance", "(", "np", ".", "ndarray", ")", ...
def inverse_method(covariance, temperatures): if len(np.shape(temperatures)) == 1: T = np.diag(temperatures) elif len(np.shape(temperatures)) == 2: T = temperatures else: raise ValueError("temperature must either be a vector or a matrix.") n, m = np.shape(covariance) eig_val,...
[ "def", "inverse_method", "(", "covariance", ",", "temperatures", ")", ":", "if", "len", "(", "np", ".", "shape", "(", "temperatures", ")", ")", "==", "1", ":", "T", "=", "np", ".", "diag", "(", "temperatures", ")", "elif", "len", "(", "np", ".", "s...
This function finds the weights of an heterogenous Ornstein-Uhlenbeck process covariance = covariance matrix of the zero-mean signal
[ "This", "function", "finds", "the", "weights", "of", "an", "heterogenous", "Ornstein", "-", "Uhlenbeck", "process", "covariance", "=", "covariance", "matrix", "of", "the", "zero", "-", "mean", "signal" ]
[ "\"\"\"This function finds the weights of an heterogenous Ornstein-Uhlenbeck \n process \n covariance = covariance matrix of the zero-mean signal\n\n Params\n ------\n\n covariance (np.ndarray): Covariance matrix of the zero-mean signal.\n\n temperatures (np.ndarray): Diffusion coefficient of eac...
[ { "param": "covariance", "type": null }, { "param": "temperatures", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "covariance", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "temperatures", "type": null, "docstring": null, "docstr...
aacad2171f8768007b014bddae2e4397c451af92
mattk7/netrd
netrd/reconstruction/exact_mean_field.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, TS, stop_criterion=True): """ Given an NxL time series, infer inter-node coupling weights using an exact mean field approximation. After [this tutorial] (https://github.com/nihcompmed/network-inference/blob/master/sphinx/codesource/inference.py) in python....
Given an NxL time series, infer inter-node coupling weights using an exact mean field approximation. After [this tutorial] (https://github.com/nihcompmed/network-inference/blob/master/sphinx/codesource/inference.py) in python. From the paper: "Exact mean field (eMF) i...
Given an NxL time series, infer inter-node coupling weights using an exact mean field approximation. After [this tutorial] in python. From the paper: "Exact mean field (eMF) is another mean field approximation, similar to naive mean field and thouless anderson palmer. We can improve the performance of this method by ...
[ "Given", "an", "NxL", "time", "series", "infer", "inter", "-", "node", "coupling", "weights", "using", "an", "exact", "mean", "field", "approximation", ".", "After", "[", "this", "tutorial", "]", "in", "python", ".", "From", "the", "paper", ":", "\"", "E...
def fit(self, TS, stop_criterion=True): N, L = np.shape(TS) m = np.mean(TS, axis=1) A = 1 - m**2 A = np.diag(A) ds = TS.T - m C = np.cov(ds, rowvar=False, bias=True) C_inv = linalg.inv(C) s1 = TS[:,1:] ...
[ "def", "fit", "(", "self", ",", "TS", ",", "stop_criterion", "=", "True", ")", ":", "N", ",", "L", "=", "np", ".", "shape", "(", "TS", ")", "m", "=", "np", ".", "mean", "(", "TS", ",", "axis", "=", "1", ")", "A", "=", "1", "-", "m", "**",...
Given an NxL time series, infer inter-node coupling weights using an exact mean field approximation.
[ "Given", "an", "NxL", "time", "series", "infer", "inter", "-", "node", "coupling", "weights", "using", "an", "exact", "mean", "field", "approximation", "." ]
[ "\"\"\"\n Given an NxL time series, infer inter-node coupling weights using an\n exact mean field approximation. \n After [this tutorial]\n (https://github.com/nihcompmed/network-inference/blob/master/sphinx/codesource/inference.py) \n in python.\n\n From the paper: \"Exact...
[ { "param": "self", "type": null }, { "param": "TS", "type": null }, { "param": "stop_criterion", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [],...
aacad2171f8768007b014bddae2e4397c451af92
mattk7/netrd
netrd/reconstruction/exact_mean_field.py
[ "MIT" ]
Python
integrand
<not_specific>
def integrand(H): """ Return the integrand of this function """ y, err = quad(fun1, -np.inf, np.inf, args=(H,)) return y - m[i0]
Return the integrand of this function
Return the integrand of this function
[ "Return", "the", "integrand", "of", "this", "function" ]
def integrand(H): y, err = quad(fun1, -np.inf, np.inf, args=(H,)) return y - m[i0]
[ "def", "integrand", "(", "H", ")", ":", "y", ",", "err", "=", "quad", "(", "fun1", ",", "-", "np", ".", "inf", ",", "np", ".", "inf", ",", "args", "=", "(", "H", ",", ")", ")", "return", "y", "-", "m", "[", "i0", "]" ]
Return the integrand of this function
[ "Return", "the", "integrand", "of", "this", "function" ]
[ "\"\"\"\n Return the integrand of this function\n \"\"\"" ]
[ { "param": "H", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "H", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b03a54b9cf009e63aa6ca17d2d63a95591fc41f9
mattk7/netrd
netrd/utilities/graph.py
[ "MIT" ]
Python
create_graph
<not_specific>
def create_graph(A, create_using=None, remove_self_loops=True): """ Function for flexibly creating a networkx graph from a numpy array. Params ------ A (np.ndarray): A numpy array. create_using (nx.Graph or None): Create the graph using a specific networkx graph. Can be used for forcing an ...
Function for flexibly creating a networkx graph from a numpy array. Params ------ A (np.ndarray): A numpy array. create_using (nx.Graph or None): Create the graph using a specific networkx graph. Can be used for forcing an asymmetric matrix to create an undirected graph, for example. remov...
Function for flexibly creating a networkx graph from a numpy array. Params A (np.ndarray): A numpy array. create_using (nx.Graph or None): Create the graph using a specific networkx graph. Can be used for forcing an asymmetric matrix to create an undirected graph, for example. remove_self_loops (bool): If True, remove...
[ "Function", "for", "flexibly", "creating", "a", "networkx", "graph", "from", "a", "numpy", "array", ".", "Params", "A", "(", "np", ".", "ndarray", ")", ":", "A", "numpy", "array", ".", "create_using", "(", "nx", ".", "Graph", "or", "None", ")", ":", ...
def create_graph(A, create_using=None, remove_self_loops=True): if remove_self_loops: np.fill_diagonal(A, 0) if create_using is None: if np.allclose(A, A.T): G = nx.from_numpy_array(G, create_using=nx.Graph) else: G = nx.from_numpy_array(G, create_using=nx.DiGraph...
[ "def", "create_graph", "(", "A", ",", "create_using", "=", "None", ",", "remove_self_loops", "=", "True", ")", ":", "if", "remove_self_loops", ":", "np", ".", "fill_diagonal", "(", "A", ",", "0", ")", "if", "create_using", "is", "None", ":", "if", "np", ...
Function for flexibly creating a networkx graph from a numpy array.
[ "Function", "for", "flexibly", "creating", "a", "networkx", "graph", "from", "a", "numpy", "array", "." ]
[ "\"\"\"\n Function for flexibly creating a networkx graph from a numpy array.\n\n Params\n ------\n A (np.ndarray): A numpy array.\n create_using (nx.Graph or None): Create the graph using a specific networkx graph.\n Can be used for forcing an asymmetric matrix to create an undirected graph, for ...
[ { "param": "A", "type": null }, { "param": "create_using", "type": null }, { "param": "remove_self_loops", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "A", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "create_using", "type": null, "docstring": null, "docstring_token...
e6137ade7959e68f3059192241332203d514a84b
mattk7/netrd
netrd/reconstruction/correlation_matrix.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, TS, cutoffs=[(-1, 1)]): """ Reconstruct a network from time series data using an unregularized form of the precision matrix. After [this tutorial]( https://github.com/valeria-io/visualising_stocks_correlations/blob/master/corr_matrix_viz.ipynb). Params ----...
Reconstruct a network from time series data using an unregularized form of the precision matrix. After [this tutorial]( https://github.com/valeria-io/visualising_stocks_correlations/blob/master/corr_matrix_viz.ipynb). Params ------ TS (np.ndarray): Array consisting of $...
Reconstruct a network from time series data using an unregularized form of the precision matrix. Params TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors cutoffs (list of tuples): When thresholding, include only edges whose correlations fall within a given range or set of ranges. The lower value ...
[ "Reconstruct", "a", "network", "from", "time", "series", "data", "using", "an", "unregularized", "form", "of", "the", "precision", "matrix", ".", "Params", "TS", "(", "np", ".", "ndarray", ")", ":", "Array", "consisting", "of", "$L$", "observations", "from",...
def fit(self, TS, cutoffs=[(-1, 1)]): cor = np.corrcoef(TS) self.results['matrix'] = cor mask_function = np.vectorize(lambda x: any([x>=cutoff[0] and x<=cutoff[1] for cutoff in cutoffs])) mask = mask_function(cor) A = cor * mask self.results['graph'] = nx.from_numpy_array...
[ "def", "fit", "(", "self", ",", "TS", ",", "cutoffs", "=", "[", "(", "-", "1", ",", "1", ")", "]", ")", ":", "cor", "=", "np", ".", "corrcoef", "(", "TS", ")", "self", ".", "results", "[", "'matrix'", "]", "=", "cor", "mask_function", "=", "n...
Reconstruct a network from time series data using an unregularized form of the precision matrix.
[ "Reconstruct", "a", "network", "from", "time", "series", "data", "using", "an", "unregularized", "form", "of", "the", "precision", "matrix", "." ]
[ "\"\"\"\n Reconstruct a network from time series data using an unregularized form of\n the precision matrix. After [this tutorial](\n https://github.com/valeria-io/visualising_stocks_correlations/blob/master/corr_matrix_viz.ipynb).\n\n Params\n ------\n TS (np.ndarray): Arr...
[ { "param": "self", "type": null }, { "param": "TS", "type": null }, { "param": "cutoffs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "TS", "type": null, "docstring": null, "docstring_tokens": [],...
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
_tagui_output
<not_specific>
def _tagui_output(): """function to wait for tagui output file to read and delete it""" global _tagui_delay # sleep to not splurge cpu cycles in while loop while not os.path.isfile('tagui_python.txt'): time.sleep(_tagui_delay) tagui_output_file = _py23_open('tagui_python.txt', 'r') tag...
function to wait for tagui output file to read and delete it
function to wait for tagui output file to read and delete it
[ "function", "to", "wait", "for", "tagui", "output", "file", "to", "read", "and", "delete", "it" ]
def _tagui_output(): global _tagui_delay while not os.path.isfile('tagui_python.txt'): time.sleep(_tagui_delay) tagui_output_file = _py23_open('tagui_python.txt', 'r') tagui_output_text = _py23_read(tagui_output_file.read()) tagui_output_file.close() os.remove('tagui_python.txt') re...
[ "def", "_tagui_output", "(", ")", ":", "global", "_tagui_delay", "while", "not", "os", ".", "path", ".", "isfile", "(", "'tagui_python.txt'", ")", ":", "time", ".", "sleep", "(", "_tagui_delay", ")", "tagui_output_file", "=", "_py23_open", "(", "'tagui_python....
function to wait for tagui output file to read and delete it
[ "function", "to", "wait", "for", "tagui", "output", "file", "to", "read", "and", "delete", "it" ]
[ "\"\"\"function to wait for tagui output file to read and delete it\"\"\"", "# sleep to not splurge cpu cycles in while loop" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
_python_flow
null
def _python_flow(): """function to create entry tagui flow without visual automation""" flow_text = '// NORMAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\r\n\r\nlive' flow_file = _py23_open('tagui_python', 'w') flow_file.write(_py23_write(flow_text)) flow_file.close()
function to create entry tagui flow without visual automation
function to create entry tagui flow without visual automation
[ "function", "to", "create", "entry", "tagui", "flow", "without", "visual", "automation" ]
def _python_flow(): flow_text = '// NORMAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\r\n\r\nlive' flow_file = _py23_open('tagui_python', 'w') flow_file.write(_py23_write(flow_text)) flow_file.close()
[ "def", "_python_flow", "(", ")", ":", "flow_text", "=", "'// NORMAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\\r\\n\\r\\nlive'", "flow_file", "=", "_py23_open", "(", "'tagui_python'", ",", "'w'", ")", "flow_file", ".", "write", "(", "_py23_write", "(", "flow_text", ...
function to create entry tagui flow without visual automation
[ "function", "to", "create", "entry", "tagui", "flow", "without", "visual", "automation" ]
[ "\"\"\"function to create entry tagui flow without visual automation\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
_visual_flow
null
def _visual_flow(): """function to create entry tagui flow with visual automation""" flow_text = '// VISUAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\r\n' + \ '// mouse_xy() - dummy trigger for SikuliX integration\r\n\r\nlive' flow_file = _py23_open('tagui_python', 'w') flow_file.w...
function to create entry tagui flow with visual automation
function to create entry tagui flow with visual automation
[ "function", "to", "create", "entry", "tagui", "flow", "with", "visual", "automation" ]
def _visual_flow(): flow_text = '// VISUAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\r\n' + \ '// mouse_xy() - dummy trigger for SikuliX integration\r\n\r\nlive' flow_file = _py23_open('tagui_python', 'w') flow_file.write(_py23_write(flow_text)) flow_file.close()
[ "def", "_visual_flow", "(", ")", ":", "flow_text", "=", "'// VISUAL ENTRY FLOW FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG\\r\\n'", "+", "'// mouse_xy() - dummy trigger for SikuliX integration\\r\\n\\r\\nlive'", "flow_file", "=", "_py23_open", "(", "'tagui_python'", ",", "'w'", ")", "fl...
function to create entry tagui flow with visual automation
[ "function", "to", "create", "entry", "tagui", "flow", "with", "visual", "automation" ]
[ "\"\"\"function to create entry tagui flow with visual automation\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
_tagui_delta
<not_specific>
def _tagui_delta(base_directory = None): """function to download stable delta files from tagui cutting edge version""" global __version__ if base_directory is None or base_directory == '': return False # skip downloading if it is already done before for current release if os.path.isfile(base_directo...
function to download stable delta files from tagui cutting edge version
function to download stable delta files from tagui cutting edge version
[ "function", "to", "download", "stable", "delta", "files", "from", "tagui", "cutting", "edge", "version" ]
def _tagui_delta(base_directory = None): global __version__ if base_directory is None or base_directory == '': return False if os.path.isfile(base_directory + '/' + 'tagui_python_' + __version__): return True delta_list = ['tagui', 'tagui.cmd', 'end_processes', 'end_processes.cmd', ...
[ "def", "_tagui_delta", "(", "base_directory", "=", "None", ")", ":", "global", "__version__", "if", "base_directory", "is", "None", "or", "base_directory", "==", "''", ":", "return", "False", "if", "os", ".", "path", ".", "isfile", "(", "base_directory", "+"...
function to download stable delta files from tagui cutting edge version
[ "function", "to", "download", "stable", "delta", "files", "from", "tagui", "cutting", "edge", "version" ]
[ "\"\"\"function to download stable delta files from tagui cutting edge version\"\"\"", "# skip downloading if it is already done before for current release", "# define list of key tagui files to be downloaded and synced locally", "# make sure execute permission is there for .tagui/src/tagui and end_processes"...
[ { "param": "base_directory", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "base_directory", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
unzip
<not_specific>
def unzip(file_to_unzip = None, unzip_location = None): """function to unzip zip file to specified location""" import zipfile if file_to_unzip is None or file_to_unzip == '': print('[TAGUI][ERROR] - filename missing for unzip()') return False elif not os.path.isfile(file_to_unzip): ...
function to unzip zip file to specified location
function to unzip zip file to specified location
[ "function", "to", "unzip", "zip", "file", "to", "specified", "location" ]
def unzip(file_to_unzip = None, unzip_location = None): import zipfile if file_to_unzip is None or file_to_unzip == '': print('[TAGUI][ERROR] - filename missing for unzip()') return False elif not os.path.isfile(file_to_unzip): print('[TAGUI][ERROR] - file specified missing for unzip...
[ "def", "unzip", "(", "file_to_unzip", "=", "None", ",", "unzip_location", "=", "None", ")", ":", "import", "zipfile", "if", "file_to_unzip", "is", "None", "or", "file_to_unzip", "==", "''", ":", "print", "(", "'[TAGUI][ERROR] - filename missing for unzip()'", ")",...
function to unzip zip file to specified location
[ "function", "to", "unzip", "zip", "file", "to", "specified", "location" ]
[ "\"\"\"function to unzip zip file to specified location\"\"\"" ]
[ { "param": "file_to_unzip", "type": null }, { "param": "unzip_location", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file_to_unzip", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "unzip_location", "type": null, "docstring": null, "d...
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
init
<not_specific>
def init(visual_automation = False, chrome_browser = True): """start and connect to tagui process by checking tagui live mode readiness""" global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if _tagui_started: print('[TAGUI][ERROR] - use close() before using init() again') ...
start and connect to tagui process by checking tagui live mode readiness
start and connect to tagui process by checking tagui live mode readiness
[ "start", "and", "connect", "to", "tagui", "process", "by", "checking", "tagui", "live", "mode", "readiness" ]
def init(visual_automation = False, chrome_browser = True): global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if _tagui_started: print('[TAGUI][ERROR] - use close() before using init() again') return False _tagui_id = 0 if platform.system() == 'Windows': ta...
[ "def", "init", "(", "visual_automation", "=", "False", ",", "chrome_browser", "=", "True", ")", ":", "global", "_process", ",", "_tagui_started", ",", "_tagui_id", ",", "_tagui_visual", ",", "_tagui_chrome", "if", "_tagui_started", ":", "print", "(", "'[TAGUI][E...
start and connect to tagui process by checking tagui live mode readiness
[ "start", "and", "connect", "to", "tagui", "process", "by", "checking", "tagui", "live", "mode", "readiness" ]
[ "\"\"\"start and connect to tagui process by checking tagui live mode readiness\"\"\"", "# reset id to track instruction count from tagui python to tagui", "# get user home folder location to locate tagui executable", "# if tagui executable is not found, initiate setup() to install tagui", "# error message ...
[ { "param": "visual_automation", "type": null }, { "param": "chrome_browser", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "visual_automation", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "chrome_browser", "type": null, "docstring": null, ...
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
_ready
<not_specific>
def _ready(): """internal function to check if tagui is ready to receive instructions after init() is called""" global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if not _tagui_started: # print output error in calling parent function instead return False try: ...
internal function to check if tagui is ready to receive instructions after init() is called
internal function to check if tagui is ready to receive instructions after init() is called
[ "internal", "function", "to", "check", "if", "tagui", "is", "ready", "to", "receive", "instructions", "after", "init", "()", "is", "called" ]
def _ready(): global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if not _tagui_started: return False try: if _process.poll() is not None: _tagui_visual = False _tagui_chrome = False _tagui_started = False return False ...
[ "def", "_ready", "(", ")", ":", "global", "_process", ",", "_tagui_started", ",", "_tagui_id", ",", "_tagui_visual", ",", "_tagui_chrome", "if", "not", "_tagui_started", ":", "return", "False", "try", ":", "if", "_process", ".", "poll", "(", ")", "is", "no...
internal function to check if tagui is ready to receive instructions after init() is called
[ "internal", "function", "to", "check", "if", "tagui", "is", "ready", "to", "receive", "instructions", "after", "init", "()", "is", "called" ]
[ "\"\"\"internal function to check if tagui is ready to receive instructions after init() is called\"\"\"", "# print output error in calling parent function instead", "# failsafe exit if tagui process gets killed for whatever reason", "# print output error in calling parent function instead", "# read next li...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
send
<not_specific>
def send(tagui_instruction = None): """send next live mode instruction to tagui for processing if tagui is ready""" global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if not _tagui_started: print('[TAGUI][ERROR] - use init() before using send()') return False if ...
send next live mode instruction to tagui for processing if tagui is ready
send next live mode instruction to tagui for processing if tagui is ready
[ "send", "next", "live", "mode", "instruction", "to", "tagui", "for", "processing", "if", "tagui", "is", "ready" ]
def send(tagui_instruction = None): global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if not _tagui_started: print('[TAGUI][ERROR] - use init() before using send()') return False if tagui_instruction is None or tagui_instruction == '': return True try: if _...
[ "def", "send", "(", "tagui_instruction", "=", "None", ")", ":", "global", "_process", ",", "_tagui_started", ",", "_tagui_id", ",", "_tagui_visual", ",", "_tagui_chrome", "if", "not", "_tagui_started", ":", "print", "(", "'[TAGUI][ERROR] - use init() before using send...
send next live mode instruction to tagui for processing if tagui is ready
[ "send", "next", "live", "mode", "instruction", "to", "tagui", "for", "processing", "if", "tagui", "is", "ready" ]
[ "\"\"\"send next live mode instruction to tagui for processing if tagui is ready\"\"\"", "# failsafe exit if tagui process gets killed for whatever reason", "# escape special characters for them to reach tagui correctly", "# special handling for single quote to work with _esq() for tagui", "# escape backsla...
[ { "param": "tagui_instruction", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tagui_instruction", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
close
<not_specific>
def close(): """disconnect from tagui process by sending 'done' trigger instruction""" global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if not _tagui_started: print('[TAGUI][ERROR] - use init() before using close()') return False try: # failsafe exit if...
disconnect from tagui process by sending 'done' trigger instruction
disconnect from tagui process by sending 'done' trigger instruction
[ "disconnect", "from", "tagui", "process", "by", "sending", "'", "done", "'", "trigger", "instruction" ]
def close(): global _process, _tagui_started, _tagui_id, _tagui_visual, _tagui_chrome if not _tagui_started: print('[TAGUI][ERROR] - use init() before using close()') return False try: if _process.poll() is not None: print('[TAGUI][ERROR] - no active TagUI process to clos...
[ "def", "close", "(", ")", ":", "global", "_process", ",", "_tagui_started", ",", "_tagui_id", ",", "_tagui_visual", ",", "_tagui_chrome", "if", "not", "_tagui_started", ":", "print", "(", "'[TAGUI][ERROR] - use init() before using close()'", ")", "return", "False", ...
disconnect from tagui process by sending 'done' trigger instruction
[ "disconnect", "from", "tagui", "process", "by", "sending", "'", "done", "'", "trigger", "instruction" ]
[ "\"\"\"disconnect from tagui process by sending 'done' trigger instruction\"\"\"", "# failsafe exit if tagui process gets killed for whatever reason", "# send 'done' instruction to terminate live mode and exit tagui", "# loop until tagui process has closed before returning control", "# remove again generate...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0114222e2740797d877ad4952680dc2a49467bcc
houruipeng/TagUI-Python
tagui.py
[ "Apache-2.0" ]
Python
download
<not_specific>
def download(download_url = None, filename_to_save = None): """function for python 2/3 compatible file download from url""" if download_url is None or download_url == '': print('[TAGUI][ERROR] - download URL missing for download()') return False # if not given, use last part of url as file...
function for python 2/3 compatible file download from url
function for python 2/3 compatible file download from url
[ "function", "for", "python", "2", "/", "3", "compatible", "file", "download", "from", "url" ]
def download(download_url = None, filename_to_save = None): if download_url is None or download_url == '': print('[TAGUI][ERROR] - download URL missing for download()') return False if filename_to_save is None or filename_to_save == '': download_url_tokens = download_url.split('/') ...
[ "def", "download", "(", "download_url", "=", "None", ",", "filename_to_save", "=", "None", ")", ":", "if", "download_url", "is", "None", "or", "download_url", "==", "''", ":", "print", "(", "'[TAGUI][ERROR] - download URL missing for download()'", ")", "return", "...
function for python 2/3 compatible file download from url
[ "function", "for", "python", "2", "/", "3", "compatible", "file", "download", "from", "url" ]
[ "\"\"\"function for python 2/3 compatible file download from url\"\"\"", "# if not given, use last part of url as filename to save", "# delete existing file if exist to ensure freshness", "# handle case where url is invalid or has no content", "# take the existence of downloaded file as success" ]
[ { "param": "download_url", "type": null }, { "param": "filename_to_save", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "download_url", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename_to_save", "type": null, "docstring": null, "...
9407c14b9647d35a6691a19d77845a7a2569a3e4
kelvinndmo/parcel
app/customers/customer_views.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): '''place a new parcel order.''' data = request.get_json() origin = data['origin'] price = data['price'] destination = data['destination'] weight = data['weight'] validate = validators.Validators() if not validate.valid_destination_name(d...
place a new parcel order.
place a new parcel order.
[ "place", "a", "new", "parcel", "order", "." ]
def post(self): data = request.get_json() origin = data['origin'] price = data['price'] destination = data['destination'] weight = data['weight'] validate = validators.Validators() if not validate.valid_destination_name(destination): return {'message':...
[ "def", "post", "(", "self", ")", ":", "data", "=", "request", ".", "get_json", "(", ")", "origin", "=", "data", "[", "'origin'", "]", "price", "=", "data", "[", "'price'", "]", "destination", "=", "data", "[", "'destination'", "]", "weight", "=", "da...
place a new parcel order.
[ "place", "a", "new", "parcel", "order", "." ]
[ "'''place a new parcel order.'''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
00b0049788cd39a262f66617e83c884d14884cb9
kelvinndmo/parcel
app/admin/admin_views.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, id): '''mark an order as completed by admin''' order = Order().get_by_id(id) if order: if order.status == "completed" or order.status == "declined": return {"message": "order already {}".format(order.status)} if order.status == "Pending": ...
mark an order as completed by admin
mark an order as completed by admin
[ "mark", "an", "order", "as", "completed", "by", "admin" ]
def put(self, id): order = Order().get_by_id(id) if order: if order.status == "completed" or order.status == "declined": return {"message": "order already {}".format(order.status)} if order.status == "Pending": return {"message": "please approve th...
[ "def", "put", "(", "self", ",", "id", ")", ":", "order", "=", "Order", "(", ")", ".", "get_by_id", "(", "id", ")", "if", "order", ":", "if", "order", ".", "status", "==", "\"completed\"", "or", "order", ".", "status", "==", "\"declined\"", ":", "re...
mark an order as completed by admin
[ "mark", "an", "order", "as", "completed", "by", "admin" ]
[ "'''mark an order as completed by admin'''" ]
[ { "param": "self", "type": null }, { "param": "id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "id", "type": null, "docstring": null, "docstring_tokens": [],...
00b0049788cd39a262f66617e83c884d14884cb9
kelvinndmo/parcel
app/admin/admin_views.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, id): '''mark order has started being transported''' order = Order().get_by_id(id) if order: if order.status == "completed" or order.status == "declined": return {"You already marked the order as {}".format(order.status)}, 200 if order.statu...
mark order has started being transported
mark order has started being transported
[ "mark", "order", "has", "started", "being", "transported" ]
def put(self, id): order = Order().get_by_id(id) if order: if order.status == "completed" or order.status == "declined": return {"You already marked the order as {}".format(order.status)}, 200 if order.status == "Pending": return {"message": "pleas...
[ "def", "put", "(", "self", ",", "id", ")", ":", "order", "=", "Order", "(", ")", ".", "get_by_id", "(", "id", ")", "if", "order", ":", "if", "order", ".", "status", "==", "\"completed\"", "or", "order", ".", "status", "==", "\"declined\"", ":", "re...
mark order has started being transported
[ "mark", "order", "has", "started", "being", "transported" ]
[ "'''mark order has started being transported'''" ]
[ { "param": "self", "type": null }, { "param": "id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "id", "type": null, "docstring": null, "docstring_tokens": [],...
925a103a74c8d06e2184885f611881abb13cb16d
codacy-badger/graphit
graphit/graph_io/io_yaml_format.py
[ "Apache-2.0" ]
Python
read_yaml
<not_specific>
def read_yaml(yaml_file, graph=None, **kwargs): """ Parse (hierarchical) YAML data structure to a graph Additional keyword arguments (kwargs) are passed to `read_pydata` :param yaml_file: yaml data to parse :type yaml_file: File, string, stream or URL :param graph: Grap...
Parse (hierarchical) YAML data structure to a graph Additional keyword arguments (kwargs) are passed to `read_pydata` :param yaml_file: yaml data to parse :type yaml_file: File, string, stream or URL :param graph: Graph object to import dictionary data in :type graph: ...
Parse (hierarchical) YAML data structure to a graph Additional keyword arguments (kwargs) are passed to `read_pydata`
[ "Parse", "(", "hierarchical", ")", "YAML", "data", "structure", "to", "a", "graph", "Additional", "keyword", "arguments", "(", "kwargs", ")", "are", "passed", "to", "`", "read_pydata", "`" ]
def read_yaml(yaml_file, graph=None, **kwargs): yaml_file = open_anything(yaml_file) try: yaml_file = yaml.safe_load(yaml_file) except IOError: logger.error('Unable to decode YAML string') return if not isinstance(yaml_file, list): yaml_file = [yaml_file] base_graph =...
[ "def", "read_yaml", "(", "yaml_file", ",", "graph", "=", "None", ",", "**", "kwargs", ")", ":", "yaml_file", "=", "open_anything", "(", "yaml_file", ")", "try", ":", "yaml_file", "=", "yaml", ".", "safe_load", "(", "yaml_file", ")", "except", "IOError", ...
Parse (hierarchical) YAML data structure to a graph Additional keyword arguments (kwargs) are passed to `read_pydata`
[ "Parse", "(", "hierarchical", ")", "YAML", "data", "structure", "to", "a", "graph", "Additional", "keyword", "arguments", "(", "kwargs", ")", "are", "passed", "to", "`", "read_pydata", "`" ]
[ "\"\"\"\n Parse (hierarchical) YAML data structure to a graph\n\n Additional keyword arguments (kwargs) are passed to `read_pydata`\n \n :param yaml_file: yaml data to parse\n :type yaml_file: File, string, stream or URL\n :param graph: Graph object to import dictionary data in...
[ { "param": "yaml_file", "type": null }, { "param": "graph", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":graphit:GraphAxis" } ], "raises": [], "params": [ { "identifier": "yaml_file", "type": null, "docstring": "yaml data to parse", "docstring_tokens": [ "yaml", ...
925a103a74c8d06e2184885f611881abb13cb16d
codacy-badger/graphit
graphit/graph_io/io_yaml_format.py
[ "Apache-2.0" ]
Python
write_yaml
<not_specific>
def write_yaml(graph, default=None, include_root=False, allow_none=True): """ Export a graph to a (nested) JSON structure Convert graph representation of the dictionary tree into JSON using a nested or flattened representation of the dictionary hierarchy. Dictionary keys and values are obt...
Export a graph to a (nested) JSON structure Convert graph representation of the dictionary tree into JSON using a nested or flattened representation of the dictionary hierarchy. Dictionary keys and values are obtained from the node attributes using `key_tag` and `value_tag`. The key_tag ...
Export a graph to a (nested) JSON structure Convert graph representation of the dictionary tree into JSON using a nested or flattened representation of the dictionary hierarchy. Dictionary keys and values are obtained from the node attributes using `key_tag` and `value_tag`. The key_tag is set to graph key_tag by def...
[ "Export", "a", "graph", "to", "a", "(", "nested", ")", "JSON", "structure", "Convert", "graph", "representation", "of", "the", "dictionary", "tree", "into", "JSON", "using", "a", "nested", "or", "flattened", "representation", "of", "the", "dictionary", "hierar...
def write_yaml(graph, default=None, include_root=False, allow_none=True): return yaml.dump(write_pydata(graph, default=default, include_root=include_root, allow_none=allow_none))
[ "def", "write_yaml", "(", "graph", ",", "default", "=", "None", ",", "include_root", "=", "False", ",", "allow_none", "=", "True", ")", ":", "return", "yaml", ".", "dump", "(", "write_pydata", "(", "graph", ",", "default", "=", "default", ",", "include_r...
Export a graph to a (nested) JSON structure Convert graph representation of the dictionary tree into JSON using a nested or flattened representation of the dictionary hierarchy.
[ "Export", "a", "graph", "to", "a", "(", "nested", ")", "JSON", "structure", "Convert", "graph", "representation", "of", "the", "dictionary", "tree", "into", "JSON", "using", "a", "nested", "or", "flattened", "representation", "of", "the", "dictionary", "hierar...
[ "\"\"\"\n Export a graph to a (nested) JSON structure\n \n Convert graph representation of the dictionary tree into JSON\n using a nested or flattened representation of the dictionary hierarchy.\n \n Dictionary keys and values are obtained from the node attributes using\n `key_tag` and `value_t...
[ { "param": "graph", "type": null }, { "param": "default", "type": null }, { "param": "include_root", "type": null }, { "param": "allow_none", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:yaml" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph object to export", "docstring_tokens": [ "Graph", "...
f8c95d03c8ed33d28b4b3e7a28912e7ca8c97446
codacy-badger/graphit
graphit/graph_io/io_xml_format.py
[ "Apache-2.0" ]
Python
read_xml
<not_specific>
def read_xml(xml_file, graph=None): """ Parse hierarchical XML data structure to a graph Uses the Python build-in etree cElementTree parser to parse the XML document and convert the elements into nodes. The XML element tag becomes the node key, XML text becomes the node value and XML attrib...
Parse hierarchical XML data structure to a graph Uses the Python build-in etree cElementTree parser to parse the XML document and convert the elements into nodes. The XML element tag becomes the node key, XML text becomes the node value and XML attributes are added to the node as additional at...
Parse hierarchical XML data structure to a graph Uses the Python build-in etree cElementTree parser to parse the XML document and convert the elements into nodes. The XML element tag becomes the node key, XML text becomes the node value and XML attributes are added to the node as additional attributes.
[ "Parse", "hierarchical", "XML", "data", "structure", "to", "a", "graph", "Uses", "the", "Python", "build", "-", "in", "etree", "cElementTree", "parser", "to", "parse", "the", "XML", "document", "and", "convert", "the", "elements", "into", "nodes", ".", "The"...
def read_xml(xml_file, graph=None): if graph is None: graph = GraphAxis() if not isinstance(graph, GraphAxis): raise TypeError('Unsupported graph type {0}'.format(type(graph))) xml_file = open_anything(xml_file) try: tree = et.fromstring(xml_file.read()) except et.ParseError ...
[ "def", "read_xml", "(", "xml_file", ",", "graph", "=", "None", ")", ":", "if", "graph", "is", "None", ":", "graph", "=", "GraphAxis", "(", ")", "if", "not", "isinstance", "(", "graph", ",", "GraphAxis", ")", ":", "raise", "TypeError", "(", "'Unsupporte...
Parse hierarchical XML data structure to a graph Uses the Python build-in etree cElementTree parser to parse the XML document and convert the elements into nodes.
[ "Parse", "hierarchical", "XML", "data", "structure", "to", "a", "graph", "Uses", "the", "Python", "build", "-", "in", "etree", "cElementTree", "parser", "to", "parse", "the", "XML", "document", "and", "convert", "the", "elements", "into", "nodes", "." ]
[ "\"\"\"\n Parse hierarchical XML data structure to a graph\n \n Uses the Python build-in etree cElementTree parser to parse the XML\n document and convert the elements into nodes.\n The XML element tag becomes the node key, XML text becomes the node\n value and XML attributes are added to the node...
[ { "param": "xml_file", "type": null }, { "param": "graph", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":graphit:GraphAxis" } ], "raises": [], "params": [ { "identifier": "xml_file", "type": null, "docstring": "XML data to parse", "docstring_tokens": [ "XML", ...
f8c95d03c8ed33d28b4b3e7a28912e7ca8c97446
codacy-badger/graphit
graphit/graph_io/io_xml_format.py
[ "Apache-2.0" ]
Python
write_xml
<not_specific>
def write_xml(graph): """ Export a graph to an XML data format :param graph: :return: """ # Graph should be of type GraphAxis with a root node nid defined if not isinstance(graph, GraphAxis): raise TypeError('Unsupported graph type {0}'.format(type(graph))) if graph.roo...
Export a graph to an XML data format :param graph: :return:
Export a graph to an XML data format
[ "Export", "a", "graph", "to", "an", "XML", "data", "format" ]
def write_xml(graph): if not isinstance(graph, GraphAxis): raise TypeError('Unsupported graph type {0}'.format(type(graph))) if graph.root is not None: raise GraphitException('No graph root node defines') curr_nt = graph.node_tools graph.node_tools = XMLNodeTools if len(graph) > 1: ...
[ "def", "write_xml", "(", "graph", ")", ":", "if", "not", "isinstance", "(", "graph", ",", "GraphAxis", ")", ":", "raise", "TypeError", "(", "'Unsupported graph type {0}'", ".", "format", "(", "type", "(", "graph", ")", ")", ")", "if", "graph", ".", "root...
Export a graph to an XML data format
[ "Export", "a", "graph", "to", "an", "XML", "data", "format" ]
[ "\"\"\"\n Export a graph to an XML data format\n \n :param graph:\n :return:\n \"\"\"", "# Graph should be of type GraphAxis with a root node nid defined", "# Set current NodeTools aside and register new one", "# Define start node for recursive export", "# Start recursive parsing", "# Resto...
[ { "param": "graph", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, ...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
fromkeys
<not_specific>
def fromkeys(self, keys, value=None): """ Create a new dictionary with keys from seq and values set to value. :param keys: sequence containing keys :param value: default value """ return
Create a new dictionary with keys from seq and values set to value. :param keys: sequence containing keys :param value: default value
Create a new dictionary with keys from seq and values set to value.
[ "Create", "a", "new", "dictionary", "with", "keys", "from", "seq", "and", "values", "set", "to", "value", "." ]
def fromkeys(self, keys, value=None): return
[ "def", "fromkeys", "(", "self", ",", "keys", ",", "value", "=", "None", ")", ":", "return" ]
Create a new dictionary with keys from seq and values set to value.
[ "Create", "a", "new", "dictionary", "with", "keys", "from", "seq", "and", "values", "set", "to", "value", "." ]
[ "\"\"\"\n Create a new dictionary with keys from seq and values set to value.\n \n :param keys: sequence containing keys\n :param value: default value\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "keys", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "keys", "type": null, "docstring": "sequence containing keys", ...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
items
<not_specific>
def items(self): """ Implement Python 3.x dictionary like 'items' method that returns a view on the items in the data store :return: data items as tuple of key/value pairs :rtype: items view instance """ return
Implement Python 3.x dictionary like 'items' method that returns a view on the items in the data store :return: data items as tuple of key/value pairs :rtype: items view instance
Implement Python 3.x dictionary like 'items' method that returns a view on the items in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "items", "'", "method", "that", "returns", "a", "view", "on", "the", "items", "in", "the", "data", "store" ]
def items(self): return
[ "def", "items", "(", "self", ")", ":", "return" ]
Implement Python 3.x dictionary like 'items' method that returns a view on the items in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "items", "'", "method", "that", "returns", "a", "view", "on", "the", "items", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 3.x dictionary like 'items' method that returns a\n view on the items in the data store\n \n :return: data items as tuple of key/value pairs\n :rtype: items view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "data items as tuple of key/value pairs", "docstring_tokens": [ "data", "items", "as", "tuple", "of", "key", "/", "value", "pairs" ], "type": "items view instance" } ], "raises": [...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
iteritems
<not_specific>
def iteritems(self): """ Implement Python 3.x dictionary like 'items' iterator method that returns a view on the items in the data store :return: data items as tuple of key/value pairs :rtype: items view instance """ return
Implement Python 3.x dictionary like 'items' iterator method that returns a view on the items in the data store :return: data items as tuple of key/value pairs :rtype: items view instance
Implement Python 3.x dictionary like 'items' iterator method that returns a view on the items in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "items", "'", "iterator", "method", "that", "returns", "a", "view", "on", "the", "items", "in", "the", "data", "store" ]
def iteritems(self): return
[ "def", "iteritems", "(", "self", ")", ":", "return" ]
Implement Python 3.x dictionary like 'items' iterator method that returns a view on the items in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "items", "'", "iterator", "method", "that", "returns", "a", "view", "on", "the", "items", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 3.x dictionary like 'items' iterator method that\n returns a view on the items in the data store\n \n :return: data items as tuple of key/value pairs\n :rtype: items view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "data items as tuple of key/value pairs", "docstring_tokens": [ "data", "items", "as", "tuple", "of", "key", "/", "value", "pairs" ], "type": "items view instance" } ], "raises": [...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
iterkeys
<not_specific>
def iterkeys(self): """ Implement Python 3.x dictionary like 'keys' iterator method that returns a view on the keys in the data store :return: data keys :rtype: keys view instance """ return
Implement Python 3.x dictionary like 'keys' iterator method that returns a view on the keys in the data store :return: data keys :rtype: keys view instance
Implement Python 3.x dictionary like 'keys' iterator method that returns a view on the keys in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "keys", "'", "iterator", "method", "that", "returns", "a", "view", "on", "the", "keys", "in", "the", "data", "store" ]
def iterkeys(self): return
[ "def", "iterkeys", "(", "self", ")", ":", "return" ]
Implement Python 3.x dictionary like 'keys' iterator method that returns a view on the keys in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "keys", "'", "iterator", "method", "that", "returns", "a", "view", "on", "the", "keys", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 3.x dictionary like 'keys' iterator method that\n returns a view on the keys in the data store\n \n :return: data keys\n :rtype: keys view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "keys view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_op...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
itervalues
<not_specific>
def itervalues(self): """ Implement Python 3.x dictionary like 'values' iterator method that returns a view on the values in the data store :return: data values :rtype: values view instance """ return
Implement Python 3.x dictionary like 'values' iterator method that returns a view on the values in the data store :return: data values :rtype: values view instance
Implement Python 3.x dictionary like 'values' iterator method that returns a view on the values in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "values", "'", "iterator", "method", "that", "returns", "a", "view", "on", "the", "values", "in", "the", "data", "store" ]
def itervalues(self): return
[ "def", "itervalues", "(", "self", ")", ":", "return" ]
Implement Python 3.x dictionary like 'values' iterator method that returns a view on the values in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "values", "'", "iterator", "method", "that", "returns", "a", "view", "on", "the", "values", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 3.x dictionary like 'values' iterator method that\n returns a view on the values in the data store\n \n :return: data values\n :rtype: values view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "values view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
keys
<not_specific>
def keys(self): """ Implement Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store :return: data keys :rtype: keys view instance """ return
Implement Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store :return: data keys :rtype: keys view instance
Implement Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "keys", "'", "method", "that", "returns", "a", "view", "on", "the", "keys", "in", "the", "data", "store" ]
def keys(self): return
[ "def", "keys", "(", "self", ")", ":", "return" ]
Implement Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "keys", "'", "method", "that", "returns", "a", "view", "on", "the", "keys", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 3.x dictionary like 'keys' method that returns\n a view on the keys in the data store\n \n :return: data keys\n :rtype: keys view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "keys view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_op...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
remove
<not_specific>
def remove(self, key): """ Base method for removing key, value pairs from the data storage :param key: Key to remove """ return
Base method for removing key, value pairs from the data storage :param key: Key to remove
Base method for removing key, value pairs from the data storage
[ "Base", "method", "for", "removing", "key", "value", "pairs", "from", "the", "data", "storage" ]
def remove(self, key): return
[ "def", "remove", "(", "self", ",", "key", ")", ":", "return" ]
Base method for removing key, value pairs from the data storage
[ "Base", "method", "for", "removing", "key", "value", "pairs", "from", "the", "data", "storage" ]
[ "\"\"\"\n Base method for removing key, value pairs from the data storage\n \n :param key: Key to remove\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "key", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": null, "docstring": "Key to remove", "docstring_...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
to_dict
<not_specific>
def to_dict(self, return_full=False): """ Return a Python dictionary of the current data view :param return_full: ignores is_view and return the full dictionary :type return_full: bool :return: py:dict """ return {}
Return a Python dictionary of the current data view :param return_full: ignores is_view and return the full dictionary :type return_full: bool :return: py:dict
Return a Python dictionary of the current data view
[ "Return", "a", "Python", "dictionary", "of", "the", "current", "data", "view" ]
def to_dict(self, return_full=False): return {}
[ "def", "to_dict", "(", "self", ",", "return_full", "=", "False", ")", ":", "return", "{", "}" ]
Return a Python dictionary of the current data view
[ "Return", "a", "Python", "dictionary", "of", "the", "current", "data", "view" ]
[ "\"\"\"\n Return a Python dictionary of the current data view\n\n :param return_full: ignores is_view and return the full dictionary\n :type return_full: bool\n\n :return: py:dict\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "return_full", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
values
<not_specific>
def values(self): """ Implement Python 3.x dictionary like 'values' method that returns a view on the values in the data store :return: data values :rtype: values view instance """ return
Implement Python 3.x dictionary like 'values' method that returns a view on the values in the data store :return: data values :rtype: values view instance
Implement Python 3.x dictionary like 'values' method that returns a view on the values in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "values", "'", "method", "that", "returns", "a", "view", "on", "the", "values", "in", "the", "data", "store" ]
def values(self): return
[ "def", "values", "(", "self", ")", ":", "return" ]
Implement Python 3.x dictionary like 'values' method that returns a view on the values in the data store
[ "Implement", "Python", "3", ".", "x", "dictionary", "like", "'", "values", "'", "method", "that", "returns", "a", "view", "on", "the", "values", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 3.x dictionary like 'values' method that returns\n a view on the values in the data store\n \n :return: data values\n :rtype: values view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "values view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
viewitems
<not_specific>
def viewitems(self): """ Implement Python 2.7 equivalent of the Python 3.x dictionary like 'items' method that returns a view on the items in the data store :return: data items :rtype: items view instance """ return
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'items' method that returns a view on the items in the data store :return: data items :rtype: items view instance
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'items' method that returns a view on the items in the data store
[ "Implement", "Python", "2", ".", "7", "equivalent", "of", "the", "Python", "3", ".", "x", "dictionary", "like", "'", "items", "'", "method", "that", "returns", "a", "view", "on", "the", "items", "in", "the", "data", "store" ]
def viewitems(self): return
[ "def", "viewitems", "(", "self", ")", ":", "return" ]
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'items' method that returns a view on the items in the data store
[ "Implement", "Python", "2", ".", "7", "equivalent", "of", "the", "Python", "3", ".", "x", "dictionary", "like", "'", "items", "'", "method", "that", "returns", "a", "view", "on", "the", "items", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 2.7 equivalent of the Python 3.x dictionary like\n 'items' method that returns a view on the items in the data store\n \n :return: data items\n :rtype: items view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "items view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_o...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
viewkeys
<not_specific>
def viewkeys(self): """ Implement Python 2.7 equivalent of the Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store :return: data keys :rtype: keys view instance """ return
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store :return: data keys :rtype: keys view instance
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store
[ "Implement", "Python", "2", ".", "7", "equivalent", "of", "the", "Python", "3", ".", "x", "dictionary", "like", "'", "keys", "'", "method", "that", "returns", "a", "view", "on", "the", "keys", "in", "the", "data", "store" ]
def viewkeys(self): return
[ "def", "viewkeys", "(", "self", ")", ":", "return" ]
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'keys' method that returns a view on the keys in the data store
[ "Implement", "Python", "2", ".", "7", "equivalent", "of", "the", "Python", "3", ".", "x", "dictionary", "like", "'", "keys", "'", "method", "that", "returns", "a", "view", "on", "the", "keys", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 2.7 equivalent of the Python 3.x dictionary like\n 'keys' method that returns a view on the keys in the data store\n \n :return: data keys\n :rtype: keys view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "keys view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_op...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
viewvalues
<not_specific>
def viewvalues(self): """ Implement Python 2.7 equivalent of the Python 3.x dictionary like 'values' method that returns a view on the values in the data store :return: data values :rtype: values view instance """ return
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'values' method that returns a view on the values in the data store :return: data values :rtype: values view instance
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'values' method that returns a view on the values in the data store
[ "Implement", "Python", "2", ".", "7", "equivalent", "of", "the", "Python", "3", ".", "x", "dictionary", "like", "'", "values", "'", "method", "that", "returns", "a", "view", "on", "the", "values", "in", "the", "data", "store" ]
def viewvalues(self): return
[ "def", "viewvalues", "(", "self", ")", ":", "return" ]
Implement Python 2.7 equivalent of the Python 3.x dictionary like 'values' method that returns a view on the values in the data store
[ "Implement", "Python", "2", ".", "7", "equivalent", "of", "the", "Python", "3", ".", "x", "dictionary", "like", "'", "values", "'", "method", "that", "returns", "a", "view", "on", "the", "values", "in", "the", "data", "store" ]
[ "\"\"\"\n Implement Python 2.7 equivalent of the Python 3.x dictionary like\n 'values' method that returns a view on the values in the data store\n \n :return: data values\n :rtype: values view instance\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "values view instance" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
difference
<not_specific>
def difference(self, other): """ Return the difference between the key set of self and other :rtype: :py:class:set """ return set(self.keys()).difference(set(other))
Return the difference between the key set of self and other :rtype: :py:class:set
Return the difference between the key set of self and other
[ "Return", "the", "difference", "between", "the", "key", "set", "of", "self", "and", "other" ]
def difference(self, other): return set(self.keys()).difference(set(other))
[ "def", "difference", "(", "self", ",", "other", ")", ":", "return", "set", "(", "self", ".", "keys", "(", ")", ")", ".", "difference", "(", "set", "(", "other", ")", ")" ]
Return the difference between the key set of self and other
[ "Return", "the", "difference", "between", "the", "key", "set", "of", "self", "and", "other" ]
[ "\"\"\"\n Return the difference between the key set of self and other\n \n :rtype: :py:class:set\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:class:set" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optiona...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
intersection
<not_specific>
def intersection(self, other): """ Return the intersection between the key set of self and other :param other: object to compare to :type other: :py:dict :rtype: :py:class:set """ return set(self.keys()).intersection(set(oth...
Return the intersection between the key set of self and other :param other: object to compare to :type other: :py:dict :rtype: :py:class:set
Return the intersection between the key set of self and other
[ "Return", "the", "intersection", "between", "the", "key", "set", "of", "self", "and", "other" ]
def intersection(self, other): return set(self.keys()).intersection(set(other))
[ "def", "intersection", "(", "self", ",", "other", ")", ":", "return", "set", "(", "self", ".", "keys", "(", ")", ")", ".", "intersection", "(", "set", "(", "other", ")", ")" ]
Return the intersection between the key set of self and other
[ "Return", "the", "intersection", "between", "the", "key", "set", "of", "self", "and", "other" ]
[ "\"\"\"\n Return the intersection between the key set of self and other\n \n :param other: object to compare to\n :type other: :py:dict\n \n :rtype: :py:class:set\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:class:set" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optiona...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
isdisjoint
<not_specific>
def isdisjoint(self, other): """ Returns a Boolean stating whether the key set in self overlap with the specified key set or iterable of other. :param other: object to compare to :type other: :py:dict :rtype: :py:bool """ ...
Returns a Boolean stating whether the key set in self overlap with the specified key set or iterable of other. :param other: object to compare to :type other: :py:dict :rtype: :py:bool
Returns a Boolean stating whether the key set in self overlap with the specified key set or iterable of other.
[ "Returns", "a", "Boolean", "stating", "whether", "the", "key", "set", "in", "self", "overlap", "with", "the", "specified", "key", "set", "or", "iterable", "of", "other", "." ]
def isdisjoint(self, other): return len(self.intersection(other)) == 0
[ "def", "isdisjoint", "(", "self", ",", "other", ")", ":", "return", "len", "(", "self", ".", "intersection", "(", "other", ")", ")", "==", "0" ]
Returns a Boolean stating whether the key set in self overlap with the specified key set or iterable of other.
[ "Returns", "a", "Boolean", "stating", "whether", "the", "key", "set", "in", "self", "overlap", "with", "the", "specified", "key", "set", "or", "iterable", "of", "other", "." ]
[ "\"\"\"\n Returns a Boolean stating whether the key set in self overlap with the\n specified key set or iterable of other.\n \n :param other: object to compare to\n :type other: :py:dict\n \n :rtype: :py:bool\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:bool" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
issubset
<not_specific>
def issubset(self, other, propper=True): """ Keys in self are also in other but other contains more keys (propper = True) :param other: object to compare to :type other: :py:dict :param propper: ensure that both key lists are not the same. :type prop...
Keys in self are also in other but other contains more keys (propper = True) :param other: object to compare to :type other: :py:dict :param propper: ensure that both key lists are not the same. :type propper: :py:bool :rtype: :py:...
Keys in self are also in other but other contains more keys (propper = True)
[ "Keys", "in", "self", "are", "also", "in", "other", "but", "other", "contains", "more", "keys", "(", "propper", "=", "True", ")" ]
def issubset(self, other, propper=True): self_keys = set(self.keys()) other_keys = set(other) if propper: return self_keys.issubset(other_keys) and self_keys != other_keys else: return self_keys.issubset(other_keys)
[ "def", "issubset", "(", "self", ",", "other", ",", "propper", "=", "True", ")", ":", "self_keys", "=", "set", "(", "self", ".", "keys", "(", ")", ")", "other_keys", "=", "set", "(", "other", ")", "if", "propper", ":", "return", "self_keys", ".", "i...
Keys in self are also in other but other contains more keys (propper = True)
[ "Keys", "in", "self", "are", "also", "in", "other", "but", "other", "contains", "more", "keys", "(", "propper", "=", "True", ")" ]
[ "\"\"\"\n Keys in self are also in other but other contains more keys\n (propper = True)\n \n :param other: object to compare to\n :type other: :py:dict\n :param propper: ensure that both key lists are not the same.\n :type propper: :py:bool\n \n ...
[ { "param": "self", "type": null }, { "param": "other", "type": null }, { "param": "propper", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:bool" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
issuperset
<not_specific>
def issuperset(self, other, propper=True): """ Keys in self are also in other but self contains more keys (propper = True) :param other: object to compare to :type other: :py:dict :param propper: ensure that both key lists are not the same. :type pro...
Keys in self are also in other but self contains more keys (propper = True) :param other: object to compare to :type other: :py:dict :param propper: ensure that both key lists are not the same. :type propper: :py:bool :rtype: :py:b...
Keys in self are also in other but self contains more keys (propper = True)
[ "Keys", "in", "self", "are", "also", "in", "other", "but", "self", "contains", "more", "keys", "(", "propper", "=", "True", ")" ]
def issuperset(self, other, propper=True): self_keys = set(self.keys()) other_keys = set(other) if propper: return self_keys.issuperset(other_keys) and self_keys != other_keys else: return self_keys.issuperset(other_keys)
[ "def", "issuperset", "(", "self", ",", "other", ",", "propper", "=", "True", ")", ":", "self_keys", "=", "set", "(", "self", ".", "keys", "(", ")", ")", "other_keys", "=", "set", "(", "other", ")", "if", "propper", ":", "return", "self_keys", ".", ...
Keys in self are also in other but self contains more keys (propper = True)
[ "Keys", "in", "self", "are", "also", "in", "other", "but", "self", "contains", "more", "keys", "(", "propper", "=", "True", ")" ]
[ "\"\"\"\n Keys in self are also in other but self contains more keys\n (propper = True)\n \n :param other: object to compare to\n :type other: :py:dict\n :param propper: ensure that both key lists are not the same.\n :type propper: :py:bool\n \n :...
[ { "param": "self", "type": null }, { "param": "other", "type": null }, { "param": "propper", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:bool" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
symmetric_difference
<not_specific>
def symmetric_difference(self, other): """ Return the symmetric difference between the key set of self and other :rtype: :py:class:set """ return set(self.keys()).symmetric_difference(set(other))
Return the symmetric difference between the key set of self and other :rtype: :py:class:set
Return the symmetric difference between the key set of self and other
[ "Return", "the", "symmetric", "difference", "between", "the", "key", "set", "of", "self", "and", "other" ]
def symmetric_difference(self, other): return set(self.keys()).symmetric_difference(set(other))
[ "def", "symmetric_difference", "(", "self", ",", "other", ")", ":", "return", "set", "(", "self", ".", "keys", "(", ")", ")", ".", "symmetric_difference", "(", "set", "(", "other", ")", ")" ]
Return the symmetric difference between the key set of self and other
[ "Return", "the", "symmetric", "difference", "between", "the", "key", "set", "of", "self", "and", "other" ]
[ "\"\"\"\n Return the symmetric difference between the key set of self and other\n \n :rtype: :py:class:set\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:class:set" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optiona...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
union
<not_specific>
def union(self, other): """ Return the union between the key set of self and other :rtype: :py:class:set """ return set(self.keys()).union(set(other))
Return the union between the key set of self and other :rtype: :py:class:set
Return the union between the key set of self and other
[ "Return", "the", "union", "between", "the", "key", "set", "of", "self", "and", "other" ]
def union(self, other): return set(self.keys()).union(set(other))
[ "def", "union", "(", "self", ",", "other", ")", ":", "return", "set", "(", "self", ".", "keys", "(", ")", ")", ".", "union", "(", "set", "(", "other", ")", ")" ]
Return the union between the key set of self and other
[ "Return", "the", "union", "between", "the", "key", "set", "of", "self", "and", "other" ]
[ "\"\"\"\n Return the union between the key set of self and other\n \n :rtype: :py:class:set\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:class:set" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optiona...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
clear
null
def clear(self): """ Remove all key, value pairs from the data source. The method uses the `keys` method as source for pairs to remove and the `remove` method for the removal. `keys` represents a view on the data. """ for key in list(self.keys()): se...
Remove all key, value pairs from the data source. The method uses the `keys` method as source for pairs to remove and the `remove` method for the removal. `keys` represents a view on the data.
Remove all key, value pairs from the data source. The method uses the `keys` method as source for pairs to remove and the `remove` method for the removal. `keys` represents a view on the data.
[ "Remove", "all", "key", "value", "pairs", "from", "the", "data", "source", ".", "The", "method", "uses", "the", "`", "keys", "`", "method", "as", "source", "for", "pairs", "to", "remove", "and", "the", "`", "remove", "`", "method", "for", "the", "remov...
def clear(self): for key in list(self.keys()): self.remove(key)
[ "def", "clear", "(", "self", ")", ":", "for", "key", "in", "list", "(", "self", ".", "keys", "(", ")", ")", ":", "self", ".", "remove", "(", "key", ")" ]
Remove all key, value pairs from the data source.
[ "Remove", "all", "key", "value", "pairs", "from", "the", "data", "source", "." ]
[ "\"\"\"\n Remove all key, value pairs from the data source.\n\n The method uses the `keys` method as source for pairs to remove and the\n `remove` method for the removal. `keys` represents a view on the data.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
pop
<not_specific>
def pop(self, key, default=__marker): """ Dictionary like pop methods Removes the key and returns the corresponding value or default if the key was not found and default is defined, otherwise a KeyError is raised. :param key: key to return value for ...
Dictionary like pop methods Removes the key and returns the corresponding value or default if the key was not found and default is defined, otherwise a KeyError is raised. :param key: key to return value for :param default: option default value if k...
Dictionary like pop methods Removes the key and returns the corresponding value or default if the key was not found and default is defined, otherwise a KeyError is raised.
[ "Dictionary", "like", "pop", "methods", "Removes", "the", "key", "and", "returns", "the", "corresponding", "value", "or", "default", "if", "the", "key", "was", "not", "found", "and", "default", "is", "defined", "otherwise", "a", "KeyError", "is", "raised", "...
def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "__marker", ")", ":", "try", ":", "value", "=", "self", "[", "key", "]", "except", "KeyError", ":", "if", "default", "is", "self", ".", "__marker", ":", "raise", "return", "default", "else",...
Dictionary like pop methods Removes the key and returns the corresponding value or default if the key was not found and default is defined, otherwise a KeyError is raised.
[ "Dictionary", "like", "pop", "methods", "Removes", "the", "key", "and", "returns", "the", "corresponding", "value", "or", "default", "if", "the", "key", "was", "not", "found", "and", "default", "is", "defined", "otherwise", "a", "KeyError", "is", "raised", "...
[ "\"\"\"\n Dictionary like pop methods\n \n Removes the key and returns the corresponding value or default if the\n key was not found and default is defined, otherwise a KeyError is\n raised.\n \n :param key: key to return value for\n :param default: option...
[ { "param": "self", "type": null }, { "param": "key", "type": null }, { "param": "default", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
popitem
<not_specific>
def popitem(self): """ Dictionary like popitem methods Remove and return some (key, value) pair as a 2-tuple but raises KeyError if the object is empty. :return: key, value pair :rtype: :py:tuple """ try: key = next(...
Dictionary like popitem methods Remove and return some (key, value) pair as a 2-tuple but raises KeyError if the object is empty. :return: key, value pair :rtype: :py:tuple
Dictionary like popitem methods Remove and return some (key, value) pair as a 2-tuple but raises KeyError if the object is empty.
[ "Dictionary", "like", "popitem", "methods", "Remove", "and", "return", "some", "(", "key", "value", ")", "pair", "as", "a", "2", "-", "tuple", "but", "raises", "KeyError", "if", "the", "object", "is", "empty", "." ]
def popitem(self): try: key = next(iter(self)) except StopIteration: raise KeyError value = self[key] del self[key] return key, value
[ "def", "popitem", "(", "self", ")", ":", "try", ":", "key", "=", "next", "(", "iter", "(", "self", ")", ")", "except", "StopIteration", ":", "raise", "KeyError", "value", "=", "self", "[", "key", "]", "del", "self", "[", "key", "]", "return", "key"...
Dictionary like popitem methods Remove and return some (key, value) pair as a 2-tuple but raises KeyError if the object is empty.
[ "Dictionary", "like", "popitem", "methods", "Remove", "and", "return", "some", "(", "key", "value", ")", "pair", "as", "a", "2", "-", "tuple", "but", "raises", "KeyError", "if", "the", "object", "is", "empty", "." ]
[ "\"\"\"\n Dictionary like popitem methods\n \n Remove and return some (key, value) pair as a 2-tuple but raises\n KeyError if the object is empty.\n \n :return: key, value pair\n :rtype: :py:tuple\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "key, value pair", "docstring_tokens": [ "key", "value", "pair" ], "type": ":py:tuple" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [],...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
update
null
def update(self, *args, **kwds): """ Dictionary like update methods Update the data store from mapping/iterable (arg) and/or from individual keyword arguments (kwargs). :param args: mapping/iterable to update from :param kwds: keyword arguments to update...
Dictionary like update methods Update the data store from mapping/iterable (arg) and/or from individual keyword arguments (kwargs). :param args: mapping/iterable to update from :param kwds: keyword arguments to update from
Dictionary like update methods Update the data store from mapping/iterable (arg) and/or from individual keyword arguments (kwargs).
[ "Dictionary", "like", "update", "methods", "Update", "the", "data", "store", "from", "mapping", "/", "iterable", "(", "arg", ")", "and", "/", "or", "from", "individual", "keyword", "arguments", "(", "kwargs", ")", "." ]
def update(self, *args, **kwds): if args: if not len(args) == 1: raise TypeError('update expected at most 1 arguments, got {0}'.format(len(args))) other = args[0] if isinstance(other, GraphDriverBaseClass): for key, value in other.iteritems(): ...
[ "def", "update", "(", "self", ",", "*", "args", ",", "**", "kwds", ")", ":", "if", "args", ":", "if", "not", "len", "(", "args", ")", "==", "1", ":", "raise", "TypeError", "(", "'update expected at most 1 arguments, got {0}'", ".", "format", "(", "len", ...
Dictionary like update methods Update the data store from mapping/iterable (arg) and/or from individual keyword arguments (kwargs).
[ "Dictionary", "like", "update", "methods", "Update", "the", "data", "store", "from", "mapping", "/", "iterable", "(", "arg", ")", "and", "/", "or", "from", "individual", "keyword", "arguments", "(", "kwargs", ")", "." ]
[ "\"\"\"\n Dictionary like update methods\n \n Update the data store from mapping/iterable (arg) and/or from\n individual keyword arguments (kwargs).\n \n :param args: mapping/iterable to update from\n :param kwds: keyword arguments to update from\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [ { "identifier": "args", "type": null, "docstring": "mappin...
97fbda2bb86068990fb31e8e5dd5d6e473b70648
codacy-badger/graphit
graphit/graph_storage_drivers/graph_driver_baseclass.py
[ "Apache-2.0" ]
Python
reset_view
null
def reset_view(self): """ Reset the selective view on the DataFrame """ self._view = None
Reset the selective view on the DataFrame
Reset the selective view on the DataFrame
[ "Reset", "the", "selective", "view", "on", "the", "DataFrame" ]
def reset_view(self): self._view = None
[ "def", "reset_view", "(", "self", ")", ":", "self", ".", "_view", "=", "None" ]
Reset the selective view on the DataFrame
[ "Reset", "the", "selective", "view", "on", "the", "DataFrame" ]
[ "\"\"\"\n Reset the selective view on the DataFrame\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
242f3ff9dfbc0077a2acbcc0e3fd040b79bfdf34
codacy-badger/graphit
graphit/graph_storage_drivers/graph_dictstorage_driver.py
[ "Apache-2.0" ]
Python
init_dictstorage_driver
<not_specific>
def init_dictstorage_driver(nodes, edges): """ DictStorage specific driver initiation method Returns a DictStorage instance for nodes and edges and a AdjacencyView for adjacency based on the initiated nodes and edges stores. :param nodes: Nodes to initiate nodes DictStorage instance :type node...
DictStorage specific driver initiation method Returns a DictStorage instance for nodes and edges and a AdjacencyView for adjacency based on the initiated nodes and edges stores. :param nodes: Nodes to initiate nodes DictStorage instance :type nodes: :py:list, :py:dict, :graphit...
DictStorage specific driver initiation method Returns a DictStorage instance for nodes and edges and a AdjacencyView for adjacency based on the initiated nodes and edges stores.
[ "DictStorage", "specific", "driver", "initiation", "method", "Returns", "a", "DictStorage", "instance", "for", "nodes", "and", "edges", "and", "a", "AdjacencyView", "for", "adjacency", "based", "on", "the", "initiated", "nodes", "and", "edges", "stores", "." ]
def init_dictstorage_driver(nodes, edges): node_storage = DictStorage(nodes) edge_storage = DictStorage(edges) adjacency_storage = AdjacencyView(node_storage, edge_storage) return node_storage, edge_storage, adjacency_storage
[ "def", "init_dictstorage_driver", "(", "nodes", ",", "edges", ")", ":", "node_storage", "=", "DictStorage", "(", "nodes", ")", "edge_storage", "=", "DictStorage", "(", "edges", ")", "adjacency_storage", "=", "AdjacencyView", "(", "node_storage", ",", "edge_storage...
DictStorage specific driver initiation method Returns a DictStorage instance for nodes and edges and a AdjacencyView for adjacency based on the initiated nodes and edges stores.
[ "DictStorage", "specific", "driver", "initiation", "method", "Returns", "a", "DictStorage", "instance", "for", "nodes", "and", "edges", "and", "a", "AdjacencyView", "for", "adjacency", "based", "on", "the", "initiated", "nodes", "and", "edges", "stores", "." ]
[ "\"\"\"\n DictStorage specific driver initiation method\n\n Returns a DictStorage instance for nodes and edges and a AdjacencyView\n for adjacency based on the initiated nodes and edges stores.\n\n :param nodes: Nodes to initiate nodes DictStorage instance\n :type nodes: :py:list, :py:dict,\n ...
[ { "param": "nodes", "type": null }, { "param": "edges", "type": null } ]
{ "returns": [ { "docstring": "Nodes and edges storage instances and Adjacency view.", "docstring_tokens": [ "Nodes", "and", "edges", "storage", "instances", "and", "Adjacency", "view", "." ], "type": null } ], ...
242f3ff9dfbc0077a2acbcc0e3fd040b79bfdf34
codacy-badger/graphit
graphit/graph_storage_drivers/graph_dictstorage_driver.py
[ "Apache-2.0" ]
Python
copy
<not_specific>
def copy(self): """ Return a deep copy of the storage class with the same view as the parent instance. :return: deep copy of storage instance :rtype: DictStorage """ deepcopy = DictStorage(copy.deepcopy(self._storage)) if self.is_view: ...
Return a deep copy of the storage class with the same view as the parent instance. :return: deep copy of storage instance :rtype: DictStorage
Return a deep copy of the storage class with the same view as the parent instance.
[ "Return", "a", "deep", "copy", "of", "the", "storage", "class", "with", "the", "same", "view", "as", "the", "parent", "instance", "." ]
def copy(self): deepcopy = DictStorage(copy.deepcopy(self._storage)) if self.is_view: deepcopy.set_view(self._view) return deepcopy
[ "def", "copy", "(", "self", ")", ":", "deepcopy", "=", "DictStorage", "(", "copy", ".", "deepcopy", "(", "self", ".", "_storage", ")", ")", "if", "self", ".", "is_view", ":", "deepcopy", ".", "set_view", "(", "self", ".", "_view", ")", "return", "dee...
Return a deep copy of the storage class with the same view as the parent instance.
[ "Return", "a", "deep", "copy", "of", "the", "storage", "class", "with", "the", "same", "view", "as", "the", "parent", "instance", "." ]
[ "\"\"\"\n Return a deep copy of the storage class with the same view as\n the parent instance.\n\n :return: deep copy of storage instance\n :rtype: DictStorage\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "deep copy of storage instance", "docstring_tokens": [ "deep", "copy", "of", "storage", "instance" ], "type": "DictStorage" } ], "raises": [], "params": [ { "identifier": "self", "type": null, ...
242f3ff9dfbc0077a2acbcc0e3fd040b79bfdf34
codacy-badger/graphit
graphit/graph_storage_drivers/graph_dictstorage_driver.py
[ "Apache-2.0" ]
Python
to_dict
<not_specific>
def to_dict(self, return_full=False): """ Return a shallow copy of the full dictionary. If the current DictStorage represent a selective view on the parent dictionary then only return a dictionary with a shallow copy of the keys in the selective view. :p...
Return a shallow copy of the full dictionary. If the current DictStorage represent a selective view on the parent dictionary then only return a dictionary with a shallow copy of the keys in the selective view. :param return_full: ignores is_view and return the ...
Return a shallow copy of the full dictionary. If the current DictStorage represent a selective view on the parent dictionary then only return a dictionary with a shallow copy of the keys in the selective view.
[ "Return", "a", "shallow", "copy", "of", "the", "full", "dictionary", ".", "If", "the", "current", "DictStorage", "represent", "a", "selective", "view", "on", "the", "parent", "dictionary", "then", "only", "return", "a", "dictionary", "with", "a", "shallow", ...
def to_dict(self, return_full=False): return_dict = self._storage if self.is_view and not return_full: return_dict = {k: v for k, v in return_dict.items() if k in self._view} return return_dict
[ "def", "to_dict", "(", "self", ",", "return_full", "=", "False", ")", ":", "return_dict", "=", "self", ".", "_storage", "if", "self", ".", "is_view", "and", "not", "return_full", ":", "return_dict", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in"...
Return a shallow copy of the full dictionary.
[ "Return", "a", "shallow", "copy", "of", "the", "full", "dictionary", "." ]
[ "\"\"\"\n Return a shallow copy of the full dictionary.\n \n If the current DictStorage represent a selective view on the parent\n dictionary then only return a dictionary with a shallow copy of the\n keys in the selective view.\n \n :param return_full: ignores is_vi...
[ { "param": "self", "type": null }, { "param": "return_full", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:dict" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
242f3ff9dfbc0077a2acbcc0e3fd040b79bfdf34
codacy-badger/graphit
graphit/graph_storage_drivers/graph_dictstorage_driver.py
[ "Apache-2.0" ]
Python
fromkeys
<not_specific>
def fromkeys(self, keys, value=None): """ Return a shallow copy of the dictionary for selected keys. If the DictStorage instance represent a selective view of the main dictionary, only those keys will be considered. TODO: value=None results in a KeyError for View based comparis...
Return a shallow copy of the dictionary for selected keys. If the DictStorage instance represent a selective view of the main dictionary, only those keys will be considered. TODO: value=None results in a KeyError for View based comparison methods :param keys: keys to return ...
Return a shallow copy of the dictionary for selected keys. If the DictStorage instance represent a selective view of the main dictionary, only those keys will be considered. value=None results in a KeyError for View based comparison methods
[ "Return", "a", "shallow", "copy", "of", "the", "dictionary", "for", "selected", "keys", ".", "If", "the", "DictStorage", "instance", "represent", "a", "selective", "view", "of", "the", "main", "dictionary", "only", "those", "keys", "will", "be", "considered", ...
def fromkeys(self, keys, value=None): return DictStorage([(k, value) for k in keys if k in self])
[ "def", "fromkeys", "(", "self", ",", "keys", ",", "value", "=", "None", ")", ":", "return", "DictStorage", "(", "[", "(", "k", ",", "value", ")", "for", "k", "in", "keys", "if", "k", "in", "self", "]", ")" ]
Return a shallow copy of the dictionary for selected keys.
[ "Return", "a", "shallow", "copy", "of", "the", "dictionary", "for", "selected", "keys", "." ]
[ "\"\"\"\n Return a shallow copy of the dictionary for selected keys.\n\n If the DictStorage instance represent a selective view of the main\n dictionary, only those keys will be considered.\n\n TODO: value=None results in a KeyError for View based comparison methods\n\n :param key...
[ { "param": "self", "type": null }, { "param": "keys", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "keys", "type": null, "docstring": "keys to return dictionary copy f...
242f3ff9dfbc0077a2acbcc0e3fd040b79bfdf34
codacy-badger/graphit
graphit/graph_storage_drivers/graph_dictstorage_driver.py
[ "Apache-2.0" ]
Python
remove
null
def remove(self, key): """ Remove key, value pairs from the dictionary If the DictStorage instance represent a selective view of the main dictionary, only allow item deletion for keys in the respective view. .. note:: Do not use this method directly to remove n...
Remove key, value pairs from the dictionary If the DictStorage instance represent a selective view of the main dictionary, only allow item deletion for keys in the respective view. .. note:: Do not use this method directly to remove nodes or edges f...
Remove key, value pairs from the dictionary If the DictStorage instance represent a selective view of the main dictionary, only allow item deletion for keys in the respective view. : Do not use this method directly to remove nodes or edges from the graph as it may leave the graph in a funny state. Use the graph remove...
[ "Remove", "key", "value", "pairs", "from", "the", "dictionary", "If", "the", "DictStorage", "instance", "represent", "a", "selective", "view", "of", "the", "main", "dictionary", "only", "allow", "item", "deletion", "for", "keys", "in", "the", "respective", "vi...
def remove(self, key): if key not in self.keys(): raise KeyError('"{0}" not in storage or not part of selective view'.format(key)) if self.is_view: self._view.remove(key) del self._storage[key]
[ "def", "remove", "(", "self", ",", "key", ")", ":", "if", "key", "not", "in", "self", ".", "keys", "(", ")", ":", "raise", "KeyError", "(", "'\"{0}\" not in storage or not part of selective view'", ".", "format", "(", "key", ")", ")", "if", "self", ".", ...
Remove key, value pairs from the dictionary If the DictStorage instance represent a selective view of the main dictionary, only allow item deletion for keys in the respective view.
[ "Remove", "key", "value", "pairs", "from", "the", "dictionary", "If", "the", "DictStorage", "instance", "represent", "a", "selective", "view", "of", "the", "main", "dictionary", "only", "allow", "item", "deletion", "for", "keys", "in", "the", "respective", "vi...
[ "\"\"\"\n Remove key, value pairs from the dictionary\n \n If the DictStorage instance represent a selective view of the main\n dictionary, only allow item deletion for keys in the respective view.\n \n .. note:: Do not use this method directly to remove nodes or edges\n ...
[ { "param": "self", "type": null }, { "param": "key", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": null, "docstring": "dictionary key to remove", ...
242f3ff9dfbc0077a2acbcc0e3fd040b79bfdf34
codacy-badger/graphit
graphit/graph_storage_drivers/graph_dictstorage_driver.py
[ "Apache-2.0" ]
Python
update
null
def update(self, *args, **kwargs): """ Update key/value pairs also updating the view if needed :param other: other key/value pairs :type other: :py:dict """ kwargs = prepaire_data_dict(kwargs) self._storage.update(*args, **kwargs) if self.is_vi...
Update key/value pairs also updating the view if needed :param other: other key/value pairs :type other: :py:dict
Update key/value pairs also updating the view if needed
[ "Update", "key", "/", "value", "pairs", "also", "updating", "the", "view", "if", "needed" ]
def update(self, *args, **kwargs): kwargs = prepaire_data_dict(kwargs) self._storage.update(*args, **kwargs) if self.is_view: other = [] if args: other = list(args[0].keys()) self._view.update(other + list(kwargs.keys()))
[ "def", "update", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "kwargs", "=", "prepaire_data_dict", "(", "kwargs", ")", "self", ".", "_storage", ".", "update", "(", "*", "args", ",", "**", "kwargs", ")", "if", "self", ".", "is_view", ...
Update key/value pairs also updating the view if needed
[ "Update", "key", "/", "value", "pairs", "also", "updating", "the", "view", "if", "needed" ]
[ "\"\"\"\n Update key/value pairs also updating the view if needed\n \n :param other: other key/value pairs\n :type other: :py:dict\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [ { "identifier": "other", "type": null, "docstring": "other...
c7a1751cff7c00f45ae8ba2091ccf3d657bbce80
codacy-badger/graphit
graphit/graph_io/io_dot_format.py
[ "Apache-2.0" ]
Python
write_dot
<not_specific>
def write_dot(graph, graph_name='graph', dot_directives=None): """ DOT graphs are either directional (digraph) or undirectional, mixed mode is not supported. Basic types for node and edge attributes are supported. :param graph: Graph object to export :type graph: :gr...
DOT graphs are either directional (digraph) or undirectional, mixed mode is not supported. Basic types for node and edge attributes are supported. :param graph: Graph object to export :type graph: :graphit:Graph :param graph_name: graph name to include :type...
DOT graphs are either directional (digraph) or undirectional, mixed mode is not supported. Basic types for node and edge attributes are supported.
[ "DOT", "graphs", "are", "either", "directional", "(", "digraph", ")", "or", "undirectional", "mixed", "mode", "is", "not", "supported", ".", "Basic", "types", "for", "node", "and", "edge", "attributes", "are", "supported", "." ]
def write_dot(graph, graph_name='graph', dot_directives=None): indent = ' ' * 4 link = '->' if graph.directed else '--' string_buffer = StringIO() string_buffer.write('//Created by {0} version {1}\n'.format(__module__, __version__)) string_buffer.write('{0} "{1}" {2}\n'.format('digraph' if graph.dir...
[ "def", "write_dot", "(", "graph", ",", "graph_name", "=", "'graph'", ",", "dot_directives", "=", "None", ")", ":", "indent", "=", "' '", "*", "4", "link", "=", "'->'", "if", "graph", ".", "directed", "else", "'--'", "string_buffer", "=", "StringIO", "(",...
DOT graphs are either directional (digraph) or undirectional, mixed mode is not supported.
[ "DOT", "graphs", "are", "either", "directional", "(", "digraph", ")", "or", "undirectional", "mixed", "mode", "is", "not", "supported", "." ]
[ "\"\"\"\n DOT graphs are either directional (digraph) or undirectional, mixed mode\n is not supported.\n \n Basic types for node and edge attributes are supported.\n \n :param graph: Graph object to export\n :type graph: :graphit:Graph\n :param graph_name: graph name t...
[ { "param": "graph", "type": null }, { "param": "graph_name", "type": null }, { "param": "dot_directives", "type": null } ]
{ "returns": [ { "docstring": "DOT graph representation", "docstring_tokens": [ "DOT", "graph", "representation" ], "type": ":py:str" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph object to ...
90dfb968c701ca7a2a1a6bab741c35a68d2f504f
codacy-badger/graphit
graphit/graph_io/io_pydata_format.py
[ "Apache-2.0" ]
Python
serialize
<not_specific>
def serialize(self, **kwargs): """ Serialize graph nodes to a Python dictionary This default `serialize` method is used when no python data type specific or custom method is returned by the ORM. It will serialize the current node children if any to a Python dictionary an...
Serialize graph nodes to a Python dictionary This default `serialize` method is used when no python data type specific or custom method is returned by the ORM. It will serialize the current node children if any to a Python dictionary and return them with the current node key. ...
Serialize graph nodes to a Python dictionary This default `serialize` method is used when no python data type specific or custom method is returned by the ORM. It will serialize the current node children if any to a Python dictionary and return them with the current node key.
[ "Serialize", "graph", "nodes", "to", "a", "Python", "dictionary", "This", "default", "`", "serialize", "`", "method", "is", "used", "when", "no", "python", "data", "type", "specific", "or", "custom", "method", "is", "returned", "by", "the", "ORM", ".", "It...
def serialize(self, **kwargs): attributes = {} if kwargs.get('export_all'): for key in self.nodes[self.nid].keys(): if key in excluded_keys or key == self.key_tag: continue value = self.get(key, default=kwargs.get('default')) ...
[ "def", "serialize", "(", "self", ",", "**", "kwargs", ")", ":", "attributes", "=", "{", "}", "if", "kwargs", ".", "get", "(", "'export_all'", ")", ":", "for", "key", "in", "self", ".", "nodes", "[", "self", ".", "nid", "]", ".", "keys", "(", ")",...
Serialize graph nodes to a Python dictionary This default `serialize` method is used when no python data type specific or custom method is returned by the ORM.
[ "Serialize", "graph", "nodes", "to", "a", "Python", "dictionary", "This", "default", "`", "serialize", "`", "method", "is", "used", "when", "no", "python", "data", "type", "specific", "or", "custom", "method", "is", "returned", "by", "the", "ORM", "." ]
[ "\"\"\"\n Serialize graph nodes to a Python dictionary\n\n This default `serialize` method is used when no python data type\n specific or custom method is returned by the ORM.\n It will serialize the current node children if any to a Python\n dictionary and return them with the cu...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
90dfb968c701ca7a2a1a6bab741c35a68d2f504f
codacy-badger/graphit
graphit/graph_io/io_pydata_format.py
[ "Apache-2.0" ]
Python
serialize
<not_specific>
def serialize(self, **kwargs): """ Serialize a node as Python dictionary :param allow_none: serialize None values :type allow_none: :py:bool :param default: default value to return if value is None :return: dictionary name (node key) an...
Serialize a node as Python dictionary :param allow_none: serialize None values :type allow_none: :py:bool :param default: default value to return if value is None :return: dictionary name (node key) and dictionary
Serialize a node as Python dictionary
[ "Serialize", "a", "node", "as", "Python", "dictionary" ]
def serialize(self, **kwargs): attributes = {} for key in self.nodes[self.nid].keys(): if key in excluded_keys or key == self.key_tag: continue value = self.get(key, default=kwargs.get('default')) if not kwargs.get('allow_none') and value is None: ...
[ "def", "serialize", "(", "self", ",", "**", "kwargs", ")", ":", "attributes", "=", "{", "}", "for", "key", "in", "self", ".", "nodes", "[", "self", ".", "nid", "]", ".", "keys", "(", ")", ":", "if", "key", "in", "excluded_keys", "or", "key", "=="...
Serialize a node as Python dictionary
[ "Serialize", "a", "node", "as", "Python", "dictionary" ]
[ "\"\"\"\n Serialize a node as Python dictionary\n \n :param allow_none: serialize None values\n :type allow_none: :py:bool\n :param default: default value to return if value is None\n \n :return: dictionary name (node key) and dictionary\n \"...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "dictionary name (node key) and dictionary", "docstring_tokens": [ "dictionary", "name", "(", "node", "key", ")", "and", "dictionary" ], "type": null } ], "raises": [], "params": [ {...
90dfb968c701ca7a2a1a6bab741c35a68d2f504f
codacy-badger/graphit
graphit/graph_io/io_pydata_format.py
[ "Apache-2.0" ]
Python
serialize
<not_specific>
def serialize(self, **kwargs): """ Serialize a node as Python list # TODO: Serialization of children when switching to 'return_nids = True' # Refactor ORM to properly deal with the inherit = False option and make # that an option you can set for every registered node/edg...
Serialize a node as Python list # TODO: Serialization of children when switching to 'return_nids = True' # Refactor ORM to properly deal with the inherit = False option and make # that an option you can set for every registered node/edge. :param allow_none: se...
Serialize a node as Python list TODO: Serialization of children when switching to 'return_nids = True' Refactor ORM to properly deal with the inherit = False option and make that an option you can set for every registered node/edge.
[ "Serialize", "a", "node", "as", "Python", "list", "TODO", ":", "Serialization", "of", "children", "when", "switching", "to", "'", "return_nids", "=", "True", "'", "Refactor", "ORM", "to", "properly", "deal", "with", "the", "inherit", "=", "False", "option", ...
def serialize(self, **kwargs): new = [] for cid in self.children(return_nids=True): child_node = self.origin.getnodes(cid) key, value = child_node.serialize(**kwargs) if not kwargs.get('allow_none') and value is None: continue new.append(va...
[ "def", "serialize", "(", "self", ",", "**", "kwargs", ")", ":", "new", "=", "[", "]", "for", "cid", "in", "self", ".", "children", "(", "return_nids", "=", "True", ")", ":", "child_node", "=", "self", ".", "origin", ".", "getnodes", "(", "cid", ")"...
Serialize a node as Python list TODO: Serialization of children when switching to 'return_nids = True' Refactor ORM to properly deal with the inherit = False option and make that an option you can set for every registered node/edge.
[ "Serialize", "a", "node", "as", "Python", "list", "TODO", ":", "Serialization", "of", "children", "when", "switching", "to", "'", "return_nids", "=", "True", "'", "Refactor", "ORM", "to", "properly", "deal", "with", "the", "inherit", "=", "False", "option", ...
[ "\"\"\"\n Serialize a node as Python list\n \n # TODO: Serialization of children when switching to 'return_nids = True'\n # Refactor ORM to properly deal with the inherit = False option and make\n # that an option you can set for every registered node/edge.\n \n :par...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "list name (node key) and list", "docstring_tokens": [ "list", "name", "(", "node", "key", ")", "and", "list" ], "type": null } ], "raises": [], "params": [ { "identifier": "se...
90dfb968c701ca7a2a1a6bab741c35a68d2f504f
codacy-badger/graphit
graphit/graph_io/io_pydata_format.py
[ "Apache-2.0" ]
Python
read_pydata
<not_specific>
def read_pydata(data, graph=None, parser_classes=ORMDEFS_LEVEL1, level=1): """ Parse (hierarchical) python data structures to a graph Many data formats are first parsed to a python structure before they are converted to a graph using the `read_pydata` function. The function supports any object that...
Parse (hierarchical) python data structures to a graph Many data formats are first parsed to a python structure before they are converted to a graph using the `read_pydata` function. The function supports any object that is an instance of, or behaves as, a Python dictionary, list, tuple or set and...
Parse (hierarchical) python data structures to a graph Many data formats are first parsed to a python structure before they are converted to a graph using the `read_pydata` function. The function supports any object that is an instance of, or behaves as, a Python dictionary, list, tuple or set and converts these (neste...
[ "Parse", "(", "hierarchical", ")", "python", "data", "structures", "to", "a", "graph", "Many", "data", "formats", "are", "first", "parsed", "to", "a", "python", "structure", "before", "they", "are", "converted", "to", "a", "graph", "using", "the", "`", "re...
def read_pydata(data, graph=None, parser_classes=ORMDEFS_LEVEL1, level=1): if graph is None: graph = GraphAxis() if not isinstance(graph, GraphAxis): raise TypeError('Unsupported graph type {0}'.format(type(graph))) if parser_classes in (ORMDEFS_LEVEL0, ORMDEFS_LEVEL1): if level == 0...
[ "def", "read_pydata", "(", "data", ",", "graph", "=", "None", ",", "parser_classes", "=", "ORMDEFS_LEVEL1", ",", "level", "=", "1", ")", ":", "if", "graph", "is", "None", ":", "graph", "=", "GraphAxis", "(", ")", "if", "not", "isinstance", "(", "graph"...
Parse (hierarchical) python data structures to a graph Many data formats are first parsed to a python structure before they are converted to a graph using the `read_pydata` function.
[ "Parse", "(", "hierarchical", ")", "python", "data", "structures", "to", "a", "graph", "Many", "data", "formats", "are", "first", "parsed", "to", "a", "python", "structure", "before", "they", "are", "converted", "to", "a", "graph", "using", "the", "`", "re...
[ "\"\"\"\n Parse (hierarchical) python data structures to a graph\n\n Many data formats are first parsed to a python structure before they are\n converted to a graph using the `read_pydata` function.\n The function supports any object that is an instance of, or behaves as, a\n Python dictionary, list,...
[ { "param": "data", "type": null }, { "param": "graph", "type": null }, { "param": "parser_classes", "type": null }, { "param": "level", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":graphit:GraphAxis" } ], "raises": [], "params": [ { "identifier": "data", "type": null, "docstring": "Python (hierarchical) data structure", "docstring_tokens": [ ...
90dfb968c701ca7a2a1a6bab741c35a68d2f504f
codacy-badger/graphit
graphit/graph_io/io_pydata_format.py
[ "Apache-2.0" ]
Python
write_pydata
<not_specific>
def write_pydata(graph, nested=True, sep='.', default=None, allow_none=True, export_all=False, include_root=False): """ Export a graph to a (nested) dictionary Convert graph representation of the dictionary tree into a dictionary using a nested or flattened representation of the dictionary hierarch...
Export a graph to a (nested) dictionary Convert graph representation of the dictionary tree into a dictionary using a nested or flattened representation of the dictionary hierarchy. In a flattened representation, the keys are concatenated using the `sep` separator. Dictionary keys and...
Export a graph to a (nested) dictionary Convert graph representation of the dictionary tree into a dictionary using a nested or flattened representation of the dictionary hierarchy. In a flattened representation, the keys are concatenated using the `sep` separator. Dictionary keys and values are obtained from the node...
[ "Export", "a", "graph", "to", "a", "(", "nested", ")", "dictionary", "Convert", "graph", "representation", "of", "the", "dictionary", "tree", "into", "a", "dictionary", "using", "a", "nested", "or", "flattened", "representation", "of", "the", "dictionary", "hi...
def write_pydata(graph, nested=True, sep='.', default=None, allow_none=True, export_all=False, include_root=False): if graph.empty(): logging.info('Graph is empty: {0}'.format(repr(graph))) return {} if not isinstance(graph, GraphAxis): raise TypeError('Unsupported graph type {0}'.format...
[ "def", "write_pydata", "(", "graph", ",", "nested", "=", "True", ",", "sep", "=", "'.'", ",", "default", "=", "None", ",", "allow_none", "=", "True", ",", "export_all", "=", "False", ",", "include_root", "=", "False", ")", ":", "if", "graph", ".", "e...
Export a graph to a (nested) dictionary Convert graph representation of the dictionary tree into a dictionary using a nested or flattened representation of the dictionary hierarchy.
[ "Export", "a", "graph", "to", "a", "(", "nested", ")", "dictionary", "Convert", "graph", "representation", "of", "the", "dictionary", "tree", "into", "a", "dictionary", "using", "a", "nested", "or", "flattened", "representation", "of", "the", "dictionary", "hi...
[ "\"\"\"\n Export a graph to a (nested) dictionary\n \n Convert graph representation of the dictionary tree into a dictionary\n using a nested or flattened representation of the dictionary hierarchy.\n \n In a flattened representation, the keys are concatenated using the `sep`\n separator.\n ...
[ { "param": "graph", "type": null }, { "param": "nested", "type": null }, { "param": "sep", "type": null }, { "param": "default", "type": null }, { "param": "allow_none", "type": null }, { "param": "export_all", "type": null }, { "param": "i...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:dict" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph object to export", "docstring_tokens": [ "Graph", "...
b247485e0ffdb277871ef78eb20a5201171ca063
codacy-badger/graphit
graphit/graph_utils/graph_utilities.py
[ "Apache-2.0" ]
Python
graph_undirectional_to_directional
<not_specific>
def graph_undirectional_to_directional(graph): """ Convert a undirectional to a directional graph Returns a deep copy of the full graph with all undirectional edges duplicated as directional ones. In an undirectional edge the egde pair shares a single attribute dictionary. This dictionary gets...
Convert a undirectional to a directional graph Returns a deep copy of the full graph with all undirectional edges duplicated as directional ones. In an undirectional edge the egde pair shares a single attribute dictionary. This dictionary gets duplicated to the unique directional edges. ...
Convert a undirectional to a directional graph Returns a deep copy of the full graph with all undirectional edges duplicated as directional ones. In an undirectional edge the egde pair shares a single attribute dictionary. This dictionary gets duplicated to the unique directional edges.
[ "Convert", "a", "undirectional", "to", "a", "directional", "graph", "Returns", "a", "deep", "copy", "of", "the", "full", "graph", "with", "all", "undirectional", "edges", "duplicated", "as", "directional", "ones", ".", "In", "an", "undirectional", "edge", "the...
def graph_undirectional_to_directional(graph): if graph.directed: logging.info('Graph already configured as directed graph') graph_copy = graph.copy(deep=True) graph_copy.directed = True graph_copy.edges.clear() for edge, attr in graph.edges.items(): graph_copy.add_edge(*edge, **attr...
[ "def", "graph_undirectional_to_directional", "(", "graph", ")", ":", "if", "graph", ".", "directed", ":", "logging", ".", "info", "(", "'Graph already configured as directed graph'", ")", "graph_copy", "=", "graph", ".", "copy", "(", "deep", "=", "True", ")", "g...
Convert a undirectional to a directional graph Returns a deep copy of the full graph with all undirectional edges duplicated as directional ones.
[ "Convert", "a", "undirectional", "to", "a", "directional", "graph", "Returns", "a", "deep", "copy", "of", "the", "full", "graph", "with", "all", "undirectional", "edges", "duplicated", "as", "directional", "ones", "." ]
[ "\"\"\"\n Convert a undirectional to a directional graph\n\n Returns a deep copy of the full graph with all undirectional edges\n duplicated as directional ones.\n\n In an undirectional edge the egde pair shares a single attribute\n dictionary. This dictionary gets duplicated to the unique directiona...
[ { "param": "graph", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":graphit:Graph" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph to convert", "docstring_tokens": [ "Graph", "...
b247485e0ffdb277871ef78eb20a5201171ca063
codacy-badger/graphit
graphit/graph_utils/graph_utilities.py
[ "Apache-2.0" ]
Python
graph_directional_to_undirectional
<not_specific>
def graph_directional_to_undirectional(graph): """ Convert a directional to an undirectional graph Returns a deep copy of the full graph with all directional edges duplicated as undirectional ones. Undirectional edges share the same data dictionary. In converting directional to undirectional ed...
Convert a directional to an undirectional graph Returns a deep copy of the full graph with all directional edges duplicated as undirectional ones. Undirectional edges share the same data dictionary. In converting directional to undirectional edges their data dictionaries will be merged. ....
Convert a directional to an undirectional graph Returns a deep copy of the full graph with all directional edges duplicated as undirectional ones. Undirectional edges share the same data dictionary. In converting directional to undirectional edges their data dictionaries will be merged. : dictionary merging may result...
[ "Convert", "a", "directional", "to", "an", "undirectional", "graph", "Returns", "a", "deep", "copy", "of", "the", "full", "graph", "with", "all", "directional", "edges", "duplicated", "as", "undirectional", "ones", ".", "Undirectional", "edges", "share", "the", ...
def graph_directional_to_undirectional(graph): if not graph.directed: logging.info('Graph already configured as undirected graph') graph_copy = graph.copy(deep=True) graph_copy.directed = False graph_copy.edges.clear() edges = list(graph.edges.keys()) while len(edges): edge = edg...
[ "def", "graph_directional_to_undirectional", "(", "graph", ")", ":", "if", "not", "graph", ".", "directed", ":", "logging", ".", "info", "(", "'Graph already configured as undirected graph'", ")", "graph_copy", "=", "graph", ".", "copy", "(", "deep", "=", "True", ...
Convert a directional to an undirectional graph Returns a deep copy of the full graph with all directional edges duplicated as undirectional ones.
[ "Convert", "a", "directional", "to", "an", "undirectional", "graph", "Returns", "a", "deep", "copy", "of", "the", "full", "graph", "with", "all", "directional", "edges", "duplicated", "as", "undirectional", "ones", "." ]
[ "\"\"\"\n Convert a directional to an undirectional graph\n\n Returns a deep copy of the full graph with all directional edges\n duplicated as undirectional ones.\n Undirectional edges share the same data dictionary. In converting\n directional to undirectional edges their data dictionaries will\n ...
[ { "param": "graph", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":graphit:Graph" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph to convert", "docstring_tokens": [ "Graph", "...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
node_neighbors
<not_specific>
def node_neighbors(graph, nid): """ Return de neighbor nodes of the node. This method is not hierarchical and thus the root node has no effect. Directed graphs and/or masked behaviour: masked nodes or directed nodes not having an edge from source to node will not be returned. :par...
Return de neighbor nodes of the node. This method is not hierarchical and thus the root node has no effect. Directed graphs and/or masked behaviour: masked nodes or directed nodes not having an edge from source to node will not be returned. :param graph: Graph to query :type grap...
Return de neighbor nodes of the node. This method is not hierarchical and thus the root node has no effect. Directed graphs and/or masked behaviour: masked nodes or directed nodes not having an edge from source to node will not be returned.
[ "Return", "de", "neighbor", "nodes", "of", "the", "node", ".", "This", "method", "is", "not", "hierarchical", "and", "thus", "the", "root", "node", "has", "no", "effect", ".", "Directed", "graphs", "and", "/", "or", "masked", "behaviour", ":", "masked", ...
def node_neighbors(graph, nid): if nid is None: return [] if graph.masked: nodes = set(graph.nodes.keys()) adjacency = set(graph.adjacency[nid]) else: nodes = set(graph.origin.nodes.keys()) adjacency = set(graph.origin.adjacency[nid]) return sorted(nodes.intersect...
[ "def", "node_neighbors", "(", "graph", ",", "nid", ")", ":", "if", "nid", "is", "None", ":", "return", "[", "]", "if", "graph", ".", "masked", ":", "nodes", "=", "set", "(", "graph", ".", "nodes", ".", "keys", "(", ")", ")", "adjacency", "=", "se...
Return de neighbor nodes of the node.
[ "Return", "de", "neighbor", "nodes", "of", "the", "node", "." ]
[ "\"\"\"\n Return de neighbor nodes of the node.\n \n This method is not hierarchical and thus the root node has no effect.\n \n Directed graphs and/or masked behaviour: masked nodes or directed\n nodes not having an edge from source to node will not be returned.\n \n :param graph: Graph to q...
[ { "param": "graph", "type": null }, { "param": "nid", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph to query", "docstring_tokens": [ "Graph", "to", "query" ], "default": null, "is_optional": null }, { "identifier": "nid", ...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
dfs
<not_specific>
def dfs(graph, root, method='dfs', max_depth=10000): """ General implementation of depth-first-search algorithm. The real power of the dfs method is combining it with the graph query methods. These allow sub graphs to be selected based on node or edge attributes such as graph directionality ...
General implementation of depth-first-search algorithm. The real power of the dfs method is combining it with the graph query methods. These allow sub graphs to be selected based on node or edge attributes such as graph directionality or edge weight. :param graph: graph to search ...
General implementation of depth-first-search algorithm. The real power of the dfs method is combining it with the graph query methods. These allow sub graphs to be selected based on node or edge attributes such as graph directionality or edge weight.
[ "General", "implementation", "of", "depth", "-", "first", "-", "search", "algorithm", ".", "The", "real", "power", "of", "the", "dfs", "method", "is", "combining", "it", "with", "the", "graph", "query", "methods", ".", "These", "allow", "sub", "graphs", "t...
def dfs(graph, root, method='dfs', max_depth=10000): root = graph.getnodes(root) stack_pop = -1 if method == 'bfs': stack_pop = 0 visited = [] stack = [root.nid] depth = 0 while stack or depth == max_depth: node = stack.pop(stack_pop) if node not in visited: ...
[ "def", "dfs", "(", "graph", ",", "root", ",", "method", "=", "'dfs'", ",", "max_depth", "=", "10000", ")", ":", "root", "=", "graph", ".", "getnodes", "(", "root", ")", "stack_pop", "=", "-", "1", "if", "method", "==", "'bfs'", ":", "stack_pop", "=...
General implementation of depth-first-search algorithm.
[ "General", "implementation", "of", "depth", "-", "first", "-", "search", "algorithm", "." ]
[ "\"\"\"\n General implementation of depth-first-search algorithm.\n \n The real power of the dfs method is combining it with the\n graph query methods. These allow sub graphs to be selected\n based on node or edge attributes such as graph directionality\n or edge weight.\n \n :param graph: ...
[ { "param": "graph", "type": null }, { "param": "root", "type": null }, { "param": "method", "type": null }, { "param": "max_depth", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "graph to search", "docstring_tokens": [ "graph", "to", "search" ], "default": null, "is_optional": null }, { "identifier": "root", ...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
dfs_paths
null
def dfs_paths(graph, start, goal, method='dfs'): """ Return all possible paths between two nodes. Setting method to 'bfs' returns the shortest path first :param graph: graph to search :type graph: graph class instance :param start: root node to start the search from :t...
Return all possible paths between two nodes. Setting method to 'bfs' returns the shortest path first :param graph: graph to search :type graph: graph class instance :param start: root node to start the search from :type start: :py:int :param goal: target nod...
Return all possible paths between two nodes. Setting method to 'bfs' returns the shortest path first
[ "Return", "all", "possible", "paths", "between", "two", "nodes", ".", "Setting", "method", "to", "'", "bfs", "'", "returns", "the", "shortest", "path", "first" ]
def dfs_paths(graph, start, goal, method='dfs'): stack_pop = -1 if method == 'bfs': stack_pop = 0 stack = [(start, [start])] while stack: (vertex, path) = stack.pop(stack_pop) neighbors = node_neighbors(graph, vertex) for next_node in set(neighbors) - set(path): ...
[ "def", "dfs_paths", "(", "graph", ",", "start", ",", "goal", ",", "method", "=", "'dfs'", ")", ":", "stack_pop", "=", "-", "1", "if", "method", "==", "'bfs'", ":", "stack_pop", "=", "0", "stack", "=", "[", "(", "start", ",", "[", "start", "]", ")...
Return all possible paths between two nodes.
[ "Return", "all", "possible", "paths", "between", "two", "nodes", "." ]
[ "\"\"\"\n Return all possible paths between two nodes.\n \n Setting method to 'bfs' returns the shortest path first\n \n :param graph: graph to search\n :type graph: graph class instance\n :param start: root node to start the search from\n :type start: :py:int\n :param g...
[ { "param": "graph", "type": null }, { "param": "start", "type": null }, { "param": "goal", "type": null }, { "param": "method", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:list" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "graph to search", "docstring_tokens": [ "graph", "to", ...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
brandes_betweenness_centrality
<not_specific>
def brandes_betweenness_centrality(graph, nodes=None, normalized=True, weight=None, endpoints=False): """ Brandes algorithm for betweenness centrality. Betweenness centrality is an indicator of a node's centrality in a network. It is equal to the number of shortest paths from all vertices to all ot...
Brandes algorithm for betweenness centrality. Betweenness centrality is an indicator of a node's centrality in a network. It is equal to the number of shortest paths from all vertices to all others that pass through that node. A node with high betweenness centrality has a large influence on th...
Brandes algorithm for betweenness centrality. Betweenness centrality is an indicator of a node's centrality in a network. It is equal to the number of shortest paths from all vertices to all others that pass through that node. A node with high betweenness centrality has a large influence on the transfer of items throug...
[ "Brandes", "algorithm", "for", "betweenness", "centrality", ".", "Betweenness", "centrality", "is", "an", "indicator", "of", "a", "node", "'", "s", "centrality", "in", "a", "network", ".", "It", "is", "equal", "to", "the", "number", "of", "shortest", "paths"...
def brandes_betweenness_centrality(graph, nodes=None, normalized=True, weight=None, endpoints=False): betweenness = dict.fromkeys(graph.nodes, 0.0) nodes = nodes or graph.nodes for node in nodes: S = [] P = {} for v in graph.nodes: P[v] = [] D = {} sigma =...
[ "def", "brandes_betweenness_centrality", "(", "graph", ",", "nodes", "=", "None", ",", "normalized", "=", "True", ",", "weight", "=", "None", ",", "endpoints", "=", "False", ")", ":", "betweenness", "=", "dict", ".", "fromkeys", "(", "graph", ".", "nodes",...
Brandes algorithm for betweenness centrality.
[ "Brandes", "algorithm", "for", "betweenness", "centrality", "." ]
[ "\"\"\"\n Brandes algorithm for betweenness centrality.\n \n Betweenness centrality is an indicator of a node's centrality in a network.\n It is equal to the number of shortest paths from all vertices to all others\n that pass through that node. A node with high betweenness centrality has a\n larg...
[ { "param": "graph", "type": null }, { "param": "nodes", "type": null }, { "param": "normalized", "type": null }, { "param": "weight", "type": null }, { "param": "endpoints", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:dict" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph to calculate Brandes betweenness centrality", "docstring_tokens": [...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
eigenvector_centrality
<not_specific>
def eigenvector_centrality(graph, normalized=True, reverse=True, rating=None, start=None, iterations=100, tolerance=0.0001): """ Eigenvector centrality for nodes in the graph (like Google's PageRank). Eigenvector centrality is a measure of the importance of a node in a direct...
Eigenvector centrality for nodes in the graph (like Google's PageRank). Eigenvector centrality is a measure of the importance of a node in a directed network. It rewards nodes with a high potential of (indirectly) connecting to high-scoring nodes. Nodes with no incoming connections have a score of...
Eigenvector centrality for nodes in the graph (like Google's PageRank). Eigenvector centrality is a measure of the importance of a node in a directed network. It rewards nodes with a high potential of (indirectly) connecting to high-scoring nodes. Nodes with no incoming connections have a score of zero. If you want to ...
[ "Eigenvector", "centrality", "for", "nodes", "in", "the", "graph", "(", "like", "Google", "'", "s", "PageRank", ")", ".", "Eigenvector", "centrality", "is", "a", "measure", "of", "the", "importance", "of", "a", "node", "in", "a", "directed", "network", "."...
def eigenvector_centrality(graph, normalized=True, reverse=True, rating=None, start=None, iterations=100, tolerance=0.0001): if rating is None: rating = {} G = graph.nodes.keys() W = adjacency(graph, directed=True, reverse=reverse) def _normalize(x): s = sum(x....
[ "def", "eigenvector_centrality", "(", "graph", ",", "normalized", "=", "True", ",", "reverse", "=", "True", ",", "rating", "=", "None", ",", "start", "=", "None", ",", "iterations", "=", "100", ",", "tolerance", "=", "0.0001", ")", ":", "if", "rating", ...
Eigenvector centrality for nodes in the graph (like Google's PageRank).
[ "Eigenvector", "centrality", "for", "nodes", "in", "the", "graph", "(", "like", "Google", "'", "s", "PageRank", ")", "." ]
[ "\"\"\"\n Eigenvector centrality for nodes in the graph (like Google's PageRank).\n \n Eigenvector centrality is a measure of the importance of a node in a directed network.\n It rewards nodes with a high potential of (indirectly) connecting to high-scoring nodes.\n Nodes with no incoming connections...
[ { "param": "graph", "type": null }, { "param": "normalized", "type": null }, { "param": "reverse", "type": null }, { "param": "rating", "type": null }, { "param": "start", "type": null }, { "param": "iterations", "type": null }, { "param": ...
{ "returns": [], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "normalized", "type": null, "docstring": null, "docstring_tok...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
is_reachable
<not_specific>
def is_reachable(graph, root, destination): """ Returns True if given node can be reached over traversable edges. :param graph: Graph to query :type graph: Graph class instance :param root: source node ID :type root: int :param destination: destintion node ID :type destination: int ...
Returns True if given node can be reached over traversable edges. :param graph: Graph to query :type graph: Graph class instance :param root: source node ID :type root: int :param destination: destintion node ID :type destination: int :return: bool
Returns True if given node can be reached over traversable edges.
[ "Returns", "True", "if", "given", "node", "can", "be", "reached", "over", "traversable", "edges", "." ]
def is_reachable(graph, root, destination): if root in graph.nodes and destination in graph.nodes: connected_path = dfs(graph, root) return destination in connected_path else: logger.error('Root or destination nodes not in graph')
[ "def", "is_reachable", "(", "graph", ",", "root", ",", "destination", ")", ":", "if", "root", "in", "graph", ".", "nodes", "and", "destination", "in", "graph", ".", "nodes", ":", "connected_path", "=", "dfs", "(", "graph", ",", "root", ")", "return", "...
Returns True if given node can be reached over traversable edges.
[ "Returns", "True", "if", "given", "node", "can", "be", "reached", "over", "traversable", "edges", "." ]
[ "\"\"\"\n Returns True if given node can be reached over traversable edges.\n \n :param graph: Graph to query\n :type graph: Graph class instance\n :param root: source node ID\n :type root: int\n :param destination: destintion node ID\n :type destination: int\n :return: bool\n \"\"\"" ...
[ { "param": "graph", "type": null }, { "param": "root", "type": null }, { "param": "destination", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph to query", "docstring_tokens": [ "Graph", "to", "...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
degree
<not_specific>
def degree(graph, nodes=None, weight=None): """ Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice. The method supports weighted degrees in which the connected nodes are multiplied by a weig...
Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice. The method supports weighted degrees in which the connected nodes are multiplied by a weight factor stored as attribute in the edges. ...
Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice. The method supports weighted degrees in which the connected nodes are multiplied by a weight factor stored as attribute in the edges.
[ "Return", "the", "degree", "of", "nodes", "in", "the", "graph", "The", "degree", "(", "or", "valency", ")", "of", "a", "graph", "node", "are", "the", "number", "of", "edges", "connected", "to", "the", "node", "with", "loops", "counted", "twice", ".", "...
def degree(graph, nodes=None, weight=None): if nodes is None: nodes = graph.nodes else: not_in_graph = [nid for nid in nodes if nid not in graph.nodes] if not_in_graph: logger.error('Nodes {0} not in graph'.format(not_in_graph)) results = {} if weight: for nod...
[ "def", "degree", "(", "graph", ",", "nodes", "=", "None", ",", "weight", "=", "None", ")", ":", "if", "nodes", "is", "None", ":", "nodes", "=", "graph", ".", "nodes", "else", ":", "not_in_graph", "=", "[", "nid", "for", "nid", "in", "nodes", "if", ...
Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice.
[ "Return", "the", "degree", "of", "nodes", "in", "the", "graph", "The", "degree", "(", "or", "valency", ")", "of", "a", "graph", "node", "are", "the", "number", "of", "edges", "connected", "to", "the", "node", "with", "loops", "counted", "twice", "." ]
[ "\"\"\"\n Return the degree of nodes in the graph\n \n The degree (or valency) of a graph node are the number of edges\n connected to the node, with loops counted twice.\n The method supports weighted degrees in which the connected\n nodes are multiplied by a weight factor stored as attribute in\n...
[ { "param": "graph", "type": null }, { "param": "nodes", "type": null }, { "param": "weight", "type": null } ]
{ "returns": [ { "docstring": "degree of each node", "docstring_tokens": [ "degree", "of", "each", "node" ], "type": "list of tuples (node, degree)" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstr...
55f0bf986b0007f8938984c34082772d2703aac4
codacy-badger/graphit
graphit/graph_algorithms.py
[ "Apache-2.0" ]
Python
size
<not_specific>
def size(graph, weight=None, is_directed=None): """ The graph `size` equals the total number of edges it contains :param graph: graph to calculate size for :type graph: :graphit:Graph :param weight: edge attribute name containing a weight value :type weight: :py:str :return: ...
The graph `size` equals the total number of edges it contains :param graph: graph to calculate size for :type graph: :graphit:Graph :param weight: edge attribute name containing a weight value :type weight: :py:str :return: graph size :rtype: :py:int, :py:float
The graph `size` equals the total number of edges it contains
[ "The", "graph", "`", "size", "`", "equals", "the", "total", "number", "of", "edges", "it", "contains" ]
def size(graph, weight=None, is_directed=None): if is_directed is None: is_directed = graph.is_directed() graph_degree = degree(graph, weight=weight) graph_size = sum(graph_degree.values()) if is_directed: return graph_size return graph_size // 2 if weight is None else graph_size / 2
[ "def", "size", "(", "graph", ",", "weight", "=", "None", ",", "is_directed", "=", "None", ")", ":", "if", "is_directed", "is", "None", ":", "is_directed", "=", "graph", ".", "is_directed", "(", ")", "graph_degree", "=", "degree", "(", "graph", ",", "we...
The graph `size` equals the total number of edges it contains
[ "The", "graph", "`", "size", "`", "equals", "the", "total", "number", "of", "edges", "it", "contains" ]
[ "\"\"\"\n The graph `size` equals the total number of edges it contains\n\n :param graph: graph to calculate size for\n :type graph: :graphit:Graph\n :param weight: edge attribute name containing a weight value\n :type weight: :py:str\n\n :return: graph size\n :rtype: :py...
[ { "param": "graph", "type": null }, { "param": "weight", "type": null }, { "param": "is_directed", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:int, :py:float" } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "graph to calculate size for", "docstring_tokens": [ "gr...
b1be7c022d7865eb602f7c9fd4fa40fce08cd958
codacy-badger/graphit
tests/module/unittest_baseclass.py
[ "Apache-2.0" ]
Python
assertViewEqual
<not_specific>
def assertViewEqual(self, expected_seq, actual_seq, msg=None): """ Test equality in items even if they are 'view' based """ return all([t in expected_seq for t in actual_seq]) and all([t in actual_seq for t in expected_seq])
Test equality in items even if they are 'view' based
Test equality in items even if they are 'view' based
[ "Test", "equality", "in", "items", "even", "if", "they", "are", "'", "view", "'", "based" ]
def assertViewEqual(self, expected_seq, actual_seq, msg=None): return all([t in expected_seq for t in actual_seq]) and all([t in actual_seq for t in expected_seq])
[ "def", "assertViewEqual", "(", "self", ",", "expected_seq", ",", "actual_seq", ",", "msg", "=", "None", ")", ":", "return", "all", "(", "[", "t", "in", "expected_seq", "for", "t", "in", "actual_seq", "]", ")", "and", "all", "(", "[", "t", "in", "actu...
Test equality in items even if they are 'view' based
[ "Test", "equality", "in", "items", "even", "if", "they", "are", "'", "view", "'", "based" ]
[ "\"\"\"\n Test equality in items even if they are 'view' based\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "expected_seq", "type": null }, { "param": "actual_seq", "type": null }, { "param": "msg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expected_seq", "type": null, "docstring": null, "docstring_to...
178552dd70c7a8e4f3b66b88c33b55a4fbb3bd04
codacy-badger/graphit
graphit/graph_storage_drivers/graph_storage_views.py
[ "Apache-2.0" ]
Python
_build_adjacency
<not_specific>
def _build_adjacency(self, nodes): """ Build the adjacency dictionary for each call to the AdjacencyView instance for all nodes or a selection. :param nodes: Nodes to determine adjacency for :type nodes: :py:list :return: adjacency :rtype: :p...
Build the adjacency dictionary for each call to the AdjacencyView instance for all nodes or a selection. :param nodes: Nodes to determine adjacency for :type nodes: :py:list :return: adjacency :rtype: :py:dict
Build the adjacency dictionary for each call to the AdjacencyView instance for all nodes or a selection.
[ "Build", "the", "adjacency", "dictionary", "for", "each", "call", "to", "the", "AdjacencyView", "instance", "for", "all", "nodes", "or", "a", "selection", "." ]
def _build_adjacency(self, nodes): adj = dict([(node, []) for node in nodes]) for edge in self.edges: if edge[0] in adj: adj[edge[0]].append(edge[1]) return adj
[ "def", "_build_adjacency", "(", "self", ",", "nodes", ")", ":", "adj", "=", "dict", "(", "[", "(", "node", ",", "[", "]", ")", "for", "node", "in", "nodes", "]", ")", "for", "edge", "in", "self", ".", "edges", ":", "if", "edge", "[", "0", "]", ...
Build the adjacency dictionary for each call to the AdjacencyView instance for all nodes or a selection.
[ "Build", "the", "adjacency", "dictionary", "for", "each", "call", "to", "the", "AdjacencyView", "instance", "for", "all", "nodes", "or", "a", "selection", "." ]
[ "\"\"\"\n Build the adjacency dictionary for each call to the AdjacencyView\n instance for all nodes or a selection.\n\n :param nodes: Nodes to determine adjacency for\n :type nodes: :py:list\n\n :return: adjacency\n :rtype: :py:dict\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "nodes", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:dict" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
178552dd70c7a8e4f3b66b88c33b55a4fbb3bd04
codacy-badger/graphit
graphit/graph_storage_drivers/graph_storage_views.py
[ "Apache-2.0" ]
Python
degree
<not_specific>
def degree(self, nodes): """ Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice. For weighted degree pleae use the dedicated 'graphit.graph_algorithms.degree' function. ...
Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice. For weighted degree pleae use the dedicated 'graphit.graph_algorithms.degree' function. :param nodes: Nodes to retur...
Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice.
[ "Return", "the", "degree", "of", "nodes", "in", "the", "graph", "The", "degree", "(", "or", "valency", ")", "of", "a", "graph", "node", "are", "the", "number", "of", "edges", "connected", "to", "the", "node", "with", "loops", "counted", "twice", "." ]
def degree(self, nodes): adj = self._build_adjacency(nodes) degree = {} for node in adj: degree[node] = len(adj[node]) if node in adj[node]: degree[node] += 1 return degree
[ "def", "degree", "(", "self", ",", "nodes", ")", ":", "adj", "=", "self", ".", "_build_adjacency", "(", "nodes", ")", "degree", "=", "{", "}", "for", "node", "in", "adj", ":", "degree", "[", "node", "]", "=", "len", "(", "adj", "[", "node", "]", ...
Return the degree of nodes in the graph The degree (or valency) of a graph node are the number of edges connected to the node, with loops counted twice.
[ "Return", "the", "degree", "of", "nodes", "in", "the", "graph", "The", "degree", "(", "or", "valency", ")", "of", "a", "graph", "node", "are", "the", "number", "of", "edges", "connected", "to", "the", "node", "with", "loops", "counted", "twice", "." ]
[ "\"\"\"\n Return the degree of nodes in the graph\n\n The degree (or valency) of a graph node are the number of edges\n connected to the node, with loops counted twice.\n For weighted degree pleae use the dedicated\n 'graphit.graph_algorithms.degree' function.\n\n :param no...
[ { "param": "self", "type": null }, { "param": "nodes", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:dict" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": n...
936fa776ec114818de9d158795c4d237cf95a163
codacy-badger/graphit
tests/module/module_storage_driver_test.py
[ "Apache-2.0" ]
Python
assertDictEqual
<not_specific>
def assertDictEqual(self, expected_seq, actual_seq, msg=None): """ Convert actual_seq to dictionary The actual_seq is a DataFrame or Series in a ArrayStore. Although they behave as dictionaries they will not pass the isinstance == dict test of the default assertDictEqual. ...
Convert actual_seq to dictionary The actual_seq is a DataFrame or Series in a ArrayStore. Although they behave as dictionaries they will not pass the isinstance == dict test of the default assertDictEqual. Convert actual_seq to dictionary explicitly by calling its 'to_dict' ...
Convert actual_seq to dictionary The actual_seq is a DataFrame or Series in a ArrayStore. Although they behave as dictionaries they will not pass the isinstance == dict test of the default assertDictEqual. Convert actual_seq to dictionary explicitly by calling its 'to_dict' method then passing it to assertDictEqual.
[ "Convert", "actual_seq", "to", "dictionary", "The", "actual_seq", "is", "a", "DataFrame", "or", "Series", "in", "a", "ArrayStore", ".", "Although", "they", "behave", "as", "dictionaries", "they", "will", "not", "pass", "the", "isinstance", "==", "dict", "test"...
def assertDictEqual(self, expected_seq, actual_seq, msg=None): if not isinstance(actual_seq, dict): actual_seq = actual_seq.to_dict() return super(UnittestPythonCompatibility, self).assertDictEqual(expected_seq, actual_seq)
[ "def", "assertDictEqual", "(", "self", ",", "expected_seq", ",", "actual_seq", ",", "msg", "=", "None", ")", ":", "if", "not", "isinstance", "(", "actual_seq", ",", "dict", ")", ":", "actual_seq", "=", "actual_seq", ".", "to_dict", "(", ")", "return", "s...
Convert actual_seq to dictionary The actual_seq is a DataFrame or Series in a ArrayStore.
[ "Convert", "actual_seq", "to", "dictionary", "The", "actual_seq", "is", "a", "DataFrame", "or", "Series", "in", "a", "ArrayStore", "." ]
[ "\"\"\"\n Convert actual_seq to dictionary\n\n The actual_seq is a DataFrame or Series in a ArrayStore. Although they\n behave as dictionaries they will not pass the isinstance == dict test\n of the default assertDictEqual.\n\n Convert actual_seq to dictionary explicitly by callin...
[ { "param": "self", "type": null }, { "param": "expected_seq", "type": null }, { "param": "actual_seq", "type": null }, { "param": "msg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expected_seq", "type": null, "docstring": null, "docstring_to...
936fa776ec114818de9d158795c4d237cf95a163
codacy-badger/graphit
tests/module/module_storage_driver_test.py
[ "Apache-2.0" ]
Python
assertViewEqual
<not_specific>
def assertViewEqual(self, expected_seq, actual_seq, msg=None): """ Test equality in items even if they are 'view' based """ new = [] for item in actual_seq: if isinstance(item, tuple): if hasattr(item[1], 'to_dict'): new.append((it...
Test equality in items even if they are 'view' based
Test equality in items even if they are 'view' based
[ "Test", "equality", "in", "items", "even", "if", "they", "are", "'", "view", "'", "based" ]
def assertViewEqual(self, expected_seq, actual_seq, msg=None): new = [] for item in actual_seq: if isinstance(item, tuple): if hasattr(item[1], 'to_dict'): new.append((item[0], item[1].to_dict())) else: new.append(item) ...
[ "def", "assertViewEqual", "(", "self", ",", "expected_seq", ",", "actual_seq", ",", "msg", "=", "None", ")", ":", "new", "=", "[", "]", "for", "item", "in", "actual_seq", ":", "if", "isinstance", "(", "item", ",", "tuple", ")", ":", "if", "hasattr", ...
Test equality in items even if they are 'view' based
[ "Test", "equality", "in", "items", "even", "if", "they", "are", "'", "view", "'", "based" ]
[ "\"\"\"\n Test equality in items even if they are 'view' based\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "expected_seq", "type": null }, { "param": "actual_seq", "type": null }, { "param": "msg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expected_seq", "type": null, "docstring": null, "docstring_to...
9075d29a41bc20b2795bdd879c62e7479750f547
codacy-badger/graphit
graphit/graph_io/io_pgf_format.py
[ "Apache-2.0" ]
Python
write_graph
null
def write_graph(graph, path=os.path.join(os.getcwd(), 'graph.gpf')): """ Export graph as Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary. The format is feature rich wth good performance but is not portable. :p...
Export graph as Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary. The format is feature rich wth good performance but is not portable. :param graph: Graph object to export :type graph: Graph ins...
Export graph as Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary. The format is feature rich wth good performance but is not portable.
[ "Export", "graph", "as", "Graph", "Python", "Format", "file", "GPF", "format", "is", "the", "modules", "own", "file", "format", "consisting", "out", "of", "a", "serialized", "nodes", "and", "edges", "dictionary", ".", "The", "format", "is", "feature", "rich"...
def write_graph(graph, path=os.path.join(os.getcwd(), 'graph.gpf')): pp = pprint.PrettyPrinter(indent=2) with open(path, 'w') as output: output.write('nodes = {0}\n'.format(pp.pformat(graph.nodes.dict()))) output.write('edges = {0}\n'.format(pp.pformat(graph.edges.dict()))) logger.info('Grap...
[ "def", "write_graph", "(", "graph", ",", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "'graph.gpf'", ")", ")", ":", "pp", "=", "pprint", ".", "PrettyPrinter", "(", "indent", "=", "2", ")", "with", "open", ...
Export graph as Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary.
[ "Export", "graph", "as", "Graph", "Python", "Format", "file", "GPF", "format", "is", "the", "modules", "own", "file", "format", "consisting", "out", "of", "a", "serialized", "nodes", "and", "edges", "dictionary", "." ]
[ "\"\"\"\n Export graph as Graph Python Format file\n \n GPF format is the modules own file format consisting out of a serialized\n nodes and edges dictionary.\n The format is feature rich wth good performance but is not portable.\n \n :param graph: Graph object to export\n :type graph...
[ { "param": "graph", "type": null }, { "param": "path", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": "Graph object to export", "docstring_tokens": [ "Graph", "object...
9075d29a41bc20b2795bdd879c62e7479750f547
codacy-badger/graphit
graphit/graph_io/io_pgf_format.py
[ "Apache-2.0" ]
Python
read_graph
<not_specific>
def read_graph(graph_file, graph=None): """ Import graph from Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary. The format is feature rich wth good performance but is not portable. :param graph_file: File pa...
Import graph from Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary. The format is feature rich wth good performance but is not portable. :param graph_file: File path to read from :type graph_file: :py:s...
Import graph from Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary. The format is feature rich wth good performance but is not portable.
[ "Import", "graph", "from", "Graph", "Python", "Format", "file", "GPF", "format", "is", "the", "modules", "own", "file", "format", "consisting", "out", "of", "a", "serialized", "nodes", "and", "edges", "dictionary", ".", "The", "format", "is", "feature", "ric...
def read_graph(graph_file, graph=None): if not graph: graph = Graph() with open(graph_file) as f: code = compile(f.read(), "GPF_file", 'exec') exec(code) return graph
[ "def", "read_graph", "(", "graph_file", ",", "graph", "=", "None", ")", ":", "if", "not", "graph", ":", "graph", "=", "Graph", "(", ")", "with", "open", "(", "graph_file", ")", "as", "f", ":", "code", "=", "compile", "(", "f", ".", "read", "(", "...
Import graph from Graph Python Format file GPF format is the modules own file format consisting out of a serialized nodes and edges dictionary.
[ "Import", "graph", "from", "Graph", "Python", "Format", "file", "GPF", "format", "is", "the", "modules", "own", "file", "format", "consisting", "out", "of", "a", "serialized", "nodes", "and", "edges", "dictionary", "." ]
[ "\"\"\"\n Import graph from Graph Python Format file\n \n GPF format is the modules own file format consisting out of a serialized\n nodes and edges dictionary.\n The format is feature rich wth good performance but is not portable.\n \n :param graph_file: File path to read from\n :type gr...
[ { "param": "graph_file", "type": null }, { "param": "graph", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "graph_file", "type": null, "docstring": "File path to read from", "docstring_tokens": [ "File", "pa...
ffeef748fba7de62ffd1970cc6b0d0724487be3a
codacy-badger/graphit
graphit/graph_io/io_helpers.py
[ "Apache-2.0" ]
Python
check_graphit_version
<not_specific>
def check_graphit_version(version=None): """ Check if the graph version of the file is (backwards) compatible with the current graphit module version """ try: version = float(version) except TypeError: logger.error('No valid graphit version identifier {0}'.format(version)) ...
Check if the graph version of the file is (backwards) compatible with the current graphit module version
Check if the graph version of the file is (backwards) compatible with the current graphit module version
[ "Check", "if", "the", "graph", "version", "of", "the", "file", "is", "(", "backwards", ")", "compatible", "with", "the", "current", "graphit", "module", "version" ]
def check_graphit_version(version=None): try: version = float(version) except TypeError: logger.error('No valid graphit version identifier {0}'.format(version)) return False if version > float(__version__): logger.error('Graph made with a newer version of graphit {0}, you hav...
[ "def", "check_graphit_version", "(", "version", "=", "None", ")", ":", "try", ":", "version", "=", "float", "(", "version", ")", "except", "TypeError", ":", "logger", ".", "error", "(", "'No valid graphit version identifier {0}'", ".", "format", "(", "version", ...
Check if the graph version of the file is (backwards) compatible with the current graphit module version
[ "Check", "if", "the", "graph", "version", "of", "the", "file", "is", "(", "backwards", ")", "compatible", "with", "the", "current", "graphit", "module", "version" ]
[ "\"\"\"\n Check if the graph version of the file is (backwards) compatible with\n the current graphit module version\n \"\"\"" ]
[ { "param": "version", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "version", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ffeef748fba7de62ffd1970cc6b0d0724487be3a
codacy-badger/graphit
graphit/graph_io/io_helpers.py
[ "Apache-2.0" ]
Python
flatten_nested_dict
<not_specific>
def flatten_nested_dict(config, parent_key='', sep='.'): """ Flatten a nested dictionary by concatenating all nested keys. Keys are converted to a string representation if needed. :param config: dictionary to flatten :type config: :py:dict :param parent_key: leading string ...
Flatten a nested dictionary by concatenating all nested keys. Keys are converted to a string representation if needed. :param config: dictionary to flatten :type config: :py:dict :param parent_key: leading string in concatenated keys :type parent_key: :py:str :param s...
Flatten a nested dictionary by concatenating all nested keys. Keys are converted to a string representation if needed.
[ "Flatten", "a", "nested", "dictionary", "by", "concatenating", "all", "nested", "keys", ".", "Keys", "are", "converted", "to", "a", "string", "representation", "if", "needed", "." ]
def flatten_nested_dict(config, parent_key='', sep='.'): items = [] for key, value in config.items(): new_key = to_unicode('{0}{1}{2}'.format(parent_key, sep, key) if parent_key else key) if isinstance(value, collections.MutableMapping): items.extend(flatten_nested_dict(value, new_ke...
[ "def", "flatten_nested_dict", "(", "config", ",", "parent_key", "=", "''", ",", "sep", "=", "'.'", ")", ":", "items", "=", "[", "]", "for", "key", ",", "value", "in", "config", ".", "items", "(", ")", ":", "new_key", "=", "to_unicode", "(", "'{0}{1}{...
Flatten a nested dictionary by concatenating all nested keys.
[ "Flatten", "a", "nested", "dictionary", "by", "concatenating", "all", "nested", "keys", "." ]
[ "\"\"\"\n Flatten a nested dictionary by concatenating all\n nested keys.\n Keys are converted to a string representation if\n needed.\n \n :param config: dictionary to flatten\n :type config: :py:dict\n :param parent_key: leading string in concatenated keys\n :type parent_key: ...
[ { "param": "config", "type": null }, { "param": "parent_key", "type": null }, { "param": "sep", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": ":py:dict" } ], "raises": [], "params": [ { "identifier": "config", "type": null, "docstring": "dictionary to flatten", "docstring_tokens": [ "dictionary", ...
ffeef748fba7de62ffd1970cc6b0d0724487be3a
codacy-badger/graphit
graphit/graph_io/io_helpers.py
[ "Apache-2.0" ]
Python
nest_flattened_dict
<not_specific>
def nest_flattened_dict(graph_dict, sep='.'): """ Convert a dictionary that has been flattened by the `_flatten_nested_dict` method to a nested representation :param graph_dict: dictionary to nest :type graph_dict: dict :param sep: concatenation seperator :type sep: str ...
Convert a dictionary that has been flattened by the `_flatten_nested_dict` method to a nested representation :param graph_dict: dictionary to nest :type graph_dict: dict :param sep: concatenation seperator :type sep: str :return: nested dictionary :rt...
Convert a dictionary that has been flattened by the `_flatten_nested_dict` method to a nested representation
[ "Convert", "a", "dictionary", "that", "has", "been", "flattened", "by", "the", "`", "_flatten_nested_dict", "`", "method", "to", "a", "nested", "representation" ]
def nest_flattened_dict(graph_dict, sep='.'): nested_dict = {} for key, value in sorted(graph_dict.items()): splitted = key.split(sep) if len(splitted) == 1: nested_dict[key] = value d = nested_dict for k in splitted[:-1]: if k not in d: d[...
[ "def", "nest_flattened_dict", "(", "graph_dict", ",", "sep", "=", "'.'", ")", ":", "nested_dict", "=", "{", "}", "for", "key", ",", "value", "in", "sorted", "(", "graph_dict", ".", "items", "(", ")", ")", ":", "splitted", "=", "key", ".", "split", "(...
Convert a dictionary that has been flattened by the `_flatten_nested_dict` method to a nested representation
[ "Convert", "a", "dictionary", "that", "has", "been", "flattened", "by", "the", "`", "_flatten_nested_dict", "`", "method", "to", "a", "nested", "representation" ]
[ "\"\"\"\n Convert a dictionary that has been flattened by the\n `_flatten_nested_dict` method to a nested representation\n \n :param graph_dict: dictionary to nest\n :type graph_dict: dict\n :param sep: concatenation seperator\n :type sep: str\n \n :return: neste...
[ { "param": "graph_dict", "type": null }, { "param": "sep", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "dict" } ], "raises": [], "params": [ { "identifier": "graph_dict", "type": null, "docstring": "dictionary to nest", "docstring_tokens": [ "dictionary", ...
151196b25e898be2c789ee1a4cd97145f05b0ad3
codacy-badger/graphit
graphit/graph_helpers.py
[ "Apache-2.0" ]
Python
edges_between_nodes
<not_specific>
def edges_between_nodes(graph, nodes): """ Return all edges in graph that connect the nodes :param graph: :param nodes: :return: """ edge_selection = [] for edge in graph.edges: if edge[0] in nodes and edge[1] in nodes: edge_selection.append(edge) return edge_s...
Return all edges in graph that connect the nodes :param graph: :param nodes: :return:
Return all edges in graph that connect the nodes
[ "Return", "all", "edges", "in", "graph", "that", "connect", "the", "nodes" ]
def edges_between_nodes(graph, nodes): edge_selection = [] for edge in graph.edges: if edge[0] in nodes and edge[1] in nodes: edge_selection.append(edge) return edge_selection
[ "def", "edges_between_nodes", "(", "graph", ",", "nodes", ")", ":", "edge_selection", "=", "[", "]", "for", "edge", "in", "graph", ".", "edges", ":", "if", "edge", "[", "0", "]", "in", "nodes", "and", "edge", "[", "1", "]", "in", "nodes", ":", "edg...
Return all edges in graph that connect the nodes
[ "Return", "all", "edges", "in", "graph", "that", "connect", "the", "nodes" ]
[ "\"\"\"\n Return all edges in graph that connect the nodes\n\n :param graph:\n :param nodes:\n :return:\n \"\"\"" ]
[ { "param": "graph", "type": null }, { "param": "nodes", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "graph", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, ...
151196b25e898be2c789ee1a4cd97145f05b0ad3
codacy-badger/graphit
graphit/graph_helpers.py
[ "Apache-2.0" ]
Python
renumber_id
<not_specific>
def renumber_id(graph, start): """ Renumber all node ID's in the graph from a new start ID and adjust edges accordingly. Useful when duplicating a graph substructure. If the graph uses auto_nid, the node nid is also changed. #TODO: this one failes if run on a subgraph. Probably need to make cha...
Renumber all node ID's in the graph from a new start ID and adjust edges accordingly. Useful when duplicating a graph substructure. If the graph uses auto_nid, the node nid is also changed. #TODO: this one failes if run on a subgraph. Probably need to make changes #to nids in place instead of ...
Renumber all node ID's in the graph from a new start ID and adjust edges accordingly. Useful when duplicating a graph substructure. If the graph uses auto_nid, the node nid is also changed. this one failes if run on a subgraph. Probably need to make changes to nids in place instead of registering new storage
[ "Renumber", "all", "node", "ID", "'", "s", "in", "the", "graph", "from", "a", "new", "start", "ID", "and", "adjust", "edges", "accordingly", ".", "Useful", "when", "duplicating", "a", "graph", "substructure", ".", "If", "the", "graph", "uses", "auto_nid", ...
def renumber_id(graph, start): start = copy.copy(start) mapper = {} for nid, value in sorted(graph.nodes.items()): mapper[value['_id']] = start value['_id'] = start start += 1 graph._nodeid = start if graph.root: graph.root = mapper[graph.root] newnodes = {} i...
[ "def", "renumber_id", "(", "graph", ",", "start", ")", ":", "start", "=", "copy", ".", "copy", "(", "start", ")", "mapper", "=", "{", "}", "for", "nid", ",", "value", "in", "sorted", "(", "graph", ".", "nodes", ".", "items", "(", ")", ")", ":", ...
Renumber all node ID's in the graph from a new start ID and adjust edges accordingly.
[ "Renumber", "all", "node", "ID", "'", "s", "in", "the", "graph", "from", "a", "new", "start", "ID", "and", "adjust", "edges", "accordingly", "." ]
[ "\"\"\"\n Renumber all node ID's in the graph from a new start ID and adjust edges\n accordingly. Useful when duplicating a graph substructure.\n If the graph uses auto_nid, the node nid is also changed.\n \n #TODO: this one failes if run on a subgraph. Probably need to make changes\n #to nids in ...
[ { "param": "graph", "type": null }, { "param": "start", "type": null } ]
{ "returns": [ { "docstring": "Renumber graph and mapping of old to new ID", "docstring_tokens": [ "Renumber", "graph", "and", "mapping", "of", "old", "to", "new", "ID" ], "type": "Graph object, :py:dict" } ], ...
9319d023764d92dd832f0a5ae1be7fd682f29308
codacy-badger/graphit
graphit/__init__.py
[ "Apache-2.0" ]
Python
check_graphbase_instance
<not_specific>
def check_graphbase_instance(*args): """ Validate if all objects in `args` are instances of the GraphBase class :param args: Arguments to check :return: True if validation successful :rtype: :py:bool :raises: AttributeError if validation fails """ # Validate arguments, sh...
Validate if all objects in `args` are instances of the GraphBase class :param args: Arguments to check :return: True if validation successful :rtype: :py:bool :raises: AttributeError if validation fails
Validate if all objects in `args` are instances of the GraphBase class
[ "Validate", "if", "all", "objects", "in", "`", "args", "`", "are", "instances", "of", "the", "GraphBase", "class" ]
def check_graphbase_instance(*args): if not all([isinstance(graph, Graph) for graph in args]): raise AttributeError('All arguments need be of type Graph') return True
[ "def", "check_graphbase_instance", "(", "*", "args", ")", ":", "if", "not", "all", "(", "[", "isinstance", "(", "graph", ",", "Graph", ")", "for", "graph", "in", "args", "]", ")", ":", "raise", "AttributeError", "(", "'All arguments need be of type Graph'", ...
Validate if all objects in `args` are instances of the GraphBase class
[ "Validate", "if", "all", "objects", "in", "`", "args", "`", "are", "instances", "of", "the", "GraphBase", "class" ]
[ "\"\"\"\n Validate if all objects in `args` are instances of the GraphBase class\n\n :param args: Arguments to check\n\n :return: True if validation successful\n :rtype: :py:bool\n :raises: AttributeError if validation fails\n \"\"\"", "# Validate arguments, should be Graph instance...
[]
{ "returns": [ { "docstring": "True if validation successful", "docstring_tokens": [ "True", "if", "validation", "successful" ], "type": ":py:bool" } ], "raises": [ { "docstring": "AttributeError if validation fails", "docstring_token...
9319d023764d92dd832f0a5ae1be7fd682f29308
codacy-badger/graphit
graphit/__init__.py
[ "Apache-2.0" ]
Python
check_graphaxis_instance
<not_specific>
def check_graphaxis_instance(*args): """ Validate if all objects in `args` are instances of the GraphAxis class :param args: Arguments to check :return: True if validation successful :rtype: :py:bool :raises: AttributeError if validation fails """ # Validate arguments, sh...
Validate if all objects in `args` are instances of the GraphAxis class :param args: Arguments to check :return: True if validation successful :rtype: :py:bool :raises: AttributeError if validation fails
Validate if all objects in `args` are instances of the GraphAxis class
[ "Validate", "if", "all", "objects", "in", "`", "args", "`", "are", "instances", "of", "the", "GraphAxis", "class" ]
def check_graphaxis_instance(*args): if not all([isinstance(graph, GraphAxis) for graph in args]): raise AttributeError('All arguments need be of type Graph') return True
[ "def", "check_graphaxis_instance", "(", "*", "args", ")", ":", "if", "not", "all", "(", "[", "isinstance", "(", "graph", ",", "GraphAxis", ")", "for", "graph", "in", "args", "]", ")", ":", "raise", "AttributeError", "(", "'All arguments need be of type Graph'"...
Validate if all objects in `args` are instances of the GraphAxis class
[ "Validate", "if", "all", "objects", "in", "`", "args", "`", "are", "instances", "of", "the", "GraphAxis", "class" ]
[ "\"\"\"\n Validate if all objects in `args` are instances of the GraphAxis class\n\n :param args: Arguments to check\n\n :return: True if validation successful\n :rtype: :py:bool\n :raises: AttributeError if validation fails\n \"\"\"", "# Validate arguments, should be GraphAxis inst...
[]
{ "returns": [ { "docstring": "True if validation successful", "docstring_tokens": [ "True", "if", "validation", "successful" ], "type": ":py:bool" } ], "raises": [ { "docstring": "AttributeError if validation fails", "docstring_token...