repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/datautil/snow_datautil/snow_read_data.py
read_node_label_matrix
def read_node_label_matrix(file_path, separator, numbering="matlab"): """ Reads node-label pairs in csv format and returns a list of tuples and a node-label matrix. Inputs: - file_path: The path where the node-label matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ...
python
def read_node_label_matrix(file_path, separator, numbering="matlab"): """ Reads node-label pairs in csv format and returns a list of tuples and a node-label matrix. Inputs: - file_path: The path where the node-label matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ...
[ "def", "read_node_label_matrix", "(", "file_path", ",", "separator", ",", "numbering", "=", "\"matlab\"", ")", ":", "# Open file", "file_row_generator", "=", "get_file_row_generator", "(", "file_path", ",", "separator", ")", "file_row", "=", "next", "(", "file_row_g...
Reads node-label pairs in csv format and returns a list of tuples and a node-label matrix. Inputs: - file_path: The path where the node-label matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ") - number_of_nodes: The number of nodes of the full graph. It is po...
[ "Reads", "node", "-", "label", "pairs", "in", "csv", "format", "and", "returns", "a", "list", "of", "tuples", "and", "a", "node", "-", "label", "matrix", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/datautil/snow_datautil/snow_read_data.py#L81-L137
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/datautil/snow_datautil/snow_read_data.py
write_screen_name_to_topics
def write_screen_name_to_topics(filepath, user_label_matrix, node_to_id, id_to_name, label_to_lemma, lemma_to_keyword, separator=","): """ Writes a user name and associated topic names per row. """ user_label_matrix = spsp.coo_matrix(user_label_matrix) shape = user_label_matrix.shape nnz = user...
python
def write_screen_name_to_topics(filepath, user_label_matrix, node_to_id, id_to_name, label_to_lemma, lemma_to_keyword, separator=","): """ Writes a user name and associated topic names per row. """ user_label_matrix = spsp.coo_matrix(user_label_matrix) shape = user_label_matrix.shape nnz = user...
[ "def", "write_screen_name_to_topics", "(", "filepath", ",", "user_label_matrix", ",", "node_to_id", ",", "id_to_name", ",", "label_to_lemma", ",", "lemma_to_keyword", ",", "separator", "=", "\",\"", ")", ":", "user_label_matrix", "=", "spsp", ".", "coo_matrix", "(",...
Writes a user name and associated topic names per row.
[ "Writes", "a", "user", "name", "and", "associated", "topic", "names", "per", "row", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/datautil/snow_datautil/snow_read_data.py#L178-L216
MultipedRobotics/pyxl320
bin/servo_ping.py
packetToDict
def packetToDict(pkt): """ Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) """ d = { 'id': pkt[4], # 'instruction': xl320.InstrToStr[pkt[7]], # 'length': (pkt[6] << 8) + pkt[5], # 'params': pkt[8:-2], 'Model Number': (pkt[10...
python
def packetToDict(pkt): """ Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) """ d = { 'id': pkt[4], # 'instruction': xl320.InstrToStr[pkt[7]], # 'length': (pkt[6] << 8) + pkt[5], # 'params': pkt[8:-2], 'Model Number': (pkt[10...
[ "def", "packetToDict", "(", "pkt", ")", ":", "d", "=", "{", "'id'", ":", "pkt", "[", "4", "]", ",", "# 'instruction': xl320.InstrToStr[pkt[7]],", "# 'length': (pkt[6] << 8) + pkt[5],", "# 'params': pkt[8:-2],", "'Model Number'", ":", "(", "pkt", "[", "10", "]", "<...
Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value)
[ "Given", "a", "packet", "this", "turns", "it", "into", "a", "dictionary", "...", "is", "this", "useful?" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/bin/servo_ping.py#L23-L42
MultipedRobotics/pyxl320
bin/servo_ping.py
sweep
def sweep(port, rate, ID, retry=3): """ Sends a ping packet to ID's from 0 to maximum and prints out any returned messages. Actually send a broadcast and will retry (resend) the ping 3 times ... """ if port == 'dummy': s = ServoSerial(port, rate, fake=True) else: s = ServoSerial(port, rate) if ID < 0: I...
python
def sweep(port, rate, ID, retry=3): """ Sends a ping packet to ID's from 0 to maximum and prints out any returned messages. Actually send a broadcast and will retry (resend) the ping 3 times ... """ if port == 'dummy': s = ServoSerial(port, rate, fake=True) else: s = ServoSerial(port, rate) if ID < 0: I...
[ "def", "sweep", "(", "port", ",", "rate", ",", "ID", ",", "retry", "=", "3", ")", ":", "if", "port", "==", "'dummy'", ":", "s", "=", "ServoSerial", "(", "port", ",", "rate", ",", "fake", "=", "True", ")", "else", ":", "s", "=", "ServoSerial", "...
Sends a ping packet to ID's from 0 to maximum and prints out any returned messages. Actually send a broadcast and will retry (resend) the ping 3 times ...
[ "Sends", "a", "ping", "packet", "to", "ID", "s", "from", "0", "to", "maximum", "and", "prints", "out", "any", "returned", "messages", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/bin/servo_ping.py#L45-L87
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/arcte/arcte.py
calculate_epsilon_effective
def calculate_epsilon_effective(rho, epsilon, seed_degree, neighbor_degrees, mean_degree): """ Semi-automatic effective epsilon threshold calculation. """ # Calculate a weighted neighborhood degree average. # neighborhood_degree = rho*seed_degree + (1-rho)*neighbor_degrees.mean() neighborhood_de...
python
def calculate_epsilon_effective(rho, epsilon, seed_degree, neighbor_degrees, mean_degree): """ Semi-automatic effective epsilon threshold calculation. """ # Calculate a weighted neighborhood degree average. # neighborhood_degree = rho*seed_degree + (1-rho)*neighbor_degrees.mean() neighborhood_de...
[ "def", "calculate_epsilon_effective", "(", "rho", ",", "epsilon", ",", "seed_degree", ",", "neighbor_degrees", ",", "mean_degree", ")", ":", "# Calculate a weighted neighborhood degree average.", "# neighborhood_degree = rho*seed_degree + (1-rho)*neighbor_degrees.mean()", "neighborho...
Semi-automatic effective epsilon threshold calculation.
[ "Semi", "-", "automatic", "effective", "epsilon", "threshold", "calculation", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/arcte/arcte.py#L26-L50
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/arcte/arcte.py
arcte_with_lazy_pagerank
def arcte_with_lazy_pagerank(adjacency_matrix, rho, epsilon, number_of_threads=None): """ Extracts local community features for all graph nodes based on the partitioning of node-centric similarity vectors. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOr...
python
def arcte_with_lazy_pagerank(adjacency_matrix, rho, epsilon, number_of_threads=None): """ Extracts local community features for all graph nodes based on the partitioning of node-centric similarity vectors. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOr...
[ "def", "arcte_with_lazy_pagerank", "(", "adjacency_matrix", ",", "rho", ",", "epsilon", ",", "number_of_threads", "=", "None", ")", ":", "adjacency_matrix", "=", "sparse", ".", "csr_matrix", "(", "adjacency_matrix", ")", "number_of_nodes", "=", "adjacency_matrix", "...
Extracts local community features for all graph nodes based on the partitioning of node-centric similarity vectors. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOrdinate matrix. - rho: Restart probability - epsilon: Approximation thres...
[ "Extracts", "local", "community", "features", "for", "all", "graph", "nodes", "based", "on", "the", "partitioning", "of", "node", "-", "centric", "similarity", "vectors", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/arcte/arcte.py#L391-L488
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/holdout.py
get_folds_generator
def get_folds_generator(node_label_matrix, labelled_node_indices, number_of_categories, dataset_memory_folder, percentage, number_of_folds=10): """ Read or form and store the seed nodes for tr...
python
def get_folds_generator(node_label_matrix, labelled_node_indices, number_of_categories, dataset_memory_folder, percentage, number_of_folds=10): """ Read or form and store the seed nodes for tr...
[ "def", "get_folds_generator", "(", "node_label_matrix", ",", "labelled_node_indices", ",", "number_of_categories", ",", "dataset_memory_folder", ",", "percentage", ",", "number_of_folds", "=", "10", ")", ":", "number_of_labeled_nodes", "=", "labelled_node_indices", ".", "...
Read or form and store the seed nodes for training and testing. Inputs: - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - labelled_node_indices: A NumPy array containing the labelled node indices. - number_of_categories: The number of categories/classes in ...
[ "Read", "or", "form", "and", "store", "the", "seed", "nodes", "for", "training", "and", "testing", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/holdout.py#L11-L77
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/holdout.py
generate_folds
def generate_folds(node_label_matrix, labelled_node_indices, number_of_categories, percentage, number_of_folds=10): """ Form the seed nodes for training and testing. Inputs: - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - labelled_node_indices: A NumPy arra...
python
def generate_folds(node_label_matrix, labelled_node_indices, number_of_categories, percentage, number_of_folds=10): """ Form the seed nodes for training and testing. Inputs: - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - labelled_node_indices: A NumPy arra...
[ "def", "generate_folds", "(", "node_label_matrix", ",", "labelled_node_indices", ",", "number_of_categories", ",", "percentage", ",", "number_of_folds", "=", "10", ")", ":", "number_of_labeled_nodes", "=", "labelled_node_indices", ".", "size", "training_set_size", "=", ...
Form the seed nodes for training and testing. Inputs: - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - labelled_node_indices: A NumPy array containing the labelled node indices. - number_of_categories: The number of categories/classes in the learning. ...
[ "Form", "the", "seed", "nodes", "for", "training", "and", "testing", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/holdout.py#L80-L111
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/holdout.py
iterative_stratification
def iterative_stratification(node_label_matrix, training_set_size, number_of_categories, random_seed=0): """ Iterative data fold stratification/balancing for two folds. Based on: Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the stratification of multi-label data. In Ma...
python
def iterative_stratification(node_label_matrix, training_set_size, number_of_categories, random_seed=0): """ Iterative data fold stratification/balancing for two folds. Based on: Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the stratification of multi-label data. In Ma...
[ "def", "iterative_stratification", "(", "node_label_matrix", ",", "training_set_size", ",", "number_of_categories", ",", "random_seed", "=", "0", ")", ":", "number_of_labelled_nodes", "=", "node_label_matrix", ".", "shape", "[", "0", "]", "testing_set_size", "=", "num...
Iterative data fold stratification/balancing for two folds. Based on: Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the stratification of multi-label data. In Machine Learning and Knowledge Discovery in Databases (pp. 145-158). Springer Berlin Heidelberg. Inp...
[ "Iterative", "data", "fold", "stratification", "/", "balancing", "for", "two", "folds", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/holdout.py#L202-L270
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/evaluation.py
form_node_label_prediction_matrix
def form_node_label_prediction_matrix(y_pred, y_test): """ Given the discriminator distances, this function forms the node-label prediction matrix. It is assumed that the number of true labels is known. Inputs: - y_pred: A NumPy array that contains the distance from the discriminator for each label f...
python
def form_node_label_prediction_matrix(y_pred, y_test): """ Given the discriminator distances, this function forms the node-label prediction matrix. It is assumed that the number of true labels is known. Inputs: - y_pred: A NumPy array that contains the distance from the discriminator for each label f...
[ "def", "form_node_label_prediction_matrix", "(", "y_pred", ",", "y_test", ")", ":", "number_of_test_nodes", "=", "y_pred", ".", "shape", "[", "0", "]", "# We calculate the number of true labels for each node.", "true_number_of_labels", "=", "np", ".", "squeeze", "(", "y...
Given the discriminator distances, this function forms the node-label prediction matrix. It is assumed that the number of true labels is known. Inputs: - y_pred: A NumPy array that contains the distance from the discriminator for each label for each user. - y_test: The node-label ground truth fo...
[ "Given", "the", "discriminator", "distances", "this", "function", "forms", "the", "node", "-", "label", "prediction", "matrix", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/evaluation.py#L9-L40
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/evaluation.py
calculate_measures
def calculate_measures(y_pred, y_test): """ Calculates the F-scores and F-score averages given a classification result and a ground truth. Inputs: - y_pred: The node-label prediction for the test set in a SciPy sparse CSR matrix format. - y_test: The node-label ground truth for the test set i...
python
def calculate_measures(y_pred, y_test): """ Calculates the F-scores and F-score averages given a classification result and a ground truth. Inputs: - y_pred: The node-label prediction for the test set in a SciPy sparse CSR matrix format. - y_test: The node-label ground truth for the test set i...
[ "def", "calculate_measures", "(", "y_pred", ",", "y_test", ")", ":", "y_pred", "=", "y_pred", ".", "toarray", "(", ")", "y_test", "=", "y_test", ".", "toarray", "(", ")", "macro_precision", ",", "macro_recall", ",", "macro_F1", ",", "macro_support", "=", "...
Calculates the F-scores and F-score averages given a classification result and a ground truth. Inputs: - y_pred: The node-label prediction for the test set in a SciPy sparse CSR matrix format. - y_test: The node-label ground truth for the test set in a SciPy sparse CSR matrix format. Outputs: - ...
[ "Calculates", "the", "F", "-", "scores", "and", "F", "-", "score", "averages", "given", "a", "classification", "result", "and", "a", "ground", "truth", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/evaluation.py#L43-L70
MultipedRobotics/pyxl320
pyxl320/ServoSerial.py
ServoSerial.decode
def decode(buff): """ Transforms the raw buffer data read in into a list of bytes """ pp = list(map(ord, buff)) if 0 == len(pp) == 1: pp = [] return pp
python
def decode(buff): """ Transforms the raw buffer data read in into a list of bytes """ pp = list(map(ord, buff)) if 0 == len(pp) == 1: pp = [] return pp
[ "def", "decode", "(", "buff", ")", ":", "pp", "=", "list", "(", "map", "(", "ord", ",", "buff", ")", ")", "if", "0", "==", "len", "(", "pp", ")", "==", "1", ":", "pp", "=", "[", "]", "return", "pp" ]
Transforms the raw buffer data read in into a list of bytes
[ "Transforms", "the", "raw", "buffer", "data", "read", "in", "into", "a", "list", "of", "bytes" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/ServoSerial.py#L147-L154
MultipedRobotics/pyxl320
pyxl320/ServoSerial.py
ServoSerial.read
def read(self, how_much=128): # FIXME: 128 might be too much ... what is largest? """ This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of valid...
python
def read(self, how_much=128): # FIXME: 128 might be too much ... what is largest? """ This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of valid...
[ "def", "read", "(", "self", ",", "how_much", "=", "128", ")", ":", "# FIXME: 128 might be too much ... what is largest?", "# ret = self.readPkts(how_much)", "# return ret", "ret", "=", "[", "]", "self", ".", "setRTS", "(", "self", ".", "DD_READ", ")", "# this in_wai...
This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of valid packets.
[ "This", "toggles", "the", "RTS", "pin", "and", "reads", "in", "data", ".", "It", "also", "converts", "the", "buffer", "back", "into", "a", "list", "of", "bytes", "and", "searches", "through", "the", "list", "to", "find", "valid", "packets", "of", "info",...
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/ServoSerial.py#L156-L182
MultipedRobotics/pyxl320
pyxl320/ServoSerial.py
ServoSerial.read2
def read2(self, how_much=128): # FIXME: 128 might be too much ... what is largest? """ This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of vali...
python
def read2(self, how_much=128): # FIXME: 128 might be too much ... what is largest? """ This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of vali...
[ "def", "read2", "(", "self", ",", "how_much", "=", "128", ")", ":", "# FIXME: 128 might be too much ... what is largest?", "ret", "=", "[", "]", "self", ".", "setRTS", "(", "self", ".", "DD_READ", ")", "header", "=", "[", "0xFF", ",", "0xFD", ",", "0x00", ...
This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of valid packets.
[ "This", "toggles", "the", "RTS", "pin", "and", "reads", "in", "data", ".", "It", "also", "converts", "the", "buffer", "back", "into", "a", "list", "of", "bytes", "and", "searches", "through", "the", "list", "to", "find", "valid", "packets", "of", "info",...
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/ServoSerial.py#L184-L230
MultipedRobotics/pyxl320
pyxl320/ServoSerial.py
ServoSerial.write
def write(self, pkt): """ This is a simple serial write command. It toggles the RTS pin and formats all of the data into bytes before it writes. """ self.setRTS(self.DD_WRITE) self.flushInput() # prep data array for transmition pkt = bytearray(pkt) pkt = bytes(pkt) num = self.serial.write(pkt) # ...
python
def write(self, pkt): """ This is a simple serial write command. It toggles the RTS pin and formats all of the data into bytes before it writes. """ self.setRTS(self.DD_WRITE) self.flushInput() # prep data array for transmition pkt = bytearray(pkt) pkt = bytes(pkt) num = self.serial.write(pkt) # ...
[ "def", "write", "(", "self", ",", "pkt", ")", ":", "self", ".", "setRTS", "(", "self", ".", "DD_WRITE", ")", "self", ".", "flushInput", "(", ")", "# prep data array for transmition", "pkt", "=", "bytearray", "(", "pkt", ")", "pkt", "=", "bytes", "(", "...
This is a simple serial write command. It toggles the RTS pin and formats all of the data into bytes before it writes.
[ "This", "is", "a", "simple", "serial", "write", "command", ".", "It", "toggles", "the", "RTS", "pin", "and", "formats", "all", "of", "the", "data", "into", "bytes", "before", "it", "writes", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/ServoSerial.py#L252-L266
MultipedRobotics/pyxl320
pyxl320/ServoSerial.py
ServoSerial.sendPkt
def sendPkt(self, pkt, retry=5, sleep_time=0.01): """ Sends a packet and waits for a return. If no return is given, then it resends the packet. If an error occurs, it also resends the packet. in: pkt - command packet to send to servo cnt - how many retries should this do? default = 5 out: array of p...
python
def sendPkt(self, pkt, retry=5, sleep_time=0.01): """ Sends a packet and waits for a return. If no return is given, then it resends the packet. If an error occurs, it also resends the packet. in: pkt - command packet to send to servo cnt - how many retries should this do? default = 5 out: array of p...
[ "def", "sendPkt", "(", "self", ",", "pkt", ",", "retry", "=", "5", ",", "sleep_time", "=", "0.01", ")", ":", "for", "cnt", "in", "range", "(", "retry", ")", ":", "self", ".", "serial", ".", "flushInput", "(", ")", "self", ".", "write", "(", "pkt"...
Sends a packet and waits for a return. If no return is given, then it resends the packet. If an error occurs, it also resends the packet. in: pkt - command packet to send to servo cnt - how many retries should this do? default = 5 out: array of packets
[ "Sends", "a", "packet", "and", "waits", "for", "a", "return", ".", "If", "no", "return", "is", "given", "then", "it", "resends", "the", "packet", ".", "If", "an", "error", "occurs", "it", "also", "resends", "the", "packet", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/ServoSerial.py#L268-L292
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/datautil/insight_datautil/insight_read_data.py
scipy_sparse_to_csv
def scipy_sparse_to_csv(filepath, matrix, separator=",", directed=False, numbering="matlab"): """ Writes sparse matrix in separated value format. """ matrix = spsp.coo_matrix(matrix) shape = matrix.shape nnz = matrix.getnnz() if numbering == "matlab": row = matrix.row + 1 c...
python
def scipy_sparse_to_csv(filepath, matrix, separator=",", directed=False, numbering="matlab"): """ Writes sparse matrix in separated value format. """ matrix = spsp.coo_matrix(matrix) shape = matrix.shape nnz = matrix.getnnz() if numbering == "matlab": row = matrix.row + 1 c...
[ "def", "scipy_sparse_to_csv", "(", "filepath", ",", "matrix", ",", "separator", "=", "\",\"", ",", "directed", "=", "False", ",", "numbering", "=", "\"matlab\"", ")", ":", "matrix", "=", "spsp", ".", "coo_matrix", "(", "matrix", ")", "shape", "=", "matrix"...
Writes sparse matrix in separated value format.
[ "Writes", "sparse", "matrix", "in", "separated", "value", "format", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/datautil/insight_datautil/insight_read_data.py#L139-L174
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/datautil/datarw.py
read_adjacency_matrix
def read_adjacency_matrix(file_path, separator, undirected): """ Reads an edge list in csv format and returns the adjacency matrix in SciPy Sparse COOrdinate format. Inputs: - file_path: The path where the adjacency matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ...
python
def read_adjacency_matrix(file_path, separator, undirected): """ Reads an edge list in csv format and returns the adjacency matrix in SciPy Sparse COOrdinate format. Inputs: - file_path: The path where the adjacency matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ...
[ "def", "read_adjacency_matrix", "(", "file_path", ",", "separator", ",", "undirected", ")", ":", "# Open file", "file_row_generator", "=", "get_file_row_generator", "(", "file_path", ",", "separator", ")", "# Initialize lists for row and column sparse matrix arguments.", "row...
Reads an edge list in csv format and returns the adjacency matrix in SciPy Sparse COOrdinate format. Inputs: - file_path: The path where the adjacency matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ") - undirected: If True, create the reciprocal edge for eac...
[ "Reads", "an", "edge", "list", "in", "csv", "format", "and", "returns", "the", "adjacency", "matrix", "in", "SciPy", "Sparse", "COOrdinate", "format", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/datautil/datarw.py#L54-L120
toumorokoshi/jsonschema-extractor
ubuild.py
publish
def publish(build): """ publish the package itself """ build.packages.install("wheel") build.packages.install("twine") build.executables.run([ "python", "setup.py", "sdist", "bdist_wheel", "--universal", "--release" ]) build.executables.run([ "twine", "upload", "dist/*" ...
python
def publish(build): """ publish the package itself """ build.packages.install("wheel") build.packages.install("twine") build.executables.run([ "python", "setup.py", "sdist", "bdist_wheel", "--universal", "--release" ]) build.executables.run([ "twine", "upload", "dist/*" ...
[ "def", "publish", "(", "build", ")", ":", "build", ".", "packages", ".", "install", "(", "\"wheel\"", ")", "build", ".", "packages", ".", "install", "(", "\"twine\"", ")", "build", ".", "executables", ".", "run", "(", "[", "\"python\"", ",", "\"setup.py\...
publish the package itself
[ "publish", "the", "package", "itself" ]
train
https://github.com/toumorokoshi/jsonschema-extractor/blob/e72c608f6ea72cb8bb43912e1177829cff32c13b/ubuild.py#L24-L34
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/eps_randomwalk/similarity.py
fast_approximate_personalized_pagerank
def fast_approximate_personalized_pagerank(s, r, w_i, a_i, out_degree, in_degree, ...
python
def fast_approximate_personalized_pagerank(s, r, w_i, a_i, out_degree, in_degree, ...
[ "def", "fast_approximate_personalized_pagerank", "(", "s", ",", "r", ",", "w_i", ",", "a_i", ",", "out_degree", ",", "in_degree", ",", "seed_node", ",", "rho", "=", "0.2", ",", "epsilon", "=", "0.00001", ")", ":", "# Initialize approximate PageRank and residual di...
Calculates the approximate personalized PageRank starting from a seed node without self-loops.
[ "Calculates", "the", "approximate", "personalized", "PageRank", "starting", "from", "a", "seed", "node", "without", "self", "-", "loops", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/eps_randomwalk/similarity.py#L11-L63
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/eps_randomwalk/similarity.py
lazy_approximate_personalized_pagerank
def lazy_approximate_personalized_pagerank(s, r, w_i, a_i, out_degree, in_degree, ...
python
def lazy_approximate_personalized_pagerank(s, r, w_i, a_i, out_degree, in_degree, ...
[ "def", "lazy_approximate_personalized_pagerank", "(", "s", ",", "r", ",", "w_i", ",", "a_i", ",", "out_degree", ",", "in_degree", ",", "seed_node", ",", "rho", "=", "0.2", ",", "epsilon", "=", "0.00001", ",", "laziness_factor", "=", "0.5", ")", ":", "# Ini...
Calculates the approximate personalized PageRank starting from a seed node with self-loops. Introduced in: Andersen, R., Chung, F., & Lang, K. (2006, October). Local graph partitioning using pagerank vectors. In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE ...
[ "Calculates", "the", "approximate", "personalized", "PageRank", "starting", "from", "a", "seed", "node", "with", "self", "-", "loops", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/eps_randomwalk/similarity.py#L66-L146
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/datautil/read_exotic_features.py
read_matlab_features
def read_matlab_features(array_paths, number_of_nodes, dimensionality): """ Returns a sparse feature matrix as calculated by a Matlab routine. """ # Read the data array file_row_gen = get_file_row_generator(array_paths[0], "\t") data = list() append_data = data.append for file_row in fil...
python
def read_matlab_features(array_paths, number_of_nodes, dimensionality): """ Returns a sparse feature matrix as calculated by a Matlab routine. """ # Read the data array file_row_gen = get_file_row_generator(array_paths[0], "\t") data = list() append_data = data.append for file_row in fil...
[ "def", "read_matlab_features", "(", "array_paths", ",", "number_of_nodes", ",", "dimensionality", ")", ":", "# Read the data array", "file_row_gen", "=", "get_file_row_generator", "(", "array_paths", "[", "0", "]", ",", "\"\\t\"", ")", "data", "=", "list", "(", ")...
Returns a sparse feature matrix as calculated by a Matlab routine.
[ "Returns", "a", "sparse", "feature", "matrix", "as", "calculated", "by", "a", "Matlab", "routine", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/datautil/read_exotic_features.py#L108-L143
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
mroc
def mroc(adjacency_matrix, alpha): """ Extracts hierarchical community features using the MROC method. Introduced in: Wang, X., Tang, L., Liu, H., & Wang, L. (2013). Learning with multi-resolution overlapping communities. Knowledge and information systems, 36(2), 517-5...
python
def mroc(adjacency_matrix, alpha): """ Extracts hierarchical community features using the MROC method. Introduced in: Wang, X., Tang, L., Liu, H., & Wang, L. (2013). Learning with multi-resolution overlapping communities. Knowledge and information systems, 36(2), 517-5...
[ "def", "mroc", "(", "adjacency_matrix", ",", "alpha", ")", ":", "# Find number of nodes", "number_of_nodes", "=", "adjacency_matrix", ".", "shape", "[", "0", "]", "####################################################################################################################",...
Extracts hierarchical community features using the MROC method. Introduced in: Wang, X., Tang, L., Liu, H., & Wang, L. (2013). Learning with multi-resolution overlapping communities. Knowledge and information systems, 36(2), 517-535. Inputs: - A in R^(nxn): Adjacency mat...
[ "Extracts", "hierarchical", "community", "features", "using", "the", "MROC", "method", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L13-L182
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
community_neighbors
def community_neighbors(c_j, reverse_index_rows, unavailable_communities, unavailable_communities_counter): """ Finds communities with shared nodes to a seed community. Called by mroc. Inputs: - c_j: The seed community for which we want to find which communities overlap. - reverse_index_rows:...
python
def community_neighbors(c_j, reverse_index_rows, unavailable_communities, unavailable_communities_counter): """ Finds communities with shared nodes to a seed community. Called by mroc. Inputs: - c_j: The seed community for which we want to find which communities overlap. - reverse_index_rows:...
[ "def", "community_neighbors", "(", "c_j", ",", "reverse_index_rows", ",", "unavailable_communities", ",", "unavailable_communities_counter", ")", ":", "indices", "=", "list", "(", ")", "extend", "=", "indices", ".", "extend", "for", "node", "in", "c_j", ":", "ex...
Finds communities with shared nodes to a seed community. Called by mroc. Inputs: - c_j: The seed community for which we want to find which communities overlap. - reverse_index_rows: A node to community indicator matrix. - unavailable_communities: A set of communities that have already ei...
[ "Finds", "communities", "with", "shared", "nodes", "to", "a", "seed", "community", ".", "Called", "by", "mroc", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L185-L204
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
jaccard
def jaccard(c_1, c_2): """ Calculates the Jaccard similarity between two sets of nodes. Called by mroc. Inputs: - c_1: Community (set of nodes) 1. - c_2: Community (set of nodes) 2. Outputs: - jaccard_similarity: The Jaccard similarity of these two communities. """ nom = np.inter...
python
def jaccard(c_1, c_2): """ Calculates the Jaccard similarity between two sets of nodes. Called by mroc. Inputs: - c_1: Community (set of nodes) 1. - c_2: Community (set of nodes) 2. Outputs: - jaccard_similarity: The Jaccard similarity of these two communities. """ nom = np.inter...
[ "def", "jaccard", "(", "c_1", ",", "c_2", ")", ":", "nom", "=", "np", ".", "intersect1d", "(", "c_1", ",", "c_2", ")", ".", "size", "denom", "=", "np", ".", "union1d", "(", "c_1", ",", "c_2", ")", ".", "size", "return", "nom", "/", "denom" ]
Calculates the Jaccard similarity between two sets of nodes. Called by mroc. Inputs: - c_1: Community (set of nodes) 1. - c_2: Community (set of nodes) 2. Outputs: - jaccard_similarity: The Jaccard similarity of these two communities.
[ "Calculates", "the", "Jaccard", "similarity", "between", "two", "sets", "of", "nodes", ".", "Called", "by", "mroc", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L207-L218
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
louvain
def louvain(adjacency_matrix): """ Performs community embedding using the LOUVAIN method. Introduced in: Blondel, V. D., Guillaume, J. L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory an...
python
def louvain(adjacency_matrix): """ Performs community embedding using the LOUVAIN method. Introduced in: Blondel, V. D., Guillaume, J. L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory an...
[ "def", "louvain", "(", "adjacency_matrix", ")", ":", "# Convert to networkx undirected graph.", "adjacency_matrix", "=", "nx", ".", "from_scipy_sparse_matrix", "(", "adjacency_matrix", ",", "create_using", "=", "nx", ".", "Graph", "(", ")", ")", "# Call LOUVAIN algorith...
Performs community embedding using the LOUVAIN method. Introduced in: Blondel, V. D., Guillaume, J. L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory and Experiment, 2008(10), P10008. Inputs...
[ "Performs", "community", "embedding", "using", "the", "LOUVAIN", "method", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L221-L261
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
laplacian_eigenmaps
def laplacian_eigenmaps(adjacency_matrix, k): """ Performs spectral graph embedding using the graph symmetric normalized Laplacian matrix. Introduced in: Belkin, M., & Niyogi, P. (2003). Laplacian eigenmaps for dimensionality reduction and data representation. Neural c...
python
def laplacian_eigenmaps(adjacency_matrix, k): """ Performs spectral graph embedding using the graph symmetric normalized Laplacian matrix. Introduced in: Belkin, M., & Niyogi, P. (2003). Laplacian eigenmaps for dimensionality reduction and data representation. Neural c...
[ "def", "laplacian_eigenmaps", "(", "adjacency_matrix", ",", "k", ")", ":", "# Calculate sparse graph Laplacian.", "laplacian", "=", "get_normalized_laplacian", "(", "adjacency_matrix", ")", "# Calculate bottom k+1 eigenvalues and eigenvectors of normalized Laplacian.", "try", ":", ...
Performs spectral graph embedding using the graph symmetric normalized Laplacian matrix. Introduced in: Belkin, M., & Niyogi, P. (2003). Laplacian eigenmaps for dimensionality reduction and data representation. Neural computation, 15(6), 1373-1396. Inputs: - A in R^(nx...
[ "Performs", "spectral", "graph", "embedding", "using", "the", "graph", "symmetric", "normalized", "Laplacian", "matrix", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L264-L294
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
replicator_eigenmaps
def replicator_eigenmaps(adjacency_matrix, k): """ Performs spectral graph embedding on the centrality reweighted adjacency matrix Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a scipy.sparse.coo_matrix - k: The number of social dimensions/eigenve...
python
def replicator_eigenmaps(adjacency_matrix, k): """ Performs spectral graph embedding on the centrality reweighted adjacency matrix Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a scipy.sparse.coo_matrix - k: The number of social dimensions/eigenve...
[ "def", "replicator_eigenmaps", "(", "adjacency_matrix", ",", "k", ")", ":", "number_of_nodes", "=", "adjacency_matrix", ".", "shape", "[", "0", "]", "max_eigenvalue", "=", "spla", ".", "eigsh", "(", "adjacency_matrix", ",", "k", "=", "1", ",", "which", "=", ...
Performs spectral graph embedding on the centrality reweighted adjacency matrix Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a scipy.sparse.coo_matrix - k: The number of social dimensions/eigenvectors to extract - max_iter: The maximum ...
[ "Performs", "spectral", "graph", "embedding", "on", "the", "centrality", "reweighted", "adjacency", "matrix" ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L297-L333
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/competing_methods.py
base_communities
def base_communities(adjacency_matrix): """ Forms the community indicator normalized feature matrix for any graph. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOrdinate matrix. Outputs: - X in R^(nxC_n): The latent space embedding represented as a ...
python
def base_communities(adjacency_matrix): """ Forms the community indicator normalized feature matrix for any graph. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOrdinate matrix. Outputs: - X in R^(nxC_n): The latent space embedding represented as a ...
[ "def", "base_communities", "(", "adjacency_matrix", ")", ":", "number_of_nodes", "=", "adjacency_matrix", ".", "shape", "[", "0", "]", "# X = A + I", "adjacency_matrix", "=", "adjacency_matrix", ".", "tocsr", "(", ")", "adjacency_matrix", "=", "adjacency_matrix", "....
Forms the community indicator normalized feature matrix for any graph. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOrdinate matrix. Outputs: - X in R^(nxC_n): The latent space embedding represented as a SciPy Sparse COOrdinate matrix.
[ "Forms", "the", "community", "indicator", "normalized", "feature", "matrix", "for", "any", "graph", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/competing_methods.py#L336-L353
WhyNotHugo/django-afip
django_afip/crypto.py
create_embeded_pkcs7_signature
def create_embeded_pkcs7_signature(data, cert, key): """ Creates an embeded ("nodetached") pkcs7 signature. This is equivalent to the output of:: openssl smime -sign -signer cert -inkey key -outform DER -nodetach < data :type data: bytes :type cert: str :type key: str """ # noqa:...
python
def create_embeded_pkcs7_signature(data, cert, key): """ Creates an embeded ("nodetached") pkcs7 signature. This is equivalent to the output of:: openssl smime -sign -signer cert -inkey key -outform DER -nodetach < data :type data: bytes :type cert: str :type key: str """ # noqa:...
[ "def", "create_embeded_pkcs7_signature", "(", "data", ",", "cert", ",", "key", ")", ":", "# noqa: E501", "assert", "isinstance", "(", "data", ",", "bytes", ")", "assert", "isinstance", "(", "cert", ",", "str", ")", "try", ":", "pkey", "=", "crypto", ".", ...
Creates an embeded ("nodetached") pkcs7 signature. This is equivalent to the output of:: openssl smime -sign -signer cert -inkey key -outform DER -nodetach < data :type data: bytes :type cert: str :type key: str
[ "Creates", "an", "embeded", "(", "nodetached", ")", "pkcs7", "signature", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/crypto.py#L8-L38
WhyNotHugo/django-afip
django_afip/crypto.py
create_key
def create_key(file_): """ Create a key and save it into ``file_``. Note that ``file`` must be opened in binary mode. """ pkey = crypto.PKey() pkey.generate_key(crypto.TYPE_RSA, 2048) file_.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) file_.flush()
python
def create_key(file_): """ Create a key and save it into ``file_``. Note that ``file`` must be opened in binary mode. """ pkey = crypto.PKey() pkey.generate_key(crypto.TYPE_RSA, 2048) file_.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) file_.flush()
[ "def", "create_key", "(", "file_", ")", ":", "pkey", "=", "crypto", ".", "PKey", "(", ")", "pkey", ".", "generate_key", "(", "crypto", ".", "TYPE_RSA", ",", "2048", ")", "file_", ".", "write", "(", "crypto", ".", "dump_privatekey", "(", "crypto", ".", ...
Create a key and save it into ``file_``. Note that ``file`` must be opened in binary mode.
[ "Create", "a", "key", "and", "save", "it", "into", "file_", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/crypto.py#L41-L51
WhyNotHugo/django-afip
django_afip/crypto.py
create_csr
def create_csr(key_file, organization_name, common_name, serial_number, file_): """Create a CSR for a key, and save it into ``file``.""" key = crypto.load_privatekey(crypto.FILETYPE_PEM, key_file.read()) req = crypto.X509Req() subj = req.get_subject() subj.O = organization_name # noqa: E741 (we c...
python
def create_csr(key_file, organization_name, common_name, serial_number, file_): """Create a CSR for a key, and save it into ``file``.""" key = crypto.load_privatekey(crypto.FILETYPE_PEM, key_file.read()) req = crypto.X509Req() subj = req.get_subject() subj.O = organization_name # noqa: E741 (we c...
[ "def", "create_csr", "(", "key_file", ",", "organization_name", ",", "common_name", ",", "serial_number", ",", "file_", ")", ":", "key", "=", "crypto", ".", "load_privatekey", "(", "crypto", ".", "FILETYPE_PEM", ",", "key_file", ".", "read", "(", ")", ")", ...
Create a CSR for a key, and save it into ``file``.
[ "Create", "a", "CSR", "for", "a", "key", "and", "save", "it", "into", "file", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/crypto.py#L54-L68
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/classification.py
model_fit
def model_fit(X_train, y_train, svm_hardness, fit_intercept, number_of_threads, classifier_type="LinearSVC"): """ Fits a Linear Support Vector Classifier to the labelled graph-based features using the LIBLINEAR library. One-vs-All: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRe...
python
def model_fit(X_train, y_train, svm_hardness, fit_intercept, number_of_threads, classifier_type="LinearSVC"): """ Fits a Linear Support Vector Classifier to the labelled graph-based features using the LIBLINEAR library. One-vs-All: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRe...
[ "def", "model_fit", "(", "X_train", ",", "y_train", ",", "svm_hardness", ",", "fit_intercept", ",", "number_of_threads", ",", "classifier_type", "=", "\"LinearSVC\"", ")", ":", "if", "classifier_type", "==", "\"LinearSVC\"", ":", "if", "X_train", ".", "shape", "...
Fits a Linear Support Vector Classifier to the labelled graph-based features using the LIBLINEAR library. One-vs-All: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html LinearSVC: http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html Inputs:...
[ "Fits", "a", "Linear", "Support", "Vector", "Classifier", "to", "the", "labelled", "graph", "-", "based", "features", "using", "the", "LIBLINEAR", "library", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/classification.py#L13-L62
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/classification.py
meta_model_fit
def meta_model_fit(X_train, y_train, svm_hardness, fit_intercept, number_of_threads, regressor_type="LinearSVR"): """ Trains meta-labeler for predicting number of labels for each user. Based on: Tang, L., Rajan, S., & Narayanan, V. K. (2009, April). Large scale multi-label classification via ...
python
def meta_model_fit(X_train, y_train, svm_hardness, fit_intercept, number_of_threads, regressor_type="LinearSVR"): """ Trains meta-labeler for predicting number of labels for each user. Based on: Tang, L., Rajan, S., & Narayanan, V. K. (2009, April). Large scale multi-label classification via ...
[ "def", "meta_model_fit", "(", "X_train", ",", "y_train", ",", "svm_hardness", ",", "fit_intercept", ",", "number_of_threads", ",", "regressor_type", "=", "\"LinearSVR\"", ")", ":", "if", "regressor_type", "==", "\"LinearSVR\"", ":", "if", "X_train", ".", "shape", ...
Trains meta-labeler for predicting number of labels for each user. Based on: Tang, L., Rajan, S., & Narayanan, V. K. (2009, April). Large scale multi-label classification via metalabeler. In Proceedings of the 18th international conference on World wide web (pp. 211-220). ACM.
[ "Trains", "meta", "-", "labeler", "for", "predicting", "number", "of", "labels", "for", "each", "user", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/classification.py#L65-L87
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/classification.py
weigh_users
def weigh_users(X_test, model, classifier_type="LinearSVC"): """ Uses a trained model and the unlabelled features to produce a user-to-label distance matrix. Inputs: - feature_matrix: The graph based-features in either NumPy or SciPy sparse array format. - model: A trained scikit-learn One-vs...
python
def weigh_users(X_test, model, classifier_type="LinearSVC"): """ Uses a trained model and the unlabelled features to produce a user-to-label distance matrix. Inputs: - feature_matrix: The graph based-features in either NumPy or SciPy sparse array format. - model: A trained scikit-learn One-vs...
[ "def", "weigh_users", "(", "X_test", ",", "model", ",", "classifier_type", "=", "\"LinearSVC\"", ")", ":", "if", "classifier_type", "==", "\"LinearSVC\"", ":", "decision_weights", "=", "model", ".", "decision_function", "(", "X_test", ")", "elif", "classifier_type...
Uses a trained model and the unlabelled features to produce a user-to-label distance matrix. Inputs: - feature_matrix: The graph based-features in either NumPy or SciPy sparse array format. - model: A trained scikit-learn One-vs-All multi-label scheme of linear SVC models. - classifier_t...
[ "Uses", "a", "trained", "model", "and", "the", "unlabelled", "features", "to", "produce", "a", "user", "-", "to", "-", "label", "distance", "matrix", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/classification.py#L90-L119
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/learning/classification.py
classify_users
def classify_users(X_test, model, classifier_type, meta_model, upper_cutoff): """ Uses a trained model and the unlabelled features to associate users with labels. The decision is done as per scikit-learn: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html h...
python
def classify_users(X_test, model, classifier_type, meta_model, upper_cutoff): """ Uses a trained model and the unlabelled features to associate users with labels. The decision is done as per scikit-learn: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html h...
[ "def", "classify_users", "(", "X_test", ",", "model", ",", "classifier_type", ",", "meta_model", ",", "upper_cutoff", ")", ":", "if", "classifier_type", "==", "\"LinearSVC\"", ":", "prediction", "=", "model", ".", "decision_function", "(", "X_test", ")", "# pred...
Uses a trained model and the unlabelled features to associate users with labels. The decision is done as per scikit-learn: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html#sklearn.svm.Lin...
[ "Uses", "a", "trained", "model", "and", "the", "unlabelled", "features", "to", "associate", "users", "with", "labels", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/learning/classification.py#L122-L234
WhyNotHugo/django-afip
django_afip/clients.py
get_client
def get_client(service_name, sandbox=False): """ Returns a client for a given service. The `sandbox` argument should only be necessary if a the client will be used to make a request. If it will only be used to serialize objects, it is irrelevant. Avoid the overhead of determining the sandbox mode ...
python
def get_client(service_name, sandbox=False): """ Returns a client for a given service. The `sandbox` argument should only be necessary if a the client will be used to make a request. If it will only be used to serialize objects, it is irrelevant. Avoid the overhead of determining the sandbox mode ...
[ "def", "get_client", "(", "service_name", ",", "sandbox", "=", "False", ")", ":", "key", "=", "(", "service_name", ".", "lower", "(", ")", ",", "sandbox", ",", ")", "try", ":", "if", "key", "not", "in", "cached_clients", ":", "cached_clients", "[", "ke...
Returns a client for a given service. The `sandbox` argument should only be necessary if a the client will be used to make a request. If it will only be used to serialize objects, it is irrelevant. Avoid the overhead of determining the sandbox mode in the calling context if only serialization operatio...
[ "Returns", "a", "client", "for", "a", "given", "service", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/clients.py#L24-L47
toumorokoshi/jsonschema-extractor
jsonschema_extractor/typing_extractor.py
_extract_seq
def _extract_seq(extractor, seq): """Convert a sequence to primitive equivalents.""" subtype = Any if seq.__args__ and seq.__args__[0] is not Any: subtype = seq.__args__[0] return _array_type(extractor.extract(subtype))
python
def _extract_seq(extractor, seq): """Convert a sequence to primitive equivalents.""" subtype = Any if seq.__args__ and seq.__args__[0] is not Any: subtype = seq.__args__[0] return _array_type(extractor.extract(subtype))
[ "def", "_extract_seq", "(", "extractor", ",", "seq", ")", ":", "subtype", "=", "Any", "if", "seq", ".", "__args__", "and", "seq", ".", "__args__", "[", "0", "]", "is", "not", "Any", ":", "subtype", "=", "seq", ".", "__args__", "[", "0", "]", "retur...
Convert a sequence to primitive equivalents.
[ "Convert", "a", "sequence", "to", "primitive", "equivalents", "." ]
train
https://github.com/toumorokoshi/jsonschema-extractor/blob/e72c608f6ea72cb8bb43912e1177829cff32c13b/jsonschema_extractor/typing_extractor.py#L65-L70
toumorokoshi/jsonschema-extractor
jsonschema_extractor/typing_extractor.py
_is_sequence
def _is_sequence(typ): """ returns True if the type in question is a Sequence[] object from the typing module. """ # PEP_560 deprecates issubclass for # List types, for the time being # we'll support a specific escape hatch. if PEP_560: # pragma: no cover return isinstance(typ, ...
python
def _is_sequence(typ): """ returns True if the type in question is a Sequence[] object from the typing module. """ # PEP_560 deprecates issubclass for # List types, for the time being # we'll support a specific escape hatch. if PEP_560: # pragma: no cover return isinstance(typ, ...
[ "def", "_is_sequence", "(", "typ", ")", ":", "# PEP_560 deprecates issubclass for", "# List types, for the time being", "# we'll support a specific escape hatch.", "if", "PEP_560", ":", "# pragma: no cover", "return", "isinstance", "(", "typ", ",", "_GenericAlias", ")", "and"...
returns True if the type in question is a Sequence[] object from the typing module.
[ "returns", "True", "if", "the", "type", "in", "question", "is", "a", "Sequence", "[]", "object", "from", "the", "typing", "module", "." ]
train
https://github.com/toumorokoshi/jsonschema-extractor/blob/e72c608f6ea72cb8bb43912e1177829cff32c13b/jsonschema_extractor/typing_extractor.py#L104-L115
toumorokoshi/jsonschema-extractor
jsonschema_extractor/attrs_extractor.py
AttrsExtractor.extract
def extract(cls, extractor, typ): """ take an attrs based class, and convert it to jsonschema. """ schema = { "title": typ.__name__, "type": "object", "properties": {}, "required": [] } for attribute in attr.fields(t...
python
def extract(cls, extractor, typ): """ take an attrs based class, and convert it to jsonschema. """ schema = { "title": typ.__name__, "type": "object", "properties": {}, "required": [] } for attribute in attr.fields(t...
[ "def", "extract", "(", "cls", ",", "extractor", ",", "typ", ")", ":", "schema", "=", "{", "\"title\"", ":", "typ", ".", "__name__", ",", "\"type\"", ":", "\"object\"", ",", "\"properties\"", ":", "{", "}", ",", "\"required\"", ":", "[", "]", "}", "fo...
take an attrs based class, and convert it to jsonschema.
[ "take", "an", "attrs", "based", "class", "and", "convert", "it", "to", "jsonschema", "." ]
train
https://github.com/toumorokoshi/jsonschema-extractor/blob/e72c608f6ea72cb8bb43912e1177829cff32c13b/jsonschema_extractor/attrs_extractor.py#L18-L34
Robpol86/flake8-pydocstyle
setup.py
readme
def readme(): """Try to read README.rst or return empty string if failed. :return: File contents. :rtype: str """ path = os.path.realpath(os.path.join(os.path.dirname(__file__), 'README.rst')) handle = None url_prefix = 'https://raw.githubusercontent.com/Robpol86/{name}/v{version}/'.format(...
python
def readme(): """Try to read README.rst or return empty string if failed. :return: File contents. :rtype: str """ path = os.path.realpath(os.path.join(os.path.dirname(__file__), 'README.rst')) handle = None url_prefix = 'https://raw.githubusercontent.com/Robpol86/{name}/v{version}/'.format(...
[ "def", "readme", "(", ")", ":", "path", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'README.rst'", ")", ")", "handle", "=", "None", "url_prefix", ...
Try to read README.rst or return empty string if failed. :return: File contents. :rtype: str
[ "Try", "to", "read", "README", ".", "rst", "or", "return", "empty", "string", "if", "failed", "." ]
train
https://github.com/Robpol86/flake8-pydocstyle/blob/657425541e1d868a6a5241a83c3a16a9a715d6b5/setup.py#L15-L30
MultipedRobotics/pyxl320
pyxl320/utils.py
listSerialPorts
def listSerialPorts(): """ http://pyserial.readthedocs.io/en/latest/shortintro.html This calls the command line tool from pyserial to list the available serial ports. """ cmd = 'python -m serial.tools.list_ports' err, ret = commands.getstatusoutput(cmd) if not err: r = ret.split('\n') ret = [] for line i...
python
def listSerialPorts(): """ http://pyserial.readthedocs.io/en/latest/shortintro.html This calls the command line tool from pyserial to list the available serial ports. """ cmd = 'python -m serial.tools.list_ports' err, ret = commands.getstatusoutput(cmd) if not err: r = ret.split('\n') ret = [] for line i...
[ "def", "listSerialPorts", "(", ")", ":", "cmd", "=", "'python -m serial.tools.list_ports'", "err", ",", "ret", "=", "commands", ".", "getstatusoutput", "(", "cmd", ")", "if", "not", "err", ":", "r", "=", "ret", ".", "split", "(", "'\\n'", ")", "ret", "="...
http://pyserial.readthedocs.io/en/latest/shortintro.html This calls the command line tool from pyserial to list the available serial ports.
[ "http", ":", "//", "pyserial", ".", "readthedocs", ".", "io", "/", "en", "/", "latest", "/", "shortintro", ".", "html" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/utils.py#L22-L38
MultipedRobotics/pyxl320
pyxl320/utils.py
prettyPrintPacket
def prettyPrintPacket(ctrl_table): """ This will pretty print out a packet's fields. in: dictionary of a packet out: nothing ... everything is printed to screen """ print('---------------------------------------') print("{:.<29} {}".format('id', ctrl_table['id'])) ctrl_table.pop('id') for key, value in ctrl_t...
python
def prettyPrintPacket(ctrl_table): """ This will pretty print out a packet's fields. in: dictionary of a packet out: nothing ... everything is printed to screen """ print('---------------------------------------') print("{:.<29} {}".format('id', ctrl_table['id'])) ctrl_table.pop('id') for key, value in ctrl_t...
[ "def", "prettyPrintPacket", "(", "ctrl_table", ")", ":", "print", "(", "'---------------------------------------'", ")", "print", "(", "\"{:.<29} {}\"", ".", "format", "(", "'id'", ",", "ctrl_table", "[", "'id'", "]", ")", ")", "ctrl_table", ".", "pop", "(", "...
This will pretty print out a packet's fields. in: dictionary of a packet out: nothing ... everything is printed to screen
[ "This", "will", "pretty", "print", "out", "a", "packet", "s", "fields", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/utils.py#L62-L73
MultipedRobotics/pyxl320
pyxl320/utils.py
JsonFile.read
def read(fname): """ Reads a Json file in: file name out: length of file, dictionary """ try: with open(fname, 'r') as f: data = json.load(f) return data except IOError: raise Exception('Could not open {0!s} for reading'.format((fname)))
python
def read(fname): """ Reads a Json file in: file name out: length of file, dictionary """ try: with open(fname, 'r') as f: data = json.load(f) return data except IOError: raise Exception('Could not open {0!s} for reading'.format((fname)))
[ "def", "read", "(", "fname", ")", ":", "try", ":", "with", "open", "(", "fname", ",", "'r'", ")", "as", "f", ":", "data", "=", "json", ".", "load", "(", "f", ")", "return", "data", "except", "IOError", ":", "raise", "Exception", "(", "'Could not op...
Reads a Json file in: file name out: length of file, dictionary
[ "Reads", "a", "Json", "file", "in", ":", "file", "name", "out", ":", "length", "of", "file", "dictionary" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/utils.py#L81-L93
MultipedRobotics/pyxl320
pyxl320/utils.py
JsonFile.write
def write(fname, data): """ Writes a Json file in: fname - file name data - dictionary of data to put into the file out: nothing, everything is written to a file """ try: with open(fname, 'w') as f: json.dump(data, f) except IOError: raise Exception('Could not open {0!s} for writing'.forma...
python
def write(fname, data): """ Writes a Json file in: fname - file name data - dictionary of data to put into the file out: nothing, everything is written to a file """ try: with open(fname, 'w') as f: json.dump(data, f) except IOError: raise Exception('Could not open {0!s} for writing'.forma...
[ "def", "write", "(", "fname", ",", "data", ")", ":", "try", ":", "with", "open", "(", "fname", ",", "'w'", ")", "as", "f", ":", "json", ".", "dump", "(", "data", ",", "f", ")", "except", "IOError", ":", "raise", "Exception", "(", "'Could not open {...
Writes a Json file in: fname - file name data - dictionary of data to put into the file out: nothing, everything is written to a file
[ "Writes", "a", "Json", "file" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/utils.py#L96-L110
MultipedRobotics/pyxl320
pyxl320/Packet.py
makePacket
def makePacket(ID, instr, reg=None, params=None): """ This makes a generic packet. TODO: look a struct ... does that add value using it? 0xFF, 0xFF, 0xFD, 0x00, ID, LEN_L, LEN_H, INST, PARAM 1, PARAM 2, ..., PARAM N, CRC_L, CRC_H] in: ID - servo id instr - instruction reg - register params - instruction ...
python
def makePacket(ID, instr, reg=None, params=None): """ This makes a generic packet. TODO: look a struct ... does that add value using it? 0xFF, 0xFF, 0xFD, 0x00, ID, LEN_L, LEN_H, INST, PARAM 1, PARAM 2, ..., PARAM N, CRC_L, CRC_H] in: ID - servo id instr - instruction reg - register params - instruction ...
[ "def", "makePacket", "(", "ID", ",", "instr", ",", "reg", "=", "None", ",", "params", "=", "None", ")", ":", "pkt", "=", "[", "]", "pkt", "+=", "[", "0xFF", ",", "0xFF", ",", "0xFD", "]", "# header", "pkt", "+=", "[", "0x00", "]", "# reserved byt...
This makes a generic packet. TODO: look a struct ... does that add value using it? 0xFF, 0xFF, 0xFD, 0x00, ID, LEN_L, LEN_H, INST, PARAM 1, PARAM 2, ..., PARAM N, CRC_L, CRC_H] in: ID - servo id instr - instruction reg - register params - instruction parameter values out: packet
[ "This", "makes", "a", "generic", "packet", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L111-L143
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeWritePacket
def makeWritePacket(ID, reg, values=None): """ Creates a packet that writes a value(s) to servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values. """ pkt = makePacket(ID, xl320.XL320_WRITE, reg, values) return pkt
python
def makeWritePacket(ID, reg, values=None): """ Creates a packet that writes a value(s) to servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values. """ pkt = makePacket(ID, xl320.XL320_WRITE, reg, values) return pkt
[ "def", "makeWritePacket", "(", "ID", ",", "reg", ",", "values", "=", "None", ")", ":", "pkt", "=", "makePacket", "(", "ID", ",", "xl320", ".", "XL320_WRITE", ",", "reg", ",", "values", ")", "return", "pkt" ]
Creates a packet that writes a value(s) to servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values.
[ "Creates", "a", "packet", "that", "writes", "a", "value", "(", "s", ")", "to", "servo", "ID", "at", "location", "reg", ".", "Make", "sure", "the", "values", "are", "in", "little", "endian", "(", "use", "Packet", ".", "le", "()", "if", "necessary", ")...
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L156-L163
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeReadPacket
def makeReadPacket(ID, reg, values=None): """ Creates a packet that reads the register(s) of servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values. """ pkt = makePacket(ID, xl320.XL320_READ, reg, values) return pkt
python
def makeReadPacket(ID, reg, values=None): """ Creates a packet that reads the register(s) of servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values. """ pkt = makePacket(ID, xl320.XL320_READ, reg, values) return pkt
[ "def", "makeReadPacket", "(", "ID", ",", "reg", ",", "values", "=", "None", ")", ":", "pkt", "=", "makePacket", "(", "ID", ",", "xl320", ".", "XL320_READ", ",", "reg", ",", "values", ")", "return", "pkt" ]
Creates a packet that reads the register(s) of servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values.
[ "Creates", "a", "packet", "that", "reads", "the", "register", "(", "s", ")", "of", "servo", "ID", "at", "location", "reg", ".", "Make", "sure", "the", "values", "are", "in", "little", "endian", "(", "use", "Packet", ".", "le", "()", "if", "necessary", ...
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L166-L173
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeResetPacket
def makeResetPacket(ID, param): """ Resets a servo to one of 3 reset states: XL320_RESET_ALL = 0xFF XL320_RESET_ALL_BUT_ID = 0x01 XL320_RESET_ALL_BUT_ID_BAUD_RATE = 0x02 """ if param not in [0x01, 0x02, 0xff]: raise Exception('Packet.makeResetPacket invalide parameter {}'.format(par...
python
def makeResetPacket(ID, param): """ Resets a servo to one of 3 reset states: XL320_RESET_ALL = 0xFF XL320_RESET_ALL_BUT_ID = 0x01 XL320_RESET_ALL_BUT_ID_BAUD_RATE = 0x02 """ if param not in [0x01, 0x02, 0xff]: raise Exception('Packet.makeResetPacket invalide parameter {}'.format(par...
[ "def", "makeResetPacket", "(", "ID", ",", "param", ")", ":", "if", "param", "not", "in", "[", "0x01", ",", "0x02", ",", "0xff", "]", ":", "raise", "Exception", "(", "'Packet.makeResetPacket invalide parameter {}'", ".", "format", "(", "param", ")", ")", "#...
Resets a servo to one of 3 reset states: XL320_RESET_ALL = 0xFF XL320_RESET_ALL_BUT_ID = 0x01 XL320_RESET_ALL_BUT_ID_BAUD_RATE = 0x02
[ "Resets", "a", "servo", "to", "one", "of", "3", "reset", "states", ":" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L176-L188
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeServoPacket
def makeServoPacket(ID, angle): """ Commands the servo to an angle (in degrees) """ if not (0.0 <= angle <= 300.0): raise Exception('makeServoPacket(), angle out of bounds: {}'.format(angle)) val = int(angle/300*1023) # lo, hi = le(val) # print('servo cmd {} deg : {} : L {} H {}'.format(angle, val, lo, hi)) p...
python
def makeServoPacket(ID, angle): """ Commands the servo to an angle (in degrees) """ if not (0.0 <= angle <= 300.0): raise Exception('makeServoPacket(), angle out of bounds: {}'.format(angle)) val = int(angle/300*1023) # lo, hi = le(val) # print('servo cmd {} deg : {} : L {} H {}'.format(angle, val, lo, hi)) p...
[ "def", "makeServoPacket", "(", "ID", ",", "angle", ")", ":", "if", "not", "(", "0.0", "<=", "angle", "<=", "300.0", ")", ":", "raise", "Exception", "(", "'makeServoPacket(), angle out of bounds: {}'", ".", "format", "(", "angle", ")", ")", "val", "=", "int...
Commands the servo to an angle (in degrees)
[ "Commands", "the", "servo", "to", "an", "angle", "(", "in", "degrees", ")" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L208-L218
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeServoMaxLimitPacket
def makeServoMaxLimitPacket(ID, angle): """ Sets the maximum servo angle (in the CCW direction) """ angle = int(angle/300.0*1023) pkt = makeWritePacket(ID, xl320.XL320_CCW_ANGLE_LIMIT, le(angle)) return pkt
python
def makeServoMaxLimitPacket(ID, angle): """ Sets the maximum servo angle (in the CCW direction) """ angle = int(angle/300.0*1023) pkt = makeWritePacket(ID, xl320.XL320_CCW_ANGLE_LIMIT, le(angle)) return pkt
[ "def", "makeServoMaxLimitPacket", "(", "ID", ",", "angle", ")", ":", "angle", "=", "int", "(", "angle", "/", "300.0", "*", "1023", ")", "pkt", "=", "makeWritePacket", "(", "ID", ",", "xl320", ".", "XL320_CCW_ANGLE_LIMIT", ",", "le", "(", "angle", ")", ...
Sets the maximum servo angle (in the CCW direction)
[ "Sets", "the", "maximum", "servo", "angle", "(", "in", "the", "CCW", "direction", ")" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L221-L227
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeServoMinLimitPacket
def makeServoMinLimitPacket(ID, angle): """ Sets the minimum servo angle (in the CW direction) """ angle = int(angle/300.0*1023) pkt = makeWritePacket(ID, xl320.XL320_CW_ANGLE_LIMIT, le(angle)) return pkt
python
def makeServoMinLimitPacket(ID, angle): """ Sets the minimum servo angle (in the CW direction) """ angle = int(angle/300.0*1023) pkt = makeWritePacket(ID, xl320.XL320_CW_ANGLE_LIMIT, le(angle)) return pkt
[ "def", "makeServoMinLimitPacket", "(", "ID", ",", "angle", ")", ":", "angle", "=", "int", "(", "angle", "/", "300.0", "*", "1023", ")", "pkt", "=", "makeWritePacket", "(", "ID", ",", "xl320", ".", "XL320_CW_ANGLE_LIMIT", ",", "le", "(", "angle", ")", "...
Sets the minimum servo angle (in the CW direction)
[ "Sets", "the", "minimum", "servo", "angle", "(", "in", "the", "CW", "direction", ")" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L230-L236
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeServoSpeedPacket
def makeServoSpeedPacket(ID, maxSpeed): """ Run servo between 0.0 to 1.0, where 1.0 is 100% (full) speed. """ if 0.0 > maxSpeed > 1.0: raise Exception('makeServoSpeed: max speed is a percentage (0.0-1.0)') speed = int(maxSpeed*1023) pkt = makeWritePacket(ID, xl320.XL320_GOAL_VELOCITY, le(speed)) return pkt
python
def makeServoSpeedPacket(ID, maxSpeed): """ Run servo between 0.0 to 1.0, where 1.0 is 100% (full) speed. """ if 0.0 > maxSpeed > 1.0: raise Exception('makeServoSpeed: max speed is a percentage (0.0-1.0)') speed = int(maxSpeed*1023) pkt = makeWritePacket(ID, xl320.XL320_GOAL_VELOCITY, le(speed)) return pkt
[ "def", "makeServoSpeedPacket", "(", "ID", ",", "maxSpeed", ")", ":", "if", "0.0", ">", "maxSpeed", ">", "1.0", ":", "raise", "Exception", "(", "'makeServoSpeed: max speed is a percentage (0.0-1.0)'", ")", "speed", "=", "int", "(", "maxSpeed", "*", "1023", ")", ...
Run servo between 0.0 to 1.0, where 1.0 is 100% (full) speed.
[ "Run", "servo", "between", "0", ".", "0", "to", "1", ".", "0", "where", "1", ".", "0", "is", "100%", "(", "full", ")", "speed", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L239-L247
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeLEDPacket
def makeLEDPacket(ID, color): """ Turn on/off the servo LED and also sets the color. """ # pkt = [255, 255, 253, 0, ID, 11, 0, 3, 25, 0, 2 crc_l, crc_h] pkt = makeWritePacket(ID, xl320.XL320_LED, [color]) return pkt
python
def makeLEDPacket(ID, color): """ Turn on/off the servo LED and also sets the color. """ # pkt = [255, 255, 253, 0, ID, 11, 0, 3, 25, 0, 2 crc_l, crc_h] pkt = makeWritePacket(ID, xl320.XL320_LED, [color]) return pkt
[ "def", "makeLEDPacket", "(", "ID", ",", "color", ")", ":", "# pkt = [255, 255, 253, 0, ID, 11, 0, 3, 25, 0, 2 crc_l, crc_h]", "pkt", "=", "makeWritePacket", "(", "ID", ",", "xl320", ".", "XL320_LED", ",", "[", "color", "]", ")", "return", "pkt" ]
Turn on/off the servo LED and also sets the color.
[ "Turn", "on", "/", "off", "the", "servo", "LED", "and", "also", "sets", "the", "color", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L250-L256
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeDelayPacket
def makeDelayPacket(ID, delay): """ It is the delay time per data value that takes from the transmission of Instruction Packet until the return of Status Packet. 0 to 254 (0xFE) can be used, and the delay time per data value is 2 usec. That is to say, if the data value is 10, 20 usec is delayed. The initial value...
python
def makeDelayPacket(ID, delay): """ It is the delay time per data value that takes from the transmission of Instruction Packet until the return of Status Packet. 0 to 254 (0xFE) can be used, and the delay time per data value is 2 usec. That is to say, if the data value is 10, 20 usec is delayed. The initial value...
[ "def", "makeDelayPacket", "(", "ID", ",", "delay", ")", ":", "pkt", "=", "makeWritePacket", "(", "ID", ",", "xl320", ".", "XL320_DELAY_TIME", ",", "delay", ")", "return", "pkt" ]
It is the delay time per data value that takes from the transmission of Instruction Packet until the return of Status Packet. 0 to 254 (0xFE) can be used, and the delay time per data value is 2 usec. That is to say, if the data value is 10, 20 usec is delayed. The initial value is 250 (0xFA) (i.e., 0.5 msec).
[ "It", "is", "the", "delay", "time", "per", "data", "value", "that", "takes", "from", "the", "transmission", "of", "Instruction", "Packet", "until", "the", "return", "of", "Status", "Packet", ".", "0", "to", "254", "(", "0xFE", ")", "can", "be", "used", ...
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L259-L268
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeControlModePacket
def makeControlModePacket(ID, mode): """ Sets the xl-320 to either servo or wheel mode """ pkt = makeWritePacket(ID, xl320.XL320_CONTROL_MODE, le(mode)) return pkt
python
def makeControlModePacket(ID, mode): """ Sets the xl-320 to either servo or wheel mode """ pkt = makeWritePacket(ID, xl320.XL320_CONTROL_MODE, le(mode)) return pkt
[ "def", "makeControlModePacket", "(", "ID", ",", "mode", ")", ":", "pkt", "=", "makeWritePacket", "(", "ID", ",", "xl320", ".", "XL320_CONTROL_MODE", ",", "le", "(", "mode", ")", ")", "return", "pkt" ]
Sets the xl-320 to either servo or wheel mode
[ "Sets", "the", "xl", "-", "320", "to", "either", "servo", "or", "wheel", "mode" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L271-L276
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeBaudRatePacket
def makeBaudRatePacket(ID, rate): """ Set baud rate of servo. in: rate - 0: 9600, 1:57600, 2:115200, 3:1Mbps out: write packet """ if rate not in [0, 1, 2, 3]: raise Exception('Packet.makeBaudRatePacket: wrong rate {}'.format(rate)) pkt = makeWritePacket(ID, xl320.XL320_BAUD_RATE, [rate]) return pkt
python
def makeBaudRatePacket(ID, rate): """ Set baud rate of servo. in: rate - 0: 9600, 1:57600, 2:115200, 3:1Mbps out: write packet """ if rate not in [0, 1, 2, 3]: raise Exception('Packet.makeBaudRatePacket: wrong rate {}'.format(rate)) pkt = makeWritePacket(ID, xl320.XL320_BAUD_RATE, [rate]) return pkt
[ "def", "makeBaudRatePacket", "(", "ID", ",", "rate", ")", ":", "if", "rate", "not", "in", "[", "0", ",", "1", ",", "2", ",", "3", "]", ":", "raise", "Exception", "(", "'Packet.makeBaudRatePacket: wrong rate {}'", ".", "format", "(", "rate", ")", ")", "...
Set baud rate of servo. in: rate - 0: 9600, 1:57600, 2:115200, 3:1Mbps out: write packet
[ "Set", "baud", "rate", "of", "servo", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L279-L289
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeSyncAnglePacket
def makeSyncAnglePacket(info): """ Write sync angle information to servos. info = [[ID, angle], [ID, angle], ...] """ addr = le(xl320.XL320_GOAL_POSITION) data = [] # since all servo angles have the same register addr (XL320_GOAL_POSITION) # and data size (2), a sinc packet is smart choice # compare bulk vs ...
python
def makeSyncAnglePacket(info): """ Write sync angle information to servos. info = [[ID, angle], [ID, angle], ...] """ addr = le(xl320.XL320_GOAL_POSITION) data = [] # since all servo angles have the same register addr (XL320_GOAL_POSITION) # and data size (2), a sinc packet is smart choice # compare bulk vs ...
[ "def", "makeSyncAnglePacket", "(", "info", ")", ":", "addr", "=", "le", "(", "xl320", ".", "XL320_GOAL_POSITION", ")", "data", "=", "[", "]", "# since all servo angles have the same register addr (XL320_GOAL_POSITION)", "# and data size (2), a sinc packet is smart choice", "#...
Write sync angle information to servos. info = [[ID, angle], [ID, angle], ...]
[ "Write", "sync", "angle", "information", "to", "servos", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L292-L322
MultipedRobotics/pyxl320
pyxl320/Packet.py
makeBulkAnglePacket
def makeBulkAnglePacket(info): """ Write bulk angle information to servos. info = [[ID, angle], [ID, angle], ...] """ addr = le(xl320.XL320_GOAL_POSITION) data = [] for pkt in info: data.append(pkt[0]) # ID data.append(addr[0]) # LSB data.append(addr[1]) # MSB data.append(2) # 2 bytes data.append(...
python
def makeBulkAnglePacket(info): """ Write bulk angle information to servos. info = [[ID, angle], [ID, angle], ...] """ addr = le(xl320.XL320_GOAL_POSITION) data = [] for pkt in info: data.append(pkt[0]) # ID data.append(addr[0]) # LSB data.append(addr[1]) # MSB data.append(2) # 2 bytes data.append(...
[ "def", "makeBulkAnglePacket", "(", "info", ")", ":", "addr", "=", "le", "(", "xl320", ".", "XL320_GOAL_POSITION", ")", "data", "=", "[", "]", "for", "pkt", "in", "info", ":", "data", ".", "append", "(", "pkt", "[", "0", "]", ")", "# ID", "data", "....
Write bulk angle information to servos. info = [[ID, angle], [ID, angle], ...]
[ "Write", "bulk", "angle", "information", "to", "servos", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L325-L347
MultipedRobotics/pyxl320
pyxl320/Packet.py
prettyPrintPacket
def prettyPrintPacket(pkt): """ not done """ s = 'packet ID: {} instr: {} len: {}'.format(pkt[4], pkt[7], int((pkt[6] << 8) + pkt[5])) if len(s) > 10: params = pkt[8:-2] s += ' params: {}'.format(params) return s
python
def prettyPrintPacket(pkt): """ not done """ s = 'packet ID: {} instr: {} len: {}'.format(pkt[4], pkt[7], int((pkt[6] << 8) + pkt[5])) if len(s) > 10: params = pkt[8:-2] s += ' params: {}'.format(params) return s
[ "def", "prettyPrintPacket", "(", "pkt", ")", ":", "s", "=", "'packet ID: {} instr: {} len: {}'", ".", "format", "(", "pkt", "[", "4", "]", ",", "pkt", "[", "7", "]", ",", "int", "(", "(", "pkt", "[", "6", "]", "<<", "8", ")", "+", "pkt", "[", "5"...
not done
[ "not", "done" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L422-L430
MultipedRobotics/pyxl320
pyxl320/Packet.py
findPkt
def findPkt(pkt): """ Search through a string of binary for a valid xl320 package. in: buffer to search through out: a list of valid data packet """ # print('findpkt', pkt) # print('-----------------------') ret = [] while len(pkt)-10 >= 0: if pkt[0:4] != [0xFF, 0xFF, 0xFD, 0x00]: pkt.pop(0) # get rid o...
python
def findPkt(pkt): """ Search through a string of binary for a valid xl320 package. in: buffer to search through out: a list of valid data packet """ # print('findpkt', pkt) # print('-----------------------') ret = [] while len(pkt)-10 >= 0: if pkt[0:4] != [0xFF, 0xFF, 0xFD, 0x00]: pkt.pop(0) # get rid o...
[ "def", "findPkt", "(", "pkt", ")", ":", "# print('findpkt', pkt)", "# print('-----------------------')", "ret", "=", "[", "]", "while", "len", "(", "pkt", ")", "-", "10", ">=", "0", ":", "if", "pkt", "[", "0", ":", "4", "]", "!=", "[", "0xFF", ",", "...
Search through a string of binary for a valid xl320 package. in: buffer to search through out: a list of valid data packet
[ "Search", "through", "a", "string", "of", "binary", "for", "a", "valid", "xl320", "package", "." ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L433-L471
MultipedRobotics/pyxl320
pyxl320/Packet.py
packetToDict
def packetToDict(pkt): """ Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) """ d = { 'id': pkt[4], 'instruction': xl320.InstrToStr[pkt[7]], 'length': (pkt[6] << 8) + pkt[5], 'params': pkt[8:-2], 'crc': pkt[-2:] } return d
python
def packetToDict(pkt): """ Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) """ d = { 'id': pkt[4], 'instruction': xl320.InstrToStr[pkt[7]], 'length': (pkt[6] << 8) + pkt[5], 'params': pkt[8:-2], 'crc': pkt[-2:] } return d
[ "def", "packetToDict", "(", "pkt", ")", ":", "d", "=", "{", "'id'", ":", "pkt", "[", "4", "]", ",", "'instruction'", ":", "xl320", ".", "InstrToStr", "[", "pkt", "[", "7", "]", "]", ",", "'length'", ":", "(", "pkt", "[", "6", "]", "<<", "8", ...
Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value)
[ "Given", "a", "packet", "this", "turns", "it", "into", "a", "dictionary", "...", "is", "this", "useful?" ]
train
https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/pyxl320/Packet.py#L474-L490
WhyNotHugo/django-afip
django_afip/models.py
populate_all
def populate_all(): """Fetch and store all metadata from the AFIP.""" ReceiptType.objects.populate() ConceptType.objects.populate() DocumentType.objects.populate() VatType.objects.populate() TaxType.objects.populate() CurrencyType.objects.populate()
python
def populate_all(): """Fetch and store all metadata from the AFIP.""" ReceiptType.objects.populate() ConceptType.objects.populate() DocumentType.objects.populate() VatType.objects.populate() TaxType.objects.populate() CurrencyType.objects.populate()
[ "def", "populate_all", "(", ")", ":", "ReceiptType", ".", "objects", ".", "populate", "(", ")", "ConceptType", ".", "objects", ".", "populate", "(", ")", "DocumentType", ".", "objects", ".", "populate", "(", ")", "VatType", ".", "objects", ".", "populate",...
Fetch and store all metadata from the AFIP.
[ "Fetch", "and", "store", "all", "metadata", "from", "the", "AFIP", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L52-L59
WhyNotHugo/django-afip
django_afip/models.py
first_currency
def first_currency(): """ Returns the id for the first currency The `default` parameter of a foreign key *MUST* be a primary key (and not an instance), else migrations break. This helper method exists solely for that purpose. """ ct = CurrencyType.objects.filter(code='PES').first() if c...
python
def first_currency(): """ Returns the id for the first currency The `default` parameter of a foreign key *MUST* be a primary key (and not an instance), else migrations break. This helper method exists solely for that purpose. """ ct = CurrencyType.objects.filter(code='PES').first() if c...
[ "def", "first_currency", "(", ")", ":", "ct", "=", "CurrencyType", ".", "objects", ".", "filter", "(", "code", "=", "'PES'", ")", ".", "first", "(", ")", "if", "ct", ":", "return", "ct", ".", "pk" ]
Returns the id for the first currency The `default` parameter of a foreign key *MUST* be a primary key (and not an instance), else migrations break. This helper method exists solely for that purpose.
[ "Returns", "the", "id", "for", "the", "first", "currency" ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L79-L89
WhyNotHugo/django-afip
django_afip/models.py
GenericAfipTypeManager.populate
def populate(self, ticket=None): """ Populate the database with types retrieved from the AFIP. If no ticket is provided, the most recent available one will be used. """ ticket = ticket or AuthTicket.objects.get_any_active('wsfe') client = clients.get_client('wsfe', ticke...
python
def populate(self, ticket=None): """ Populate the database with types retrieved from the AFIP. If no ticket is provided, the most recent available one will be used. """ ticket = ticket or AuthTicket.objects.get_any_active('wsfe') client = clients.get_client('wsfe', ticke...
[ "def", "populate", "(", "self", ",", "ticket", "=", "None", ")", ":", "ticket", "=", "ticket", "or", "AuthTicket", ".", "objects", ".", "get_any_active", "(", "'wsfe'", ")", "client", "=", "clients", ".", "get_client", "(", "'wsfe'", ",", "ticket", ".", ...
Populate the database with types retrieved from the AFIP. If no ticket is provided, the most recent available one will be used.
[ "Populate", "the", "database", "with", "types", "retrieved", "from", "the", "AFIP", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L106-L125
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.certificate_object
def certificate_object(self): """ Returns the certificate as an OpenSSL object Returns the certificate as an OpenSSL object (rather than as a file object). """ if not self.certificate: return None self.certificate.seek(0) return crypto.parse_c...
python
def certificate_object(self): """ Returns the certificate as an OpenSSL object Returns the certificate as an OpenSSL object (rather than as a file object). """ if not self.certificate: return None self.certificate.seek(0) return crypto.parse_c...
[ "def", "certificate_object", "(", "self", ")", ":", "if", "not", "self", ".", "certificate", ":", "return", "None", "self", ".", "certificate", ".", "seek", "(", "0", ")", "return", "crypto", ".", "parse_certificate", "(", "self", ".", "certificate", ".", ...
Returns the certificate as an OpenSSL object Returns the certificate as an OpenSSL object (rather than as a file object).
[ "Returns", "the", "certificate", "as", "an", "OpenSSL", "object" ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L295-L305
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.get_certificate_expiration
def get_certificate_expiration(self): """ Gets the certificate expiration from the certificate Gets the certificate expiration from the certificate file. Note that this value is stored into ``certificate_expiration`` when an instance is saved, so you should generally prefer tha...
python
def get_certificate_expiration(self): """ Gets the certificate expiration from the certificate Gets the certificate expiration from the certificate file. Note that this value is stored into ``certificate_expiration`` when an instance is saved, so you should generally prefer tha...
[ "def", "get_certificate_expiration", "(", "self", ")", ":", "datestring", "=", "self", ".", "certificate_object", ".", "get_notAfter", "(", ")", ".", "decode", "(", ")", "dt", "=", "datetime", ".", "strptime", "(", "datestring", ",", "'%Y%m%d%H%M%SZ'", ")", ...
Gets the certificate expiration from the certificate Gets the certificate expiration from the certificate file. Note that this value is stored into ``certificate_expiration`` when an instance is saved, so you should generally prefer that method (since this one requires reading and pars...
[ "Gets", "the", "certificate", "expiration", "from", "the", "certificate" ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L307-L319
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.generate_key
def generate_key(self, force=False): """ Creates a key file for this TaxPayer Creates a key file for this TaxPayer if it does not have one, and immediately saves it. Returns True if and only if a key was created. """ if self.key and not force: logger...
python
def generate_key(self, force=False): """ Creates a key file for this TaxPayer Creates a key file for this TaxPayer if it does not have one, and immediately saves it. Returns True if and only if a key was created. """ if self.key and not force: logger...
[ "def", "generate_key", "(", "self", ",", "force", "=", "False", ")", ":", "if", "self", ".", "key", "and", "not", "force", ":", "logger", ".", "warning", "(", "'Tried to generate key for a taxpayer that already had one'", ")", "return", "False", "with", "NamedTe...
Creates a key file for this TaxPayer Creates a key file for this TaxPayer if it does not have one, and immediately saves it. Returns True if and only if a key was created.
[ "Creates", "a", "key", "file", "for", "this", "TaxPayer" ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L321-L341
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.generate_csr
def generate_csr(self, basename='djangoafip'): """ Creates a CSR for this TaxPayer's key Creates a file-like object that contains the CSR which can be used to request a new certificate from AFIP. """ csr = BytesIO() crypto.create_csr( self.key.file, ...
python
def generate_csr(self, basename='djangoafip'): """ Creates a CSR for this TaxPayer's key Creates a file-like object that contains the CSR which can be used to request a new certificate from AFIP. """ csr = BytesIO() crypto.create_csr( self.key.file, ...
[ "def", "generate_csr", "(", "self", ",", "basename", "=", "'djangoafip'", ")", ":", "csr", "=", "BytesIO", "(", ")", "crypto", ".", "create_csr", "(", "self", ".", "key", ".", "file", ",", "self", ".", "name", ",", "'{}{}'", ".", "format", "(", "base...
Creates a CSR for this TaxPayer's key Creates a file-like object that contains the CSR which can be used to request a new certificate from AFIP.
[ "Creates", "a", "CSR", "for", "this", "TaxPayer", "s", "key" ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L343-L359
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.create_ticket
def create_ticket(self, service): """Create an AuthTicket for a given service.""" ticket = AuthTicket(owner=self, service=service) ticket.authorize() return ticket
python
def create_ticket(self, service): """Create an AuthTicket for a given service.""" ticket = AuthTicket(owner=self, service=service) ticket.authorize() return ticket
[ "def", "create_ticket", "(", "self", ",", "service", ")", ":", "ticket", "=", "AuthTicket", "(", "owner", "=", "self", ",", "service", "=", "service", ")", "ticket", ".", "authorize", "(", ")", "return", "ticket" ]
Create an AuthTicket for a given service.
[ "Create", "an", "AuthTicket", "for", "a", "given", "service", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L361-L365
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.get_ticket
def get_ticket(self, service): """Return an existing AuthTicket for a given service.""" return self.auth_tickets \ .filter(expires__gt=datetime.now(timezone.utc), service=service) \ .last()
python
def get_ticket(self, service): """Return an existing AuthTicket for a given service.""" return self.auth_tickets \ .filter(expires__gt=datetime.now(timezone.utc), service=service) \ .last()
[ "def", "get_ticket", "(", "self", ",", "service", ")", ":", "return", "self", ".", "auth_tickets", ".", "filter", "(", "expires__gt", "=", "datetime", ".", "now", "(", "timezone", ".", "utc", ")", ",", "service", "=", "service", ")", ".", "last", "(", ...
Return an existing AuthTicket for a given service.
[ "Return", "an", "existing", "AuthTicket", "for", "a", "given", "service", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L367-L371
WhyNotHugo/django-afip
django_afip/models.py
TaxPayer.fetch_points_of_sales
def fetch_points_of_sales(self, ticket=None): """ Fetch all point of sales objects. Fetch all point of sales from the WS and store (or update) them locally. Returns a list of tuples with the format (pos, created,). """ ticket = ticket or self.get_or_create_ticke...
python
def fetch_points_of_sales(self, ticket=None): """ Fetch all point of sales objects. Fetch all point of sales from the WS and store (or update) them locally. Returns a list of tuples with the format (pos, created,). """ ticket = ticket or self.get_or_create_ticke...
[ "def", "fetch_points_of_sales", "(", "self", ",", "ticket", "=", "None", ")", ":", "ticket", "=", "ticket", "or", "self", ".", "get_or_create_ticket", "(", "'wsfe'", ")", "client", "=", "clients", ".", "get_client", "(", "'wsfe'", ",", "self", ".", "is_san...
Fetch all point of sales objects. Fetch all point of sales from the WS and store (or update) them locally. Returns a list of tuples with the format (pos, created,).
[ "Fetch", "all", "point", "of", "sales", "objects", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L385-L414
WhyNotHugo/django-afip
django_afip/models.py
TaxPayerExtras.logo_as_data_uri
def logo_as_data_uri(self): """This TaxPayer's logo as a data uri.""" _, ext = os.path.splitext(self.logo.file.name) with open(self.logo.file.name, 'rb') as f: data = base64.b64encode(f.read()) return 'data:image/{};base64,{}'.format( ext[1:], # Remove the leadi...
python
def logo_as_data_uri(self): """This TaxPayer's logo as a data uri.""" _, ext = os.path.splitext(self.logo.file.name) with open(self.logo.file.name, 'rb') as f: data = base64.b64encode(f.read()) return 'data:image/{};base64,{}'.format( ext[1:], # Remove the leadi...
[ "def", "logo_as_data_uri", "(", "self", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "self", ".", "logo", ".", "file", ".", "name", ")", "with", "open", "(", "self", ".", "logo", ".", "file", ".", "name", ",", "'rb'", ...
This TaxPayer's logo as a data uri.
[ "This", "TaxPayer", "s", "logo", "as", "a", "data", "uri", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L501-L510
WhyNotHugo/django-afip
django_afip/models.py
AuthTicket.authorize
def authorize(self): """Send this ticket to AFIP for authorization.""" request = self.__create_request_xml() request = self.__sign_request(request) request = b64encode(request).decode() client = clients.get_client('wsaa', self.owner.is_sandboxed) try: raw_res...
python
def authorize(self): """Send this ticket to AFIP for authorization.""" request = self.__create_request_xml() request = self.__sign_request(request) request = b64encode(request).decode() client = clients.get_client('wsaa', self.owner.is_sandboxed) try: raw_res...
[ "def", "authorize", "(", "self", ")", ":", "request", "=", "self", ".", "__create_request_xml", "(", ")", "request", "=", "self", ".", "__sign_request", "(", "request", ")", "request", "=", "b64encode", "(", "request", ")", ".", "decode", "(", ")", "clie...
Send this ticket to AFIP for authorization.
[ "Send", "this", "ticket", "to", "AFIP", "for", "authorization", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L669-L689
WhyNotHugo/django-afip
django_afip/models.py
ReceiptQuerySet._assign_numbers
def _assign_numbers(self): """ Assign numbers in preparation for validating these receipts. WARNING: Don't call the method manually unless you know what you're doing! """ first = self.select_related('point_of_sales', 'receipt_type').first() next_num = Receipt.ob...
python
def _assign_numbers(self): """ Assign numbers in preparation for validating these receipts. WARNING: Don't call the method manually unless you know what you're doing! """ first = self.select_related('point_of_sales', 'receipt_type').first() next_num = Receipt.ob...
[ "def", "_assign_numbers", "(", "self", ")", ":", "first", "=", "self", ".", "select_related", "(", "'point_of_sales'", ",", "'receipt_type'", ")", ".", "first", "(", ")", "next_num", "=", "Receipt", ".", "objects", ".", "fetch_last_receipt_number", "(", "first...
Assign numbers in preparation for validating these receipts. WARNING: Don't call the method manually unless you know what you're doing!
[ "Assign", "numbers", "in", "preparation", "for", "validating", "these", "receipts", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L704-L726
WhyNotHugo/django-afip
django_afip/models.py
ReceiptQuerySet.check_groupable
def check_groupable(self): """ Checks that all receipts returned by this queryset are groupable. "Groupable" means that they can be validated together: they have the same POS and receipt type. Returns the same queryset is all receipts are groupable, otherwise, raises :c...
python
def check_groupable(self): """ Checks that all receipts returned by this queryset are groupable. "Groupable" means that they can be validated together: they have the same POS and receipt type. Returns the same queryset is all receipts are groupable, otherwise, raises :c...
[ "def", "check_groupable", "(", "self", ")", ":", "types", "=", "self", ".", "aggregate", "(", "poses", "=", "Count", "(", "'point_of_sales_id'", ",", "distinct", "=", "True", ")", ",", "types", "=", "Count", "(", "'receipt_type'", ",", "distinct", "=", "...
Checks that all receipts returned by this queryset are groupable. "Groupable" means that they can be validated together: they have the same POS and receipt type. Returns the same queryset is all receipts are groupable, otherwise, raises :class:`~.CannotValidateTogether`.
[ "Checks", "that", "all", "receipts", "returned", "by", "this", "queryset", "are", "groupable", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L728-L746
WhyNotHugo/django-afip
django_afip/models.py
ReceiptQuerySet.validate
def validate(self, ticket=None): """ Validates all receipts matching this queryset. Note that, due to how AFIP implements its numbering, this method is not thread-safe, or even multiprocess-safe. Because of this, it is possible that not all instances matching this query...
python
def validate(self, ticket=None): """ Validates all receipts matching this queryset. Note that, due to how AFIP implements its numbering, this method is not thread-safe, or even multiprocess-safe. Because of this, it is possible that not all instances matching this query...
[ "def", "validate", "(", "self", ",", "ticket", "=", "None", ")", ":", "# Skip any already-validated ones:", "qs", "=", "self", ".", "filter", "(", "validation__isnull", "=", "True", ")", ".", "check_groupable", "(", ")", "if", "qs", ".", "count", "(", ")",...
Validates all receipts matching this queryset. Note that, due to how AFIP implements its numbering, this method is not thread-safe, or even multiprocess-safe. Because of this, it is possible that not all instances matching this queryset are validated properly. Obviously, only successfu...
[ "Validates", "all", "receipts", "matching", "this", "queryset", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L748-L777
WhyNotHugo/django-afip
django_afip/models.py
ReceiptManager.fetch_last_receipt_number
def fetch_last_receipt_number(self, point_of_sales, receipt_type): """Returns the number for the last validated receipt.""" client = clients.get_client('wsfe', point_of_sales.owner.is_sandboxed) response_xml = client.service.FECompUltimoAutorizado( serializers.serialize_ticket( ...
python
def fetch_last_receipt_number(self, point_of_sales, receipt_type): """Returns the number for the last validated receipt.""" client = clients.get_client('wsfe', point_of_sales.owner.is_sandboxed) response_xml = client.service.FECompUltimoAutorizado( serializers.serialize_ticket( ...
[ "def", "fetch_last_receipt_number", "(", "self", ",", "point_of_sales", ",", "receipt_type", ")", ":", "client", "=", "clients", ".", "get_client", "(", "'wsfe'", ",", "point_of_sales", ".", "owner", ".", "is_sandboxed", ")", "response_xml", "=", "client", ".", ...
Returns the number for the last validated receipt.
[ "Returns", "the", "number", "for", "the", "last", "validated", "receipt", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L836-L863
WhyNotHugo/django-afip
django_afip/models.py
Receipt.total_vat
def total_vat(self): """Returns the sum of all Vat objects.""" q = Vat.objects.filter(receipt=self).aggregate(total=Sum('amount')) return q['total'] or 0
python
def total_vat(self): """Returns the sum of all Vat objects.""" q = Vat.objects.filter(receipt=self).aggregate(total=Sum('amount')) return q['total'] or 0
[ "def", "total_vat", "(", "self", ")", ":", "q", "=", "Vat", ".", "objects", ".", "filter", "(", "receipt", "=", "self", ")", ".", "aggregate", "(", "total", "=", "Sum", "(", "'amount'", ")", ")", "return", "q", "[", "'total'", "]", "or", "0" ]
Returns the sum of all Vat objects.
[ "Returns", "the", "sum", "of", "all", "Vat", "objects", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1031-L1034
WhyNotHugo/django-afip
django_afip/models.py
Receipt.total_tax
def total_tax(self): """Returns the sum of all Tax objects.""" q = Tax.objects.filter(receipt=self).aggregate(total=Sum('amount')) return q['total'] or 0
python
def total_tax(self): """Returns the sum of all Tax objects.""" q = Tax.objects.filter(receipt=self).aggregate(total=Sum('amount')) return q['total'] or 0
[ "def", "total_tax", "(", "self", ")", ":", "q", "=", "Tax", ".", "objects", ".", "filter", "(", "receipt", "=", "self", ")", ".", "aggregate", "(", "total", "=", "Sum", "(", "'amount'", ")", ")", "return", "q", "[", "'total'", "]", "or", "0" ]
Returns the sum of all Tax objects.
[ "Returns", "the", "sum", "of", "all", "Tax", "objects", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1037-L1040
WhyNotHugo/django-afip
django_afip/models.py
Receipt.is_validated
def is_validated(self): """ Returns True if this instance is validated. Note that resolving this property requires a DB query, so if you've a very large amount of receipts you should prefetch (see django's ``select_related``) the ``validation`` field. Even so, a DB query *may* ...
python
def is_validated(self): """ Returns True if this instance is validated. Note that resolving this property requires a DB query, so if you've a very large amount of receipts you should prefetch (see django's ``select_related``) the ``validation`` field. Even so, a DB query *may* ...
[ "def", "is_validated", "(", "self", ")", ":", "# Avoid the DB lookup if possible:", "if", "not", "self", ".", "receipt_number", ":", "return", "False", "try", ":", "return", "self", ".", "validation", ".", "result", "==", "ReceiptValidation", ".", "RESULT_APPROVED...
Returns True if this instance is validated. Note that resolving this property requires a DB query, so if you've a very large amount of receipts you should prefetch (see django's ``select_related``) the ``validation`` field. Even so, a DB query *may* be triggered. If you need a ...
[ "Returns", "True", "if", "this", "instance", "is", "validated", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1052-L1075
WhyNotHugo/django-afip
django_afip/models.py
Receipt.validate
def validate(self, ticket=None, raise_=False): """ Validates this receipt. This is a shortcut to :class:`~.ReceiptQuerySet`'s method of the same name. Calling this validates only this instance. :param AuthTicket ticket: Use this ticket. If None, one will be loaded o...
python
def validate(self, ticket=None, raise_=False): """ Validates this receipt. This is a shortcut to :class:`~.ReceiptQuerySet`'s method of the same name. Calling this validates only this instance. :param AuthTicket ticket: Use this ticket. If None, one will be loaded o...
[ "def", "validate", "(", "self", ",", "ticket", "=", "None", ",", "raise_", "=", "False", ")", ":", "# XXX: Maybe actually have this sortcut raise an exception?", "rv", "=", "Receipt", ".", "objects", ".", "filter", "(", "pk", "=", "self", ".", "pk", ")", "."...
Validates this receipt. This is a shortcut to :class:`~.ReceiptQuerySet`'s method of the same name. Calling this validates only this instance. :param AuthTicket ticket: Use this ticket. If None, one will be loaded or created automatically. :param bool raise_: If True, an ex...
[ "Validates", "this", "receipt", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1077-L1096
WhyNotHugo/django-afip
django_afip/models.py
ReceiptPDFManager.create_for_receipt
def create_for_receipt(self, receipt, **kwargs): """ Creates a ReceiptPDF object for a given receipt. Does not actually generate the related PDF file. All attributes will be completed with the information for the relevant ``TaxPayerProfile`` instance. :param Receipt rec...
python
def create_for_receipt(self, receipt, **kwargs): """ Creates a ReceiptPDF object for a given receipt. Does not actually generate the related PDF file. All attributes will be completed with the information for the relevant ``TaxPayerProfile`` instance. :param Receipt rec...
[ "def", "create_for_receipt", "(", "self", ",", "receipt", ",", "*", "*", "kwargs", ")", ":", "try", ":", "profile", "=", "TaxPayerProfile", ".", "objects", ".", "get", "(", "taxpayer__points_of_sales__receipts", "=", "receipt", ",", ")", "except", "TaxPayerPro...
Creates a ReceiptPDF object for a given receipt. Does not actually generate the related PDF file. All attributes will be completed with the information for the relevant ``TaxPayerProfile`` instance. :param Receipt receipt: The receipt for the PDF which will be generated.
[ "Creates", "a", "ReceiptPDF", "object", "for", "a", "given", "receipt", ".", "Does", "not", "actually", "generate", "the", "related", "PDF", "file", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1124-L1153
WhyNotHugo/django-afip
django_afip/models.py
ReceiptPDF.save_pdf
def save_pdf(self, save_model=True): """ Save the receipt as a PDF related to this model. The related :class:`~.Receipt` should be validated first, of course. :param bool save_model: If True, immediately save this model instance. """ from django_afip.views import Receip...
python
def save_pdf(self, save_model=True): """ Save the receipt as a PDF related to this model. The related :class:`~.Receipt` should be validated first, of course. :param bool save_model: If True, immediately save this model instance. """ from django_afip.views import Receip...
[ "def", "save_pdf", "(", "self", ",", "save_model", "=", "True", ")", ":", "from", "django_afip", ".", "views", "import", "ReceiptPDFView", "if", "not", "self", ".", "receipt", ".", "is_validated", ":", "raise", "exceptions", ".", "DjangoAfipException", "(", ...
Save the receipt as a PDF related to this model. The related :class:`~.Receipt` should be validated first, of course. :param bool save_model: If True, immediately save this model instance.
[ "Save", "the", "receipt", "as", "a", "PDF", "related", "to", "this", "model", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1230-L1255
WhyNotHugo/django-afip
django_afip/models.py
Tax.compute_amount
def compute_amount(self): """Auto-assign and return the total amount for this tax.""" self.amount = self.base_amount * self.aliquot / 100 return self.amount
python
def compute_amount(self): """Auto-assign and return the total amount for this tax.""" self.amount = self.base_amount * self.aliquot / 100 return self.amount
[ "def", "compute_amount", "(", "self", ")", ":", "self", ".", "amount", "=", "self", ".", "base_amount", "*", "self", ".", "aliquot", "/", "100", "return", "self", ".", "amount" ]
Auto-assign and return the total amount for this tax.
[ "Auto", "-", "assign", "and", "return", "the", "total", "amount", "for", "this", "tax", "." ]
train
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L1348-L1351
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/eps_randomwalk/transition.py
get_label_based_random_walk_matrix
def get_label_based_random_walk_matrix(adjacency_matrix, labelled_nodes, label_absorption_probability): """ Returns the label-absorbing random walk transition probability matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains th...
python
def get_label_based_random_walk_matrix(adjacency_matrix, labelled_nodes, label_absorption_probability): """ Returns the label-absorbing random walk transition probability matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains th...
[ "def", "get_label_based_random_walk_matrix", "(", "adjacency_matrix", ",", "labelled_nodes", ",", "label_absorption_probability", ")", ":", "# Turn to sparse.csr_matrix format for faster row access.", "rw_transition", "=", "sparse", ".", "csr_matrix", "(", "adjacency_matrix", ","...
Returns the label-absorbing random walk transition probability matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains the natural random walk transition probability matrix.
[ "Returns", "the", "label", "-", "absorbing", "random", "walk", "transition", "probability", "matrix", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/eps_randomwalk/transition.py#L9-L40
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/eps_randomwalk/transition.py
get_natural_random_walk_matrix
def get_natural_random_walk_matrix(adjacency_matrix, make_shared=False): """ Returns the natural random walk transition probability matrix given the adjacency matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains the natural ra...
python
def get_natural_random_walk_matrix(adjacency_matrix, make_shared=False): """ Returns the natural random walk transition probability matrix given the adjacency matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains the natural ra...
[ "def", "get_natural_random_walk_matrix", "(", "adjacency_matrix", ",", "make_shared", "=", "False", ")", ":", "# Turn to sparse.csr_matrix format for faster row access.", "rw_transition", "=", "sparse", ".", "csr_matrix", "(", "adjacency_matrix", ",", "dtype", "=", "np", ...
Returns the natural random walk transition probability matrix given the adjacency matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains the natural random walk transition probability matrix.
[ "Returns", "the", "natural", "random", "walk", "transition", "probability", "matrix", "given", "the", "adjacency", "matrix", "." ]
train
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/eps_randomwalk/transition.py#L43-L99
Riparo/nougat
nougat/utils.py
is_middleware
def is_middleware(func) -> bool: """ test whether it is a middleware :return: Boolean """ if inspect.isfunction(func): _check = func _name = func.__name__ else: _check = func.__call__ _name = func.__class__.__name__ if not inspect.iscoroutinefunction(_check)...
python
def is_middleware(func) -> bool: """ test whether it is a middleware :return: Boolean """ if inspect.isfunction(func): _check = func _name = func.__name__ else: _check = func.__call__ _name = func.__class__.__name__ if not inspect.iscoroutinefunction(_check)...
[ "def", "is_middleware", "(", "func", ")", "->", "bool", ":", "if", "inspect", ".", "isfunction", "(", "func", ")", ":", "_check", "=", "func", "_name", "=", "func", ".", "__name__", "else", ":", "_check", "=", "func", ".", "__call__", "_name", "=", "...
test whether it is a middleware :return: Boolean
[ "test", "whether", "it", "is", "a", "middleware", ":", "return", ":", "Boolean" ]
train
https://github.com/Riparo/nougat/blob/8453bc37e0b782f296952f0a418532ebbbcd74f3/nougat/utils.py#L16-L38
matheuscas/pyIE
ie/ro.py
start
def start(st_reg_number): """Checks the number valiaty for the Rondônia state""" divisor = 11 weight = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] if len(st_reg_number) != 9 and len(st_reg_number) != 14: return False if len(st_reg_number) == 9: sum_total = 0 peso = 6 ...
python
def start(st_reg_number): """Checks the number valiaty for the Rondônia state""" divisor = 11 weight = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] if len(st_reg_number) != 9 and len(st_reg_number) != 14: return False if len(st_reg_number) == 9: sum_total = 0 peso = 6 ...
[ "def", "start", "(", "st_reg_number", ")", ":", "divisor", "=", "11", "weight", "=", "[", "6", ",", "5", ",", "4", ",", "3", ",", "2", ",", "9", ",", "8", ",", "7", ",", "6", ",", "5", ",", "4", ",", "3", ",", "2", "]", "if", "len", "("...
Checks the number valiaty for the Rondônia state
[ "Checks", "the", "number", "valiaty", "for", "the", "Rondônia", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/ro.py#L5-L47
matheuscas/pyIE
ie/sp.py
start
def start(st_reg_number): """Checks the number valiaty for the São Paulo state""" divisor = 11 verificador_one = int(st_reg_number[len(st_reg_number)-4]) verificador_two = int(st_reg_number[len(st_reg_number)-1]) weights_first = [1, 3, 4, 5, 6, 7, 8, 10] weights_secund = [3, 2, 10, 9, 8, 7, 6,...
python
def start(st_reg_number): """Checks the number valiaty for the São Paulo state""" divisor = 11 verificador_one = int(st_reg_number[len(st_reg_number)-4]) verificador_two = int(st_reg_number[len(st_reg_number)-1]) weights_first = [1, 3, 4, 5, 6, 7, 8, 10] weights_secund = [3, 2, 10, 9, 8, 7, 6,...
[ "def", "start", "(", "st_reg_number", ")", ":", "divisor", "=", "11", "verificador_one", "=", "int", "(", "st_reg_number", "[", "len", "(", "st_reg_number", ")", "-", "4", "]", ")", "verificador_two", "=", "int", "(", "st_reg_number", "[", "len", "(", "s...
Checks the number valiaty for the São Paulo state
[ "Checks", "the", "number", "valiaty", "for", "the", "São", "Paulo", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/sp.py#L5-L74
matheuscas/pyIE
ie/pe.py
start
def start(st_reg_number): """Checks the number valiaty for the Pernanbuco state""" divisor = 11 if len(st_reg_number) > 9: return False if len(st_reg_number) < 9: return False sum_total = 0 peso = 8 for i in range(len(st_reg_number)-2): sum_total = sum_total + int(...
python
def start(st_reg_number): """Checks the number valiaty for the Pernanbuco state""" divisor = 11 if len(st_reg_number) > 9: return False if len(st_reg_number) < 9: return False sum_total = 0 peso = 8 for i in range(len(st_reg_number)-2): sum_total = sum_total + int(...
[ "def", "start", "(", "st_reg_number", ")", ":", "divisor", "=", "11", "if", "len", "(", "st_reg_number", ")", ">", "9", ":", "return", "False", "if", "len", "(", "st_reg_number", ")", "<", "9", ":", "return", "False", "sum_total", "=", "0", "peso", "...
Checks the number valiaty for the Pernanbuco state
[ "Checks", "the", "number", "valiaty", "for", "the", "Pernanbuco", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/pe.py#L5-L57
Riparo/nougat
nougat/context/response.py
Response.set_header
def set_header(self, key: str, value: str) -> None: """ set response header :param key: the key of header :param value: the value of header """ self.headers[key] = value
python
def set_header(self, key: str, value: str) -> None: """ set response header :param key: the key of header :param value: the value of header """ self.headers[key] = value
[ "def", "set_header", "(", "self", ",", "key", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "self", ".", "headers", "[", "key", "]", "=", "value" ]
set response header :param key: the key of header :param value: the value of header
[ "set", "response", "header", ":", "param", "key", ":", "the", "key", "of", "header", ":", "param", "value", ":", "the", "value", "of", "header" ]
train
https://github.com/Riparo/nougat/blob/8453bc37e0b782f296952f0a418532ebbbcd74f3/nougat/context/response.py#L26-L32
matheuscas/pyIE
ie/ba.py
start
def start(st_reg_number): """Checks the number valiaty for the Bahia state""" weights_second_digit = range(len(st_reg_number)-1, 1, -1) weights_first_digit = range(len(st_reg_number), 1, -1) second_digits = st_reg_number[-1:] number_state_registration = st_reg_number[0:len(st_reg_number) - 2] d...
python
def start(st_reg_number): """Checks the number valiaty for the Bahia state""" weights_second_digit = range(len(st_reg_number)-1, 1, -1) weights_first_digit = range(len(st_reg_number), 1, -1) second_digits = st_reg_number[-1:] number_state_registration = st_reg_number[0:len(st_reg_number) - 2] d...
[ "def", "start", "(", "st_reg_number", ")", ":", "weights_second_digit", "=", "range", "(", "len", "(", "st_reg_number", ")", "-", "1", ",", "1", ",", "-", "1", ")", "weights_first_digit", "=", "range", "(", "len", "(", "st_reg_number", ")", ",", "1", "...
Checks the number valiaty for the Bahia state
[ "Checks", "the", "number", "valiaty", "for", "the", "Bahia", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/ba.py#L5-L75
Riparo/nougat
nougat/asgi.py
send_http_response
async def send_http_response(writer, http_code: int, headers: List[Tuple[str, str]], content: bytes, http_status: str= None ) -> None: """ generate http response paylo...
python
async def send_http_response(writer, http_code: int, headers: List[Tuple[str, str]], content: bytes, http_status: str= None ) -> None: """ generate http response paylo...
[ "async", "def", "send_http_response", "(", "writer", ",", "http_code", ":", "int", ",", "headers", ":", "List", "[", "Tuple", "[", "str", ",", "str", "]", "]", ",", "content", ":", "bytes", ",", "http_status", ":", "str", "=", "None", ")", "->", "Non...
generate http response payload and send to writer
[ "generate", "http", "response", "payload", "and", "send", "to", "writer" ]
train
https://github.com/Riparo/nougat/blob/8453bc37e0b782f296952f0a418532ebbbcd74f3/nougat/asgi.py#L165-L186
Riparo/nougat
nougat/asgi.py
serve
async def serve(http_handler: HTTP_WRAPPER_TYPE, websocket_handler=None, address: str='127.0.0.1', port: int=8000): """ start server """ return await asyncio.start_server(SocketWrapper(http_handler, websocket_handler), address, port)
python
async def serve(http_handler: HTTP_WRAPPER_TYPE, websocket_handler=None, address: str='127.0.0.1', port: int=8000): """ start server """ return await asyncio.start_server(SocketWrapper(http_handler, websocket_handler), address, port)
[ "async", "def", "serve", "(", "http_handler", ":", "HTTP_WRAPPER_TYPE", ",", "websocket_handler", "=", "None", ",", "address", ":", "str", "=", "'127.0.0.1'", ",", "port", ":", "int", "=", "8000", ")", ":", "return", "await", "asyncio", ".", "start_server", ...
start server
[ "start", "server" ]
train
https://github.com/Riparo/nougat/blob/8453bc37e0b782f296952f0a418532ebbbcd74f3/nougat/asgi.py#L189-L196
Riparo/nougat
nougat/context/request.py
Request.__body_format
def __body_format(self, body): """ format body into different type :param body: :return: """ ctype, pdict = parse_header(self.content_type) if ctype == 'application/json': self.form = json.loads(body.decode()) elif ctype == 'application/x-www...
python
def __body_format(self, body): """ format body into different type :param body: :return: """ ctype, pdict = parse_header(self.content_type) if ctype == 'application/json': self.form = json.loads(body.decode()) elif ctype == 'application/x-www...
[ "def", "__body_format", "(", "self", ",", "body", ")", ":", "ctype", ",", "pdict", "=", "parse_header", "(", "self", ".", "content_type", ")", "if", "ctype", "==", "'application/json'", ":", "self", ".", "form", "=", "json", ".", "loads", "(", "body", ...
format body into different type :param body: :return:
[ "format", "body", "into", "different", "type", ":", "param", "body", ":", ":", "return", ":" ]
train
https://github.com/Riparo/nougat/blob/8453bc37e0b782f296952f0a418532ebbbcd74f3/nougat/context/request.py#L49-L78
matheuscas/pyIE
ie/pb.py
start
def start(st_reg_number): """Checks the number valiaty for the Paraiba state""" #st_reg_number = str(st_reg_number) weights = [9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 9: return False sum_total = 0 for i in range(0, 8): ...
python
def start(st_reg_number): """Checks the number valiaty for the Paraiba state""" #st_reg_number = str(st_reg_number) weights = [9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 9: return False sum_total = 0 for i in range(0, 8): ...
[ "def", "start", "(", "st_reg_number", ")", ":", "#st_reg_number = str(st_reg_number)", "weights", "=", "[", "9", ",", "8", ",", "7", ",", "6", ",", "5", ",", "4", ",", "3", ",", "2", "]", "digit_state_registration", "=", "st_reg_number", "[", "-", "1", ...
Checks the number valiaty for the Paraiba state
[ "Checks", "the", "number", "valiaty", "for", "the", "Paraiba", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/pb.py#L5-L24
matheuscas/pyIE
ie/mt.py
start
def start(st_reg_number): """Checks the number valiaty for the Mato Grosso state""" #st_reg_number = str(st_reg_number) weights = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 11: return False sum = 0 for i in range(0, 10): ...
python
def start(st_reg_number): """Checks the number valiaty for the Mato Grosso state""" #st_reg_number = str(st_reg_number) weights = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 11: return False sum = 0 for i in range(0, 10): ...
[ "def", "start", "(", "st_reg_number", ")", ":", "#st_reg_number = str(st_reg_number)", "weights", "=", "[", "3", ",", "2", ",", "9", ",", "8", ",", "7", ",", "6", ",", "5", ",", "4", ",", "3", ",", "2", "]", "digit_state_registration", "=", "st_reg_num...
Checks the number valiaty for the Mato Grosso state
[ "Checks", "the", "number", "valiaty", "for", "the", "Mato", "Grosso", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/mt.py#L5-L24
matheuscas/pyIE
ie/se.py
start
def start(st_reg_number): """Checks the number valiaty for the Sergipe state""" divisor = 11 if len(st_reg_number) > 9: return False if len(st_reg_number) < 9: return False sum_total = 0 peso = 9 for i in range(len(st_reg_number)-1): sum_total = sum_total + int(st...
python
def start(st_reg_number): """Checks the number valiaty for the Sergipe state""" divisor = 11 if len(st_reg_number) > 9: return False if len(st_reg_number) < 9: return False sum_total = 0 peso = 9 for i in range(len(st_reg_number)-1): sum_total = sum_total + int(st...
[ "def", "start", "(", "st_reg_number", ")", ":", "divisor", "=", "11", "if", "len", "(", "st_reg_number", ")", ">", "9", ":", "return", "False", "if", "len", "(", "st_reg_number", ")", "<", "9", ":", "return", "False", "sum_total", "=", "0", "peso", "...
Checks the number valiaty for the Sergipe state
[ "Checks", "the", "number", "valiaty", "for", "the", "Sergipe", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/se.py#L5-L28
matheuscas/pyIE
ie/go.py
start
def start(st_reg_number): """Checks the number valiaty for the Espirito Santo state""" weights = [9, 8, 7, 6, 5, 4, 3, 2] number_state_registration = st_reg_number[0:len(st_reg_number) - 1] digit_state_registration = st_reg_number[-1] if st_reg_number[0:2] not in ['10', '11', '12']: return...
python
def start(st_reg_number): """Checks the number valiaty for the Espirito Santo state""" weights = [9, 8, 7, 6, 5, 4, 3, 2] number_state_registration = st_reg_number[0:len(st_reg_number) - 1] digit_state_registration = st_reg_number[-1] if st_reg_number[0:2] not in ['10', '11', '12']: return...
[ "def", "start", "(", "st_reg_number", ")", ":", "weights", "=", "[", "9", ",", "8", ",", "7", ",", "6", ",", "5", ",", "4", ",", "3", ",", "2", "]", "number_state_registration", "=", "st_reg_number", "[", "0", ":", "len", "(", "st_reg_number", ")",...
Checks the number valiaty for the Espirito Santo state
[ "Checks", "the", "number", "valiaty", "for", "the", "Espirito", "Santo", "state" ]
train
https://github.com/matheuscas/pyIE/blob/9e942dd692d0eab8a1e7717ad7ff3fe90d590ffb/ie/go.py#L5-L39