hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
00beaa3976bea4af417e97762ac28b52ae74dc67
dsar/Twitter_Sentiment_Analysis
src/utils.py
[ "MIT" ]
Python
read_file
<not_specific>
def read_file(filename): """ DESCRIPTION: Reads a file and returns it as a list INPUT: filename: Name of the file to be read """ data = [] with open(filename, "r") as ins: for line in ins: data.append(line) return data
DESCRIPTION: Reads a file and returns it as a list INPUT: filename: Name of the file to be read
Reads a file and returns it as a list INPUT: filename: Name of the file to be read
[ "Reads", "a", "file", "and", "returns", "it", "as", "a", "list", "INPUT", ":", "filename", ":", "Name", "of", "the", "file", "to", "be", "read" ]
def read_file(filename): data = [] with open(filename, "r") as ins: for line in ins: data.append(line) return data
[ "def", "read_file", "(", "filename", ")", ":", "data", "=", "[", "]", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "ins", ":", "for", "line", "in", "ins", ":", "data", ".", "append", "(", "line", ")", "return", "data" ]
DESCRIPTION: Reads a file and returns it as a list INPUT: filename: Name of the file to be read
[ "DESCRIPTION", ":", "Reads", "a", "file", "and", "returns", "it", "as", "a", "list", "INPUT", ":", "filename", ":", "Name", "of", "the", "file", "to", "be", "read" ]
[ "\"\"\"\r\n DESCRIPTION: \r\n Reads a file and returns it as a list\r\n INPUT: \r\n filename: Name of the file to be read\r\n \"\"\"" ]
[ { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a980759cc99c031b29815f24a7fcab4d1846ae88
dsar/Twitter_Sentiment_Analysis
src/fast_text.py
[ "MIT" ]
Python
write_tweets_with_fasttext_labels
null
def write_tweets_with_fasttext_labels(tweets): """ DESCRIPTION: writes tweets with fasttext labels to a file INPUT: tweets: Dataframe of train tweets """ f = open(FASTTEXT_TRAIN_FILE,'w') for t,s in zip(tweets['tweet'], tweets['sentiment']): f.write((t.rstrip()+...
DESCRIPTION: writes tweets with fasttext labels to a file INPUT: tweets: Dataframe of train tweets
writes tweets with fasttext labels to a file INPUT: tweets: Dataframe of train tweets
[ "writes", "tweets", "with", "fasttext", "labels", "to", "a", "file", "INPUT", ":", "tweets", ":", "Dataframe", "of", "train", "tweets" ]
def write_tweets_with_fasttext_labels(tweets): f = open(FASTTEXT_TRAIN_FILE,'w') for t,s in zip(tweets['tweet'], tweets['sentiment']): f.write((t.rstrip()+ ' '+s+'\n')) f.close()
[ "def", "write_tweets_with_fasttext_labels", "(", "tweets", ")", ":", "f", "=", "open", "(", "FASTTEXT_TRAIN_FILE", ",", "'w'", ")", "for", "t", ",", "s", "in", "zip", "(", "tweets", "[", "'tweet'", "]", ",", "tweets", "[", "'sentiment'", "]", ")", ":", ...
DESCRIPTION: writes tweets with fasttext labels to a file INPUT: tweets: Dataframe of train tweets
[ "DESCRIPTION", ":", "writes", "tweets", "with", "fasttext", "labels", "to", "a", "file", "INPUT", ":", "tweets", ":", "Dataframe", "of", "train", "tweets" ]
[ "\"\"\"\n DESCRIPTION: \n writes tweets with fasttext labels to a file\n INPUT: \n tweets: Dataframe of train tweets\n \"\"\"" ]
[ { "param": "tweets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
43d6ec9df882424767d9dce45e5cf9ac37fe3649
dsar/Twitter_Sentiment_Analysis
src/options.py
[ "MIT" ]
Python
print_dict_settings
null
def print_dict_settings(dict_, msg='settings\n'): """ DESCRIPTION: Prints a dictionary (which probably contains settings & options) in to a user friendly format. INPUT: dict_: the dictionary that contains the parameters msg: a user friendly message ...
DESCRIPTION: Prints a dictionary (which probably contains settings & options) in to a user friendly format. INPUT: dict_: the dictionary that contains the parameters msg: a user friendly message
Prints a dictionary (which probably contains settings & options) in to a user friendly format. INPUT: dict_: the dictionary that contains the parameters msg: a user friendly message
[ "Prints", "a", "dictionary", "(", "which", "probably", "contains", "settings", "&", "options", ")", "in", "to", "a", "user", "friendly", "format", ".", "INPUT", ":", "dict_", ":", "the", "dictionary", "that", "contains", "the", "parameters", "msg", ":", "a...
def print_dict_settings(dict_, msg='settings\n'): print(msg) for key, value in dict_.items(): print('\t',key,':\t',value) print('-\n')
[ "def", "print_dict_settings", "(", "dict_", ",", "msg", "=", "'settings\\n'", ")", ":", "print", "(", "msg", ")", "for", "key", ",", "value", "in", "dict_", ".", "items", "(", ")", ":", "print", "(", "'\\t'", ",", "key", ",", "':\\t'", ",", "value", ...
DESCRIPTION: Prints a dictionary (which probably contains settings & options) in to a user friendly format.
[ "DESCRIPTION", ":", "Prints", "a", "dictionary", "(", "which", "probably", "contains", "settings", "&", "options", ")", "in", "to", "a", "user", "friendly", "format", "." ]
[ "\"\"\"\r\n DESCRIPTION: \r\n Prints a dictionary (which probably contains settings & options) in to a\r\n user friendly format.\r\n INPUT: \r\n dict_: the dictionary that contains the parameters\r\n msg: a user friendly message\r\n \"\"\"" ]
[ { "param": "dict_", "type": null }, { "param": "msg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dict_", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": null, "docstring": null, "docstring_tokens": [...
cf7b58925d5b89f105c3340acb872cc5e3d62ca6
dsar/Twitter_Sentiment_Analysis
src/tfidf_embdedding_vectorizer.py
[ "MIT" ]
Python
tfidf_embdedding_vectorizer
<not_specific>
def tfidf_embdedding_vectorizer(tweets, test_tweets): """ DESCRIPTION: Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in th...
DESCRIPTION: Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embeddin...
Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding with it's tfidf value. This is done for tweets and tes...
[ "Given", "the", "calculated", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "of", "the", "training", "and", "test", "set", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension", "by", "just", "a...
def tfidf_embdedding_vectorizer(tweets, test_tweets): words = get_embeddings_dictionary(tweets) print('building train tfidf') algorithm['options']['TFIDF']['tokenizer'] = None tfidf = init_tfidf_vectorizer() X = tfidf.fit_transform(tweets['tweet']) print('train tweets: building (TF-IDF-weighted)...
[ "def", "tfidf_embdedding_vectorizer", "(", "tweets", ",", "test_tweets", ")", ":", "words", "=", "get_embeddings_dictionary", "(", "tweets", ")", "print", "(", "'building train tfidf'", ")", "algorithm", "[", "'options'", "]", "[", "'TFIDF'", "]", "[", "'tokenizer...
DESCRIPTION: Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding with it's tfidf value.
[ "DESCRIPTION", ":", "Given", "the", "calculated", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "of", "the", "training", "and", "test", "set", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension"...
[ "\"\"\"\n DESCRIPTION: \n Given the calculated word embedings (of some dimension d) of the training and test set, \n this function returns the tweet embeddings of the same d dimension by just averaging the\n vectors of each word in the same tweet and multipliying the correspondin...
[ { "param": "tweets", "type": null }, { "param": "test_tweets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test_tweets", "type": null, "docstring": null, "docstring_t...
cf7b58925d5b89f105c3340acb872cc5e3d62ca6
dsar/Twitter_Sentiment_Analysis
src/tfidf_embdedding_vectorizer.py
[ "MIT" ]
Python
average_vectors
<not_specific>
def average_vectors(tweets, words, tfidf, X): """ DESCRIPTION: Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tw...
DESCRIPTION: Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding...
Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding with it's tfidf value.
[ "Given", "a", "pandas", "Dataframe", "of", "tweets", "and", "the", "trained", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension", "by", "just", "...
def average_vectors(tweets, words, tfidf, X): we_tweets = np.zeros((tweets.shape[0], len(next(iter(words.values()))))) for i, tweet in enumerate(tweets['tweet']): try: split_tweet = tweet.split() except: continue; foundEmbeddings = 0 for word in split_twee...
[ "def", "average_vectors", "(", "tweets", ",", "words", ",", "tfidf", ",", "X", ")", ":", "we_tweets", "=", "np", ".", "zeros", "(", "(", "tweets", ".", "shape", "[", "0", "]", ",", "len", "(", "next", "(", "iter", "(", "words", ".", "values", "("...
DESCRIPTION: Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding with it's tfidf value.
[ "DESCRIPTION", ":", "Given", "a", "pandas", "Dataframe", "of", "tweets", "and", "the", "trained", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension...
[ "\"\"\"\n DESCRIPTION: \n Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d)\n this function returns the tweet embeddings of the same d dimension by just averaging the\n vectors of each word in the same tweet and multipliying the corresponding...
[ { "param": "tweets", "type": null }, { "param": "words", "type": null }, { "param": "tfidf", "type": null }, { "param": "X", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "words", "type": null, "docstring": null, "docstring_tokens"...
44bf89373c88ddb1bd13dd968de4249c6ebfe73a
dsar/Twitter_Sentiment_Analysis
src/vectorizer.py
[ "MIT" ]
Python
init_tfidf_vectorizer
<not_specific>
def init_tfidf_vectorizer(): """ DESCRIPTION: Initializes the tfidf vectorizer by taking the parameters from options.py """ print_dict_settings(algorithm['options']['TFIDF'], msg='tf-idf Vectorizer settings\n') if algorithm['options']['TFIDF']['number_of_stopwords'] != None: algori...
DESCRIPTION: Initializes the tfidf vectorizer by taking the parameters from options.py
Initializes the tfidf vectorizer by taking the parameters from options.py
[ "Initializes", "the", "tfidf", "vectorizer", "by", "taking", "the", "parameters", "from", "options", ".", "py" ]
def init_tfidf_vectorizer(): print_dict_settings(algorithm['options']['TFIDF'], msg='tf-idf Vectorizer settings\n') if algorithm['options']['TFIDF']['number_of_stopwords'] != None: algorithm['options']['TFIDF']['number_of_stopwords'] = find_stopwords(number_of_stopwords=algorithm['options']['TFIDF']['number_o...
[ "def", "init_tfidf_vectorizer", "(", ")", ":", "print_dict_settings", "(", "algorithm", "[", "'options'", "]", "[", "'TFIDF'", "]", ",", "msg", "=", "'tf-idf Vectorizer settings\\n'", ")", "if", "algorithm", "[", "'options'", "]", "[", "'TFIDF'", "]", "[", "'n...
DESCRIPTION: Initializes the tfidf vectorizer by taking the parameters from options.py
[ "DESCRIPTION", ":", "Initializes", "the", "tfidf", "vectorizer", "by", "taking", "the", "parameters", "from", "options", ".", "py" ]
[ "\"\"\"\r\n DESCRIPTION: \r\n Initializes the tfidf vectorizer by taking the parameters from options.py\r\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
44bf89373c88ddb1bd13dd968de4249c6ebfe73a
dsar/Twitter_Sentiment_Analysis
src/vectorizer.py
[ "MIT" ]
Python
load_vectorizer
<not_specific>
def load_vectorizer(tweets, test_tweets): """ DESCRIPTION: If there exists a cached tfidf file then it is loaded and returned. Otherwisem a new vectorizer is fittied by the gived data. INPUT: tweets: Dataframe of a set of tweets test_tweets: Dataframe of a set of test_twee...
DESCRIPTION: If there exists a cached tfidf file then it is loaded and returned. Otherwisem a new vectorizer is fittied by the gived data. INPUT: tweets: Dataframe of a set of tweets test_tweets: Dataframe of a set of test_tweets OUTPUT: train_reptweets: TFIDF r...
If there exists a cached tfidf file then it is loaded and returned. Otherwisem a new vectorizer is fittied by the gived data.
[ "If", "there", "exists", "a", "cached", "tfidf", "file", "then", "it", "is", "loaded", "and", "returned", ".", "Otherwisem", "a", "new", "vectorizer", "is", "fittied", "by", "the", "gived", "data", "." ]
def load_vectorizer(tweets, test_tweets): import os.path if(os.path.exists(TFIDF_TRAIN_FILE) and os.path.exists(TFIDF_TRAIN_FILE)): f = open(TFIDF_TRAIN_FILE,'rb') train_reptweets = pickle.load(f) f = open(TFIDF_TEST_FILE,'rb') test_reptweets = pickle.load(f) else: tfidf = init_tfidf_vectorize...
[ "def", "load_vectorizer", "(", "tweets", ",", "test_tweets", ")", ":", "import", "os", ".", "path", "if", "(", "os", ".", "path", ".", "exists", "(", "TFIDF_TRAIN_FILE", ")", "and", "os", ".", "path", ".", "exists", "(", "TFIDF_TRAIN_FILE", ")", ")", "...
DESCRIPTION: If there exists a cached tfidf file then it is loaded and returned.
[ "DESCRIPTION", ":", "If", "there", "exists", "a", "cached", "tfidf", "file", "then", "it", "is", "loaded", "and", "returned", "." ]
[ "\"\"\"\r\n DESCRIPTION: \r\n If there exists a cached tfidf file then it is loaded and returned. Otherwisem a new vectorizer is fittied\r\n by the gived data.\r\n INPUT: \r\n tweets: Dataframe of a set of tweets\r\n test_tweets: Dataframe of a set of test_tweets\r\n OUTPUT: \r\n ...
[ { "param": "tweets", "type": null }, { "param": "test_tweets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test_tweets", "type": null, "docstring": null, "docstring_t...
2dc4de91d6055ac290d04328bc9e9fac56cb9f4e
dsar/Twitter_Sentiment_Analysis
src/build_embeddings.py
[ "MIT" ]
Python
load_glove_embeddings_from_txt_file
<not_specific>
def load_glove_embeddings_from_txt_file(filename): """ DESCRIPTION: Loads a word embedding file and returns a python dictionary of the form (word, [vector of embeddings]) in memory INPUT: filename: name of the word embedding file to be loaded OUTPUT: wo...
DESCRIPTION: Loads a word embedding file and returns a python dictionary of the form (word, [vector of embeddings]) in memory INPUT: filename: name of the word embedding file to be loaded OUTPUT: words: python dictionary of the form (word, [vector of embed...
Loads a word embedding file and returns a python dictionary of the form (word, [vector of embeddings]) in memory INPUT: filename: name of the word embedding file to be loaded OUTPUT: words: python dictionary of the form (word, [vector of embeddings])
[ "Loads", "a", "word", "embedding", "file", "and", "returns", "a", "python", "dictionary", "of", "the", "form", "(", "word", "[", "vector", "of", "embeddings", "]", ")", "in", "memory", "INPUT", ":", "filename", ":", "name", "of", "the", "word", "embeddin...
def load_glove_embeddings_from_txt_file(filename): print('Loading', filename ,'embeddings file') if not os.path.exists(filename): print(filename,'embeddings not found') return None print('Constructing dictionary for', filename, 'file') words = {} with open(filename, "r") as f: ...
[ "def", "load_glove_embeddings_from_txt_file", "(", "filename", ")", ":", "print", "(", "'Loading'", ",", "filename", ",", "'embeddings file'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "print", "(", "filename", ",", "'emb...
DESCRIPTION: Loads a word embedding file and returns a python dictionary of the form (word, [vector of embeddings]) in memory INPUT: filename: name of the word embedding file to be loaded OUTPUT: words: python dictionary of the form (word, [vector of embeddings])
[ "DESCRIPTION", ":", "Loads", "a", "word", "embedding", "file", "and", "returns", "a", "python", "dictionary", "of", "the", "form", "(", "word", "[", "vector", "of", "embeddings", "]", ")", "in", "memory", "INPUT", ":", "filename", ":", "name", "of", "the...
[ "\"\"\"\n DESCRIPTION: \n Loads a word embedding file and returns a python dictionary of the form\n (word, [vector of embeddings]) in memory\n INPUT: \n filename: name of the word embedding file to be loaded\n OUTPUT: \n words: python dictionary of the form (word...
[ { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2dc4de91d6055ac290d04328bc9e9fac56cb9f4e
dsar/Twitter_Sentiment_Analysis
src/build_embeddings.py
[ "MIT" ]
Python
build_merge_embeddings
<not_specific>
def build_merge_embeddings(): """ DESCRIPTION: Loads the pretrained word embeddings from Stanford and builds also the word embeddings matrix based on our training dataset by using the glove_python method. Then all the missing words from the pretrained word embeddings are filled by the glove_pyth...
DESCRIPTION: Loads the pretrained word embeddings from Stanford and builds also the word embeddings matrix based on our training dataset by using the glove_python method. Then all the missing words from the pretrained word embeddings are filled by the glove_python word embeddings. OUTPUT: ...
Loads the pretrained word embeddings from Stanford and builds also the word embeddings matrix based on our training dataset by using the glove_python method. Then all the missing words from the pretrained word embeddings are filled by the glove_python word embeddings. OUTPUT: glove_words: merged python dictionary of th...
[ "Loads", "the", "pretrained", "word", "embeddings", "from", "Stanford", "and", "builds", "also", "the", "word", "embeddings", "matrix", "based", "on", "our", "training", "dataset", "by", "using", "the", "glove_python", "method", ".", "Then", "all", "the", "mis...
def build_merge_embeddings(): print('Build merged Embeddings') os.system('join -i -a1 -a2 ' +PRETRAINED_EMBEDDINGS_FILE + ' ' + MY_GLOVE_PYTHON_EMBEDDINGS_TXT_FILE +' 2>/dev/null | cut -d \' \' -f1-'+str(algorithm['options']['WE']['we_features'])+" > "+ MERGED_EMBEDDINGS_FILE) glove_words = load_glove_embeddings_fr...
[ "def", "build_merge_embeddings", "(", ")", ":", "print", "(", "'Build merged Embeddings'", ")", "os", ".", "system", "(", "'join -i -a1 -a2 '", "+", "PRETRAINED_EMBEDDINGS_FILE", "+", "' '", "+", "MY_GLOVE_PYTHON_EMBEDDINGS_TXT_FILE", "+", "' 2>/dev/null | cut -d \\' \\' -f...
DESCRIPTION: Loads the pretrained word embeddings from Stanford and builds also the word embeddings matrix based on our training dataset by using the glove_python method.
[ "DESCRIPTION", ":", "Loads", "the", "pretrained", "word", "embeddings", "from", "Stanford", "and", "builds", "also", "the", "word", "embeddings", "matrix", "based", "on", "our", "training", "dataset", "by", "using", "the", "glove_python", "method", "." ]
[ "\"\"\"\n\tDESCRIPTION: \n\t Loads the pretrained word embeddings from Stanford and builds\n\t also the word embeddings matrix based on our training dataset by using the \n\t glove_python method. Then all the missing words from the pretrained word\n\t embeddings are filled by the glove_python word embed...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2dc4de91d6055ac290d04328bc9e9fac56cb9f4e
dsar/Twitter_Sentiment_Analysis
src/build_embeddings.py
[ "MIT" ]
Python
call_init
<not_specific>
def call_init(): """ DESCRIPTION: Builds the baseline word embeddings. Calls all the required files given in the project's description in order to build the baseline word embeddings. OUTPUT: words: python dictionary of the form (word, [vector of embeddings]) """ words = load_glove_embeddings_...
DESCRIPTION: Builds the baseline word embeddings. Calls all the required files given in the project's description in order to build the baseline word embeddings. OUTPUT: words: python dictionary of the form (word, [vector of embeddings])
Builds the baseline word embeddings. Calls all the required files given in the project's description in order to build the baseline word embeddings. OUTPUT: words: python dictionary of the form (word, [vector of embeddings])
[ "Builds", "the", "baseline", "word", "embeddings", ".", "Calls", "all", "the", "required", "files", "given", "in", "the", "project", "'", "s", "description", "in", "order", "to", "build", "the", "baseline", "word", "embeddings", ".", "OUTPUT", ":", "words", ...
def call_init(): words = load_glove_embeddings_from_txt_file(MY_EMBEDDINGS_TXT_FILE) if words != None: return words print('start init.sh') os.system('bash init.sh ' + POS_TWEETS_FILE + ' ' + NEG_TWEETS_FILE) print('baseline embeddings created') return load_glove_embeddings_from_txt_file(MY_EMBEDDINGS_TXT_FILE)
[ "def", "call_init", "(", ")", ":", "words", "=", "load_glove_embeddings_from_txt_file", "(", "MY_EMBEDDINGS_TXT_FILE", ")", "if", "words", "!=", "None", ":", "return", "words", "print", "(", "'start init.sh'", ")", "os", ".", "system", "(", "'bash init.sh '", "+...
DESCRIPTION: Builds the baseline word embeddings.
[ "DESCRIPTION", ":", "Builds", "the", "baseline", "word", "embeddings", "." ]
[ "\"\"\"\n\tDESCRIPTION: \n\t Builds the baseline word embeddings.\n\t Calls all the required files given in the project's description\n\t in order to build the baseline word embeddings.\n\tOUTPUT: \n\t words: python dictionary of the form (word, [vector of embeddings])\n\t\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2dc4de91d6055ac290d04328bc9e9fac56cb9f4e
dsar/Twitter_Sentiment_Analysis
src/build_embeddings.py
[ "MIT" ]
Python
build_python_glove_representation
<not_specific>
def build_python_glove_representation(tweets): """ DESCRIPTION: Converts initial tweet representation (pandas Dataframe) on the required representation for glove_python algorithm. OUTPUT: A list of lists that contains all the training tweets """ return tweets....
DESCRIPTION: Converts initial tweet representation (pandas Dataframe) on the required representation for glove_python algorithm. OUTPUT: A list of lists that contains all the training tweets
Converts initial tweet representation (pandas Dataframe) on the required representation for glove_python algorithm. OUTPUT: A list of lists that contains all the training tweets
[ "Converts", "initial", "tweet", "representation", "(", "pandas", "Dataframe", ")", "on", "the", "required", "representation", "for", "glove_python", "algorithm", ".", "OUTPUT", ":", "A", "list", "of", "lists", "that", "contains", "all", "the", "training", "tweet...
def build_python_glove_representation(tweets): return tweets.apply(lambda tweet: tweet.split()).tolist()
[ "def", "build_python_glove_representation", "(", "tweets", ")", ":", "return", "tweets", ".", "apply", "(", "lambda", "tweet", ":", "tweet", ".", "split", "(", ")", ")", ".", "tolist", "(", ")" ]
DESCRIPTION: Converts initial tweet representation (pandas Dataframe) on the required representation for glove_python algorithm.
[ "DESCRIPTION", ":", "Converts", "initial", "tweet", "representation", "(", "pandas", "Dataframe", ")", "on", "the", "required", "representation", "for", "glove_python", "algorithm", "." ]
[ "\"\"\"\n DESCRIPTION: \n Converts initial tweet representation (pandas Dataframe) \n on the required representation for glove_python algorithm. \n OUTPUT: \n A list of lists that contains all the training tweets\n \"\"\"" ]
[ { "param": "tweets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2dc4de91d6055ac290d04328bc9e9fac56cb9f4e
dsar/Twitter_Sentiment_Analysis
src/build_embeddings.py
[ "MIT" ]
Python
build_glove_embeddings
<not_specific>
def build_glove_embeddings(corpus): """ DESCRIPTION: Applies the Glove python SGD algorithm given by glove_python library and build the word embeddings from our training set. INPUT: corpus: a list of lists where each sub-list represent a tweet. The outer list represent...
DESCRIPTION: Applies the Glove python SGD algorithm given by glove_python library and build the word embeddings from our training set. INPUT: corpus: a list of lists where each sub-list represent a tweet. The outer list represents the whole training da...
Applies the Glove python SGD algorithm given by glove_python library and build the word embeddings from our training set. INPUT: corpus: a list of lists where each sub-list represent a tweet. The outer list represents the whole training dataset. OUTPUT: words: python dictionary of the form (word, [vector of embeddings]...
[ "Applies", "the", "Glove", "python", "SGD", "algorithm", "given", "by", "glove_python", "library", "and", "build", "the", "word", "embeddings", "from", "our", "training", "set", ".", "INPUT", ":", "corpus", ":", "a", "list", "of", "lists", "where", "each", ...
def build_glove_embeddings(corpus): words = load_glove_embeddings_from_txt_file(MY_GLOVE_PYTHON_EMBEDDINGS_TXT_FILE) if words != None: return words model = Corpus() model.fit(corpus, window = algorithm['options']['WE']['window_size']) glove = Glove(no_components=algorithm['options']['WE']['...
[ "def", "build_glove_embeddings", "(", "corpus", ")", ":", "words", "=", "load_glove_embeddings_from_txt_file", "(", "MY_GLOVE_PYTHON_EMBEDDINGS_TXT_FILE", ")", "if", "words", "!=", "None", ":", "return", "words", "model", "=", "Corpus", "(", ")", "model", ".", "fi...
DESCRIPTION: Applies the Glove python SGD algorithm given by glove_python library and build the word embeddings from our training set.
[ "DESCRIPTION", ":", "Applies", "the", "Glove", "python", "SGD", "algorithm", "given", "by", "glove_python", "library", "and", "build", "the", "word", "embeddings", "from", "our", "training", "set", "." ]
[ "\"\"\"\n DESCRIPTION: \n Applies the Glove python SGD algorithm given by glove_python library and build the\n word embeddings from our training set.\n INPUT:\n corpus: a list of lists where each sub-list represent a tweet. The outer list represents\n the ...
[ { "param": "corpus", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "corpus", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2dc4de91d6055ac290d04328bc9e9fac56cb9f4e
dsar/Twitter_Sentiment_Analysis
src/build_embeddings.py
[ "MIT" ]
Python
store_embeddings_to_txt_file
null
def store_embeddings_to_txt_file(dict, filename): """ DESCRIPTION: Stores a python dictionary of the form (word, [vector of embeddings]) (which represents the word embeddings matrix of our model) to a txt file. INPUT: dict: python dictionary of the form (word, [vector of embeddings]) filename...
DESCRIPTION: Stores a python dictionary of the form (word, [vector of embeddings]) (which represents the word embeddings matrix of our model) to a txt file. INPUT: dict: python dictionary of the form (word, [vector of embeddings]) filename: name of the file to write the word embeddings dictio...
Stores a python dictionary of the form (word, [vector of embeddings]) (which represents the word embeddings matrix of our model) to a txt file. INPUT: dict: python dictionary of the form (word, [vector of embeddings]) filename: name of the file to write the word embeddings dictionary
[ "Stores", "a", "python", "dictionary", "of", "the", "form", "(", "word", "[", "vector", "of", "embeddings", "]", ")", "(", "which", "represents", "the", "word", "embeddings", "matrix", "of", "our", "model", ")", "to", "a", "txt", "file", ".", "INPUT", ...
def store_embeddings_to_txt_file(dict, filename): with open(filename, "w") as f: for k, v in dict.items(): line = k + str(v) + '\n' f.write(str(k+' ')) for i in v: f.write("%s " % i) f.write('\n')
[ "def", "store_embeddings_to_txt_file", "(", "dict", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "for", "k", ",", "v", "in", "dict", ".", "items", "(", ")", ":", "line", "=", "k", "+", "str", "(", ...
DESCRIPTION: Stores a python dictionary of the form (word, [vector of embeddings]) (which represents the word embeddings matrix of our model) to a txt file.
[ "DESCRIPTION", ":", "Stores", "a", "python", "dictionary", "of", "the", "form", "(", "word", "[", "vector", "of", "embeddings", "]", ")", "(", "which", "represents", "the", "word", "embeddings", "matrix", "of", "our", "model", ")", "to", "a", "txt", "fil...
[ "\"\"\"\n\tDESCRIPTION: \n\t Stores a python dictionary of the form (word, [vector of embeddings]) (which represents\n\t the word embeddings matrix of our model) to a txt file. \n\tINPUT:\n\t dict: python dictionary of the form (word, [vector of embeddings])\n\t filename: name of the file to write the...
[ { "param": "dict", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dict", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
69a61ef3c10c88c981275fc11b646f11285340f2
dsar/Twitter_Sentiment_Analysis
src/we_mean.py
[ "MIT" ]
Python
we_mean
<not_specific>
def we_mean(tweets, test_tweets): """ DESCRIPTION: Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet. This i...
DESCRIPTION: Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet. This is done for tweets and test_tweets pandas ...
Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet. This is done for tweets and test_tweets pandas Dataframes.
[ "Given", "the", "calculated", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "of", "the", "training", "and", "test", "set", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension", "by", "just", "a...
def we_mean(tweets, test_tweets): words = get_embeddings_dictionary(tweets) print('\nBuilding tweets Embeddings') we_tweets = average_vectors(tweets, words) print('Building test tweets Embeddings') we_test_tweets = average_vectors(test_tweets, words) return we_tweets, we_test_tweets
[ "def", "we_mean", "(", "tweets", ",", "test_tweets", ")", ":", "words", "=", "get_embeddings_dictionary", "(", "tweets", ")", "print", "(", "'\\nBuilding tweets Embeddings'", ")", "we_tweets", "=", "average_vectors", "(", "tweets", ",", "words", ")", "print", "(...
DESCRIPTION: Given the calculated word embedings (of some dimension d) of the training and test set, this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet.
[ "DESCRIPTION", ":", "Given", "the", "calculated", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "of", "the", "training", "and", "test", "set", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension"...
[ "\"\"\"\n DESCRIPTION: \n Given the calculated word embedings (of some dimension d) of the training and test set, \n this function returns the tweet embeddings of the same d dimension by just averaging the\n vectors of each word in the same tweet. This is done for tweets and test...
[ { "param": "tweets", "type": null }, { "param": "test_tweets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test_tweets", "type": null, "docstring": null, "docstring_t...
69a61ef3c10c88c981275fc11b646f11285340f2
dsar/Twitter_Sentiment_Analysis
src/we_mean.py
[ "MIT" ]
Python
average_vectors
<not_specific>
def average_vectors(tweets, words): """ DESCRIPTION: Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet. ...
DESCRIPTION: Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet. INPUT: tweets: Dataframe of a ...
Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet.
[ "Given", "a", "pandas", "Dataframe", "of", "tweets", "and", "the", "trained", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension", "by", "just", "...
def average_vectors(tweets, words): we_tweets = np.zeros((tweets.shape[0], len(next(iter(words.values()))))) for i, tweet in enumerate(tweets['tweet']): try: split_tweet = tweet.split() except: continue; foundEmbeddings = 0 for word in split_tweet: ...
[ "def", "average_vectors", "(", "tweets", ",", "words", ")", ":", "we_tweets", "=", "np", ".", "zeros", "(", "(", "tweets", ".", "shape", "[", "0", "]", ",", "len", "(", "next", "(", "iter", "(", "words", ".", "values", "(", ")", ")", ")", ")", ...
DESCRIPTION: Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d) this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet.
[ "DESCRIPTION", ":", "Given", "a", "pandas", "Dataframe", "of", "tweets", "and", "the", "trained", "word", "embedings", "(", "of", "some", "dimension", "d", ")", "this", "function", "returns", "the", "tweet", "embeddings", "of", "the", "same", "d", "dimension...
[ "\"\"\"\n DESCRIPTION: \n Given a pandas Dataframe of tweets and the trained word embedings (of some dimension d)\n this function returns the tweet embeddings of the same d dimension by just averaging the\n vectors of each word in the same tweet. \n INPUT: \n tweets...
[ { "param": "tweets", "type": null }, { "param": "words", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "words", "type": null, "docstring": null, "docstring_tokens"...
e3ad1ad00cb165954fcf4c9a3c7c302a37728885
dsar/Twitter_Sentiment_Analysis
src/doc2vec_solution.py
[ "MIT" ]
Python
doc2vec
<not_specific>
def doc2vec(tweets, test_tweets): """ DESCRIPTION: Given as an input our train and test datasets, this function builds Document to Vector (DOC2VEC) representation by using the Doc2Vec Gensim library. INPUT: tweets: Dataframe of training tweets t...
DESCRIPTION: Given as an input our train and test datasets, this function builds Document to Vector (DOC2VEC) representation by using the Doc2Vec Gensim library. INPUT: tweets: Dataframe of training tweets test_tweets: Dataframe of testing tweets ...
Given as an input our train and test datasets, this function builds Document to Vector (DOC2VEC) representation by using the Doc2Vec Gensim library.
[ "Given", "as", "an", "input", "our", "train", "and", "test", "datasets", "this", "function", "builds", "Document", "to", "Vector", "(", "DOC2VEC", ")", "representation", "by", "using", "the", "Doc2Vec", "Gensim", "library", "." ]
def doc2vec(tweets, test_tweets): pos = tweets[tweets['sentiment'] == 1]['tweet'] pos.to_csv(PREPROC_DATA_PATH+'train_pos.d2v', header=False, index=False, encoding='utf-8') neg = tweets[tweets['sentiment'] == -1]['tweet'] neg.to_csv(PREPROC_DATA_PATH+'train_neg.d2v', header=False, index=False, encoding=...
[ "def", "doc2vec", "(", "tweets", ",", "test_tweets", ")", ":", "pos", "=", "tweets", "[", "tweets", "[", "'sentiment'", "]", "==", "1", "]", "[", "'tweet'", "]", "pos", ".", "to_csv", "(", "PREPROC_DATA_PATH", "+", "'train_pos.d2v'", ",", "header", "=", ...
DESCRIPTION: Given as an input our train and test datasets, this function builds Document to Vector (DOC2VEC) representation by using the Doc2Vec Gensim library.
[ "DESCRIPTION", ":", "Given", "as", "an", "input", "our", "train", "and", "test", "datasets", "this", "function", "builds", "Document", "to", "Vector", "(", "DOC2VEC", ")", "representation", "by", "using", "the", "Doc2Vec", "Gensim", "library", "." ]
[ "\"\"\"\n DESCRIPTION: \n Given as an input our train and test datasets, this function builds\n Document to Vector (DOC2VEC) representation by using the Doc2Vec Gensim\n library. \n INPUT: \n tweets: Dataframe of training tweets\n test_tweets: Dataframe o...
[ { "param": "tweets", "type": null }, { "param": "test_tweets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tweets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "test_tweets", "type": null, "docstring": null, "docstring_t...
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
st_nlink
<not_specific>
def st_nlink(self): """Return number of hard links.""" if self.mask & self._STATX_NLINK: return self._struct_statx_buf.stx_nlink return None
Return number of hard links.
Return number of hard links.
[ "Return", "number", "of", "hard", "links", "." ]
def st_nlink(self): if self.mask & self._STATX_NLINK: return self._struct_statx_buf.stx_nlink return None
[ "def", "st_nlink", "(", "self", ")", ":", "if", "self", ".", "mask", "&", "self", ".", "_STATX_NLINK", ":", "return", "self", ".", "_struct_statx_buf", ".", "stx_nlink", "return", "None" ]
Return number of hard links.
[ "Return", "number", "of", "hard", "links", "." ]
[ "\"\"\"Return number of hard links.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
st_uid
<not_specific>
def st_uid(self): """Return user ID of owner.""" if self.mask & self._STATX_UID: return self._struct_statx_buf.stx_uid return None
Return user ID of owner.
Return user ID of owner.
[ "Return", "user", "ID", "of", "owner", "." ]
def st_uid(self): if self.mask & self._STATX_UID: return self._struct_statx_buf.stx_uid return None
[ "def", "st_uid", "(", "self", ")", ":", "if", "self", ".", "mask", "&", "self", ".", "_STATX_UID", ":", "return", "self", ".", "_struct_statx_buf", ".", "stx_uid", "return", "None" ]
Return user ID of owner.
[ "Return", "user", "ID", "of", "owner", "." ]
[ "\"\"\"Return user ID of owner.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
st_gid
<not_specific>
def st_gid(self): """Return group ID of owner.""" if self.mask & self._STATX_GID: return self._struct_statx_buf.stx_gid return None
Return group ID of owner.
Return group ID of owner.
[ "Return", "group", "ID", "of", "owner", "." ]
def st_gid(self): if self.mask & self._STATX_GID: return self._struct_statx_buf.stx_gid return None
[ "def", "st_gid", "(", "self", ")", ":", "if", "self", ".", "mask", "&", "self", ".", "_STATX_GID", ":", "return", "self", ".", "_struct_statx_buf", ".", "stx_gid", "return", "None" ]
Return group ID of owner.
[ "Return", "group", "ID", "of", "owner", "." ]
[ "\"\"\"Return group ID of owner.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
st_size
<not_specific>
def st_size(self): """Return total size in bytes.""" if self.mask & self._STATX_SIZE: return self._struct_statx_buf.stx_size return None
Return total size in bytes.
Return total size in bytes.
[ "Return", "total", "size", "in", "bytes", "." ]
def st_size(self): if self.mask & self._STATX_SIZE: return self._struct_statx_buf.stx_size return None
[ "def", "st_size", "(", "self", ")", ":", "if", "self", ".", "mask", "&", "self", ".", "_STATX_SIZE", ":", "return", "self", ".", "_struct_statx_buf", ".", "stx_size", "return", "None" ]
Return total size in bytes.
[ "Return", "total", "size", "in", "bytes", "." ]
[ "\"\"\"Return total size in bytes.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
st_blocks
<not_specific>
def st_blocks(self): """Return number of 512B blocks allocated.""" if self.mask & self._STATX_BLOCKS: return self._struct_statx_buf.stx_blocks return None
Return number of 512B blocks allocated.
Return number of 512B blocks allocated.
[ "Return", "number", "of", "512B", "blocks", "allocated", "." ]
def st_blocks(self): if self.mask & self._STATX_BLOCKS: return self._struct_statx_buf.stx_blocks return None
[ "def", "st_blocks", "(", "self", ")", ":", "if", "self", ".", "mask", "&", "self", ".", "_STATX_BLOCKS", ":", "return", "self", ".", "_struct_statx_buf", ".", "stx_blocks", "return", "None" ]
Return number of 512B blocks allocated.
[ "Return", "number", "of", "512B", "blocks", "allocated", "." ]
[ "\"\"\"Return number of 512B blocks allocated.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
st_atime
<not_specific>
def st_atime(self): """Return the last access time.""" if self.mask & self._STATX_ATIME: return _stx_timestamp(self._struct_statx_buf.stx_atime) return None
Return the last access time.
Return the last access time.
[ "Return", "the", "last", "access", "time", "." ]
def st_atime(self): if self.mask & self._STATX_ATIME: return _stx_timestamp(self._struct_statx_buf.stx_atime) return None
[ "def", "st_atime", "(", "self", ")", ":", "if", "self", ".", "mask", "&", "self", ".", "_STATX_ATIME", ":", "return", "_stx_timestamp", "(", "self", ".", "_struct_statx_buf", ".", "stx_atime", ")", "return", "None" ]
Return the last access time.
[ "Return", "the", "last", "access", "time", "." ]
[ "\"\"\"Return the last access time.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e86560c52df2c47a88cfb7b97c2a5daae5b73621
kero99/docker-forensics
mac-robber.py
[ "BSD-3-Clause" ]
Python
statx
<not_specific>
def statx(filepath, no_automount=False, follow_symlinks=True, get_basic_stats=False, get_filesize_only=False, force_sync=False, dont_sync=False): """Return statx data buffer object.""" return _Statx(filepath, no_automount=no_automount...
Return statx data buffer object.
Return statx data buffer object.
[ "Return", "statx", "data", "buffer", "object", "." ]
def statx(filepath, no_automount=False, follow_symlinks=True, get_basic_stats=False, get_filesize_only=False, force_sync=False, dont_sync=False): return _Statx(filepath, no_automount=no_automount, follow_symlinks=follow_...
[ "def", "statx", "(", "filepath", ",", "no_automount", "=", "False", ",", "follow_symlinks", "=", "True", ",", "get_basic_stats", "=", "False", ",", "get_filesize_only", "=", "False", ",", "force_sync", "=", "False", ",", "dont_sync", "=", "False", ")", ":", ...
Return statx data buffer object.
[ "Return", "statx", "data", "buffer", "object", "." ]
[ "\"\"\"Return statx data buffer object.\"\"\"" ]
[ { "param": "filepath", "type": null }, { "param": "no_automount", "type": null }, { "param": "follow_symlinks", "type": null }, { "param": "get_basic_stats", "type": null }, { "param": "get_filesize_only", "type": null }, { "param": "force_sync", "...
{ "returns": [], "raises": [], "params": [ { "identifier": "filepath", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "no_automount", "type": null, "docstring": null, "docstrin...
de2c38f47f669d468d3ba2fa8795302fc92d48f5
roym899/yoco
yoco.py
[ "MIT" ]
Python
load_config_from_args
dict
def load_config_from_args( parser: _argparse.ArgumentParser, args: Optional[list] = None, search_paths: Optional[List[str]] = None, ) -> dict: """Parse arguments and load configs into a config dictionary. Strings following -- will be used as key. Dots in that string are used to access nested di...
Parse arguments and load configs into a config dictionary. Strings following -- will be used as key. Dots in that string are used to access nested dictionaries. YAML will be used for type conversion of the value. Args: parser: Parser used to parse known and unknown arguments. ...
Parse arguments and load configs into a config dictionary. Strings following -- will be used as key. Dots in that string are used to access nested dictionaries. YAML will be used for type conversion of the value.
[ "Parse", "arguments", "and", "load", "configs", "into", "a", "config", "dictionary", ".", "Strings", "following", "--", "will", "be", "used", "as", "key", ".", "Dots", "in", "that", "string", "are", "used", "to", "access", "nested", "dictionaries", ".", "Y...
def load_config_from_args( parser: _argparse.ArgumentParser, args: Optional[list] = None, search_paths: Optional[List[str]] = None, ) -> dict: no_default_parser = copy.deepcopy(parser) for a in no_default_parser._actions: if a.dest != "config": a.default = None known, other_a...
[ "def", "load_config_from_args", "(", "parser", ":", "_argparse", ".", "ArgumentParser", ",", "args", ":", "Optional", "[", "list", "]", "=", "None", ",", "search_paths", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", ")", "->", "...
Parse arguments and load configs into a config dictionary.
[ "Parse", "arguments", "and", "load", "configs", "into", "a", "config", "dictionary", "." ]
[ "\"\"\"Parse arguments and load configs into a config dictionary.\n\n Strings following -- will be used as key. Dots in that string are used to access\n nested dictionaries. YAML will be used for type conversion of the value.\n\n Args:\n parser:\n Parser used to parse known and unknown ar...
[ { "param": "parser", "type": "_argparse.ArgumentParser" }, { "param": "args", "type": "Optional[list]" }, { "param": "search_paths", "type": "Optional[List[str]]" } ]
{ "returns": [ { "docstring": "Loaded configuration dictionary.", "docstring_tokens": [ "Loaded", "configuration", "dictionary", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "parser", "type": "_argparse.Argumen...
de2c38f47f669d468d3ba2fa8795302fc92d48f5
roym899/yoco
yoco.py
[ "MIT" ]
Python
load_config_from_file
dict
def load_config_from_file( path: str, current_dict: Optional[dict] = None, parent: Optional[str] = None, search_paths: Optional[List[str]] = None, ) -> dict: """Load configuration from a file. Args: path: Path of YAML file to load. current_dict: Current configuration...
Load configuration from a file. Args: path: Path of YAML file to load. current_dict: Current configuration dictionary. Will not be modified. If None, an empty dictionary will be created. parent: Parent directory. If not None, path will be assu...
Load configuration from a file.
[ "Load", "configuration", "from", "a", "file", "." ]
def load_config_from_file( path: str, current_dict: Optional[dict] = None, parent: Optional[str] = None, search_paths: Optional[List[str]] = None, ) -> dict: if current_dict is None: current_dict = {} full_path = resolve_path(path, parent, search_paths) parent = _os.path.dirname(full...
[ "def", "load_config_from_file", "(", "path", ":", "str", ",", "current_dict", ":", "Optional", "[", "dict", "]", "=", "None", ",", "parent", ":", "Optional", "[", "str", "]", "=", "None", ",", "search_paths", ":", "Optional", "[", "List", "[", "str", "...
Load configuration from a file.
[ "Load", "configuration", "from", "a", "file", "." ]
[ "\"\"\"Load configuration from a file.\n\n Args:\n path: Path of YAML file to load.\n current_dict:\n Current configuration dictionary. Will not be modified.\n If None, an empty dictionary will be created.\n parent:\n Parent directory.\n If not Non...
[ { "param": "path", "type": "str" }, { "param": "current_dict", "type": "Optional[dict]" }, { "param": "parent", "type": "Optional[str]" }, { "param": "search_paths", "type": "Optional[List[str]]" } ]
{ "returns": [ { "docstring": "Updated configuration dictionary.", "docstring_tokens": [ "Updated", "configuration", "dictionary", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "path", "type": "str", "docs...
de2c38f47f669d468d3ba2fa8795302fc92d48f5
roym899/yoco
yoco.py
[ "MIT" ]
Python
load_config
dict
def load_config( config_dict: dict, current_dict: Optional[dict] = None, parent: Optional[str] = None, search_paths: Optional[List[str]] = None, ) -> dict: """Load a config dictionary. If a key is already in current_dict, config_dict will overwrite it. Args: config_dict: Configurat...
Load a config dictionary. If a key is already in current_dict, config_dict will overwrite it. Args: config_dict: Configuration dictionary to be parsed. current_dict: Current configuration dictionary to be updated, will not be changed. parent: Path of parent config. Used to ...
Load a config dictionary. If a key is already in current_dict, config_dict will overwrite it.
[ "Load", "a", "config", "dictionary", ".", "If", "a", "key", "is", "already", "in", "current_dict", "config_dict", "will", "overwrite", "it", "." ]
def load_config( config_dict: dict, current_dict: Optional[dict] = None, parent: Optional[str] = None, search_paths: Optional[List[str]] = None, ) -> dict: config_dict = copy.deepcopy(config_dict) if current_dict is None: current_dict = {} else: current_dict = copy.deepcopy(c...
[ "def", "load_config", "(", "config_dict", ":", "dict", ",", "current_dict", ":", "Optional", "[", "dict", "]", "=", "None", ",", "parent", ":", "Optional", "[", "str", "]", "=", "None", ",", "search_paths", ":", "Optional", "[", "List", "[", "str", "]"...
Load a config dictionary.
[ "Load", "a", "config", "dictionary", "." ]
[ "\"\"\"Load a config dictionary.\n\n If a key is already in current_dict, config_dict will overwrite it.\n\n Args:\n config_dict: Configuration dictionary to be parsed.\n current_dict:\n Current configuration dictionary to be updated, will not be changed.\n parent: Path of pare...
[ { "param": "config_dict", "type": "dict" }, { "param": "current_dict", "type": "Optional[dict]" }, { "param": "parent", "type": "Optional[str]" }, { "param": "search_paths", "type": "Optional[List[str]]" } ]
{ "returns": [ { "docstring": "Loaded / updated configuration dictionary.", "docstring_tokens": [ "Loaded", "/", "updated", "configuration", "dictionary", "." ], "type": null } ], "raises": [], "params": [ { "identifier": ...
de2c38f47f669d468d3ba2fa8795302fc92d48f5
roym899/yoco
yoco.py
[ "MIT" ]
Python
_merge_dictionaries
dict
def _merge_dictionaries(start_dict: dict, added_dict: dict) -> dict: """Create a dictionary by merging one into another. Keys present in start_dict will be overwritten by added_dict. Args: start_dict: The starting dictionary. added_dict: The dictionary to merge into current_dictionary. ...
Create a dictionary by merging one into another. Keys present in start_dict will be overwritten by added_dict. Args: start_dict: The starting dictionary. added_dict: The dictionary to merge into current_dictionary. Returns: The merged dictionary.
Create a dictionary by merging one into another. Keys present in start_dict will be overwritten by added_dict.
[ "Create", "a", "dictionary", "by", "merging", "one", "into", "another", ".", "Keys", "present", "in", "start_dict", "will", "be", "overwritten", "by", "added_dict", "." ]
def _merge_dictionaries(start_dict: dict, added_dict: dict) -> dict: merged_dictionary = copy.deepcopy(start_dict) for key, value in added_dict.items(): if ( key in start_dict and isinstance(start_dict[key], dict) and isinstance(added_dict[key], dict) ): ...
[ "def", "_merge_dictionaries", "(", "start_dict", ":", "dict", ",", "added_dict", ":", "dict", ")", "->", "dict", ":", "merged_dictionary", "=", "copy", ".", "deepcopy", "(", "start_dict", ")", "for", "key", ",", "value", "in", "added_dict", ".", "items", "...
Create a dictionary by merging one into another.
[ "Create", "a", "dictionary", "by", "merging", "one", "into", "another", "." ]
[ "\"\"\"Create a dictionary by merging one into another.\n\n Keys present in start_dict will be overwritten by added_dict.\n\n Args:\n start_dict: The starting dictionary.\n added_dict: The dictionary to merge into current_dictionary.\n\n Returns:\n The merged dictionary.\n \"\"\"" ]
[ { "param": "start_dict", "type": "dict" }, { "param": "added_dict", "type": "dict" } ]
{ "returns": [ { "docstring": "The merged dictionary.", "docstring_tokens": [ "The", "merged", "dictionary", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "start_dict", "type": "dict", "docstring": "The st...
de2c38f47f669d468d3ba2fa8795302fc92d48f5
roym899/yoco
yoco.py
[ "MIT" ]
Python
_resolve_paths_recursively
None
def _resolve_paths_recursively(config_dict: dict, parent: str) -> None: """Resolve relative paths in values of config dict. Only strings starting with ./, ../, ~/ are handled, since general strings might otherwise be falsely handled as paths. """ for key, value in config_dict.items(): if is...
Resolve relative paths in values of config dict. Only strings starting with ./, ../, ~/ are handled, since general strings might otherwise be falsely handled as paths.
Resolve relative paths in values of config dict. Only strings starting with ./, ../, ~/ are handled, since general strings might otherwise be falsely handled as paths.
[ "Resolve", "relative", "paths", "in", "values", "of", "config", "dict", ".", "Only", "strings", "starting", "with", ".", "/", "..", "/", "~", "/", "are", "handled", "since", "general", "strings", "might", "otherwise", "be", "falsely", "handled", "as", "pat...
def _resolve_paths_recursively(config_dict: dict, parent: str) -> None: for key, value in config_dict.items(): if isinstance(config_dict[key], dict): _resolve_paths_recursively(config_dict[key], parent) elif isinstance(value, str) and ( value.startswith("./") or value.startsw...
[ "def", "_resolve_paths_recursively", "(", "config_dict", ":", "dict", ",", "parent", ":", "str", ")", "->", "None", ":", "for", "key", ",", "value", "in", "config_dict", ".", "items", "(", ")", ":", "if", "isinstance", "(", "config_dict", "[", "key", "]"...
Resolve relative paths in values of config dict.
[ "Resolve", "relative", "paths", "in", "values", "of", "config", "dict", "." ]
[ "\"\"\"Resolve relative paths in values of config dict.\n\n Only strings starting with ./, ../, ~/ are handled, since general strings might\n otherwise be falsely handled as paths.\n \"\"\"" ]
[ { "param": "config_dict", "type": "dict" }, { "param": "parent", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "config_dict", "type": "dict", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parent", "type": "str", "docstring": null, "docstrin...
076213de053c56b91d94bc9727644280c32bb4fb
leszkolukasz/minimalistic_english_vocabulary_app
scripts/old_scripts/clean_database.py
[ "MIT" ]
Python
clean_database
null
def clean_database(): """ Get rid of letters and nonbase forms of words """ dictionary = create_database.get_dictionary() with open('data/cleaned_dictionary.txt', 'r+') as saved: for line in saved: word, frequency, position = line.split() frequency, position = map(i...
Get rid of letters and nonbase forms of words
Get rid of letters and nonbase forms of words
[ "Get", "rid", "of", "letters", "and", "nonbase", "forms", "of", "words" ]
def clean_database(): dictionary = create_database.get_dictionary() with open('data/cleaned_dictionary.txt', 'r+') as saved: for line in saved: word, frequency, position = line.split() frequency, position = map(int, [frequency, position]) for cnt, (word, frequency) in enu...
[ "def", "clean_database", "(", ")", ":", "dictionary", "=", "create_database", ".", "get_dictionary", "(", ")", "with", "open", "(", "'data/cleaned_dictionary.txt'", ",", "'r+'", ")", "as", "saved", ":", "for", "line", "in", "saved", ":", "word", ",", "freque...
Get rid of letters and nonbase forms of words
[ "Get", "rid", "of", "letters", "and", "nonbase", "forms", "of", "words" ]
[ "\"\"\"\n Get rid of letters and nonbase forms of words\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
a9a737806c4cfd275e1e1112572cd151e354cdcb
leszkolukasz/minimalistic_english_vocabulary_app
scripts/old_scripts/clean_further.py
[ "MIT" ]
Python
clean_database
null
def clean_database(): """ Get rid of word with no entry in PyDictionary """ dictionary = PyDictionary.PyDictionary() with open('data/cleaned_dictionary.txt', 'r') as saved, open('data/cleaned_dictionary_v2.txt', 'r+') as destination: for line in destination: word, frequency, po...
Get rid of word with no entry in PyDictionary
Get rid of word with no entry in PyDictionary
[ "Get", "rid", "of", "word", "with", "no", "entry", "in", "PyDictionary" ]
def clean_database(): dictionary = PyDictionary.PyDictionary() with open('data/cleaned_dictionary.txt', 'r') as saved, open('data/cleaned_dictionary_v2.txt', 'r+') as destination: for line in destination: word, frequency, position = line.split() frequency, position = map(int, [fr...
[ "def", "clean_database", "(", ")", ":", "dictionary", "=", "PyDictionary", ".", "PyDictionary", "(", ")", "with", "open", "(", "'data/cleaned_dictionary.txt'", ",", "'r'", ")", "as", "saved", ",", "open", "(", "'data/cleaned_dictionary_v2.txt'", ",", "'r+'", ")"...
Get rid of word with no entry in PyDictionary
[ "Get", "rid", "of", "word", "with", "no", "entry", "in", "PyDictionary" ]
[ "\"\"\"\n Get rid of word with no entry in PyDictionary\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
806a9d3edcdc502b1f87db1711addd36900c2f28
bodgerbarnett/django-rest-email-manager
rest_email_manager/app_settings.py
[ "BSD-3-Clause" ]
Python
_setting
<not_specific>
def _setting(self, name, default): """ Retrieve a setting from the current Django settings. Settings are retrieved from the ``REST_EMAIL_MANAGER`` dict in the settings file. Args: name (str): The name of the setting to retrieve. default: ...
Retrieve a setting from the current Django settings. Settings are retrieved from the ``REST_EMAIL_MANAGER`` dict in the settings file. Args: name (str): The name of the setting to retrieve. default: The setting's default value. ...
Retrieve a setting from the current Django settings. Settings are retrieved from the ``REST_EMAIL_MANAGER`` dict in the settings file.
[ "Retrieve", "a", "setting", "from", "the", "current", "Django", "settings", ".", "Settings", "are", "retrieved", "from", "the", "`", "`", "REST_EMAIL_MANAGER", "`", "`", "dict", "in", "the", "settings", "file", "." ]
def _setting(self, name, default): from django.conf import settings settings_dict = getattr(settings, "REST_EMAIL_MANAGER", {}) return settings_dict.get(name, default)
[ "def", "_setting", "(", "self", ",", "name", ",", "default", ")", ":", "from", "django", ".", "conf", "import", "settings", "settings_dict", "=", "getattr", "(", "settings", ",", "\"REST_EMAIL_MANAGER\"", ",", "{", "}", ")", "return", "settings_dict", ".", ...
Retrieve a setting from the current Django settings.
[ "Retrieve", "a", "setting", "from", "the", "current", "Django", "settings", "." ]
[ "\"\"\"\n Retrieve a setting from the current Django settings.\n Settings are retrieved from the ``REST_EMAIL_MANAGER`` dict in the\n settings file.\n Args:\n name (str):\n The name of the setting to retrieve.\n default:\n The setting's...
[ { "param": "self", "type": null }, { "param": "name", "type": null }, { "param": "default", "type": null } ]
{ "returns": [ { "docstring": "The value provided in the settings dictionary if it exists.\nThe default value is returned otherwise.", "docstring_tokens": [ "The", "value", "provided", "in", "the", "settings", "dictionary", "if", ...
806a9d3edcdc502b1f87db1711addd36900c2f28
bodgerbarnett/django-rest-email-manager
rest_email_manager/app_settings.py
[ "BSD-3-Clause" ]
Python
SEND_VERIFICATION_EMAIL
<not_specific>
def SEND_VERIFICATION_EMAIL(self): """ The function that sends the verification email """ return self._setting( "SEND_VERIFICATION_EMAIL", "rest_email_manager.utils.send_verification_email", )
The function that sends the verification email
The function that sends the verification email
[ "The", "function", "that", "sends", "the", "verification", "email" ]
def SEND_VERIFICATION_EMAIL(self): return self._setting( "SEND_VERIFICATION_EMAIL", "rest_email_manager.utils.send_verification_email", )
[ "def", "SEND_VERIFICATION_EMAIL", "(", "self", ")", ":", "return", "self", ".", "_setting", "(", "\"SEND_VERIFICATION_EMAIL\"", ",", "\"rest_email_manager.utils.send_verification_email\"", ",", ")" ]
The function that sends the verification email
[ "The", "function", "that", "sends", "the", "verification", "email" ]
[ "\"\"\"\n The function that sends the verification email\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
806a9d3edcdc502b1f87db1711addd36900c2f28
bodgerbarnett/django-rest-email-manager
rest_email_manager/app_settings.py
[ "BSD-3-Clause" ]
Python
SEND_NOTIFICATION_EMAIL
<not_specific>
def SEND_NOTIFICATION_EMAIL(self): """ The function that sends the notification email """ return self._setting( "SEND_NOTIFICATION_EMAIL", "rest_email_manager.utils.send_notification_email", )
The function that sends the notification email
The function that sends the notification email
[ "The", "function", "that", "sends", "the", "notification", "email" ]
def SEND_NOTIFICATION_EMAIL(self): return self._setting( "SEND_NOTIFICATION_EMAIL", "rest_email_manager.utils.send_notification_email", )
[ "def", "SEND_NOTIFICATION_EMAIL", "(", "self", ")", ":", "return", "self", ".", "_setting", "(", "\"SEND_NOTIFICATION_EMAIL\"", ",", "\"rest_email_manager.utils.send_notification_email\"", ",", ")" ]
The function that sends the notification email
[ "The", "function", "that", "sends", "the", "notification", "email" ]
[ "\"\"\"\n The function that sends the notification email\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f83e55f97a55927a2101f333c388af4a0c2b9cdf
wandering-tales/django-miny-tiny-url
url_shortener/views.py
[ "MIT" ]
Python
retrieve
<not_specific>
def retrieve(self, request, *args, **kwargs): """ Override the model instance retrieval method. Instead of building a standard response with the model instance, it redirects the short URL to the real, longer URL ('url' model field) it's linked to. Just before the redirect...
Override the model instance retrieval method. Instead of building a standard response with the model instance, it redirects the short URL to the real, longer URL ('url' model field) it's linked to. Just before the redirection is performed the 'usage_count' model field is...
Override the model instance retrieval method. Instead of building a standard response with the model instance, it redirects the short URL to the real, longer URL ('url' model field) it's linked to. Just before the redirection is performed the 'usage_count' model field is incremented.
[ "Override", "the", "model", "instance", "retrieval", "method", ".", "Instead", "of", "building", "a", "standard", "response", "with", "the", "model", "instance", "it", "redirects", "the", "short", "URL", "to", "the", "real", "longer", "URL", "(", "'", "url",...
def retrieve(self, request, *args, **kwargs): instance = self.get_object() instance.usage_count += 1 instance.save() return HttpResponsePermanentRedirect(instance.url)
[ "def", "retrieve", "(", "self", ",", "request", ",", "*", "args", ",", "**", "kwargs", ")", ":", "instance", "=", "self", ".", "get_object", "(", ")", "instance", ".", "usage_count", "+=", "1", "instance", ".", "save", "(", ")", "return", "HttpResponse...
Override the model instance retrieval method.
[ "Override", "the", "model", "instance", "retrieval", "method", "." ]
[ "\"\"\"\n Override the model instance retrieval method.\n Instead of building a standard response with the model instance,\n it redirects the short URL to the real, longer URL ('url' model field)\n it's linked to.\n Just before the redirection is performed the 'usage_count' model ...
[ { "param": "self", "type": null }, { "param": "request", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request", "type": null, "docstring": null, "docstring_tokens"...
cd529bdda8b163b0ae613f2b22526c2d1fdfa4e6
wandering-tales/django-miny-tiny-url
django_miny_tiny_url/contrib/sites/migrations/0003_set_site_domain_and_name.py
[ "MIT" ]
Python
update_site_forward
null
def update_site_forward(apps, schema_editor): """Set site domain and name.""" Site = apps.get_model("sites", "Site") Site.objects.update_or_create( id=settings.SITE_ID, defaults={ "domain": "example.com", "name": "Django Miny Tiny URL", }, )
Set site domain and name.
Set site domain and name.
[ "Set", "site", "domain", "and", "name", "." ]
def update_site_forward(apps, schema_editor): Site = apps.get_model("sites", "Site") Site.objects.update_or_create( id=settings.SITE_ID, defaults={ "domain": "example.com", "name": "Django Miny Tiny URL", }, )
[ "def", "update_site_forward", "(", "apps", ",", "schema_editor", ")", ":", "Site", "=", "apps", ".", "get_model", "(", "\"sites\"", ",", "\"Site\"", ")", "Site", ".", "objects", ".", "update_or_create", "(", "id", "=", "settings", ".", "SITE_ID", ",", "def...
Set site domain and name.
[ "Set", "site", "domain", "and", "name", "." ]
[ "\"\"\"Set site domain and name.\"\"\"" ]
[ { "param": "apps", "type": null }, { "param": "schema_editor", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "apps", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "schema_editor", "type": null, "docstring": null, "docstring_t...
3f2ebf00300b6e910667ed2214e3a34c6fe81a07
wandering-tales/django-miny-tiny-url
url_shortener/baseconv.py
[ "MIT" ]
Python
_convert
<not_specific>
def _convert(number, fromdigits, todigits): """ Converts a "number" between two bases of arbitrary digits. The input number is assumed to be a string of digits from the 'fromdigits' string (which is in order of smallest to largest digit). The return value is a string of elements...
Converts a "number" between two bases of arbitrary digits. The input number is assumed to be a string of digits from the 'fromdigits' string (which is in order of smallest to largest digit). The return value is a string of elements from 'todigits' (ordered in the same way). The...
Converts a "number" between two bases of arbitrary digits. The input number is assumed to be a string of digits from the 'fromdigits' string (which is in order of smallest to largest digit). The return value is a string of elements from 'todigits' (ordered in the same way). The input and output bases are determined fro...
[ "Converts", "a", "\"", "number", "\"", "between", "two", "bases", "of", "arbitrary", "digits", ".", "The", "input", "number", "is", "assumed", "to", "be", "a", "string", "of", "digits", "from", "the", "'", "fromdigits", "'", "string", "(", "which", "is",...
def _convert(number, fromdigits, todigits): if str(number)[0] == '-': number, neg = str(number)[1:], 1 else: neg = 0 x = 0 for digit in str(number): x = x * len(fromdigits) + fromdigits.index(digit) if x == 0: res = todigits[0] ...
[ "def", "_convert", "(", "number", ",", "fromdigits", ",", "todigits", ")", ":", "if", "str", "(", "number", ")", "[", "0", "]", "==", "'-'", ":", "number", ",", "neg", "=", "str", "(", "number", ")", "[", "1", ":", "]", ",", "1", "else", ":", ...
Converts a "number" between two bases of arbitrary digits.
[ "Converts", "a", "\"", "number", "\"", "between", "two", "bases", "of", "arbitrary", "digits", "." ]
[ "\"\"\"\n Converts a \"number\" between two bases of arbitrary digits.\n\n The input number is assumed to be a string of digits from the\n 'fromdigits' string (which is in order of smallest to largest digit).\n The return value is a string of elements from 'todigits'\n (ordered in...
[ { "param": "number", "type": null }, { "param": "fromdigits", "type": null }, { "param": "todigits", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "number", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fromdigits", "type": null, "docstring": null, "docstring_to...
c6206bf0e8f3f77a0a51b4130af45f1bda743fb7
LemonNoel/models
PaddleRec/ncf/evaluate.py
[ "Apache-2.0" ]
Python
evaluate_model
<not_specific>
def evaluate_model(args, testRatings, testNegatives, K, model_path): """ Evaluate the performance (Hit_Ratio, NDCG) of top-K recommendation Return: score of each test rating. """ global _model global _testRatings global _testNegatives global _K global _model_path global _args ...
Evaluate the performance (Hit_Ratio, NDCG) of top-K recommendation Return: score of each test rating.
Evaluate the performance (Hit_Ratio, NDCG) of top-K recommendation Return: score of each test rating.
[ "Evaluate", "the", "performance", "(", "Hit_Ratio", "NDCG", ")", "of", "top", "-", "K", "recommendation", "Return", ":", "score", "of", "each", "test", "rating", "." ]
def evaluate_model(args, testRatings, testNegatives, K, model_path): global _model global _testRatings global _testNegatives global _K global _model_path global _args _args = args _model_path= model_path _testRatings = testRatings _testNegatives = testNegatives _K = K hi...
[ "def", "evaluate_model", "(", "args", ",", "testRatings", ",", "testNegatives", ",", "K", ",", "model_path", ")", ":", "global", "_model", "global", "_testRatings", "global", "_testNegatives", "global", "_K", "global", "_model_path", "global", "_args", "_args", ...
Evaluate the performance (Hit_Ratio, NDCG) of top-K recommendation Return: score of each test rating.
[ "Evaluate", "the", "performance", "(", "Hit_Ratio", "NDCG", ")", "of", "top", "-", "K", "recommendation", "Return", ":", "score", "of", "each", "test", "rating", "." ]
[ "\"\"\"\n Evaluate the performance (Hit_Ratio, NDCG) of top-K recommendation\n Return: score of each test rating.\n \"\"\"" ]
[ { "param": "args", "type": null }, { "param": "testRatings", "type": null }, { "param": "testNegatives", "type": null }, { "param": "K", "type": null }, { "param": "model_path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "args", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "testRatings", "type": null, "docstring": null, "docstring_tok...
05ac96e99bd3e400ae82aa66917b285f1473e15c
mrichardson03/panos-ips-reports
panos_util/policies.py
[ "Apache-2.0" ]
Python
create_from_element
SecurityRule
def create_from_element(e: Element) -> SecurityRule: """Create SecurityRule from XML element.""" name = e.get("name") action = strip_empty(e.findtext("action")) disabled = strip_empty(e.findtext("disabled")) if disabled == "yes": disabled = True else: ...
Create SecurityRule from XML element.
Create SecurityRule from XML element.
[ "Create", "SecurityRule", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> SecurityRule: name = e.get("name") action = strip_empty(e.findtext("action")) disabled = strip_empty(e.findtext("disabled")) if disabled == "yes": disabled = True else: disabled = False security_profile_group ...
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "SecurityRule", ":", "name", "=", "e", ".", "get", "(", "\"name\"", ")", "action", "=", "strip_empty", "(", "e", ".", "findtext", "(", "\"action\"", ")", ")", "disabled", "=", "strip_empt...
Create SecurityRule from XML element.
[ "Create", "SecurityRule", "from", "XML", "element", "." ]
[ "\"\"\"Create SecurityRule from XML element.\"\"\"" ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28d3dfb9c0d00c9d24292f0413ba21f9c486107f
mrichardson03/panos-ips-reports
panos_util/__init__.py
[ "Apache-2.0" ]
Python
strip_empty
str
def strip_empty(s: str) -> str: """If s is empty, return None. This is needed because getting the text attribute for an XML element returns an empty string if the element is empty. For example, the text attribute of XML element '<element/>' will be the empty string, not None. """ if s == "": ...
If s is empty, return None. This is needed because getting the text attribute for an XML element returns an empty string if the element is empty. For example, the text attribute of XML element '<element/>' will be the empty string, not None.
If s is empty, return None. This is needed because getting the text attribute for an XML element returns an empty string if the element is empty. For example, the text attribute of XML element '' will be the empty string, not None.
[ "If", "s", "is", "empty", "return", "None", ".", "This", "is", "needed", "because", "getting", "the", "text", "attribute", "for", "an", "XML", "element", "returns", "an", "empty", "string", "if", "the", "element", "is", "empty", ".", "For", "example", "t...
def strip_empty(s: str) -> str: if s == "": return None else: return s
[ "def", "strip_empty", "(", "s", ":", "str", ")", "->", "str", ":", "if", "s", "==", "\"\"", ":", "return", "None", "else", ":", "return", "s" ]
If s is empty, return None.
[ "If", "s", "is", "empty", "return", "None", "." ]
[ "\"\"\"If s is empty, return None.\n\n This is needed because getting the text attribute for an XML element returns\n an empty string if the element is empty. For example, the text attribute of\n XML element '<element/>' will be the empty string, not None.\n \"\"\"" ]
[ { "param": "s", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
398432fe9a14b01bd955bb734855bc482d32aad9
mrichardson03/panos-ips-reports
panos_util/panorama.py
[ "Apache-2.0" ]
Python
create_from_element
Panorama
def create_from_element(e: Element) -> Panorama: """Create Panorama object from XML element.""" device_groups = {} shared_e = e.find("./shared") shared_obj = DeviceGroup.create_from_element(shared_e) shared_obj.name = "shared" # Helps with debugging. device_groups.updat...
Create Panorama object from XML element.
Create Panorama object from XML element.
[ "Create", "Panorama", "object", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> Panorama: device_groups = {} shared_e = e.find("./shared") shared_obj = DeviceGroup.create_from_element(shared_e) shared_obj.name = "shared" device_groups.update({"shared": shared_obj}) for dg_e in e.findall("./devices/entry/device...
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "Panorama", ":", "device_groups", "=", "{", "}", "shared_e", "=", "e", ".", "find", "(", "\"./shared\"", ")", "shared_obj", "=", "DeviceGroup", ".", "create_from_element", "(", "shared_e", ")...
Create Panorama object from XML element.
[ "Create", "Panorama", "object", "from", "XML", "element", "." ]
[ "\"\"\"Create Panorama object from XML element.\"\"\"", "# Helps with debugging.", "# Properly set parent device group.", "# If no 'parent-dg' element was defined, parent is 'shared'.", "# Get parent object out of DG hash, set reference on current object." ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
398432fe9a14b01bd955bb734855bc482d32aad9
mrichardson03/panos-ips-reports
panos_util/panorama.py
[ "Apache-2.0" ]
Python
rule_counts
Counter
def rule_counts(self, force_update=False) -> Counter: """Returns a Counter object containing stats for this DeviceGroup.""" if self._rule_counts is None: self._rule_counts = Counter() self._update_rule_counts() else: if force_update is True: # pragma: no cove...
Returns a Counter object containing stats for this DeviceGroup.
Returns a Counter object containing stats for this DeviceGroup.
[ "Returns", "a", "Counter", "object", "containing", "stats", "for", "this", "DeviceGroup", "." ]
def rule_counts(self, force_update=False) -> Counter: if self._rule_counts is None: self._rule_counts = Counter() self._update_rule_counts() else: if force_update is True: self._update_rule_counts() return self._rule_counts
[ "def", "rule_counts", "(", "self", ",", "force_update", "=", "False", ")", "->", "Counter", ":", "if", "self", ".", "_rule_counts", "is", "None", ":", "self", ".", "_rule_counts", "=", "Counter", "(", ")", "self", ".", "_update_rule_counts", "(", ")", "e...
Returns a Counter object containing stats for this DeviceGroup.
[ "Returns", "a", "Counter", "object", "containing", "stats", "for", "this", "DeviceGroup", "." ]
[ "\"\"\"Returns a Counter object containing stats for this DeviceGroup.\"\"\"", "# pragma: no cover" ]
[ { "param": "self", "type": null }, { "param": "force_update", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "force_update", "type": null, "docstring": null, "docstring_to...
398432fe9a14b01bd955bb734855bc482d32aad9
mrichardson03/panos-ips-reports
panos_util/panorama.py
[ "Apache-2.0" ]
Python
_update_rule_counts
None
def _update_rule_counts(self) -> None: """Recalculates the rule stats for this DeviceGroup.""" for rule in self.rules: self._rule_counts["total"] += 1 if rule.disabled is False: self._rule_counts[rule.action] += 1 vp = None if rul...
Recalculates the rule stats for this DeviceGroup.
Recalculates the rule stats for this DeviceGroup.
[ "Recalculates", "the", "rule", "stats", "for", "this", "DeviceGroup", "." ]
def _update_rule_counts(self) -> None: for rule in self.rules: self._rule_counts["total"] += 1 if rule.disabled is False: self._rule_counts[rule.action] += 1 vp = None if rule.vulnerability_profile is not None: vp = self...
[ "def", "_update_rule_counts", "(", "self", ")", "->", "None", ":", "for", "rule", "in", "self", ".", "rules", ":", "self", ".", "_rule_counts", "[", "\"total\"", "]", "+=", "1", "if", "rule", ".", "disabled", "is", "False", ":", "self", ".", "_rule_cou...
Recalculates the rule stats for this DeviceGroup.
[ "Recalculates", "the", "rule", "stats", "for", "this", "DeviceGroup", "." ]
[ "\"\"\"Recalculates the rule stats for this DeviceGroup.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
398432fe9a14b01bd955bb734855bc482d32aad9
mrichardson03/panos-ips-reports
panos_util/panorama.py
[ "Apache-2.0" ]
Python
resolve_profile
VulnerabilityProfile
def resolve_profile(self, name: str) -> VulnerabilityProfile: """Looks up a VulnerabiltyProfile by name.""" profile = self.vuln_profiles.get(name, None) if profile is None: return self.parent_dg.resolve_profile(name) return profile
Looks up a VulnerabiltyProfile by name.
Looks up a VulnerabiltyProfile by name.
[ "Looks", "up", "a", "VulnerabiltyProfile", "by", "name", "." ]
def resolve_profile(self, name: str) -> VulnerabilityProfile: profile = self.vuln_profiles.get(name, None) if profile is None: return self.parent_dg.resolve_profile(name) return profile
[ "def", "resolve_profile", "(", "self", ",", "name", ":", "str", ")", "->", "VulnerabilityProfile", ":", "profile", "=", "self", ".", "vuln_profiles", ".", "get", "(", "name", ",", "None", ")", "if", "profile", "is", "None", ":", "return", "self", ".", ...
Looks up a VulnerabiltyProfile by name.
[ "Looks", "up", "a", "VulnerabiltyProfile", "by", "name", "." ]
[ "\"\"\"Looks up a VulnerabiltyProfile by name.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "name", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "str", "docstring": null, "docstring_tokens": ...
398432fe9a14b01bd955bb734855bc482d32aad9
mrichardson03/panos-ips-reports
panos_util/panorama.py
[ "Apache-2.0" ]
Python
resolve_profile_group
VulnerabilityProfile
def resolve_profile_group(self, name: str) -> VulnerabilityProfile: """Looks up a VulnerabilityProfile by SecurityProfileGroup name.""" group = self.profile_groups.get(name, None) if group is not None: return self.resolve_profile(group.vulnerability) else: return...
Looks up a VulnerabilityProfile by SecurityProfileGroup name.
Looks up a VulnerabilityProfile by SecurityProfileGroup name.
[ "Looks", "up", "a", "VulnerabilityProfile", "by", "SecurityProfileGroup", "name", "." ]
def resolve_profile_group(self, name: str) -> VulnerabilityProfile: group = self.profile_groups.get(name, None) if group is not None: return self.resolve_profile(group.vulnerability) else: return self.parent_dg.resolve_profile_group(name)
[ "def", "resolve_profile_group", "(", "self", ",", "name", ":", "str", ")", "->", "VulnerabilityProfile", ":", "group", "=", "self", ".", "profile_groups", ".", "get", "(", "name", ",", "None", ")", "if", "group", "is", "not", "None", ":", "return", "self...
Looks up a VulnerabilityProfile by SecurityProfileGroup name.
[ "Looks", "up", "a", "VulnerabilityProfile", "by", "SecurityProfileGroup", "name", "." ]
[ "\"\"\"Looks up a VulnerabilityProfile by SecurityProfileGroup name.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "name", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "str", "docstring": null, "docstring_tokens": ...
398432fe9a14b01bd955bb734855bc482d32aad9
mrichardson03/panos-ips-reports
panos_util/panorama.py
[ "Apache-2.0" ]
Python
create_from_element
DeviceGroup
def create_from_element(e: Element) -> DeviceGroup: """Create DeviceGroup from XML element.""" name = e.get("name") vuln_profiles = {} for vuln_profile in e.findall("./profiles/vulnerability/entry"): vp = VulnerabilityProfile.create_from_element(vuln_profile) vul...
Create DeviceGroup from XML element.
Create DeviceGroup from XML element.
[ "Create", "DeviceGroup", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> DeviceGroup: name = e.get("name") vuln_profiles = {} for vuln_profile in e.findall("./profiles/vulnerability/entry"): vp = VulnerabilityProfile.create_from_element(vuln_profile) vuln_profiles.update({vp.name: vp}) profile_gro...
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "DeviceGroup", ":", "name", "=", "e", ".", "get", "(", "\"name\"", ")", "vuln_profiles", "=", "{", "}", "for", "vuln_profile", "in", "e", ".", "findall", "(", "\"./profiles/vulnerability/entr...
Create DeviceGroup from XML element.
[ "Create", "DeviceGroup", "from", "XML", "element", "." ]
[ "\"\"\"Create DeviceGroup from XML element.\"\"\"" ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
blocks_criticals
bool
def blocks_criticals(self) -> bool: """Returns True if this profile has a rule that blocks critical events.""" for rule in self.rules: if rule.blocks_criticals(): return True return False
Returns True if this profile has a rule that blocks critical events.
Returns True if this profile has a rule that blocks critical events.
[ "Returns", "True", "if", "this", "profile", "has", "a", "rule", "that", "blocks", "critical", "events", "." ]
def blocks_criticals(self) -> bool: for rule in self.rules: if rule.blocks_criticals(): return True return False
[ "def", "blocks_criticals", "(", "self", ")", "->", "bool", ":", "for", "rule", "in", "self", ".", "rules", ":", "if", "rule", ".", "blocks_criticals", "(", ")", ":", "return", "True", "return", "False" ]
Returns True if this profile has a rule that blocks critical events.
[ "Returns", "True", "if", "this", "profile", "has", "a", "rule", "that", "blocks", "critical", "events", "." ]
[ "\"\"\"Returns True if this profile has a rule that blocks critical events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
blocks_high
bool
def blocks_high(self) -> bool: """Returns True if this profile has a rule that blocks high events.""" for rule in self.rules: if rule.blocks_high(): return True return False
Returns True if this profile has a rule that blocks high events.
Returns True if this profile has a rule that blocks high events.
[ "Returns", "True", "if", "this", "profile", "has", "a", "rule", "that", "blocks", "high", "events", "." ]
def blocks_high(self) -> bool: for rule in self.rules: if rule.blocks_high(): return True return False
[ "def", "blocks_high", "(", "self", ")", "->", "bool", ":", "for", "rule", "in", "self", ".", "rules", ":", "if", "rule", ".", "blocks_high", "(", ")", ":", "return", "True", "return", "False" ]
Returns True if this profile has a rule that blocks high events.
[ "Returns", "True", "if", "this", "profile", "has", "a", "rule", "that", "blocks", "high", "events", "." ]
[ "\"\"\"Returns True if this profile has a rule that blocks high events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
blocks_medium
bool
def blocks_medium(self) -> bool: """Returns True if this profile has a rule that blocks medium events.""" for rule in self.rules: if rule.blocks_medium(): return True return False
Returns True if this profile has a rule that blocks medium events.
Returns True if this profile has a rule that blocks medium events.
[ "Returns", "True", "if", "this", "profile", "has", "a", "rule", "that", "blocks", "medium", "events", "." ]
def blocks_medium(self) -> bool: for rule in self.rules: if rule.blocks_medium(): return True return False
[ "def", "blocks_medium", "(", "self", ")", "->", "bool", ":", "for", "rule", "in", "self", ".", "rules", ":", "if", "rule", ".", "blocks_medium", "(", ")", ":", "return", "True", "return", "False" ]
Returns True if this profile has a rule that blocks medium events.
[ "Returns", "True", "if", "this", "profile", "has", "a", "rule", "that", "blocks", "medium", "events", "." ]
[ "\"\"\"Returns True if this profile has a rule that blocks medium events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
alert_only
bool
def alert_only(self) -> bool: """Returns True if this profile has only alert rules.""" if len(self.rules) > 0: for rule in self.rules: if not rule.alert_only(): return False return True else: return False
Returns True if this profile has only alert rules.
Returns True if this profile has only alert rules.
[ "Returns", "True", "if", "this", "profile", "has", "only", "alert", "rules", "." ]
def alert_only(self) -> bool: if len(self.rules) > 0: for rule in self.rules: if not rule.alert_only(): return False return True else: return False
[ "def", "alert_only", "(", "self", ")", "->", "bool", ":", "if", "len", "(", "self", ".", "rules", ")", ">", "0", ":", "for", "rule", "in", "self", ".", "rules", ":", "if", "not", "rule", ".", "alert_only", "(", ")", ":", "return", "False", "retur...
Returns True if this profile has only alert rules.
[ "Returns", "True", "if", "this", "profile", "has", "only", "alert", "rules", "." ]
[ "\"\"\"Returns True if this profile has only alert rules.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
create_from_element
VulnerabilityProfile
def create_from_element(e: Element) -> VulnerabilityProfile: """Create VulnerabilityProfile from XML element.""" name = e.get("name") rules = [] for rule in e.findall(".//rules/entry"): r = VulnerabilityProfileRule.create_from_element(rule) rules.append(r) ...
Create VulnerabilityProfile from XML element.
Create VulnerabilityProfile from XML element.
[ "Create", "VulnerabilityProfile", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> VulnerabilityProfile: name = e.get("name") rules = [] for rule in e.findall(".//rules/entry"): r = VulnerabilityProfileRule.create_from_element(rule) rules.append(r) return VulnerabilityProfile(name, rules)
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "VulnerabilityProfile", ":", "name", "=", "e", ".", "get", "(", "\"name\"", ")", "rules", "=", "[", "]", "for", "rule", "in", "e", ".", "findall", "(", "\".//rules/entry\"", ")", ":", "...
Create VulnerabilityProfile from XML element.
[ "Create", "VulnerabilityProfile", "from", "XML", "element", "." ]
[ "\"\"\"Create VulnerabilityProfile from XML element.\"\"\"" ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
blocks_criticals
bool
def blocks_criticals(self) -> bool: """Returns True if a block action would be taken on critical events.""" if self.severity is not None and "critical" in self.severity: if self.action is not None and self.action in [ "block-ip", "drop", "reset...
Returns True if a block action would be taken on critical events.
Returns True if a block action would be taken on critical events.
[ "Returns", "True", "if", "a", "block", "action", "would", "be", "taken", "on", "critical", "events", "." ]
def blocks_criticals(self) -> bool: if self.severity is not None and "critical" in self.severity: if self.action is not None and self.action in [ "block-ip", "drop", "reset-both", "reset-client", "reset-server", ...
[ "def", "blocks_criticals", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "severity", "is", "not", "None", "and", "\"critical\"", "in", "self", ".", "severity", ":", "if", "self", ".", "action", "is", "not", "None", "and", "self", ".", "action...
Returns True if a block action would be taken on critical events.
[ "Returns", "True", "if", "a", "block", "action", "would", "be", "taken", "on", "critical", "events", "." ]
[ "\"\"\"Returns True if a block action would be taken on critical events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
blocks_high
bool
def blocks_high(self) -> bool: """Returns True if a block action would be taken on high events.""" if self.severity is not None and "high" in self.severity: if self.action is not None and self.action in [ "block-ip", "drop", "reset-both", ...
Returns True if a block action would be taken on high events.
Returns True if a block action would be taken on high events.
[ "Returns", "True", "if", "a", "block", "action", "would", "be", "taken", "on", "high", "events", "." ]
def blocks_high(self) -> bool: if self.severity is not None and "high" in self.severity: if self.action is not None and self.action in [ "block-ip", "drop", "reset-both", "reset-client", "reset-server", ]: ...
[ "def", "blocks_high", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "severity", "is", "not", "None", "and", "\"high\"", "in", "self", ".", "severity", ":", "if", "self", ".", "action", "is", "not", "None", "and", "self", ".", "action", "in"...
Returns True if a block action would be taken on high events.
[ "Returns", "True", "if", "a", "block", "action", "would", "be", "taken", "on", "high", "events", "." ]
[ "\"\"\"Returns True if a block action would be taken on high events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
blocks_medium
bool
def blocks_medium(self) -> bool: """Returns True if a block action would be taken on medium events.""" if self.severity is not None and "medium" in self.severity: if self.action is not None and self.action in [ "block-ip", "drop", "reset-both",...
Returns True if a block action would be taken on medium events.
Returns True if a block action would be taken on medium events.
[ "Returns", "True", "if", "a", "block", "action", "would", "be", "taken", "on", "medium", "events", "." ]
def blocks_medium(self) -> bool: if self.severity is not None and "medium" in self.severity: if self.action is not None and self.action in [ "block-ip", "drop", "reset-both", "reset-client", "reset-server", ]...
[ "def", "blocks_medium", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "severity", "is", "not", "None", "and", "\"medium\"", "in", "self", ".", "severity", ":", "if", "self", ".", "action", "is", "not", "None", "and", "self", ".", "action", ...
Returns True if a block action would be taken on medium events.
[ "Returns", "True", "if", "a", "block", "action", "would", "be", "taken", "on", "medium", "events", "." ]
[ "\"\"\"Returns True if a block action would be taken on medium events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
alert_only
bool
def alert_only(self) -> bool: """Returns True if an alert action would be taken on events.""" if self.action == "alert": return True else: return False
Returns True if an alert action would be taken on events.
Returns True if an alert action would be taken on events.
[ "Returns", "True", "if", "an", "alert", "action", "would", "be", "taken", "on", "events", "." ]
def alert_only(self) -> bool: if self.action == "alert": return True else: return False
[ "def", "alert_only", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "action", "==", "\"alert\"", ":", "return", "True", "else", ":", "return", "False" ]
Returns True if an alert action would be taken on events.
[ "Returns", "True", "if", "an", "alert", "action", "would", "be", "taken", "on", "events", "." ]
[ "\"\"\"Returns True if an alert action would be taken on events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
create_from_element
VulnerabilityProfileRule
def create_from_element(e: Element) -> VulnerabilityProfileRule: """Create VulnerabilityProfileRule from XML element.""" name = e.get("name") vendor_ids = [] for vendor_id in e.findall(".//vendor-id/member"): vendor_ids.append(vendor_id.text) severities = [] ...
Create VulnerabilityProfileRule from XML element.
Create VulnerabilityProfileRule from XML element.
[ "Create", "VulnerabilityProfileRule", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> VulnerabilityProfileRule: name = e.get("name") vendor_ids = [] for vendor_id in e.findall(".//vendor-id/member"): vendor_ids.append(vendor_id.text) severities = [] for severity in e.findall(".//severity/member"): seve...
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "VulnerabilityProfileRule", ":", "name", "=", "e", ".", "get", "(", "\"name\"", ")", "vendor_ids", "=", "[", "]", "for", "vendor_id", "in", "e", ".", "findall", "(", "\".//vendor-id/member\""...
Create VulnerabilityProfileRule from XML element.
[ "Create", "VulnerabilityProfileRule", "from", "XML", "element", "." ]
[ "\"\"\"Create VulnerabilityProfileRule from XML element.\"\"\"" ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
create_from_element
VulnerabilitySignature
def create_from_element(e: Element) -> VulnerabilitySignature: """Create VulnerabilitySignature from XML element.""" threat_id = e.get("name") threat_name = strip_empty(e.findtext("threatname")) vendor_id = [] for vendor in e.findall(".//vendor/member"): vendor_id.ap...
Create VulnerabilitySignature from XML element.
Create VulnerabilitySignature from XML element.
[ "Create", "VulnerabilitySignature", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> VulnerabilitySignature: threat_id = e.get("name") threat_name = strip_empty(e.findtext("threatname")) vendor_id = [] for vendor in e.findall(".//vendor/member"): vendor_id.append(vendor.text) cve_id = [] for cve in e.find...
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "VulnerabilitySignature", ":", "threat_id", "=", "e", ".", "get", "(", "\"name\"", ")", "threat_name", "=", "strip_empty", "(", "e", ".", "findtext", "(", "\"threatname\"", ")", ")", "vendor_...
Create VulnerabilitySignature from XML element.
[ "Create", "VulnerabilitySignature", "from", "XML", "element", "." ]
[ "\"\"\"Create VulnerabilitySignature from XML element.\"\"\"" ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
25a4b7da9dc7b7320c57a4fc5d2232ea06246f5d
mrichardson03/panos-ips-reports
panos_util/objects.py
[ "Apache-2.0" ]
Python
create_from_element
SecurityProfileGroup
def create_from_element(e: Element) -> SecurityProfileGroup: """Create SecurityProfileGroup from XML element.""" name = e.get("name") virus = strip_empty(e.findtext(".//virus/member")) spyware = strip_empty(e.findtext(".//spyware/member")) vulnerability = strip_empty(e.findtext(...
Create SecurityProfileGroup from XML element.
Create SecurityProfileGroup from XML element.
[ "Create", "SecurityProfileGroup", "from", "XML", "element", "." ]
def create_from_element(e: Element) -> SecurityProfileGroup: name = e.get("name") virus = strip_empty(e.findtext(".//virus/member")) spyware = strip_empty(e.findtext(".//spyware/member")) vulnerability = strip_empty(e.findtext(".//vulnerability/member")) url_filtering = strip_emp...
[ "def", "create_from_element", "(", "e", ":", "Element", ")", "->", "SecurityProfileGroup", ":", "name", "=", "e", ".", "get", "(", "\"name\"", ")", "virus", "=", "strip_empty", "(", "e", ".", "findtext", "(", "\".//virus/member\"", ")", ")", "spyware", "="...
Create SecurityProfileGroup from XML element.
[ "Create", "SecurityProfileGroup", "from", "XML", "element", "." ]
[ "\"\"\"Create SecurityProfileGroup from XML element.\"\"\"" ]
[ { "param": "e", "type": "Element" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "Element", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3d51dd0f78ff9cabd9e7fb9a4720e075c11f041a
volprjir/Face-Recognition
faces.py
[ "MIT" ]
Python
validate_files
null
def validate_files(): """ Check if files created from faces_train.py script """ recognizer_f = glob("./recognizers/*.yml") pickle_f = glob("./pickles/*.pickle") if not len(recognizer_f) or not len(pickle_f): raise Exception("Missing files for recognizing people. Please create a dataset a...
Check if files created from faces_train.py script
Check if files created from faces_train.py script
[ "Check", "if", "files", "created", "from", "faces_train", ".", "py", "script" ]
def validate_files(): recognizer_f = glob("./recognizers/*.yml") pickle_f = glob("./pickles/*.pickle") if not len(recognizer_f) or not len(pickle_f): raise Exception("Missing files for recognizing people. Please create a dataset and run faces_train.py first.")
[ "def", "validate_files", "(", ")", ":", "recognizer_f", "=", "glob", "(", "\"./recognizers/*.yml\"", ")", "pickle_f", "=", "glob", "(", "\"./pickles/*.pickle\"", ")", "if", "not", "len", "(", "recognizer_f", ")", "or", "not", "len", "(", "pickle_f", ")", ":"...
Check if files created from faces_train.py script
[ "Check", "if", "files", "created", "from", "faces_train", ".", "py", "script" ]
[ "\"\"\"\n Check if files created from faces_train.py script\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3d51dd0f78ff9cabd9e7fb9a4720e075c11f041a
volprjir/Face-Recognition
faces.py
[ "MIT" ]
Python
validate_folder_structure
null
def validate_folder_structure(): """ Check if folder structure is correct """ if not os.path.isdir("./cascades/data/") or \ not os.path.isdir("./recognizers") or \ not os.path.isdir("./pickles") or \ not os.path.isdir("./reports"): raise Exception("Missing com...
Check if folder structure is correct
Check if folder structure is correct
[ "Check", "if", "folder", "structure", "is", "correct" ]
def validate_folder_structure(): if not os.path.isdir("./cascades/data/") or \ not os.path.isdir("./recognizers") or \ not os.path.isdir("./pickles") or \ not os.path.isdir("./reports"): raise Exception("Missing compulsory folder structure. Please do git checkout.")
[ "def", "validate_folder_structure", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "\"./cascades/data/\"", ")", "or", "not", "os", ".", "path", ".", "isdir", "(", "\"./recognizers\"", ")", "or", "not", "os", ".", "path", ".", "isdir", ...
Check if folder structure is correct
[ "Check", "if", "folder", "structure", "is", "correct" ]
[ "\"\"\"\n Check if folder structure is correct\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3d51dd0f78ff9cabd9e7fb9a4720e075c11f041a
volprjir/Face-Recognition
faces.py
[ "MIT" ]
Python
process_data
<not_specific>
def process_data(people_logger): """ Creates a dictionary of DataFrames from the log and write the results to csv file. :param people_logger: input data from face recognition :return: dictionary of DataFrames """ # create dictionary DataFrames with name as a key and times ppl_logger_df = {ke...
Creates a dictionary of DataFrames from the log and write the results to csv file. :param people_logger: input data from face recognition :return: dictionary of DataFrames
Creates a dictionary of DataFrames from the log and write the results to csv file.
[ "Creates", "a", "dictionary", "of", "DataFrames", "from", "the", "log", "and", "write", "the", "results", "to", "csv", "file", "." ]
def process_data(people_logger): ppl_logger_df = {key: pd.DataFrame(people_logger[key]) for key in people_logger.keys()} [ppl_logger_df[key].to_csv(os.path.join(os.getcwd(), "reports", f"{key}.csv")) for key in ppl_logger_df.keys()] return ppl_logger_df
[ "def", "process_data", "(", "people_logger", ")", ":", "ppl_logger_df", "=", "{", "key", ":", "pd", ".", "DataFrame", "(", "people_logger", "[", "key", "]", ")", "for", "key", "in", "people_logger", ".", "keys", "(", ")", "}", "[", "ppl_logger_df", "[", ...
Creates a dictionary of DataFrames from the log and write the results to csv file.
[ "Creates", "a", "dictionary", "of", "DataFrames", "from", "the", "log", "and", "write", "the", "results", "to", "csv", "file", "." ]
[ "\"\"\"\n Creates a dictionary of DataFrames from the log and write the results to csv file.\n :param people_logger: input data from face recognition\n :return: dictionary of DataFrames\n \"\"\"", "# create dictionary DataFrames with name as a key and times", "# save data to csv" ]
[ { "param": "people_logger", "type": null } ]
{ "returns": [ { "docstring": "dictionary of DataFrames", "docstring_tokens": [ "dictionary", "of", "DataFrames" ], "type": null } ], "raises": [], "params": [ { "identifier": "people_logger", "type": null, "docstring": "input data fr...
4b283f07b89b700bc33414c0afc925ff4f26d029
volprjir/Face-Recognition
create_dataset.py
[ "MIT" ]
Python
create_dataset
null
def create_dataset(dataset_dir, count, camera): """ Generates dataset from the connected camera :param dataset_dir: Directory to store the output. :param count: Number of frames to capture. :param camera: Camera ID for opencv lib. :raise Exception: If camera does not work. """ if input("...
Generates dataset from the connected camera :param dataset_dir: Directory to store the output. :param count: Number of frames to capture. :param camera: Camera ID for opencv lib. :raise Exception: If camera does not work.
Generates dataset from the connected camera
[ "Generates", "dataset", "from", "the", "connected", "camera" ]
def create_dataset(dataset_dir, count, camera): if input("Are you ready to take pictures? y/n: ") == "n": exit(0) video = cv2.VideoCapture(camera) cnt = 0 print(f"Turning on the camera with id {camera} to take {count} frames. Smile :)...") unique_seq = unique_id() while cnt != count: ...
[ "def", "create_dataset", "(", "dataset_dir", ",", "count", ",", "camera", ")", ":", "if", "input", "(", "\"Are you ready to take pictures? y/n: \"", ")", "==", "\"n\"", ":", "exit", "(", "0", ")", "video", "=", "cv2", ".", "VideoCapture", "(", "camera", ")",...
Generates dataset from the connected camera
[ "Generates", "dataset", "from", "the", "connected", "camera" ]
[ "\"\"\"\n Generates dataset from the connected camera\n :param dataset_dir: Directory to store the output.\n :param count: Number of frames to capture.\n :param camera: Camera ID for opencv lib.\n :raise Exception: If camera does not work.\n \"\"\"" ]
[ { "param": "dataset_dir", "type": null }, { "param": "count", "type": null }, { "param": "camera", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "If camera does not work.", "docstring_tokens": [ "If", "camera", "does", "not", "work", "." ], "type": "Exception" } ], "params": [ { "identifier": "dataset_dir", "type": ...
4b283f07b89b700bc33414c0afc925ff4f26d029
volprjir/Face-Recognition
create_dataset.py
[ "MIT" ]
Python
process_dataset_directory
<not_specific>
def process_dataset_directory(base_dir, name, clean): """ Prepare the dataset folder. Clean it or create it if necessary. :param base_dir: Base directory for storing output :param name: Name of dataset :param clean: Should remove all files in it :return: Final dataset directory """ datas...
Prepare the dataset folder. Clean it or create it if necessary. :param base_dir: Base directory for storing output :param name: Name of dataset :param clean: Should remove all files in it :return: Final dataset directory
Prepare the dataset folder. Clean it or create it if necessary.
[ "Prepare", "the", "dataset", "folder", ".", "Clean", "it", "or", "create", "it", "if", "necessary", "." ]
def process_dataset_directory(base_dir, name, clean): dataset_dir = os.path.join(base_dir, name) if clean and os.path.isdir(dataset_dir): shutil.rmtree(dataset_dir) if not os.path.isdir(dataset_dir): os.makedirs(dataset_dir) return os.path.join(dataset_dir, '')
[ "def", "process_dataset_directory", "(", "base_dir", ",", "name", ",", "clean", ")", ":", "dataset_dir", "=", "os", ".", "path", ".", "join", "(", "base_dir", ",", "name", ")", "if", "clean", "and", "os", ".", "path", ".", "isdir", "(", "dataset_dir", ...
Prepare the dataset folder.
[ "Prepare", "the", "dataset", "folder", "." ]
[ "\"\"\"\n Prepare the dataset folder. Clean it or create it if necessary.\n :param base_dir: Base directory for storing output\n :param name: Name of dataset\n :param clean: Should remove all files in it\n :return: Final dataset directory\n \"\"\"" ]
[ { "param": "base_dir", "type": null }, { "param": "name", "type": null }, { "param": "clean", "type": null } ]
{ "returns": [ { "docstring": "Final dataset directory", "docstring_tokens": [ "Final", "dataset", "directory" ], "type": null } ], "raises": [], "params": [ { "identifier": "base_dir", "type": null, "docstring": "Base directory for s...
4b283f07b89b700bc33414c0afc925ff4f26d029
volprjir/Face-Recognition
create_dataset.py
[ "MIT" ]
Python
main
null
def main(name, count, base_dir, clean, camera, run_train): """ Basic script to create a dataset for face recognition app. :param name: Name of dataset :param count: Count of images to create :param base_dir: Base directory for storing the output :param clean: Should clean the folder if exists ...
Basic script to create a dataset for face recognition app. :param name: Name of dataset :param count: Count of images to create :param base_dir: Base directory for storing the output :param clean: Should clean the folder if exists :param camera: Camera id for opencv lib :param run_train: S...
Basic script to create a dataset for face recognition app.
[ "Basic", "script", "to", "create", "a", "dataset", "for", "face", "recognition", "app", "." ]
def main(name, count, base_dir, clean, camera, run_train): clean = bool(clean) run_train = bool(run_train) check_basedir(base_dir) dataset_dir = process_dataset_directory(base_dir, name, clean) create_dataset(dataset_dir, count, camera) if not run_train: print("Please run faces_train.py ...
[ "def", "main", "(", "name", ",", "count", ",", "base_dir", ",", "clean", ",", "camera", ",", "run_train", ")", ":", "clean", "=", "bool", "(", "clean", ")", "run_train", "=", "bool", "(", "run_train", ")", "check_basedir", "(", "base_dir", ")", "datase...
Basic script to create a dataset for face recognition app.
[ "Basic", "script", "to", "create", "a", "dataset", "for", "face", "recognition", "app", "." ]
[ "\"\"\"\n Basic script to create a dataset for face recognition app.\n\n :param name: Name of dataset\n :param count: Count of images to create\n :param base_dir: Base directory for storing the output\n :param clean: Should clean the folder if exists\n :param camera: Camera id for opencv lib\n ...
[ { "param": "name", "type": null }, { "param": "count", "type": null }, { "param": "base_dir", "type": null }, { "param": "clean", "type": null }, { "param": "camera", "type": null }, { "param": "run_train", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": null, "docstring": "Name of dataset", "docstring_tokens": [ "Name", "of", "dataset" ], "default": null, "is_optional": null }, { "identifier": "count", ...
f9e7faee4158ddfa530aaccc1feb3b74197d41ac
schmidtbri/regression-model
insurance_charges_model/prediction/model.py
[ "BSD-3-Clause" ]
Python
predict
InsuranceChargesModelOutput
def predict(self, data: InsuranceChargesModelInput) -> InsuranceChargesModelOutput: """Make a prediction with the model. :param data: Data for making a prediction with the model. Object must meet requirements of the input schema. :rtype: dict -- The result of the prediction, the output object w...
Make a prediction with the model. :param data: Data for making a prediction with the model. Object must meet requirements of the input schema. :rtype: dict -- The result of the prediction, the output object will meet the requirements of the output schema.
Make a prediction with the model.
[ "Make", "a", "prediction", "with", "the", "model", "." ]
def predict(self, data: InsuranceChargesModelInput) -> InsuranceChargesModelOutput: X = pd.DataFrame([[data.age, data.sex.value, data.bmi, data.children, data.smoker, data.region.value]], columns=["age", "sex", "bmi", "children", "smoker", "region"]) y_hat = round(float(self._sv...
[ "def", "predict", "(", "self", ",", "data", ":", "InsuranceChargesModelInput", ")", "->", "InsuranceChargesModelOutput", ":", "X", "=", "pd", ".", "DataFrame", "(", "[", "[", "data", ".", "age", ",", "data", ".", "sex", ".", "value", ",", "data", ".", ...
Make a prediction with the model.
[ "Make", "a", "prediction", "with", "the", "model", "." ]
[ "\"\"\"Make a prediction with the model.\n\n :param data: Data for making a prediction with the model. Object must meet requirements of the input schema.\n :rtype: dict -- The result of the prediction, the output object will meet the requirements of the output schema.\n\n \"\"\"", "# converti...
[ { "param": "self", "type": null }, { "param": "data", "type": "InsuranceChargesModelInput" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "dict -- The result of the prediction, the output object will meet the requirements of the output schema." } ], "raises": [], "params": [ { "identifier": "self", "type": null, ...
5c39d299862a363bf07fec10cf188e4a080f7452
schmidtbri/regression-model
insurance_charges_model/prediction/transformers.py
[ "BSD-3-Clause" ]
Python
fit
<not_specific>
def fit(self, X, y=None): """Fit the transformer to a dataset.""" entityset = ft.EntitySet(id="Transactions") if "index" not in X.columns: entityset = entityset.entity_from_dataframe(entity_id=self.target_entity, dataframe=X, ...
Fit the transformer to a dataset.
Fit the transformer to a dataset.
[ "Fit", "the", "transformer", "to", "a", "dataset", "." ]
def fit(self, X, y=None): entityset = ft.EntitySet(id="Transactions") if "index" not in X.columns: entityset = entityset.entity_from_dataframe(entity_id=self.target_entity, dataframe=X, ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "entityset", "=", "ft", ".", "EntitySet", "(", "id", "=", "\"Transactions\"", ")", "if", "\"index\"", "not", "in", "X", ".", "columns", ":", "entityset", "=", "entityset", ".", "...
Fit the transformer to a dataset.
[ "Fit", "the", "transformer", "to", "a", "dataset", "." ]
[ "\"\"\"Fit the transformer to a dataset.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "X", "type": null }, { "param": "y", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "X", "type": null, "docstring": null, "docstring_tokens": [], ...
a83a4eed3758647dc96b1e29e0194532634cb8d9
tdm-project/edge-device-handler
src/housekeeping.py
[ "Apache-2.0" ]
Python
memoryTotal
<not_specific>
def memoryTotal(): """ Retrieves total system memory from /proc/meminfo in MB """ meminfo = { _l.split()[0].rstrip(':'): int(_l.split()[1]) for _l in open('/proc/meminfo').readlines()} return int(meminfo['MemTotal'] / 1024)
Retrieves total system memory from /proc/meminfo in MB
Retrieves total system memory from /proc/meminfo in MB
[ "Retrieves", "total", "system", "memory", "from", "/", "proc", "/", "meminfo", "in", "MB" ]
def memoryTotal(): meminfo = { _l.split()[0].rstrip(':'): int(_l.split()[1]) for _l in open('/proc/meminfo').readlines()} return int(meminfo['MemTotal'] / 1024)
[ "def", "memoryTotal", "(", ")", ":", "meminfo", "=", "{", "_l", ".", "split", "(", ")", "[", "0", "]", ".", "rstrip", "(", "':'", ")", ":", "int", "(", "_l", ".", "split", "(", ")", "[", "1", "]", ")", "for", "_l", "in", "open", "(", "'/pro...
Retrieves total system memory from /proc/meminfo in MB
[ "Retrieves", "total", "system", "memory", "from", "/", "proc", "/", "meminfo", "in", "MB" ]
[ "\"\"\"\n Retrieves total system memory from /proc/meminfo in MB\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
a83a4eed3758647dc96b1e29e0194532634cb8d9
tdm-project/edge-device-handler
src/housekeeping.py
[ "Apache-2.0" ]
Python
memoryFree
<not_specific>
def memoryFree(): """ Retrieves free system memory from /proc/meminfo in MB """ meminfo = { _l.split()[0].rstrip(':'): int(_l.split()[1]) for _l in open('/proc/meminfo').readlines()} return int(meminfo['MemFree'] / 1024)
Retrieves free system memory from /proc/meminfo in MB
Retrieves free system memory from /proc/meminfo in MB
[ "Retrieves", "free", "system", "memory", "from", "/", "proc", "/", "meminfo", "in", "MB" ]
def memoryFree(): meminfo = { _l.split()[0].rstrip(':'): int(_l.split()[1]) for _l in open('/proc/meminfo').readlines()} return int(meminfo['MemFree'] / 1024)
[ "def", "memoryFree", "(", ")", ":", "meminfo", "=", "{", "_l", ".", "split", "(", ")", "[", "0", "]", ".", "rstrip", "(", "':'", ")", ":", "int", "(", "_l", ".", "split", "(", ")", "[", "1", "]", ")", "for", "_l", "in", "open", "(", "'/proc...
Retrieves free system memory from /proc/meminfo in MB
[ "Retrieves", "free", "system", "memory", "from", "/", "proc", "/", "meminfo", "in", "MB" ]
[ "\"\"\"\n Retrieves free system memory from /proc/meminfo in MB\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c0a45d336a4beb3d495471f4bd2e375cc4a7c635
zhaofeng-shu33/ace_cream
ace_cream/ace_cream.py
[ "Apache-1.1" ]
Python
ace_cream
<not_specific>
def ace_cream(x, y, wt = None, delrsq = 0.01, ns = 1, cat = None): ''' Uses the alternating conditional expectations algorithm to find the transformations of y and x that maximise the proportion of variation in y explained by x. Parameters ---------- x : array_like a matrix contai...
Uses the alternating conditional expectations algorithm to find the transformations of y and x that maximise the proportion of variation in y explained by x. Parameters ---------- x : array_like a matrix containing the independent variables. each row is an observation of data...
Uses the alternating conditional expectations algorithm to find the transformations of y and x that maximise the proportion of variation in y explained by x. Parameters x : array_like a matrix containing the independent variables. each row is an observation of data. y : array_like a vector containing the response var...
[ "Uses", "the", "alternating", "conditional", "expectations", "algorithm", "to", "find", "the", "transformations", "of", "y", "and", "x", "that", "maximise", "the", "proportion", "of", "variation", "in", "y", "explained", "by", "x", ".", "Parameters", "x", ":",...
def ace_cream(x, y, wt = None, delrsq = 0.01, ns = 1, cat = None): if wt is None: wt = np.ones(x.shape[0]) if(len(x.shape) == 1): x_internal = x.reshape([x.shape[0],1]) else: x_internal = x x_row = x_internal.shape[0] x_col = x_internal.shape[1] iy = x_col + 1 l = n...
[ "def", "ace_cream", "(", "x", ",", "y", ",", "wt", "=", "None", ",", "delrsq", "=", "0.01", ",", "ns", "=", "1", ",", "cat", "=", "None", ")", ":", "if", "wt", "is", "None", ":", "wt", "=", "np", ".", "ones", "(", "x", ".", "shape", "[", ...
Uses the alternating conditional expectations algorithm to find the transformations of y and x that maximise the proportion of variation in y explained by x.
[ "Uses", "the", "alternating", "conditional", "expectations", "algorithm", "to", "find", "the", "transformations", "of", "y", "and", "x", "that", "maximise", "the", "proportion", "of", "variation", "in", "y", "explained", "by", "x", "." ]
[ "''' \n Uses the alternating conditional expectations algorithm\n to find the transformations of y and x that maximise the \n proportion of variation in y explained by x.\n\n Parameters\n ----------\n x : array_like\n a matrix containing the independent variables.\n each row is an ob...
[ { "param": "x", "type": null }, { "param": "y", "type": null }, { "param": "wt", "type": null }, { "param": "delrsq", "type": null }, { "param": "ns", "type": null }, { "param": "cat", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
flush
null
def flush(self): """Flush all changes to the buffer to the LCD""" for i in range(len(self._buffer)): if self._buffer[i] != self._written[i]: diffs = self._diff(self._buffer[i], self._written[i]) for start, end in diffs: self._lcd.cursor_pos...
Flush all changes to the buffer to the LCD
Flush all changes to the buffer to the LCD
[ "Flush", "all", "changes", "to", "the", "buffer", "to", "the", "LCD" ]
def flush(self): for i in range(len(self._buffer)): if self._buffer[i] != self._written[i]: diffs = self._diff(self._buffer[i], self._written[i]) for start, end in diffs: self._lcd.cursor_pos = (i, start) self._lcd.write_string(...
[ "def", "flush", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_buffer", ")", ")", ":", "if", "self", ".", "_buffer", "[", "i", "]", "!=", "self", ".", "_written", "[", "i", "]", ":", "diffs", "=", "self", "....
Flush all changes to the buffer to the LCD
[ "Flush", "all", "changes", "to", "the", "buffer", "to", "the", "LCD" ]
[ "\"\"\"Flush all changes to the buffer to the LCD\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
flash
null
def flash(self, message): """ Write a simple message to the screen, replacing all previous content :param message: The message :type message: basestring """ self.clear() self.set_line(0, message) self.flush()
Write a simple message to the screen, replacing all previous content :param message: The message :type message: basestring
Write a simple message to the screen, replacing all previous content
[ "Write", "a", "simple", "message", "to", "the", "screen", "replacing", "all", "previous", "content" ]
def flash(self, message): self.clear() self.set_line(0, message) self.flush()
[ "def", "flash", "(", "self", ",", "message", ")", ":", "self", ".", "clear", "(", ")", "self", ".", "set_line", "(", "0", ",", "message", ")", "self", ".", "flush", "(", ")" ]
Write a simple message to the screen, replacing all previous content
[ "Write", "a", "simple", "message", "to", "the", "screen", "replacing", "all", "previous", "content" ]
[ "\"\"\"\n Write a simple message to the screen, replacing all previous content\n :param message: The message\n :type message: basestring\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": null, "docstring": null, "docstring_tokens"...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
_cancel_backlight_timer
null
def _cancel_backlight_timer(self): """Cancel and clear any backlight timer""" if self._backlight_timer: try: self._backlight_timer.cancel() except ValueError: # if the event has already run, we will receive this error # It is safe t...
Cancel and clear any backlight timer
Cancel and clear any backlight timer
[ "Cancel", "and", "clear", "any", "backlight", "timer" ]
def _cancel_backlight_timer(self): if self._backlight_timer: try: self._backlight_timer.cancel() except ValueError: pass self._backlight_timer = None
[ "def", "_cancel_backlight_timer", "(", "self", ")", ":", "if", "self", ".", "_backlight_timer", ":", "try", ":", "self", ".", "_backlight_timer", ".", "cancel", "(", ")", "except", "ValueError", ":", "pass", "self", ".", "_backlight_timer", "=", "None" ]
Cancel and clear any backlight timer
[ "Cancel", "and", "clear", "any", "backlight", "timer" ]
[ "\"\"\"Cancel and clear any backlight timer\"\"\"", "# if the event has already run, we will receive this error", "# It is safe to ignore" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
_cancel_update_timer
null
def _cancel_update_timer(self): """Cancel and clear any update time""" if self._update_timer: try: self._update_timer.cancel() except ValueError: # if the event has already run, we will receive this error # It is safe to ignore ...
Cancel and clear any update time
Cancel and clear any update time
[ "Cancel", "and", "clear", "any", "update", "time" ]
def _cancel_update_timer(self): if self._update_timer: try: self._update_timer.cancel() except ValueError: pass self._update_timer = None
[ "def", "_cancel_update_timer", "(", "self", ")", ":", "if", "self", ".", "_update_timer", ":", "try", ":", "self", ".", "_update_timer", ".", "cancel", "(", ")", "except", "ValueError", ":", "pass", "self", ".", "_update_timer", "=", "None" ]
Cancel and clear any update time
[ "Cancel", "and", "clear", "any", "update", "time" ]
[ "\"\"\"Cancel and clear any update time\"\"\"", "# if the event has already run, we will receive this error", "# It is safe to ignore" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
_touch
null
def _touch(self): """ Update the object indicating the user has interacted with it at this point in time. This is used to manage the backlight :return: """ self._counter = 0 self.lcd.backlight_on() # Set up a timer that will turn off the backlight after a...
Update the object indicating the user has interacted with it at this point in time. This is used to manage the backlight :return:
Update the object indicating the user has interacted with it at this point in time. This is used to manage the backlight
[ "Update", "the", "object", "indicating", "the", "user", "has", "interacted", "with", "it", "at", "this", "point", "in", "time", ".", "This", "is", "used", "to", "manage", "the", "backlight" ]
def _touch(self): self._counter = 0 self.lcd.backlight_on() def dim(): self._backlight_timer = None self._cancel_update_timer() self.lcd.backlight_off() self._cancel_backlight_timer() self._backlight_timer = Timer(BACKLIGHT_DELAY, dim) ...
[ "def", "_touch", "(", "self", ")", ":", "self", ".", "_counter", "=", "0", "self", ".", "lcd", ".", "backlight_on", "(", ")", "def", "dim", "(", ")", ":", "self", ".", "_backlight_timer", "=", "None", "self", ".", "_cancel_update_timer", "(", ")", "s...
Update the object indicating the user has interacted with it at this point in time.
[ "Update", "the", "object", "indicating", "the", "user", "has", "interacted", "with", "it", "at", "this", "point", "in", "time", "." ]
[ "\"\"\"\n Update the object indicating the user has interacted with it at this\n point in time. This is used to manage the backlight\n :return:\n \"\"\"", "# Set up a timer that will turn off the backlight after a short delay" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
push
null
def push(self, menu_item): """ Pushes a new create_submenu to the display :param menu_item: :type menu_item: dict :return: """ self._stack.append(menu_item) self.display()
Pushes a new create_submenu to the display :param menu_item: :type menu_item: dict :return:
Pushes a new create_submenu to the display
[ "Pushes", "a", "new", "create_submenu", "to", "the", "display" ]
def push(self, menu_item): self._stack.append(menu_item) self.display()
[ "def", "push", "(", "self", ",", "menu_item", ")", ":", "self", ".", "_stack", ".", "append", "(", "menu_item", ")", "self", ".", "display", "(", ")" ]
Pushes a new create_submenu to the display
[ "Pushes", "a", "new", "create_submenu", "to", "the", "display" ]
[ "\"\"\"\n Pushes a new create_submenu to the display\n :param menu_item:\n :type menu_item: dict\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "menu_item", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
swap
null
def swap(self, menu_item): """ Swaps the current menu with another one, and displays it :param menu_item: :type menu_item: dict :return: """ self._stack[-1] = menu_item self.display()
Swaps the current menu with another one, and displays it :param menu_item: :type menu_item: dict :return:
Swaps the current menu with another one, and displays it
[ "Swaps", "the", "current", "menu", "with", "another", "one", "and", "displays", "it" ]
def swap(self, menu_item): self._stack[-1] = menu_item self.display()
[ "def", "swap", "(", "self", ",", "menu_item", ")", ":", "self", ".", "_stack", "[", "-", "1", "]", "=", "menu_item", "self", ".", "display", "(", ")" ]
Swaps the current menu with another one, and displays it
[ "Swaps", "the", "current", "menu", "with", "another", "one", "and", "displays", "it" ]
[ "\"\"\"\n Swaps the current menu with another one, and displays it\n :param menu_item:\n :type menu_item: dict\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "menu_item", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
pop
<not_specific>
def pop(self): """ Removes the current menu item and displays its parent :return: the previous menu item """ item = self._stack[-1] if not self.is_root_menu(): # Do not pop the last item on the menu self._stack = self._stack[:-1] self.d...
Removes the current menu item and displays its parent :return: the previous menu item
Removes the current menu item and displays its parent
[ "Removes", "the", "current", "menu", "item", "and", "displays", "its", "parent" ]
def pop(self): item = self._stack[-1] if not self.is_root_menu(): self._stack = self._stack[:-1] self.display() return item
[ "def", "pop", "(", "self", ")", ":", "item", "=", "self", ".", "_stack", "[", "-", "1", "]", "if", "not", "self", ".", "is_root_menu", "(", ")", ":", "self", ".", "_stack", "=", "self", ".", "_stack", "[", ":", "-", "1", "]", "self", ".", "di...
Removes the current menu item and displays its parent
[ "Removes", "the", "current", "menu", "item", "and", "displays", "its", "parent" ]
[ "\"\"\"\n Removes the current menu item and displays its parent\n :return: the previous menu item\n \"\"\"", "# Do not pop the last item on the menu" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "the previous menu item", "docstring_tokens": [ "the", "previous", "menu", "item" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "doc...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
display
null
def display(self): """Set the display to display the correct menu item (or nothing)""" self._touch() menu_item = self.peek() if menu_item: # Set the timer to draw the screen as soon as reasonably possible self._set_update_time(menu_item, JIFFY) else: ...
Set the display to display the correct menu item (or nothing)
Set the display to display the correct menu item (or nothing)
[ "Set", "the", "display", "to", "display", "the", "correct", "menu", "item", "(", "or", "nothing", ")" ]
def display(self): self._touch() menu_item = self.peek() if menu_item: self._set_update_time(menu_item, JIFFY) else: self._cancel_update_timer() self.lcd.clear()
[ "def", "display", "(", "self", ")", ":", "self", ".", "_touch", "(", ")", "menu_item", "=", "self", ".", "peek", "(", ")", "if", "menu_item", ":", "self", ".", "_set_update_time", "(", "menu_item", ",", "JIFFY", ")", "else", ":", "self", ".", "_cance...
Set the display to display the correct menu item (or nothing)
[ "Set", "the", "display", "to", "display", "the", "correct", "menu", "item", "(", "or", "nothing", ")" ]
[ "\"\"\"Set the display to display the correct menu item (or nothing)\"\"\"", "# Set the timer to draw the screen as soon as reasonably possible" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
_set_update_time
null
def _set_update_time(self, menu_item, delay): """ Set up a timer that will redraw the menu item in a short time But only do this if the backlight is on (i.e. the display is visible) :param menu_item: The menu item to draw """ if self.lcd.is_backlight_on(): def...
Set up a timer that will redraw the menu item in a short time But only do this if the backlight is on (i.e. the display is visible) :param menu_item: The menu item to draw
Set up a timer that will redraw the menu item in a short time But only do this if the backlight is on
[ "Set", "up", "a", "timer", "that", "will", "redraw", "the", "menu", "item", "in", "a", "short", "time", "But", "only", "do", "this", "if", "the", "backlight", "is", "on" ]
def _set_update_time(self, menu_item, delay): if self.lcd.is_backlight_on(): def redraw(): self._draw_text(menu_item) self._cancel_update_timer() self._update_timer = Timer(delay, redraw) self._update_timer.start()
[ "def", "_set_update_time", "(", "self", ",", "menu_item", ",", "delay", ")", ":", "if", "self", ".", "lcd", ".", "is_backlight_on", "(", ")", ":", "def", "redraw", "(", ")", ":", "self", ".", "_draw_text", "(", "menu_item", ")", "self", ".", "_cancel_u...
Set up a timer that will redraw the menu item in a short time But only do this if the backlight is on (i.e.
[ "Set", "up", "a", "timer", "that", "will", "redraw", "the", "menu", "item", "in", "a", "short", "time", "But", "only", "do", "this", "if", "the", "backlight", "is", "on", "(", "i", ".", "e", "." ]
[ "\"\"\"\n Set up a timer that will redraw the menu item in a short time\n But only do this if the backlight is on (i.e. the display is visible)\n :param menu_item: The menu item to draw\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "menu_item", "type": null }, { "param": "delay", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "menu_item", "type": null, "docstring": "The menu item to draw", ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
_draw_text
null
def _draw_text(self, menu_item): """Obtain the text for the menu item and draw it on the display, setting up a timer to redraw the item in a periodic fashion""" title = menu_item[TITLE](self) description = menu_item[DESCRIPTION](self) # Format them pre = "" if self.is_r...
Obtain the text for the menu item and draw it on the display, setting up a timer to redraw the item in a periodic fashion
Obtain the text for the menu item and draw it on the display, setting up a timer to redraw the item in a periodic fashion
[ "Obtain", "the", "text", "for", "the", "menu", "item", "and", "draw", "it", "on", "the", "display", "setting", "up", "a", "timer", "to", "redraw", "the", "item", "in", "a", "periodic", "fashion" ]
def _draw_text(self, menu_item): title = menu_item[TITLE](self) description = menu_item[DESCRIPTION](self) pre = "" if self.is_root_menu() else self.lcd.UP post = "" if menu_item[PREV] and \ menu_item[NEXT] and \ menu_item[PREV][ID] != menu_item[NE...
[ "def", "_draw_text", "(", "self", ",", "menu_item", ")", ":", "title", "=", "menu_item", "[", "TITLE", "]", "(", "self", ")", "description", "=", "menu_item", "[", "DESCRIPTION", "]", "(", "self", ")", "pre", "=", "\"\"", "if", "self", ".", "is_root_me...
Obtain the text for the menu item and draw it on the display, setting up a timer to redraw the item in a periodic fashion
[ "Obtain", "the", "text", "for", "the", "menu", "item", "and", "draw", "it", "on", "the", "display", "setting", "up", "a", "timer", "to", "redraw", "the", "item", "in", "a", "periodic", "fashion" ]
[ "\"\"\"Obtain the text for the menu item and draw it on the display,\n setting up a timer to redraw the item in a periodic fashion\"\"\"", "# Format them" ]
[ { "param": "self", "type": null }, { "param": "menu_item", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "menu_item", "type": null, "docstring": null, "docstring_token...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
_format
<not_specific>
def _format(self, message, pre="", post="", just=-1): """ Formats a message for the screen, padding any shortfall with spaces. :param message: The main message to display :type message: basestring :param pre: A possible prefix for the message :param post: A possible suffi...
Formats a message for the screen, padding any shortfall with spaces. :param message: The main message to display :type message: basestring :param pre: A possible prefix for the message :param post: A possible suffix displayed a the RHS :param just: -1 for left justified,...
Formats a message for the screen, padding any shortfall with spaces.
[ "Formats", "a", "message", "for", "the", "screen", "padding", "any", "shortfall", "with", "spaces", "." ]
def _format(self, message, pre="", post="", just=-1): length = self.lcd.cols - len(pre) - len(post) if len(message) > length: start = self._counter % (length + 1) justified = (message + "|" + message)[start:start + length] else: justified = message if ...
[ "def", "_format", "(", "self", ",", "message", ",", "pre", "=", "\"\"", ",", "post", "=", "\"\"", ",", "just", "=", "-", "1", ")", ":", "length", "=", "self", ".", "lcd", ".", "cols", "-", "len", "(", "pre", ")", "-", "len", "(", "post", ")",...
Formats a message for the screen, padding any shortfall with spaces.
[ "Formats", "a", "message", "for", "the", "screen", "padding", "any", "shortfall", "with", "spaces", "." ]
[ "\"\"\"\n Formats a message for the screen, padding any shortfall with spaces.\n :param message: The main message to display\n :type message: basestring\n :param pre: A possible prefix for the message\n :param post: A possible suffix displayed a the RHS\n :param just: -1 fo...
[ { "param": "self", "type": null }, { "param": "message", "type": null }, { "param": "pre", "type": null }, { "param": "post", "type": null }, { "param": "just", "type": null } ]
{ "returns": [ { "docstring": "The formatted string, padded with spaces to the width of the\nscreen", "docstring_tokens": [ "The", "formatted", "string", "padded", "with", "spaces", "to", "the", "width", "of", "the...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
do_action
null
def do_action(self): """This method is called when the 'action' button is pressed""" menu_item = self.peek() action = menu_item[ACTION] if action: action(self) self.display()
This method is called when the 'action' button is pressed
This method is called when the 'action' button is pressed
[ "This", "method", "is", "called", "when", "the", "'", "action", "'", "button", "is", "pressed" ]
def do_action(self): menu_item = self.peek() action = menu_item[ACTION] if action: action(self) self.display()
[ "def", "do_action", "(", "self", ")", ":", "menu_item", "=", "self", ".", "peek", "(", ")", "action", "=", "menu_item", "[", "ACTION", "]", "if", "action", ":", "action", "(", "self", ")", "self", ".", "display", "(", ")" ]
This method is called when the 'action' button is pressed
[ "This", "method", "is", "called", "when", "the", "'", "action", "'", "button", "is", "pressed" ]
[ "\"\"\"This method is called when the 'action' button is pressed\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
do_prev
null
def do_prev(self): """This method is called when the 'prev' button is pressed""" menu_item = self.peek() prev = menu_item[PREV] if prev: self.swap(prev)
This method is called when the 'prev' button is pressed
This method is called when the 'prev' button is pressed
[ "This", "method", "is", "called", "when", "the", "'", "prev", "'", "button", "is", "pressed" ]
def do_prev(self): menu_item = self.peek() prev = menu_item[PREV] if prev: self.swap(prev)
[ "def", "do_prev", "(", "self", ")", ":", "menu_item", "=", "self", ".", "peek", "(", ")", "prev", "=", "menu_item", "[", "PREV", "]", "if", "prev", ":", "self", ".", "swap", "(", "prev", ")" ]
This method is called when the 'prev' button is pressed
[ "This", "method", "is", "called", "when", "the", "'", "prev", "'", "button", "is", "pressed" ]
[ "\"\"\"This method is called when the 'prev' button is pressed\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
do_next
null
def do_next(self): """This method is called when the 'next' button is pressed""" menu_item = self.peek() nxt = menu_item[NEXT] if next: self.swap(nxt)
This method is called when the 'next' button is pressed
This method is called when the 'next' button is pressed
[ "This", "method", "is", "called", "when", "the", "'", "next", "'", "button", "is", "pressed" ]
def do_next(self): menu_item = self.peek() nxt = menu_item[NEXT] if next: self.swap(nxt)
[ "def", "do_next", "(", "self", ")", ":", "menu_item", "=", "self", ".", "peek", "(", ")", "nxt", "=", "menu_item", "[", "NEXT", "]", "if", "next", ":", "self", ".", "swap", "(", "nxt", ")" ]
This method is called when the 'next' button is pressed
[ "This", "method", "is", "called", "when", "the", "'", "next", "'", "button", "is", "pressed" ]
[ "\"\"\"This method is called when the 'next' button is pressed\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
quit
null
def quit(self): """A handler that is called when the program quits.""" self._cancel_backlight_timer() self._cancel_update_timer() self.lcd.backlight_off() self.lcd.clear()
A handler that is called when the program quits.
A handler that is called when the program quits.
[ "A", "handler", "that", "is", "called", "when", "the", "program", "quits", "." ]
def quit(self): self._cancel_backlight_timer() self._cancel_update_timer() self.lcd.backlight_off() self.lcd.clear()
[ "def", "quit", "(", "self", ")", ":", "self", ".", "_cancel_backlight_timer", "(", ")", "self", ".", "_cancel_update_timer", "(", ")", "self", ".", "lcd", ".", "backlight_off", "(", ")", "self", ".", "lcd", ".", "clear", "(", ")" ]
A handler that is called when the program quits.
[ "A", "handler", "that", "is", "called", "when", "the", "program", "quits", "." ]
[ "\"\"\"A handler that is called when the program quits.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
execute_command
<not_specific>
def execute_command(self, command): """Process a command from the keyboard""" if command in ["^", "u", "6"]: self.pop() elif command in ["<", "p", ","]: self.do_prev() elif command in [">", "n", "."]: self.do_next() elif command in ["*", "x", "...
Process a command from the keyboard
Process a command from the keyboard
[ "Process", "a", "command", "from", "the", "keyboard" ]
def execute_command(self, command): if command in ["^", "u", "6"]: self.pop() elif command in ["<", "p", ","]: self.do_prev() elif command in [">", "n", "."]: self.do_next() elif command in ["*", "x", " "]: self.do_action() elif com...
[ "def", "execute_command", "(", "self", ",", "command", ")", ":", "if", "command", "in", "[", "\"^\"", ",", "\"u\"", ",", "\"6\"", "]", ":", "self", ".", "pop", "(", ")", "elif", "command", "in", "[", "\"<\"", ",", "\"p\"", ",", "\",\"", "]", ":", ...
Process a command from the keyboard
[ "Process", "a", "command", "from", "the", "keyboard" ]
[ "\"\"\"Process a command from the keyboard\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "command", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "command", "type": null, "docstring": null, "docstring_tokens"...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
run_keyboard
null
def run_keyboard(self): """Run using the keyboard for input rather than hardware buttons""" while True: command = get_char().lower() if self.execute_command(command): break
Run using the keyboard for input rather than hardware buttons
Run using the keyboard for input rather than hardware buttons
[ "Run", "using", "the", "keyboard", "for", "input", "rather", "than", "hardware", "buttons" ]
def run_keyboard(self): while True: command = get_char().lower() if self.execute_command(command): break
[ "def", "run_keyboard", "(", "self", ")", ":", "while", "True", ":", "command", "=", "get_char", "(", ")", ".", "lower", "(", ")", "if", "self", ".", "execute_command", "(", "command", ")", ":", "break" ]
Run using the keyboard for input rather than hardware buttons
[ "Run", "using", "the", "keyboard", "for", "input", "rather", "than", "hardware", "buttons" ]
[ "\"\"\"Run using the keyboard for input rather than hardware buttons\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
probe_system_service
<not_specific>
def probe_system_service(name): """Query for systemctl for service _name_, returning a map of state information. The returned map has the keys: * LoadState * ActiveState * SubState :param name: The name of the service to query :type name: basestring :return: A map""" all_states = [LO...
Query for systemctl for service _name_, returning a map of state information. The returned map has the keys: * LoadState * ActiveState * SubState :param name: The name of the service to query :type name: basestring :return: A map
Query for systemctl for service _name_, returning a map of state information.
[ "Query", "for", "systemctl", "for", "service", "_name_", "returning", "a", "map", "of", "state", "information", "." ]
def probe_system_service(name): all_states = [LOAD_STATE, ACTIVE_STATE, SUB_STATE] states = "".join(["-p " + p + " " for p in all_states]) s = popen("systemctl show " + states + name).read().strip() if not s: return {} ll = [i.split("=") for i in s.split("\n")] properties = {i[0]: i[1] f...
[ "def", "probe_system_service", "(", "name", ")", ":", "all_states", "=", "[", "LOAD_STATE", ",", "ACTIVE_STATE", ",", "SUB_STATE", "]", "states", "=", "\"\"", ".", "join", "(", "[", "\"-p \"", "+", "p", "+", "\" \"", "for", "p", "in", "all_states", "]", ...
Query for systemctl for service _name_, returning a map of state information.
[ "Query", "for", "systemctl", "for", "service", "_name_", "returning", "a", "map", "of", "state", "information", "." ]
[ "\"\"\"Query for systemctl for service _name_, returning a map of state\n information. The returned map has the keys:\n * LoadState\n * ActiveState\n * SubState\n :param name: The name of the service to query\n :type name: basestring\n :return: A map\"\"\"" ]
[ { "param": "name", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "name", "type": null, "docstring": "The name of the service to query", "docstring_tokens": [ "The", ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
create_menu_item
<not_specific>
def create_menu_item(title, description, action=None, refresh_rate=REFRESH_SLOW): """Create a menu item data structure, returning it. Both title and description may be strings (or things that can be turned into strings), or a function that returns a string :param title: The title of...
Create a menu item data structure, returning it. Both title and description may be strings (or things that can be turned into strings), or a function that returns a string :param title: The title of the menu item, a function taking MenuState as argument :param description: The description of the men...
Create a menu item data structure, returning it. Both title and description may be strings (or things that can be turned into strings), or a function that returns a string
[ "Create", "a", "menu", "item", "data", "structure", "returning", "it", ".", "Both", "title", "and", "description", "may", "be", "strings", "(", "or", "things", "that", "can", "be", "turned", "into", "strings", ")", "or", "a", "function", "that", "returns",...
def create_menu_item(title, description, action=None, refresh_rate=REFRESH_SLOW): title_resolved = title if callable(title) else lambda _: str(title) description_resolved = description if callable(description) \ else lambda _: str(description) return {ID: uuid4(), TI...
[ "def", "create_menu_item", "(", "title", ",", "description", ",", "action", "=", "None", ",", "refresh_rate", "=", "REFRESH_SLOW", ")", ":", "title_resolved", "=", "title", "if", "callable", "(", "title", ")", "else", "lambda", "_", ":", "str", "(", "title...
Create a menu item data structure, returning it.
[ "Create", "a", "menu", "item", "data", "structure", "returning", "it", "." ]
[ "\"\"\"Create a menu item data structure, returning it. Both title and\n description may be strings (or things that can be turned into strings),\n or a function that returns a string\n :param title: The title of the menu item, a function taking MenuState as\n argument\n :param description: The descri...
[ { "param": "title", "type": null }, { "param": "description", "type": null }, { "param": "action", "type": null }, { "param": "refresh_rate", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "title", "type": null, "docstring": "The title of the menu item, a function taking MenuState as\nargument", "docstring_tokens": [ "The", "title", "of", "the", "menu", "item", ...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
create_service_menu
<not_specific>
def create_service_menu(service_name): """Creates a menu for the specified service :param service_name: The full name of the systemctl service, with or without the .service suffic :type service_name: basestring :return: A menu item datastructure""" def get_service_state(_): properties =...
Creates a menu for the specified service :param service_name: The full name of the systemctl service, with or without the .service suffic :type service_name: basestring :return: A menu item datastructure
Creates a menu for the specified service
[ "Creates", "a", "menu", "for", "the", "specified", "service" ]
def create_service_menu(service_name): def get_service_state(_): properties = probe_system_service(service_name) try: return properties[ACTIVE_STATE] + ", " + properties[SUB_STATE] except KeyError: return "Unknown state" return create_menu_item(service_name, get_s...
[ "def", "create_service_menu", "(", "service_name", ")", ":", "def", "get_service_state", "(", "_", ")", ":", "properties", "=", "probe_system_service", "(", "service_name", ")", "try", ":", "return", "properties", "[", "ACTIVE_STATE", "]", "+", "\", \"", "+", ...
Creates a menu for the specified service
[ "Creates", "a", "menu", "for", "the", "specified", "service" ]
[ "\"\"\"Creates a menu for the specified service\n :param service_name: The full name of the systemctl service, with or\n without the .service suffic\n :type service_name: basestring\n :return: A menu item datastructure\"\"\"" ]
[ { "param": "service_name", "type": null } ]
{ "returns": [ { "docstring": "A menu item datastructure", "docstring_tokens": [ "A", "menu", "item", "datastructure" ], "type": null } ], "raises": [], "params": [ { "identifier": "service_name", "type": null, "docstring": "T...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
link_menus
<not_specific>
def link_menus(*menu_items): """ Links a list of menu items into a loop of menu items :param menu_items: :return: the first menu item """ def link(a, b): a[NEXT] = b b[PREV] = a prev = menu_items[-1] for menu_item in menu_items: link(prev, menu_item) prev...
Links a list of menu items into a loop of menu items :param menu_items: :return: the first menu item
Links a list of menu items into a loop of menu items
[ "Links", "a", "list", "of", "menu", "items", "into", "a", "loop", "of", "menu", "items" ]
def link_menus(*menu_items): def link(a, b): a[NEXT] = b b[PREV] = a prev = menu_items[-1] for menu_item in menu_items: link(prev, menu_item) prev = menu_item return menu_items[0]
[ "def", "link_menus", "(", "*", "menu_items", ")", ":", "def", "link", "(", "a", ",", "b", ")", ":", "a", "[", "NEXT", "]", "=", "b", "b", "[", "PREV", "]", "=", "a", "prev", "=", "menu_items", "[", "-", "1", "]", "for", "menu_item", "in", "me...
Links a list of menu items into a loop of menu items
[ "Links", "a", "list", "of", "menu", "items", "into", "a", "loop", "of", "menu", "items" ]
[ "\"\"\"\n Links a list of menu items into a loop of menu items\n :param menu_items:\n :return: the first menu item\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "the first menu item", "docstring_tokens": [ "the", "first", "menu", "item" ], "type": null } ], "raises": [], "params": [], "outlier_params": [ { "identifier": "menu_items", "type": null, "docs...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
create_submenu
<not_specific>
def create_submenu(parent, *menu_items): """Make a menu item open a submenu consisting of the nominated menu items :param parent: A menu item that, when invoked, opens a sub menu :type parent: dict (a menu item) :param menu_items: An unbounded number of menu item data structures that comprise the cr...
Make a menu item open a submenu consisting of the nominated menu items :param parent: A menu item that, when invoked, opens a sub menu :type parent: dict (a menu item) :param menu_items: An unbounded number of menu item data structures that comprise the create_submenu :type menu_items: dict :ret...
Make a menu item open a submenu consisting of the nominated menu items
[ "Make", "a", "menu", "item", "open", "a", "submenu", "consisting", "of", "the", "nominated", "menu", "items" ]
def create_submenu(parent, *menu_items): link_menus(*menu_items) parent[ACTION] = lambda state: state.push(menu_items[0]) return parent
[ "def", "create_submenu", "(", "parent", ",", "*", "menu_items", ")", ":", "link_menus", "(", "*", "menu_items", ")", "parent", "[", "ACTION", "]", "=", "lambda", "state", ":", "state", ".", "push", "(", "menu_items", "[", "0", "]", ")", "return", "pare...
Make a menu item open a submenu consisting of the nominated menu items
[ "Make", "a", "menu", "item", "open", "a", "submenu", "consisting", "of", "the", "nominated", "menu", "items" ]
[ "\"\"\"Make a menu item open a submenu consisting of the nominated menu items\n :param parent: A menu item that, when invoked, opens a sub menu\n :type parent: dict (a menu item)\n :param menu_items: An unbounded number of menu item data structures\n that comprise the create_submenu\n :type menu_item...
[ { "param": "parent", "type": null } ]
{ "returns": [ { "docstring": "the parent menu item", "docstring_tokens": [ "the", "parent", "menu", "item" ], "type": null } ], "raises": [], "params": [ { "identifier": "parent", "type": null, "docstring": "A menu item that,...
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
load_average
<not_specific>
def load_average(_): """Return the load average component of the uptime command""" values = popen("uptime").read().strip().split(' ')[-3:] out = [] for value in values: if len(value) > 4: # This value is too big to display well try: ...
Return the load average component of the uptime command
Return the load average component of the uptime command
[ "Return", "the", "load", "average", "component", "of", "the", "uptime", "command" ]
def load_average(_): values = popen("uptime").read().strip().split(' ')[-3:] out = [] for value in values: if len(value) > 4: try: f = float(value) if f > 100.0: value = "{:.0f}".format(f) ...
[ "def", "load_average", "(", "_", ")", ":", "values", "=", "popen", "(", "\"uptime\"", ")", ".", "read", "(", ")", ".", "strip", "(", ")", ".", "split", "(", "' '", ")", "[", "-", "3", ":", "]", "out", "=", "[", "]", "for", "value", "in", "val...
Return the load average component of the uptime command
[ "Return", "the", "load", "average", "component", "of", "the", "uptime", "command" ]
[ "\"\"\"Return the load average component of the uptime command\"\"\"", "# This value is too big to display well", "# Unfortunately this load avg is inherently too big", "# Just display the integer", "# Round to 3 sig fig to display in 4 digits or less", "# Ensure the output is at least 14 characters to en...
[ { "param": "_", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "_", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
install
<not_specific>
def install(): """Install this into a system. Must be root""" # First - do we the correct libraries installed? print("Testing that we have the right libraries...") try: import RPLCD.i2c import gpiozero except ImportError: print("ERROR: Please install the RPLCD and gpiozero P...
Install this into a system. Must be root
Install this into a system. Must be root
[ "Install", "this", "into", "a", "system", ".", "Must", "be", "root" ]
def install(): print("Testing that we have the right libraries...") try: import RPLCD.i2c import gpiozero except ImportError: print("ERROR: Please install the RPLCD and gpiozero Python libraries") return from os import system print("Probing whether " + SERVICE + " alr...
[ "def", "install", "(", ")", ":", "print", "(", "\"Testing that we have the right libraries...\"", ")", "try", ":", "import", "RPLCD", ".", "i2c", "import", "gpiozero", "except", "ImportError", ":", "print", "(", "\"ERROR: Please install the RPLCD and gpiozero Python libra...
Install this into a system.
[ "Install", "this", "into", "a", "system", "." ]
[ "\"\"\"Install this into a system. Must be root\"\"\"", "# First - do we the correct libraries installed?" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
66e79effd98fdef103bbe10ff5153384947d7476
aalcock/HD44780LCD
menu/lcdmenu.py
[ "MIT" ]
Python
create_arg_parser
<not_specific>
def create_arg_parser(): """Create an argparse object for lcdmenu parameters""" from argparse import ArgumentParser parser = ArgumentParser( description="System control menu on HD44780 LCD panel") parser.add_argument("mode", nargs="?", choices=["si...
Create an argparse object for lcdmenu parameters
Create an argparse object for lcdmenu parameters
[ "Create", "an", "argparse", "object", "for", "lcdmenu", "parameters" ]
def create_arg_parser(): from argparse import ArgumentParser parser = ArgumentParser( description="System control menu on HD44780 LCD panel") parser.add_argument("mode", nargs="?", choices=["simulate", "lcd", "install"], default...
[ "def", "create_arg_parser", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", "parser", "=", "ArgumentParser", "(", "description", "=", "\"System control menu on HD44780 LCD panel\"", ")", "parser", ".", "add_argument", "(", "\"mode\"", ",", "nargs", "=",...
Create an argparse object for lcdmenu parameters
[ "Create", "an", "argparse", "object", "for", "lcdmenu", "parameters" ]
[ "\"\"\"Create an argparse object for lcdmenu parameters\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
403d128a91e13ee8596cc1a7640b70e210499667
mfincker/sweettweet-app
backend/sweettweet/api.py
[ "BSD-3-Clause" ]
Python
api_getGlucoseData
<not_specific>
def api_getGlucoseData(): ''' Return 12 h of cgm data from a user to prepopulate the glucose visualization component. ''' SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) data_url = os.path.join(SITE_ROOT, 'static/data', 'glucose_data_example_vega.json') data = json.load(open(data_ur...
Return 12 h of cgm data from a user to prepopulate the glucose visualization component.
Return 12 h of cgm data from a user to prepopulate the glucose visualization component.
[ "Return", "12", "h", "of", "cgm", "data", "from", "a", "user", "to", "prepopulate", "the", "glucose", "visualization", "component", "." ]
def api_getGlucoseData(): SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) data_url = os.path.join(SITE_ROOT, 'static/data', 'glucose_data_example_vega.json') data = json.load(open(data_url)) resp = jsonify({'data' : data}) resp.status_code = 200 return resp
[ "def", "api_getGlucoseData", "(", ")", ":", "SITE_ROOT", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "data_url", "=", "os", ".", "path", ".", "join", "(", "SITE_ROOT", ",", "'static/data'"...
Return 12 h of cgm data from a user to prepopulate the glucose visualization component.
[ "Return", "12", "h", "of", "cgm", "data", "from", "a", "user", "to", "prepopulate", "the", "glucose", "visualization", "component", "." ]
[ "'''\n Return 12 h of cgm data from a user to prepopulate the glucose\n visualization component.\n '''" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
403d128a91e13ee8596cc1a7640b70e210499667
mfincker/sweettweet-app
backend/sweettweet/api.py
[ "BSD-3-Clause" ]
Python
api_updateGlucose
<not_specific>
def api_updateGlucose(): ''' Get glucose data from request and return the glucose predictions for the next 30 mins (6 timepoints). Also send an SMS alert if model predicts hypoglycemia in the next 30 mins if user provides a phone number. ''' # Extract data from request req_data = ...
Get glucose data from request and return the glucose predictions for the next 30 mins (6 timepoints). Also send an SMS alert if model predicts hypoglycemia in the next 30 mins if user provides a phone number.
Get glucose data from request and return the glucose predictions for the next 30 mins (6 timepoints). Also send an SMS alert if model predicts hypoglycemia in the next 30 mins if user provides a phone number.
[ "Get", "glucose", "data", "from", "request", "and", "return", "the", "glucose", "predictions", "for", "the", "next", "30", "mins", "(", "6", "timepoints", ")", ".", "Also", "send", "an", "SMS", "alert", "if", "model", "predicts", "hypoglycemia", "in", "the...
def api_updateGlucose(): req_data = request.get_json() newBG = req_data['newBG'] past_data = req_data['data'] past_alarm = req_data['alarm'] user_info = req_data['userInfo'] data, alarm = app.model.forecast(past_data, user_info, newBG) sent_alarm = 0 if alarm == 1 and past_alarm == 0: ...
[ "def", "api_updateGlucose", "(", ")", ":", "req_data", "=", "request", ".", "get_json", "(", ")", "newBG", "=", "req_data", "[", "'newBG'", "]", "past_data", "=", "req_data", "[", "'data'", "]", "past_alarm", "=", "req_data", "[", "'alarm'", "]", "user_inf...
Get glucose data from request and return the glucose predictions for the next 30 mins (6 timepoints).
[ "Get", "glucose", "data", "from", "request", "and", "return", "the", "glucose", "predictions", "for", "the", "next", "30", "mins", "(", "6", "timepoints", ")", "." ]
[ "'''\n Get glucose data from request and return the glucose predictions \n for the next 30 mins (6 timepoints).\n \n Also send an SMS alert if model predicts hypoglycemia in the next\n 30 mins if user provides a phone number.\n '''", "# Extract data from request", "# Update glucose data with n...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
403d128a91e13ee8596cc1a7640b70e210499667
mfincker/sweettweet-app
backend/sweettweet/api.py
[ "BSD-3-Clause" ]
Python
send_alert
null
def send_alert(phone_number): ''' Send an SMS alert to @phone_number to warn about impending hypoglycemia using Twilio service ''' if phone_number: message = 'Your blood sugar level is likely to dip below 70 in the next half hour. How about some orange juice?' twilio_service = Twi...
Send an SMS alert to @phone_number to warn about impending hypoglycemia using Twilio service
Send an SMS alert to @phone_number to warn about impending hypoglycemia using Twilio service
[ "Send", "an", "SMS", "alert", "to", "@phone_number", "to", "warn", "about", "impending", "hypoglycemia", "using", "Twilio", "service" ]
def send_alert(phone_number): if phone_number: message = 'Your blood sugar level is likely to dip below 70 in the next half hour. How about some orange juice?' twilio_service = TwilioService() try: twilio_service.send_message(message, phone_number) except TwilioRestExcept...
[ "def", "send_alert", "(", "phone_number", ")", ":", "if", "phone_number", ":", "message", "=", "'Your blood sugar level is likely to dip below 70 in the next half hour. How about some orange juice?'", "twilio_service", "=", "TwilioService", "(", ")", "try", ":", "twilio_service...
Send an SMS alert to @phone_number to warn about impending hypoglycemia using Twilio service
[ "Send", "an", "SMS", "alert", "to", "@phone_number", "to", "warn", "about", "impending", "hypoglycemia", "using", "Twilio", "service" ]
[ "'''\n Send an SMS alert to @phone_number to warn about \n impending hypoglycemia using Twilio service\n '''" ]
[ { "param": "phone_number", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "phone_number", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e135829c41312c5d26428aecb06997ddeeba8427
mfincker/sweettweet-app
backend/sweettweet/services/lstm_model.py
[ "BSD-3-Clause" ]
Python
forecast
<not_specific>
def forecast(self, past_data, user_info, new_bg): ''' Return predicted glucose data along with past data and hypoglycemic alarm state based on input past data, user info and new glucose measurement. ''' # read in past glucose data data = pd.read_json(json.dumps(past_data...
Return predicted glucose data along with past data and hypoglycemic alarm state based on input past data, user info and new glucose measurement.
Return predicted glucose data along with past data and hypoglycemic alarm state based on input past data, user info and new glucose measurement.
[ "Return", "predicted", "glucose", "data", "along", "with", "past", "data", "and", "hypoglycemic", "alarm", "state", "based", "on", "input", "past", "data", "user", "info", "and", "new", "glucose", "measurement", "." ]
def forecast(self, past_data, user_info, new_bg): data = pd.read_json(json.dumps(past_data)) data.actualTime = [pd.Timestamp(d, unit='ms') for d in data.actualTime] data.forecastTime = [pd.Timestamp(d, unit='ms') for d in data.forecastTime] data.sort_values(['actualTime', 'forecastTime']...
[ "def", "forecast", "(", "self", ",", "past_data", ",", "user_info", ",", "new_bg", ")", ":", "data", "=", "pd", ".", "read_json", "(", "json", ".", "dumps", "(", "past_data", ")", ")", "data", ".", "actualTime", "=", "[", "pd", ".", "Timestamp", "(",...
Return predicted glucose data along with past data and hypoglycemic alarm state based on input past data, user info and new glucose measurement.
[ "Return", "predicted", "glucose", "data", "along", "with", "past", "data", "and", "hypoglycemic", "alarm", "state", "based", "on", "input", "past", "data", "user", "info", "and", "new", "glucose", "measurement", "." ]
[ "'''\n Return predicted glucose data along with past data and hypoglycemic\n alarm state based on input past data, user info and new glucose measurement.\n '''", "# read in past glucose data", "# format columns to timestamp", "# new measurement timestamp", "# add new measurement to past...
[ { "param": "self", "type": null }, { "param": "past_data", "type": null }, { "param": "user_info", "type": null }, { "param": "new_bg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "past_data", "type": null, "docstring": null, "docstring_token...
2f9be1bb0d326f06c6e6fbd5b49648aaafd4d87c
mfincker/sweettweet-app
backend/sweettweet/services/utils.py
[ "BSD-3-Clause" ]
Python
f_beta
<not_specific>
def f_beta(p, r, beta = 2): ''' Return f_beta score given a precision and recall score ''' return ((1+beta * beta) * (p * r)) / ((beta * beta * p) + r)
Return f_beta score given a precision and recall score
Return f_beta score given a precision and recall score
[ "Return", "f_beta", "score", "given", "a", "precision", "and", "recall", "score" ]
def f_beta(p, r, beta = 2): return ((1+beta * beta) * (p * r)) / ((beta * beta * p) + r)
[ "def", "f_beta", "(", "p", ",", "r", ",", "beta", "=", "2", ")", ":", "return", "(", "(", "1", "+", "beta", "*", "beta", ")", "*", "(", "p", "*", "r", ")", ")", "/", "(", "(", "beta", "*", "beta", "*", "p", ")", "+", "r", ")" ]
Return f_beta score given a precision and recall score
[ "Return", "f_beta", "score", "given", "a", "precision", "and", "recall", "score" ]
[ "'''\n\tReturn f_beta score given a precision and recall score\n\t'''" ]
[ { "param": "p", "type": null }, { "param": "r", "type": null }, { "param": "beta", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r", "type": null, "docstring": null, "docstring_tokens": [], ...
2f9be1bb0d326f06c6e6fbd5b49648aaafd4d87c
mfincker/sweettweet-app
backend/sweettweet/services/utils.py
[ "BSD-3-Clause" ]
Python
weighted_mse
<not_specific>
def weighted_mse(yTrue,yPred): ''' Custom mean-squared error that emphasizes the weights for later predictions during multi-step forecasting. ''' ones = K.ones_like(yTrue[0,:]) #a simple vector with ones shaped as (forecast_step,) idx = K.cumsum(ones) #similar to a 'range(1,forecast_step + 1)' idx = K.reverse(i...
Custom mean-squared error that emphasizes the weights for later predictions during multi-step forecasting.
Custom mean-squared error that emphasizes the weights for later predictions during multi-step forecasting.
[ "Custom", "mean", "-", "squared", "error", "that", "emphasizes", "the", "weights", "for", "later", "predictions", "during", "multi", "-", "step", "forecasting", "." ]
def weighted_mse(yTrue,yPred): ones = K.ones_like(yTrue[0,:]) idx = K.cumsum(ones) idx = K.reverse(idx, axes = 0) return K.mean((1/idx)*K.square(yTrue-yPred))
[ "def", "weighted_mse", "(", "yTrue", ",", "yPred", ")", ":", "ones", "=", "K", ".", "ones_like", "(", "yTrue", "[", "0", ",", ":", "]", ")", "idx", "=", "K", ".", "cumsum", "(", "ones", ")", "idx", "=", "K", ".", "reverse", "(", "idx", ",", "...
Custom mean-squared error that emphasizes the weights for later predictions during multi-step forecasting.
[ "Custom", "mean", "-", "squared", "error", "that", "emphasizes", "the", "weights", "for", "later", "predictions", "during", "multi", "-", "step", "forecasting", "." ]
[ "'''\n\tCustom mean-squared error that emphasizes the weights for \n\tlater predictions during multi-step forecasting.\n\t'''", "#a simple vector with ones shaped as (forecast_step,)", "#similar to a 'range(1,forecast_step + 1)'" ]
[ { "param": "yTrue", "type": null }, { "param": "yPred", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "yTrue", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "yPred", "type": null, "docstring": null, "docstring_tokens":...