repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
acutesoftware/AIKIF
aikif/web_app/page_search.py
search_aikif
def search_aikif(txt, formatHTML=True): """ search for text - currently this looks in all folders in the root of AIKIF but that also contains binaries so will need to use the agent_filelist.py to specify the list of folders. NOTE - this needs to use indexes rather than full search each time ...
python
def search_aikif(txt, formatHTML=True): """ search for text - currently this looks in all folders in the root of AIKIF but that also contains binaries so will need to use the agent_filelist.py to specify the list of folders. NOTE - this needs to use indexes rather than full search each time ...
[ "def", "search_aikif", "(", "txt", ",", "formatHTML", "=", "True", ")", ":", "results", "=", "[", "]", "num_found", "=", "0", "import", "aikif", ".", "lib", ".", "cls_filelist", "as", "mod_fl", "my_files", "=", "mod_fl", ".", "FileList", "(", "[", "aik...
search for text - currently this looks in all folders in the root of AIKIF but that also contains binaries so will need to use the agent_filelist.py to specify the list of folders. NOTE - this needs to use indexes rather than full search each time
[ "search", "for", "text", "-", "currently", "this", "looks", "in", "all", "folders", "in", "the", "root", "of", "AIKIF", "but", "that", "also", "contains", "binaries", "so", "will", "need", "to", "use", "the", "agent_filelist", ".", "py", "to", "specify", ...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_search.py#L23-L58
train
acutesoftware/AIKIF
aikif/web_app/page_search.py
format_result
def format_result(line, line_num, txt): """ highlight the search result """ return '&nbsp;&nbsp;' + str(line_num) + ': ' + line.replace(txt, '<span style="background-color: #FFFF00">' + txt + '</span>')
python
def format_result(line, line_num, txt): """ highlight the search result """ return '&nbsp;&nbsp;' + str(line_num) + ': ' + line.replace(txt, '<span style="background-color: #FFFF00">' + txt + '</span>')
[ "def", "format_result", "(", "line", ",", "line_num", ",", "txt", ")", ":", "return", "'&nbsp;&nbsp;'", "+", "str", "(", "line_num", ")", "+", "': '", "+", "line", ".", "replace", "(", "txt", ",", "'<span style=\"background-color: #FFFF00\">'", "+", "txt", "...
highlight the search result
[ "highlight", "the", "search", "result" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_search.py#L60-L63
train
acutesoftware/AIKIF
aikif/environments/happiness.py
TEST
def TEST(): """ Modules for testing happiness of 'persons' in 'worlds' based on simplistic preferences. Just a toy - dont take seriously ----- WORLD SUMMARY for : Mars ----- population = 0 tax_rate = 0.0 tradition = 0.9 equity = 0.0 Preferences for Rov...
python
def TEST(): """ Modules for testing happiness of 'persons' in 'worlds' based on simplistic preferences. Just a toy - dont take seriously ----- WORLD SUMMARY for : Mars ----- population = 0 tax_rate = 0.0 tradition = 0.9 equity = 0.0 Preferences for Rov...
[ "def", "TEST", "(", ")", ":", "w", "=", "World", "(", "'Mars'", ",", "[", "0", ",", "0.0", ",", "0.9", ",", "0.0", "]", ")", "print", "(", "w", ")", "p", "=", "Person", "(", "'Rover'", ",", "{", "'tax_min'", ":", "0.0", ",", "'tax_max'", ":",...
Modules for testing happiness of 'persons' in 'worlds' based on simplistic preferences. Just a toy - dont take seriously ----- WORLD SUMMARY for : Mars ----- population = 0 tax_rate = 0.0 tradition = 0.9 equity = 0.0 Preferences for Rover tax_min = 0....
[ "Modules", "for", "testing", "happiness", "of", "persons", "in", "worlds", "based", "on", "simplistic", "preferences", ".", "Just", "a", "toy", "-", "dont", "take", "seriously" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L3-L39
train
acutesoftware/AIKIF
aikif/environments/happiness.py
WorldFinder.solve
def solve(self, max_worlds=10000, silent=False): """ find the best world to make people happy """ self.num_worlds = 0 num_unhappy = 0 for tax_rate in range(self.tax_range[0],self.tax_range[1]): for equity in range(self.equity_range[0],self.equity_range[1]): ...
python
def solve(self, max_worlds=10000, silent=False): """ find the best world to make people happy """ self.num_worlds = 0 num_unhappy = 0 for tax_rate in range(self.tax_range[0],self.tax_range[1]): for equity in range(self.equity_range[0],self.equity_range[1]): ...
[ "def", "solve", "(", "self", ",", "max_worlds", "=", "10000", ",", "silent", "=", "False", ")", ":", "self", ".", "num_worlds", "=", "0", "num_unhappy", "=", "0", "for", "tax_rate", "in", "range", "(", "self", ".", "tax_range", "[", "0", "]", ",", ...
find the best world to make people happy
[ "find", "the", "best", "world", "to", "make", "people", "happy" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L129-L153
train
acutesoftware/AIKIF
aikif/environments/happiness.py
Happiness.show_details
def show_details(self): """ extended print details of happiness parameters """ res = str(self) res += '\nDETAILS\n' for f in self.factors: res += str(f) return res
python
def show_details(self): """ extended print details of happiness parameters """ res = str(self) res += '\nDETAILS\n' for f in self.factors: res += str(f) return res
[ "def", "show_details", "(", "self", ")", ":", "res", "=", "str", "(", "self", ")", "res", "+=", "'\\nDETAILS\\n'", "for", "f", "in", "self", ".", "factors", ":", "res", "+=", "str", "(", "f", ")", "return", "res" ]
extended print details of happiness parameters
[ "extended", "print", "details", "of", "happiness", "parameters" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L222-L231
train
acutesoftware/AIKIF
aikif/environments/happiness.py
Value.match_value_to_text
def match_value_to_text(self, text): """ this is going to be the tricky bit - probably not possible to get the 'exact' rating for a value. Will need to do sentiment analysis of the text to see how it matches the rating. Even that sounds like it wont work - maybe a ML algorithm wo...
python
def match_value_to_text(self, text): """ this is going to be the tricky bit - probably not possible to get the 'exact' rating for a value. Will need to do sentiment analysis of the text to see how it matches the rating. Even that sounds like it wont work - maybe a ML algorithm wo...
[ "def", "match_value_to_text", "(", "self", ",", "text", ")", ":", "if", "self", ".", "nme", "in", "text", ":", "res", "=", "0.8", "else", ":", "res", "=", "0.2", "return", "self", ".", "nme", "+", "' = '", "+", "str", "(", "res", ")", "+", "' mat...
this is going to be the tricky bit - probably not possible to get the 'exact' rating for a value. Will need to do sentiment analysis of the text to see how it matches the rating. Even that sounds like it wont work - maybe a ML algorithm would do it, but that requires a large body of text...
[ "this", "is", "going", "to", "be", "the", "tricky", "bit", "-", "probably", "not", "possible", "to", "get", "the", "exact", "rating", "for", "a", "value", ".", "Will", "need", "to", "do", "sentiment", "analysis", "of", "the", "text", "to", "see", "how"...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L310-L329
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
list2html
def list2html(lst): """ convert a list to html using table formatting """ txt = '<TABLE width=100% border=0>' for l in lst: txt += '<TR>\n' if type(l) is str: txt+= '<TD>' + l + '</TD>\n' elif type(l) is list: txt+= '<TD>' for i in l: ...
python
def list2html(lst): """ convert a list to html using table formatting """ txt = '<TABLE width=100% border=0>' for l in lst: txt += '<TR>\n' if type(l) is str: txt+= '<TD>' + l + '</TD>\n' elif type(l) is list: txt+= '<TD>' for i in l: ...
[ "def", "list2html", "(", "lst", ")", ":", "txt", "=", "'<TABLE width=100% border=0>'", "for", "l", "in", "lst", ":", "txt", "+=", "'<TR>\\n'", "if", "type", "(", "l", ")", "is", "str", ":", "txt", "+=", "'<TD>'", "+", "l", "+", "'</TD>\\n'", "elif", ...
convert a list to html using table formatting
[ "convert", "a", "list", "to", "html", "using", "table", "formatting" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L10-L28
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
build_edit_form
def build_edit_form(title, id, cols, return_page): """ returns the html for a simple edit form """ txt = '<H3>' + title + '<H3>' txt += '<form action="' + return_page + '" method="POST">\n' # return_page = /agents txt += ' updating id:' + str(id) + '\n<BR>' txt += ' <input type="hidden" ...
python
def build_edit_form(title, id, cols, return_page): """ returns the html for a simple edit form """ txt = '<H3>' + title + '<H3>' txt += '<form action="' + return_page + '" method="POST">\n' # return_page = /agents txt += ' updating id:' + str(id) + '\n<BR>' txt += ' <input type="hidden" ...
[ "def", "build_edit_form", "(", "title", ",", "id", ",", "cols", ",", "return_page", ")", ":", "txt", "=", "'<H3>'", "+", "title", "+", "'<H3>'", "txt", "+=", "'<form action=\"'", "+", "return_page", "+", "'\" method=\"POST\">\\n'", "txt", "+=", "' updating id...
returns the html for a simple edit form
[ "returns", "the", "html", "for", "a", "simple", "edit", "form" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L67-L89
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
build_html_listbox
def build_html_listbox(lst, nme): """ returns the html to display a listbox """ res = '<select name="' + nme + '" multiple="multiple">\n' for l in lst: res += ' <option>' + str(l) + '</option>\n' res += '</select>\n' return res
python
def build_html_listbox(lst, nme): """ returns the html to display a listbox """ res = '<select name="' + nme + '" multiple="multiple">\n' for l in lst: res += ' <option>' + str(l) + '</option>\n' res += '</select>\n' return res
[ "def", "build_html_listbox", "(", "lst", ",", "nme", ")", ":", "res", "=", "'<select name=\"'", "+", "nme", "+", "'\" multiple=\"multiple\">\\n'", "for", "l", "in", "lst", ":", "res", "+=", "' <option>'", "+", "str", "(", "l", ")", "+", "'</option>\\n'", ...
returns the html to display a listbox
[ "returns", "the", "html", "to", "display", "a", "listbox" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L91-L100
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
build_data_list
def build_data_list(lst): """ returns the html with supplied list as a HTML listbox """ txt = '<H3>' + List + '<H3><UL>' for i in lst: txt += '<LI>' + i + '</LI>' txt += '<UL>' return txt
python
def build_data_list(lst): """ returns the html with supplied list as a HTML listbox """ txt = '<H3>' + List + '<H3><UL>' for i in lst: txt += '<LI>' + i + '</LI>' txt += '<UL>' return txt
[ "def", "build_data_list", "(", "lst", ")", ":", "txt", "=", "'<H3>'", "+", "List", "+", "'<H3><UL>'", "for", "i", "in", "lst", ":", "txt", "+=", "'<LI>'", "+", "i", "+", "'</LI>'", "txt", "+=", "'<UL>'", "return", "txt" ]
returns the html with supplied list as a HTML listbox
[ "returns", "the", "html", "with", "supplied", "list", "as", "a", "HTML", "listbox" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L102-L111
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
filelist2html
def filelist2html(lst, fldr, hasHeader='N'): """ formats a standard filelist to htmk using table formats """ txt = '<TABLE width=100% border=0>' numRows = 1 if lst: for l in lst: if hasHeader == 'Y': if numRows == 1: td_begin = '<TH>' ...
python
def filelist2html(lst, fldr, hasHeader='N'): """ formats a standard filelist to htmk using table formats """ txt = '<TABLE width=100% border=0>' numRows = 1 if lst: for l in lst: if hasHeader == 'Y': if numRows == 1: td_begin = '<TH>' ...
[ "def", "filelist2html", "(", "lst", ",", "fldr", ",", "hasHeader", "=", "'N'", ")", ":", "txt", "=", "'<TABLE width=100% border=0>'", "numRows", "=", "1", "if", "lst", ":", "for", "l", "in", "lst", ":", "if", "hasHeader", "==", "'Y'", ":", "if", "numRo...
formats a standard filelist to htmk using table formats
[ "formats", "a", "standard", "filelist", "to", "htmk", "using", "table", "formats" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L114-L145
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
link_file
def link_file(f, fldr): """ creates a html link for a file using folder fldr """ fname = os.path.join(fldr,f) if os.path.isfile(fname): return '<a href="/aikif/data/core/' + f + '">' + f + '</a>' else: return f
python
def link_file(f, fldr): """ creates a html link for a file using folder fldr """ fname = os.path.join(fldr,f) if os.path.isfile(fname): return '<a href="/aikif/data/core/' + f + '">' + f + '</a>' else: return f
[ "def", "link_file", "(", "f", ",", "fldr", ")", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "fldr", ",", "f", ")", "if", "os", ".", "path", ".", "isfile", "(", "fname", ")", ":", "return", "'<a href=\"/aikif/data/core/'", "+", "f", "+",...
creates a html link for a file using folder fldr
[ "creates", "a", "html", "link", "for", "a", "file", "using", "folder", "fldr" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L147-L155
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
dict_to_htmlrow
def dict_to_htmlrow(d): """ converts a dictionary to a HTML table row """ res = "<TR>\n" for k, v in d.items(): if type(v) == str: res = res + '<TD><p>' + k + ':</p></TD><TD><p>' + v + '</p></TD>' else: res = res + '<TD><p>' + k + ':</p></TD><TD><p>' + str(v) ...
python
def dict_to_htmlrow(d): """ converts a dictionary to a HTML table row """ res = "<TR>\n" for k, v in d.items(): if type(v) == str: res = res + '<TD><p>' + k + ':</p></TD><TD><p>' + v + '</p></TD>' else: res = res + '<TD><p>' + k + ':</p></TD><TD><p>' + str(v) ...
[ "def", "dict_to_htmlrow", "(", "d", ")", ":", "res", "=", "\"<TR>\\n\"", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "type", "(", "v", ")", "==", "str", ":", "res", "=", "res", "+", "'<TD><p>'", "+", "k", "+", "':</p></T...
converts a dictionary to a HTML table row
[ "converts", "a", "dictionary", "to", "a", "HTML", "table", "row" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L157-L168
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
read_csv_to_html_table
def read_csv_to_html_table(csvFile, hasHeader='N'): """ reads a CSV file and converts it to HTML """ txt = '<table class="as-table as-table-zebra as-table-horizontal">' with open(csvFile, "r") as f: # numRows = 1 for row in f: if hasHeader == 'Y': if num...
python
def read_csv_to_html_table(csvFile, hasHeader='N'): """ reads a CSV file and converts it to HTML """ txt = '<table class="as-table as-table-zebra as-table-horizontal">' with open(csvFile, "r") as f: # numRows = 1 for row in f: if hasHeader == 'Y': if num...
[ "def", "read_csv_to_html_table", "(", "csvFile", ",", "hasHeader", "=", "'N'", ")", ":", "txt", "=", "'<table class=\"as-table as-table-zebra as-table-horizontal\">'", "with", "open", "(", "csvFile", ",", "\"r\"", ")", "as", "f", ":", "numRows", "=", "1", "for", ...
reads a CSV file and converts it to HTML
[ "reads", "a", "CSV", "file", "and", "converts", "it", "to", "HTML" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L170-L202
train
acutesoftware/AIKIF
aikif/web_app/web_utils.py
read_csv_to_html_list
def read_csv_to_html_list(csvFile): """ reads a CSV file and converts it to a HTML List """ txt = '' with open(csvFile) as csv_file: for row in csv.reader(csv_file, delimiter=','): txt += '<div id="table_row">' for col in row: txt += " " ...
python
def read_csv_to_html_list(csvFile): """ reads a CSV file and converts it to a HTML List """ txt = '' with open(csvFile) as csv_file: for row in csv.reader(csv_file, delimiter=','): txt += '<div id="table_row">' for col in row: txt += " " ...
[ "def", "read_csv_to_html_list", "(", "csvFile", ")", ":", "txt", "=", "''", "with", "open", "(", "csvFile", ")", "as", "csv_file", ":", "for", "row", "in", "csv", ".", "reader", "(", "csv_file", ",", "delimiter", "=", "','", ")", ":", "txt", "+=", "'...
reads a CSV file and converts it to a HTML List
[ "reads", "a", "CSV", "file", "and", "converts", "it", "to", "a", "HTML", "List" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_utils.py#L206-L222
train
acutesoftware/AIKIF
aikif/agents/explore/agent_explore_grid.py
ExploreAgent.do_your_job
def do_your_job(self): """ the goal of the explore agent is to move to the target while avoiding blockages on the grid. This function is messy and needs to be looked at. It currently has a bug in that the backtrack oscillates so need a new method of doing this - probably...
python
def do_your_job(self): """ the goal of the explore agent is to move to the target while avoiding blockages on the grid. This function is messy and needs to be looked at. It currently has a bug in that the backtrack oscillates so need a new method of doing this - probably...
[ "def", "do_your_job", "(", "self", ")", ":", "y", ",", "x", "=", "self", ".", "get_intended_direction", "(", ")", "if", "self", ".", "target_x", "==", "self", ".", "current_x", "and", "self", ".", "target_y", "==", "self", ".", "current_y", ":", "if", ...
the goal of the explore agent is to move to the target while avoiding blockages on the grid. This function is messy and needs to be looked at. It currently has a bug in that the backtrack oscillates so need a new method of doing this - probably checking if previously backtracked...
[ "the", "goal", "of", "the", "explore", "agent", "is", "to", "move", "to", "the", "target", "while", "avoiding", "blockages", "on", "the", "grid", ".", "This", "function", "is", "messy", "and", "needs", "to", "be", "looked", "at", ".", "It", "currently", ...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/explore/agent_explore_grid.py#L43-L95
train
acutesoftware/AIKIF
aikif/agents/explore/agent_explore_grid.py
ExploreAgent.lg_mv
def lg_mv(self, log_lvl, txt): """ wrapper for debugging print and log methods """ if log_lvl <= self.LOG_LEVEL: print(txt + str(self.current_y) + "," + str(self.current_x))
python
def lg_mv(self, log_lvl, txt): """ wrapper for debugging print and log methods """ if log_lvl <= self.LOG_LEVEL: print(txt + str(self.current_y) + "," + str(self.current_x))
[ "def", "lg_mv", "(", "self", ",", "log_lvl", ",", "txt", ")", ":", "if", "log_lvl", "<=", "self", ".", "LOG_LEVEL", ":", "print", "(", "txt", "+", "str", "(", "self", ".", "current_y", ")", "+", "\",\"", "+", "str", "(", "self", ".", "current_x", ...
wrapper for debugging print and log methods
[ "wrapper", "for", "debugging", "print", "and", "log", "methods" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/explore/agent_explore_grid.py#L98-L103
train
acutesoftware/AIKIF
aikif/agents/explore/agent_explore_grid.py
ExploreAgent.get_intended_direction
def get_intended_direction(self): """ returns a Y,X value showing which direction the agent should move in order to get to the target """ x = 0 y = 0 if self.target_x == self.current_x and self.target_y == self.current_y: return y,x # target already a...
python
def get_intended_direction(self): """ returns a Y,X value showing which direction the agent should move in order to get to the target """ x = 0 y = 0 if self.target_x == self.current_x and self.target_y == self.current_y: return y,x # target already a...
[ "def", "get_intended_direction", "(", "self", ")", ":", "x", "=", "0", "y", "=", "0", "if", "self", ".", "target_x", "==", "self", ".", "current_x", "and", "self", ".", "target_y", "==", "self", ".", "current_y", ":", "return", "y", ",", "x", "if", ...
returns a Y,X value showing which direction the agent should move in order to get to the target
[ "returns", "a", "Y", "X", "value", "showing", "which", "direction", "the", "agent", "should", "move", "in", "order", "to", "get", "to", "the", "target" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/explore/agent_explore_grid.py#L105-L122
train
acutesoftware/AIKIF
aikif/agents/explore/agent_explore_grid.py
ExploreAgent.show_status
def show_status(self): """ dumps the status of the agent """ txt = 'Agent Status:\n' print(txt) txt += "start_x = " + str(self.start_x) + "\n" txt += "start_y = " + str(self.start_y) + "\n" txt += "target_x = " + str(self.target_x) + "\n" txt += ...
python
def show_status(self): """ dumps the status of the agent """ txt = 'Agent Status:\n' print(txt) txt += "start_x = " + str(self.start_x) + "\n" txt += "start_y = " + str(self.start_y) + "\n" txt += "target_x = " + str(self.target_x) + "\n" txt += ...
[ "def", "show_status", "(", "self", ")", ":", "txt", "=", "'Agent Status:\\n'", "print", "(", "txt", ")", "txt", "+=", "\"start_x = \"", "+", "str", "(", "self", ".", "start_x", ")", "+", "\"\\n\"", "txt", "+=", "\"start_y = \"", "+", "str", "(", "self"...
dumps the status of the agent
[ "dumps", "the", "status", "of", "the", "agent" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/explore/agent_explore_grid.py#L135-L150
train
acutesoftware/AIKIF
aikif/toolbox/audio_tools.py
get_audio_metadata_old
def get_audio_metadata_old(fname): """ retrieve the metadata from an MP3 file """ audio_dict = {} print("IDv2 tag info for %s:" % fname) try: audio = mutagenx.id3.ID3(fname, translate=False) except StandardError as err: print("ERROR = " + str(err)) #else: #print(audio.ppr...
python
def get_audio_metadata_old(fname): """ retrieve the metadata from an MP3 file """ audio_dict = {} print("IDv2 tag info for %s:" % fname) try: audio = mutagenx.id3.ID3(fname, translate=False) except StandardError as err: print("ERROR = " + str(err)) #else: #print(audio.ppr...
[ "def", "get_audio_metadata_old", "(", "fname", ")", ":", "audio_dict", "=", "{", "}", "print", "(", "\"IDv2 tag info for %s:\"", "%", "fname", ")", "try", ":", "audio", "=", "mutagenx", ".", "id3", ".", "ID3", "(", "fname", ",", "translate", "=", "False", ...
retrieve the metadata from an MP3 file
[ "retrieve", "the", "metadata", "from", "an", "MP3", "file" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/audio_tools.py#L65-L100
train
Nachtfeuer/pipeline
spline/tools/table.py
calculate_columns
def calculate_columns(sequence): """ Find all row names and the maximum column widths. Args: columns (dict): the keys are the column name and the value the max length. Returns: dict: column names (key) and widths (value). """ columns = {} for row in sequence: for k...
python
def calculate_columns(sequence): """ Find all row names and the maximum column widths. Args: columns (dict): the keys are the column name and the value the max length. Returns: dict: column names (key) and widths (value). """ columns = {} for row in sequence: for k...
[ "def", "calculate_columns", "(", "sequence", ")", ":", "columns", "=", "{", "}", "for", "row", "in", "sequence", ":", "for", "key", "in", "row", ".", "keys", "(", ")", ":", "if", "key", "not", "in", "columns", ":", "columns", "[", "key", "]", "=", ...
Find all row names and the maximum column widths. Args: columns (dict): the keys are the column name and the value the max length. Returns: dict: column names (key) and widths (value).
[ "Find", "all", "row", "names", "and", "the", "maximum", "column", "widths", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/table.py#L5-L26
train
Nachtfeuer/pipeline
spline/tools/table.py
calculate_row_format
def calculate_row_format(columns, keys=None): """ Calculate row format. Args: columns (dict): the keys are the column name and the value the max length. keys (list): optional list of keys to order columns as well as to filter for them. Returns: str: format for table row """...
python
def calculate_row_format(columns, keys=None): """ Calculate row format. Args: columns (dict): the keys are the column name and the value the max length. keys (list): optional list of keys to order columns as well as to filter for them. Returns: str: format for table row """...
[ "def", "calculate_row_format", "(", "columns", ",", "keys", "=", "None", ")", ":", "row_format", "=", "''", "if", "keys", "is", "None", ":", "keys", "=", "columns", ".", "keys", "(", ")", "else", ":", "keys", "=", "[", "key", "for", "key", "in", "k...
Calculate row format. Args: columns (dict): the keys are the column name and the value the max length. keys (list): optional list of keys to order columns as well as to filter for them. Returns: str: format for table row
[ "Calculate", "row", "format", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/table.py#L29-L51
train
Nachtfeuer/pipeline
spline/tools/table.py
pprint
def pprint(sequence, keys=None): """ Print sequence as ascii table to stdout. Args: sequence (list or tuple): a sequence with a dictionary each entry. keys (list): optional list of keys to order columns as well as to filter for them. """ if len(sequence) > 0: columns = calcu...
python
def pprint(sequence, keys=None): """ Print sequence as ascii table to stdout. Args: sequence (list or tuple): a sequence with a dictionary each entry. keys (list): optional list of keys to order columns as well as to filter for them. """ if len(sequence) > 0: columns = calcu...
[ "def", "pprint", "(", "sequence", ",", "keys", "=", "None", ")", ":", "if", "len", "(", "sequence", ")", ">", "0", ":", "columns", "=", "calculate_columns", "(", "sequence", ")", "row_format", "=", "calculate_row_format", "(", "columns", ",", "keys", ")"...
Print sequence as ascii table to stdout. Args: sequence (list or tuple): a sequence with a dictionary each entry. keys (list): optional list of keys to order columns as well as to filter for them.
[ "Print", "sequence", "as", "ascii", "table", "to", "stdout", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/table.py#L54-L75
train
Nachtfeuer/pipeline
spline/matrix.py
matrix_worker
def matrix_worker(data): """ Run pipelines in parallel. Args: data(dict): parameters for the pipeline (model, options, ...). Returns: dict: with two fields: success True/False and captured output (list of str). """ matrix = data['matrix'] Logger.get_logger(__name__ + '.worke...
python
def matrix_worker(data): """ Run pipelines in parallel. Args: data(dict): parameters for the pipeline (model, options, ...). Returns: dict: with two fields: success True/False and captured output (list of str). """ matrix = data['matrix'] Logger.get_logger(__name__ + '.worke...
[ "def", "matrix_worker", "(", "data", ")", ":", "matrix", "=", "data", "[", "'matrix'", "]", "Logger", ".", "get_logger", "(", "__name__", "+", "'.worker'", ")", ".", "info", "(", "\"Processing pipeline for matrix entry '%s'\"", ",", "matrix", "[", "'name'", "]...
Run pipelines in parallel. Args: data(dict): parameters for the pipeline (model, options, ...). Returns: dict: with two fields: success True/False and captured output (list of str).
[ "Run", "pipelines", "in", "parallel", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/matrix.py#L32-L50
train
Nachtfeuer/pipeline
spline/matrix.py
Matrix.can_process_matrix
def can_process_matrix(entry, matrix_tags): """ Check given matrix tags to be in the given list of matric tags. Args: entry (dict): matrix item (in yaml). matrix_tags (list): represents --matrix-tags defined by user in command line. Returns: bool: Tru...
python
def can_process_matrix(entry, matrix_tags): """ Check given matrix tags to be in the given list of matric tags. Args: entry (dict): matrix item (in yaml). matrix_tags (list): represents --matrix-tags defined by user in command line. Returns: bool: Tru...
[ "def", "can_process_matrix", "(", "entry", ",", "matrix_tags", ")", ":", "if", "len", "(", "matrix_tags", ")", "==", "0", ":", "return", "True", "count", "=", "0", "if", "'tags'", "in", "entry", ":", "for", "tag", "in", "matrix_tags", ":", "if", "tag",...
Check given matrix tags to be in the given list of matric tags. Args: entry (dict): matrix item (in yaml). matrix_tags (list): represents --matrix-tags defined by user in command line. Returns: bool: True when matrix entry can be processed.
[ "Check", "given", "matrix", "tags", "to", "be", "in", "the", "given", "list", "of", "matric", "tags", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/matrix.py#L115-L134
train
Nachtfeuer/pipeline
spline/matrix.py
Matrix.run_matrix_ordered
def run_matrix_ordered(self, process_data): """ Running pipelines one after the other. Returns dict: with two fields: success True/False and captured output (list of str). """ output = [] for entry in self.matrix: env = entry['env'].copy() ...
python
def run_matrix_ordered(self, process_data): """ Running pipelines one after the other. Returns dict: with two fields: success True/False and captured output (list of str). """ output = [] for entry in self.matrix: env = entry['env'].copy() ...
[ "def", "run_matrix_ordered", "(", "self", ",", "process_data", ")", ":", "output", "=", "[", "]", "for", "entry", "in", "self", ".", "matrix", ":", "env", "=", "entry", "[", "'env'", "]", ".", "copy", "(", ")", "env", ".", "update", "(", "{", "'PIP...
Running pipelines one after the other. Returns dict: with two fields: success True/False and captured output (list of str).
[ "Running", "pipelines", "one", "after", "the", "other", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/matrix.py#L136-L157
train
Nachtfeuer/pipeline
spline/matrix.py
Matrix.run_matrix_in_parallel
def run_matrix_in_parallel(self, process_data): """Running pipelines in parallel.""" worker_data = [{'matrix': entry, 'pipeline': process_data.pipeline, 'model': process_data.model, 'options': process_data.options, 'hooks': process_data.hooks} for entry in...
python
def run_matrix_in_parallel(self, process_data): """Running pipelines in parallel.""" worker_data = [{'matrix': entry, 'pipeline': process_data.pipeline, 'model': process_data.model, 'options': process_data.options, 'hooks': process_data.hooks} for entry in...
[ "def", "run_matrix_in_parallel", "(", "self", ",", "process_data", ")", ":", "worker_data", "=", "[", "{", "'matrix'", ":", "entry", ",", "'pipeline'", ":", "process_data", ".", "pipeline", ",", "'model'", ":", "process_data", ".", "model", ",", "'options'", ...
Running pipelines in parallel.
[ "Running", "pipelines", "in", "parallel", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/matrix.py#L159-L172
train
Nachtfeuer/pipeline
spline/matrix.py
Matrix.process
def process(self, process_data): """Process the pipeline per matrix item.""" if self.parallel and not process_data.options.dry_run: return self.run_matrix_in_parallel(process_data) return self.run_matrix_ordered(process_data)
python
def process(self, process_data): """Process the pipeline per matrix item.""" if self.parallel and not process_data.options.dry_run: return self.run_matrix_in_parallel(process_data) return self.run_matrix_ordered(process_data)
[ "def", "process", "(", "self", ",", "process_data", ")", ":", "if", "self", ".", "parallel", "and", "not", "process_data", ".", "options", ".", "dry_run", ":", "return", "self", ".", "run_matrix_in_parallel", "(", "process_data", ")", "return", "self", ".", ...
Process the pipeline per matrix item.
[ "Process", "the", "pipeline", "per", "matrix", "item", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/matrix.py#L174-L178
train
aartur/mschematool
mschematool/core.py
_sqlfile_to_statements
def _sqlfile_to_statements(sql): """ Takes a SQL string containing 0 or more statements and returns a list of individual statements as strings. Comments and empty statements are ignored. """ statements = (sqlparse.format(stmt, strip_comments=True).strip() for stmt in sqlparse.split(sql)) re...
python
def _sqlfile_to_statements(sql): """ Takes a SQL string containing 0 or more statements and returns a list of individual statements as strings. Comments and empty statements are ignored. """ statements = (sqlparse.format(stmt, strip_comments=True).strip() for stmt in sqlparse.split(sql)) re...
[ "def", "_sqlfile_to_statements", "(", "sql", ")", ":", "statements", "=", "(", "sqlparse", ".", "format", "(", "stmt", ",", "strip_comments", "=", "True", ")", ".", "strip", "(", ")", "for", "stmt", "in", "sqlparse", ".", "split", "(", "sql", ")", ")",...
Takes a SQL string containing 0 or more statements and returns a list of individual statements as strings. Comments and empty statements are ignored.
[ "Takes", "a", "SQL", "string", "containing", "0", "or", "more", "statements", "and", "returns", "a", "list", "of", "individual", "statements", "as", "strings", ".", "Comments", "and", "empty", "statements", "are", "ignored", "." ]
57ec9541f80b44890294126eab92ce243c8833c4
https://github.com/aartur/mschematool/blob/57ec9541f80b44890294126eab92ce243c8833c4/mschematool/core.py#L94-L101
train
aartur/mschematool
mschematool/core.py
MigrationsRepository.generate_migration_name
def generate_migration_name(self, name, suffix): """Returns a name of a new migration. It will usually be a filename with a valid and unique name. :param name: human-readable name of a migration :param suffix: file suffix (extension) - eg. 'sql' """ return os.path.join(s...
python
def generate_migration_name(self, name, suffix): """Returns a name of a new migration. It will usually be a filename with a valid and unique name. :param name: human-readable name of a migration :param suffix: file suffix (extension) - eg. 'sql' """ return os.path.join(s...
[ "def", "generate_migration_name", "(", "self", ",", "name", ",", "suffix", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "dir", ",", "'m{datestr}_{name}.{suffix}'", ".", "format", "(", "datestr", "=", "datetime", ".", "datetime", "....
Returns a name of a new migration. It will usually be a filename with a valid and unique name. :param name: human-readable name of a migration :param suffix: file suffix (extension) - eg. 'sql'
[ "Returns", "a", "name", "of", "a", "new", "migration", ".", "It", "will", "usually", "be", "a", "filename", "with", "a", "valid", "and", "unique", "name", "." ]
57ec9541f80b44890294126eab92ce243c8833c4
https://github.com/aartur/mschematool/blob/57ec9541f80b44890294126eab92ce243c8833c4/mschematool/core.py#L118-L129
train
aartur/mschematool
mschematool/core.py
MigrationsExecutor._call_migrate
def _call_migrate(self, module, connection_param): """Subclasses should call this method instead of `module.migrate` directly, to support `db_config` optional argument. """ args = [connection_param] spec = inspect.getargspec(module.migrate) if len(spec.args) == 2: ...
python
def _call_migrate(self, module, connection_param): """Subclasses should call this method instead of `module.migrate` directly, to support `db_config` optional argument. """ args = [connection_param] spec = inspect.getargspec(module.migrate) if len(spec.args) == 2: ...
[ "def", "_call_migrate", "(", "self", ",", "module", ",", "connection_param", ")", ":", "args", "=", "[", "connection_param", "]", "spec", "=", "inspect", ".", "getargspec", "(", "module", ".", "migrate", ")", "if", "len", "(", "spec", ".", "args", ")", ...
Subclasses should call this method instead of `module.migrate` directly, to support `db_config` optional argument.
[ "Subclasses", "should", "call", "this", "method", "instead", "of", "module", ".", "migrate", "directly", "to", "support", "db_config", "optional", "argument", "." ]
57ec9541f80b44890294126eab92ce243c8833c4
https://github.com/aartur/mschematool/blob/57ec9541f80b44890294126eab92ce243c8833c4/mschematool/core.py#L232-L240
train
acutesoftware/AIKIF
aikif/dataTools/cls_data.py
Data._identify_datatype
def _identify_datatype(self, input_data): """ uses the input data, which may be a string, list, number or file to work out how to load the data (this can be overridden by passing the data_type on the command line """ if isinstance(input_data, (int, float)) : ...
python
def _identify_datatype(self, input_data): """ uses the input data, which may be a string, list, number or file to work out how to load the data (this can be overridden by passing the data_type on the command line """ if isinstance(input_data, (int, float)) : ...
[ "def", "_identify_datatype", "(", "self", ",", "input_data", ")", ":", "if", "isinstance", "(", "input_data", ",", "(", "int", ",", "float", ")", ")", ":", "self", ".", "data_type", "=", "'number'", "elif", "isinstance", "(", "input_data", ",", "(", "lis...
uses the input data, which may be a string, list, number or file to work out how to load the data (this can be overridden by passing the data_type on the command line
[ "uses", "the", "input", "data", "which", "may", "be", "a", "string", "list", "number", "or", "file", "to", "work", "out", "how", "to", "load", "the", "data", "(", "this", "can", "be", "overridden", "by", "passing", "the", "data_type", "on", "the", "com...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_data.py#L51-L71
train
acutesoftware/AIKIF
aikif/dataTools/cls_data.py
Data._calc_size_stats
def _calc_size_stats(self): """ get the size in bytes and num records of the content """ self.total_records = 0 self.total_length = 0 self.total_nodes = 0 if type(self.content['data']) is dict: self.total_length += len(str(self.content['data'])) ...
python
def _calc_size_stats(self): """ get the size in bytes and num records of the content """ self.total_records = 0 self.total_length = 0 self.total_nodes = 0 if type(self.content['data']) is dict: self.total_length += len(str(self.content['data'])) ...
[ "def", "_calc_size_stats", "(", "self", ")", ":", "self", ".", "total_records", "=", "0", "self", ".", "total_length", "=", "0", "self", ".", "total_nodes", "=", "0", "if", "type", "(", "self", ".", "content", "[", "'data'", "]", ")", "is", "dict", "...
get the size in bytes and num records of the content
[ "get", "the", "size", "in", "bytes", "and", "num", "records", "of", "the", "content" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_data.py#L120-L138
train
acutesoftware/AIKIF
aikif/dataTools/cls_data.py
Data._get_size_recursive
def _get_size_recursive(self, dat): """ recursively walk through a data set or json file to get the total number of nodes """ self.total_records += 1 #self.total_nodes += 1 for rec in dat: if hasattr(rec, '__iter__') and type(rec) is not str: ...
python
def _get_size_recursive(self, dat): """ recursively walk through a data set or json file to get the total number of nodes """ self.total_records += 1 #self.total_nodes += 1 for rec in dat: if hasattr(rec, '__iter__') and type(rec) is not str: ...
[ "def", "_get_size_recursive", "(", "self", ",", "dat", ")", ":", "self", ".", "total_records", "+=", "1", "for", "rec", "in", "dat", ":", "if", "hasattr", "(", "rec", ",", "'__iter__'", ")", "and", "type", "(", "rec", ")", "is", "not", "str", ":", ...
recursively walk through a data set or json file to get the total number of nodes
[ "recursively", "walk", "through", "a", "data", "set", "or", "json", "file", "to", "get", "the", "total", "number", "of", "nodes" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_data.py#L140-L152
train
staticdev/django-pagination-bootstrap
pagination_bootstrap/version.py
_make_version
def _make_version(major, minor, micro, releaselevel, serial): """Create a readable version string from version_info tuple components.""" assert releaselevel in ['alpha', 'beta', 'candidate', 'final'] version = "%d.%d" % (major, minor) if micro: version += ".%d" % (micro,) if releaselevel != ...
python
def _make_version(major, minor, micro, releaselevel, serial): """Create a readable version string from version_info tuple components.""" assert releaselevel in ['alpha', 'beta', 'candidate', 'final'] version = "%d.%d" % (major, minor) if micro: version += ".%d" % (micro,) if releaselevel != ...
[ "def", "_make_version", "(", "major", ",", "minor", ",", "micro", ",", "releaselevel", ",", "serial", ")", ":", "assert", "releaselevel", "in", "[", "'alpha'", ",", "'beta'", ",", "'candidate'", ",", "'final'", "]", "version", "=", "\"%d.%d\"", "%", "(", ...
Create a readable version string from version_info tuple components.
[ "Create", "a", "readable", "version", "string", "from", "version_info", "tuple", "components", "." ]
b4bf8352a364b223babbc5f33e14ecabd82c0886
https://github.com/staticdev/django-pagination-bootstrap/blob/b4bf8352a364b223babbc5f33e14ecabd82c0886/pagination_bootstrap/version.py#L3-L12
train
staticdev/django-pagination-bootstrap
pagination_bootstrap/version.py
_make_url
def _make_url(major, minor, micro, releaselevel, serial): """Make the URL people should start at for this version of coverage.py.""" url = "https://django-pagination-bootstrap.readthedocs.io" if releaselevel != 'final': # For pre-releases, use a version-specific URL. url += "/en/" + _make_ve...
python
def _make_url(major, minor, micro, releaselevel, serial): """Make the URL people should start at for this version of coverage.py.""" url = "https://django-pagination-bootstrap.readthedocs.io" if releaselevel != 'final': # For pre-releases, use a version-specific URL. url += "/en/" + _make_ve...
[ "def", "_make_url", "(", "major", ",", "minor", ",", "micro", ",", "releaselevel", ",", "serial", ")", ":", "url", "=", "\"https://django-pagination-bootstrap.readthedocs.io\"", "if", "releaselevel", "!=", "'final'", ":", "url", "+=", "\"/en/\"", "+", "_make_versi...
Make the URL people should start at for this version of coverage.py.
[ "Make", "the", "URL", "people", "should", "start", "at", "for", "this", "version", "of", "coverage", ".", "py", "." ]
b4bf8352a364b223babbc5f33e14ecabd82c0886
https://github.com/staticdev/django-pagination-bootstrap/blob/b4bf8352a364b223babbc5f33e14ecabd82c0886/pagination_bootstrap/version.py#L15-L21
train
acutesoftware/AIKIF
aikif/lib/cls_filelist.py
FileList.get_list_of_paths
def get_list_of_paths(self): """ return a list of unique paths in the file list """ all_paths = [] for p in self.fl_metadata: try: all_paths.append(p['path']) except: try: print('cls_filelist - ...
python
def get_list_of_paths(self): """ return a list of unique paths in the file list """ all_paths = [] for p in self.fl_metadata: try: all_paths.append(p['path']) except: try: print('cls_filelist - ...
[ "def", "get_list_of_paths", "(", "self", ")", ":", "all_paths", "=", "[", "]", "for", "p", "in", "self", ".", "fl_metadata", ":", "try", ":", "all_paths", ".", "append", "(", "p", "[", "'path'", "]", ")", "except", ":", "try", ":", "print", "(", "'...
return a list of unique paths in the file list
[ "return", "a", "list", "of", "unique", "paths", "in", "the", "file", "list" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_filelist.py#L47-L61
train
acutesoftware/AIKIF
aikif/lib/cls_filelist.py
FileList.add_file_metadata
def add_file_metadata(self, fname): """ collects the files metadata - note that this will fail with strange errors if network connection drops out to shared folder, but it is better to stop the program rather than do a try except otherwise you will get an incomplete...
python
def add_file_metadata(self, fname): """ collects the files metadata - note that this will fail with strange errors if network connection drops out to shared folder, but it is better to stop the program rather than do a try except otherwise you will get an incomplete...
[ "def", "add_file_metadata", "(", "self", ",", "fname", ")", ":", "file_dict", "=", "{", "}", "file_dict", "[", "\"fullfilename\"", "]", "=", "fname", "try", ":", "file_dict", "[", "\"name\"", "]", "=", "os", ".", "path", ".", "basename", "(", "fname", ...
collects the files metadata - note that this will fail with strange errors if network connection drops out to shared folder, but it is better to stop the program rather than do a try except otherwise you will get an incomplete set of files.
[ "collects", "the", "files", "metadata", "-", "note", "that", "this", "will", "fail", "with", "strange", "errors", "if", "network", "connection", "drops", "out", "to", "shared", "folder", "but", "it", "is", "better", "to", "stop", "the", "program", "rather", ...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_filelist.py#L100-L119
train
acutesoftware/AIKIF
aikif/lib/cls_filelist.py
FileList.print_file_details_as_csv
def print_file_details_as_csv(self, fname, col_headers): """ saves as csv format """ line = '' qu = '"' d = ',' for fld in col_headers: if fld == "fullfilename": line = line + qu + fname + qu + d if fld == "name": l...
python
def print_file_details_as_csv(self, fname, col_headers): """ saves as csv format """ line = '' qu = '"' d = ',' for fld in col_headers: if fld == "fullfilename": line = line + qu + fname + qu + d if fld == "name": l...
[ "def", "print_file_details_as_csv", "(", "self", ",", "fname", ",", "col_headers", ")", ":", "line", "=", "''", "qu", "=", "'\"'", "d", "=", "','", "for", "fld", "in", "col_headers", ":", "if", "fld", "==", "\"fullfilename\"", ":", "line", "=", "line", ...
saves as csv format
[ "saves", "as", "csv", "format" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_filelist.py#L145-L165
train
acutesoftware/AIKIF
aikif/lib/cls_filelist.py
FileList.save_filelist
def save_filelist(self, opFile, opFormat, delim=',', qu='"'): """ uses a List of files and collects meta data on them and saves to an text file as a list or with metadata depending on opFormat. """ op_folder = os.path.dirname(opFile) if op_folder is not None: # ...
python
def save_filelist(self, opFile, opFormat, delim=',', qu='"'): """ uses a List of files and collects meta data on them and saves to an text file as a list or with metadata depending on opFormat. """ op_folder = os.path.dirname(opFile) if op_folder is not None: # ...
[ "def", "save_filelist", "(", "self", ",", "opFile", ",", "opFormat", ",", "delim", "=", "','", ",", "qu", "=", "'\"'", ")", ":", "op_folder", "=", "os", ".", "path", ".", "dirname", "(", "opFile", ")", "if", "op_folder", "is", "not", "None", ":", "...
uses a List of files and collects meta data on them and saves to an text file as a list or with metadata depending on opFormat.
[ "uses", "a", "List", "of", "files", "and", "collects", "meta", "data", "on", "them", "and", "saves", "to", "an", "text", "file", "as", "a", "list", "or", "with", "metadata", "depending", "on", "opFormat", "." ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_filelist.py#L192-L228
train
acutesoftware/AIKIF
aikif/dataTools/cls_dataset.py
DataSet.login
def login(self, schema, username, password): """ connect here - use the other classes cls_oracle, cls_mysql, etc otherwise this has the credentials used to access a share folder """ self.schema = schema self.username = username self.password = password sel...
python
def login(self, schema, username, password): """ connect here - use the other classes cls_oracle, cls_mysql, etc otherwise this has the credentials used to access a share folder """ self.schema = schema self.username = username self.password = password sel...
[ "def", "login", "(", "self", ",", "schema", ",", "username", ",", "password", ")", ":", "self", ".", "schema", "=", "schema", "self", ".", "username", "=", "username", "self", ".", "password", "=", "password", "self", ".", "connection", "=", "schema" ]
connect here - use the other classes cls_oracle, cls_mysql, etc otherwise this has the credentials used to access a share folder
[ "connect", "here", "-", "use", "the", "other", "classes", "cls_oracle", "cls_mysql", "etc", "otherwise", "this", "has", "the", "credentials", "used", "to", "access", "a", "share", "folder" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_dataset.py#L34-L42
train
Phelimb/atlas
mykatlas/typing/typer/presence.py
GeneCollectionTyper.type
def type(self, sequence_coverage_collection, min_gene_percent_covg_threshold=99): """Types a collection of genes returning the most likely gene version in the collection with it's genotype""" best_versions = self.get_best_version( sequence_coverage_collection.values(...
python
def type(self, sequence_coverage_collection, min_gene_percent_covg_threshold=99): """Types a collection of genes returning the most likely gene version in the collection with it's genotype""" best_versions = self.get_best_version( sequence_coverage_collection.values(...
[ "def", "type", "(", "self", ",", "sequence_coverage_collection", ",", "min_gene_percent_covg_threshold", "=", "99", ")", ":", "best_versions", "=", "self", ".", "get_best_version", "(", "sequence_coverage_collection", ".", "values", "(", ")", ",", "min_gene_percent_co...
Types a collection of genes returning the most likely gene version in the collection with it's genotype
[ "Types", "a", "collection", "of", "genes", "returning", "the", "most", "likely", "gene", "version", "in", "the", "collection", "with", "it", "s", "genotype" ]
02e85497bb5ac423d6452a10dca11964582ac4d7
https://github.com/Phelimb/atlas/blob/02e85497bb5ac423d6452a10dca11964582ac4d7/mykatlas/typing/typer/presence.py#L146-L154
train
acutesoftware/AIKIF
aikif/programs.py
Programs.list_all_python_programs
def list_all_python_programs(self): """ collects a filelist of all .py programs """ self.tot_lines = 0 self.tot_bytes = 0 self.tot_files = 0 self.tot_loc = 0 self.lstPrograms = [] fl = mod_fl.FileList([self.fldr], ['*.py'], ["__pycache__", "/venv/"...
python
def list_all_python_programs(self): """ collects a filelist of all .py programs """ self.tot_lines = 0 self.tot_bytes = 0 self.tot_files = 0 self.tot_loc = 0 self.lstPrograms = [] fl = mod_fl.FileList([self.fldr], ['*.py'], ["__pycache__", "/venv/"...
[ "def", "list_all_python_programs", "(", "self", ")", ":", "self", ".", "tot_lines", "=", "0", "self", ".", "tot_bytes", "=", "0", "self", ".", "tot_files", "=", "0", "self", ".", "tot_loc", "=", "0", "self", ".", "lstPrograms", "=", "[", "]", "fl", "...
collects a filelist of all .py programs
[ "collects", "a", "filelist", "of", "all", ".", "py", "programs" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/programs.py#L38-L58
train
acutesoftware/AIKIF
aikif/programs.py
Programs.save
def save(self, fname=''): """ Save the list of items to AIKIF core and optionally to local file fname """ if fname != '': with open(fname, 'w') as f: for i in self.lstPrograms: f.write(self.get_file_info_line(i, ',')) # sa...
python
def save(self, fname=''): """ Save the list of items to AIKIF core and optionally to local file fname """ if fname != '': with open(fname, 'w') as f: for i in self.lstPrograms: f.write(self.get_file_info_line(i, ',')) # sa...
[ "def", "save", "(", "self", ",", "fname", "=", "''", ")", ":", "if", "fname", "!=", "''", ":", "with", "open", "(", "fname", ",", "'w'", ")", "as", "f", ":", "for", "i", "in", "self", ".", "lstPrograms", ":", "f", ".", "write", "(", "self", "...
Save the list of items to AIKIF core and optionally to local file fname
[ "Save", "the", "list", "of", "items", "to", "AIKIF", "core", "and", "optionally", "to", "local", "file", "fname" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/programs.py#L88-L112
train
acutesoftware/AIKIF
aikif/programs.py
Programs.collect_program_info
def collect_program_info(self, fname): """ gets details on the program, size, date, list of functions and produces a Markdown file for documentation """ md = '#AIKIF Technical details\n' md += 'Autogenerated list of programs with comments and progress\n' md += '\n...
python
def collect_program_info(self, fname): """ gets details on the program, size, date, list of functions and produces a Markdown file for documentation """ md = '#AIKIF Technical details\n' md += 'Autogenerated list of programs with comments and progress\n' md += '\n...
[ "def", "collect_program_info", "(", "self", ",", "fname", ")", ":", "md", "=", "'#AIKIF Technical details\\n'", "md", "+=", "'Autogenerated list of programs with comments and progress\\n'", "md", "+=", "'\\nFilename | Comment | Date | Size\\n'", "md", "+=", "'--- | --- | --- | ...
gets details on the program, size, date, list of functions and produces a Markdown file for documentation
[ "gets", "details", "on", "the", "program", "size", "date", "list", "of", "functions", "and", "produces", "a", "Markdown", "file", "for", "documentation" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/programs.py#L140-L154
train
mpg-age-bioinformatics/AGEpy
AGEpy/david.py
id_nameDAVID
def id_nameDAVID(df,GTF=None,name_id=None): """ Given a DAVIDenrich output it converts ensembl gene ids to genes names and adds this column to the output :param df: a dataframe output from DAVIDenrich :param GTF: a GTF dataframe from readGTF() :param name_id: instead of a gtf dataframe a dataframe ...
python
def id_nameDAVID(df,GTF=None,name_id=None): """ Given a DAVIDenrich output it converts ensembl gene ids to genes names and adds this column to the output :param df: a dataframe output from DAVIDenrich :param GTF: a GTF dataframe from readGTF() :param name_id: instead of a gtf dataframe a dataframe ...
[ "def", "id_nameDAVID", "(", "df", ",", "GTF", "=", "None", ",", "name_id", "=", "None", ")", ":", "if", "name_id", "is", "None", ":", "gene_name", "=", "retrieve_GTF_field", "(", "'gene_name'", ",", "GTF", ")", "gene_id", "=", "retrieve_GTF_field", "(", ...
Given a DAVIDenrich output it converts ensembl gene ids to genes names and adds this column to the output :param df: a dataframe output from DAVIDenrich :param GTF: a GTF dataframe from readGTF() :param name_id: instead of a gtf dataframe a dataframe with the columns 'gene_name' and 'gene_id' can be given ...
[ "Given", "a", "DAVIDenrich", "output", "it", "converts", "ensembl", "gene", "ids", "to", "genes", "names", "and", "adds", "this", "column", "to", "the", "output" ]
887808a7a2c1504f39ce8d8cb36c15c1721cd29f
https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/david.py#L92-L134
train
mpg-age-bioinformatics/AGEpy
AGEpy/david.py
DAVIDgetGeneAttribute
def DAVIDgetGeneAttribute(x,df,refCol="ensembl_gene_id",fieldTOretrieve="gene_name"): """ Returns a list of gene names for given gene ids. :param x: a string with the list of IDs separated by ', ' :param df: a dataframe with the reference column and a the column to retrieve :param refCol: the heade...
python
def DAVIDgetGeneAttribute(x,df,refCol="ensembl_gene_id",fieldTOretrieve="gene_name"): """ Returns a list of gene names for given gene ids. :param x: a string with the list of IDs separated by ', ' :param df: a dataframe with the reference column and a the column to retrieve :param refCol: the heade...
[ "def", "DAVIDgetGeneAttribute", "(", "x", ",", "df", ",", "refCol", "=", "\"ensembl_gene_id\"", ",", "fieldTOretrieve", "=", "\"gene_name\"", ")", ":", "l", "=", "x", ".", "split", "(", "\", \"", ")", "l", "=", "[", "s", ".", "upper", "(", ")", "for", ...
Returns a list of gene names for given gene ids. :param x: a string with the list of IDs separated by ', ' :param df: a dataframe with the reference column and a the column to retrieve :param refCol: the header of the column containing the identifiers :param fieldTOretrieve: the field to retrieve from ...
[ "Returns", "a", "list", "of", "gene", "names", "for", "given", "gene", "ids", "." ]
887808a7a2c1504f39ce8d8cb36c15c1721cd29f
https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/david.py#L136-L157
train
Nachtfeuer/pipeline
spline/tools/loc/application.py
main
def main(**options): """Spline loc tool.""" application = Application(**options) # fails application when your defined threshold is higher than your ratio of com/loc. if not application.run(): sys.exit(1) return application
python
def main(**options): """Spline loc tool.""" application = Application(**options) # fails application when your defined threshold is higher than your ratio of com/loc. if not application.run(): sys.exit(1) return application
[ "def", "main", "(", "**", "options", ")", ":", "application", "=", "Application", "(", "**", "options", ")", "if", "not", "application", ".", "run", "(", ")", ":", "sys", ".", "exit", "(", "1", ")", "return", "application" ]
Spline loc tool.
[ "Spline", "loc", "tool", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loc/application.py#L170-L176
train
Nachtfeuer/pipeline
spline/tools/loc/application.py
Application.load_configuration
def load_configuration(self): """Loading configuration.""" filename = os.path.join(os.path.dirname(__file__), 'templates/spline-loc.yml.j2') with open(filename) as handle: return Adapter(safe_load(handle)).configuration
python
def load_configuration(self): """Loading configuration.""" filename = os.path.join(os.path.dirname(__file__), 'templates/spline-loc.yml.j2') with open(filename) as handle: return Adapter(safe_load(handle)).configuration
[ "def", "load_configuration", "(", "self", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'templates/spline-loc.yml.j2'", ")", "with", "open", "(", "filename", ")", "as", "han...
Loading configuration.
[ "Loading", "configuration", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loc/application.py#L56-L60
train
Nachtfeuer/pipeline
spline/tools/loc/application.py
Application.ignore_path
def ignore_path(path): """ Verify whether to ignore a path. Args: path (str): path to check. Returns: bool: True when to ignore given path. """ ignore = False for name in ['.tox', 'dist', 'build', 'node_modules', 'htmlcov']: i...
python
def ignore_path(path): """ Verify whether to ignore a path. Args: path (str): path to check. Returns: bool: True when to ignore given path. """ ignore = False for name in ['.tox', 'dist', 'build', 'node_modules', 'htmlcov']: i...
[ "def", "ignore_path", "(", "path", ")", ":", "ignore", "=", "False", "for", "name", "in", "[", "'.tox'", ",", "'dist'", ",", "'build'", ",", "'node_modules'", ",", "'htmlcov'", "]", ":", "if", "path", ".", "find", "(", "name", ")", ">=", "0", ":", ...
Verify whether to ignore a path. Args: path (str): path to check. Returns: bool: True when to ignore given path.
[ "Verify", "whether", "to", "ignore", "a", "path", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loc/application.py#L63-L78
train
Nachtfeuer/pipeline
spline/tools/loc/application.py
Application.walk_files_for
def walk_files_for(paths, supported_extensions): """ Iterating files for given extensions. Args: supported_extensions (list): supported file extentsion for which to check loc and com. Returns: str: yield each full path and filename found. """ for...
python
def walk_files_for(paths, supported_extensions): """ Iterating files for given extensions. Args: supported_extensions (list): supported file extentsion for which to check loc and com. Returns: str: yield each full path and filename found. """ for...
[ "def", "walk_files_for", "(", "paths", ",", "supported_extensions", ")", ":", "for", "path", "in", "paths", ":", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "if", "Application", ".", "ignore_path", "(", "root"...
Iterating files for given extensions. Args: supported_extensions (list): supported file extentsion for which to check loc and com. Returns: str: yield each full path and filename found.
[ "Iterating", "files", "for", "given", "extensions", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loc/application.py#L81-L99
train
Nachtfeuer/pipeline
spline/tools/loc/application.py
Application.analyse
def analyse(self, path_and_filename, pattern): """ Find out lines of code and lines of comments. Args: path_and_filename (str): path and filename to parse for loc and com. pattern (str): regex to search for line commens and block comments Returns: i...
python
def analyse(self, path_and_filename, pattern): """ Find out lines of code and lines of comments. Args: path_and_filename (str): path and filename to parse for loc and com. pattern (str): regex to search for line commens and block comments Returns: i...
[ "def", "analyse", "(", "self", ",", "path_and_filename", ",", "pattern", ")", ":", "with", "open", "(", "path_and_filename", ")", "as", "handle", ":", "content", "=", "handle", ".", "read", "(", ")", "loc", "=", "content", ".", "count", "(", "'\\n'", "...
Find out lines of code and lines of comments. Args: path_and_filename (str): path and filename to parse for loc and com. pattern (str): regex to search for line commens and block comments Returns: int, int: loc and com for given file.
[ "Find", "out", "lines", "of", "code", "and", "lines", "of", "comments", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loc/application.py#L101-L119
train
mpg-age-bioinformatics/AGEpy
AGEpy/biom.py
datasetsBM
def datasetsBM(host=biomart_host): """ Lists BioMart datasets. :param host: address of the host server, default='http://www.ensembl.org/biomart' :returns: nothing """ stdout_ = sys.stdout #Keep track of the previous value. stream = StringIO() sys.stdout = stream server = Biomar...
python
def datasetsBM(host=biomart_host): """ Lists BioMart datasets. :param host: address of the host server, default='http://www.ensembl.org/biomart' :returns: nothing """ stdout_ = sys.stdout #Keep track of the previous value. stream = StringIO() sys.stdout = stream server = Biomar...
[ "def", "datasetsBM", "(", "host", "=", "biomart_host", ")", ":", "stdout_", "=", "sys", ".", "stdout", "stream", "=", "StringIO", "(", ")", "sys", ".", "stdout", "=", "stream", "server", "=", "BiomartServer", "(", "biomart_host", ")", "server", ".", "sho...
Lists BioMart datasets. :param host: address of the host server, default='http://www.ensembl.org/biomart' :returns: nothing
[ "Lists", "BioMart", "datasets", "." ]
887808a7a2c1504f39ce8d8cb36c15c1721cd29f
https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/biom.py#L12-L31
train
mpg-age-bioinformatics/AGEpy
AGEpy/biom.py
filtersBM
def filtersBM(dataset,host=biomart_host): """ Lists BioMart filters for a specific dataset. :param dataset: dataset to list filters of. :param host: address of the host server, default='http://www.ensembl.org/biomart' :returns: nothing """ stdout_ = sys.stdout #Keep track of the previous ...
python
def filtersBM(dataset,host=biomart_host): """ Lists BioMart filters for a specific dataset. :param dataset: dataset to list filters of. :param host: address of the host server, default='http://www.ensembl.org/biomart' :returns: nothing """ stdout_ = sys.stdout #Keep track of the previous ...
[ "def", "filtersBM", "(", "dataset", ",", "host", "=", "biomart_host", ")", ":", "stdout_", "=", "sys", ".", "stdout", "stream", "=", "StringIO", "(", ")", "sys", ".", "stdout", "=", "stream", "server", "=", "BiomartServer", "(", "host", ")", "d", "=", ...
Lists BioMart filters for a specific dataset. :param dataset: dataset to list filters of. :param host: address of the host server, default='http://www.ensembl.org/biomart' :returns: nothing
[ "Lists", "BioMart", "filters", "for", "a", "specific", "dataset", "." ]
887808a7a2c1504f39ce8d8cb36c15c1721cd29f
https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/biom.py#L33-L54
train
acutesoftware/AIKIF
aikif/core_data.py
CoreData.format_csv
def format_csv(self, delim=',', qu='"'): """ Prepares the data in CSV format """ res = qu + self.name + qu + delim if self.data: for d in self.data: res += qu + str(d) + qu + delim return res + '\n'
python
def format_csv(self, delim=',', qu='"'): """ Prepares the data in CSV format """ res = qu + self.name + qu + delim if self.data: for d in self.data: res += qu + str(d) + qu + delim return res + '\n'
[ "def", "format_csv", "(", "self", ",", "delim", "=", "','", ",", "qu", "=", "'\"'", ")", ":", "res", "=", "qu", "+", "self", ".", "name", "+", "qu", "+", "delim", "if", "self", ".", "data", ":", "for", "d", "in", "self", ".", "data", ":", "re...
Prepares the data in CSV format
[ "Prepares", "the", "data", "in", "CSV", "format" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L40-L48
train
acutesoftware/AIKIF
aikif/core_data.py
CoreData.format_all
def format_all(self): """ return a trace of parents and children of the obect """ res = '\n--- Format all : ' + str(self.name) + ' -------------\n' res += ' parent = ' + str(self.parent) + '\n' res += self._get_all_children() res += self._get_links() ...
python
def format_all(self): """ return a trace of parents and children of the obect """ res = '\n--- Format all : ' + str(self.name) + ' -------------\n' res += ' parent = ' + str(self.parent) + '\n' res += self._get_all_children() res += self._get_links() ...
[ "def", "format_all", "(", "self", ")", ":", "res", "=", "'\\n--- Format all : '", "+", "str", "(", "self", ".", "name", ")", "+", "' -------------\\n'", "res", "+=", "' parent = '", "+", "str", "(", "self", ".", "parent", ")", "+", "'\\n'", "res", "+=", ...
return a trace of parents and children of the obect
[ "return", "a", "trace", "of", "parents", "and", "children", "of", "the", "obect" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L60-L69
train
acutesoftware/AIKIF
aikif/core_data.py
CoreData._get_all_children
def _get_all_children(self,): """ return the list of children of a node """ res = '' if self.child_nodes: for c in self.child_nodes: res += ' child = ' + str(c) + '\n' if c.child_nodes: for grandchild in c.child_nod...
python
def _get_all_children(self,): """ return the list of children of a node """ res = '' if self.child_nodes: for c in self.child_nodes: res += ' child = ' + str(c) + '\n' if c.child_nodes: for grandchild in c.child_nod...
[ "def", "_get_all_children", "(", "self", ",", ")", ":", "res", "=", "''", "if", "self", ".", "child_nodes", ":", "for", "c", "in", "self", ".", "child_nodes", ":", "res", "+=", "' child = '", "+", "str", "(", "c", ")", "+", "'\\n'", "if", "c", ".",...
return the list of children of a node
[ "return", "the", "list", "of", "children", "of", "a", "node" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L71-L84
train
acutesoftware/AIKIF
aikif/core_data.py
CoreData._get_links
def _get_links(self,): """ return the list of links of a node """ res = '' if self.links: for l in self.links: res += ' links = ' + str(l[0]) + '\n' if l[0].child_nodes: for chld in l[0].child_nodes: ...
python
def _get_links(self,): """ return the list of links of a node """ res = '' if self.links: for l in self.links: res += ' links = ' + str(l[0]) + '\n' if l[0].child_nodes: for chld in l[0].child_nodes: ...
[ "def", "_get_links", "(", "self", ",", ")", ":", "res", "=", "''", "if", "self", ".", "links", ":", "for", "l", "in", "self", ".", "links", ":", "res", "+=", "' links = '", "+", "str", "(", "l", "[", "0", "]", ")", "+", "'\\n'", "if", "l", "[...
return the list of links of a node
[ "return", "the", "list", "of", "links", "of", "a", "node" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L86-L103
train
acutesoftware/AIKIF
aikif/core_data.py
CoreData.get_child_by_name
def get_child_by_name(self, name): """ find the child object by name and return the object """ for c in self.child_nodes: if c.name == name: return c return None
python
def get_child_by_name(self, name): """ find the child object by name and return the object """ for c in self.child_nodes: if c.name == name: return c return None
[ "def", "get_child_by_name", "(", "self", ",", "name", ")", ":", "for", "c", "in", "self", ".", "child_nodes", ":", "if", "c", ".", "name", "==", "name", ":", "return", "c", "return", "None" ]
find the child object by name and return the object
[ "find", "the", "child", "object", "by", "name", "and", "return", "the", "object" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L149-L156
train
acutesoftware/AIKIF
aikif/core_data.py
CoreTable.get_filename
def get_filename(self, year): """ returns the filename """ res = self.fldr + os.sep + self.type + year + '.' + self.user return res
python
def get_filename(self, year): """ returns the filename """ res = self.fldr + os.sep + self.type + year + '.' + self.user return res
[ "def", "get_filename", "(", "self", ",", "year", ")", ":", "res", "=", "self", ".", "fldr", "+", "os", ".", "sep", "+", "self", ".", "type", "+", "year", "+", "'.'", "+", "self", ".", "user", "return", "res" ]
returns the filename
[ "returns", "the", "filename" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L301-L306
train
acutesoftware/AIKIF
aikif/core_data.py
CoreTable.save
def save(self, file_tag='2016', add_header='N'): """ save table to folder in appropriate files NOTE - ONLY APPEND AT THIS STAGE - THEN USE DATABASE """ fname = self.get_filename(file_tag) with open(fname, 'a') as f: if add_header == 'Y': f.writ...
python
def save(self, file_tag='2016', add_header='N'): """ save table to folder in appropriate files NOTE - ONLY APPEND AT THIS STAGE - THEN USE DATABASE """ fname = self.get_filename(file_tag) with open(fname, 'a') as f: if add_header == 'Y': f.writ...
[ "def", "save", "(", "self", ",", "file_tag", "=", "'2016'", ",", "add_header", "=", "'N'", ")", ":", "fname", "=", "self", ".", "get_filename", "(", "file_tag", ")", "with", "open", "(", "fname", ",", "'a'", ")", "as", "f", ":", "if", "add_header", ...
save table to folder in appropriate files NOTE - ONLY APPEND AT THIS STAGE - THEN USE DATABASE
[ "save", "table", "to", "folder", "in", "appropriate", "files", "NOTE", "-", "ONLY", "APPEND", "AT", "THIS", "STAGE", "-", "THEN", "USE", "DATABASE" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L320-L331
train
acutesoftware/AIKIF
aikif/core_data.py
CoreTable.format_hdr
def format_hdr(self, delim=',', qu='"'): """ Prepares the header in CSV format """ res = '' if self.header: for d in self.header: res += qu + str(d) + qu + delim return res + '\n'
python
def format_hdr(self, delim=',', qu='"'): """ Prepares the header in CSV format """ res = '' if self.header: for d in self.header: res += qu + str(d) + qu + delim return res + '\n'
[ "def", "format_hdr", "(", "self", ",", "delim", "=", "','", ",", "qu", "=", "'\"'", ")", ":", "res", "=", "''", "if", "self", ".", "header", ":", "for", "d", "in", "self", ".", "header", ":", "res", "+=", "qu", "+", "str", "(", "d", ")", "+",...
Prepares the header in CSV format
[ "Prepares", "the", "header", "in", "CSV", "format" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L333-L341
train
acutesoftware/AIKIF
aikif/core_data.py
CoreTable.generate_diary
def generate_diary(self): """ extracts event information from core tables into diary files """ print('Generate diary files from Event rows only') for r in self.table: print(str(type(r)) + ' = ', r)
python
def generate_diary(self): """ extracts event information from core tables into diary files """ print('Generate diary files from Event rows only') for r in self.table: print(str(type(r)) + ' = ', r)
[ "def", "generate_diary", "(", "self", ")", ":", "print", "(", "'Generate diary files from Event rows only'", ")", "for", "r", "in", "self", ".", "table", ":", "print", "(", "str", "(", "type", "(", "r", ")", ")", "+", "' = '", ",", "r", ")" ]
extracts event information from core tables into diary files
[ "extracts", "event", "information", "from", "core", "tables", "into", "diary", "files" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L344-L350
train
Phelimb/atlas
mykatlas/typing/typer/variant.py
VariantTyper.type
def type(self, variant_probe_coverages, variant=None): """ Takes a list of VariantProbeCoverages and returns a Call for the Variant. Note, in the simplest case the list will be of length one. However, we may be typing the Variant on multiple backgrouds leading to multiple Var...
python
def type(self, variant_probe_coverages, variant=None): """ Takes a list of VariantProbeCoverages and returns a Call for the Variant. Note, in the simplest case the list will be of length one. However, we may be typing the Variant on multiple backgrouds leading to multiple Var...
[ "def", "type", "(", "self", ",", "variant_probe_coverages", ",", "variant", "=", "None", ")", ":", "if", "not", "isinstance", "(", "variant_probe_coverages", ",", "list", ")", ":", "variant_probe_coverages", "=", "[", "variant_probe_coverages", "]", "calls", "="...
Takes a list of VariantProbeCoverages and returns a Call for the Variant. Note, in the simplest case the list will be of length one. However, we may be typing the Variant on multiple backgrouds leading to multiple VariantProbes for a single Variant.
[ "Takes", "a", "list", "of", "VariantProbeCoverages", "and", "returns", "a", "Call", "for", "the", "Variant", ".", "Note", "in", "the", "simplest", "case", "the", "list", "will", "be", "of", "length", "one", ".", "However", "we", "may", "be", "typing", "t...
02e85497bb5ac423d6452a10dca11964582ac4d7
https://github.com/Phelimb/atlas/blob/02e85497bb5ac423d6452a10dca11964582ac4d7/mykatlas/typing/typer/variant.py#L64-L88
train
Nachtfeuer/pipeline
spline/components/ansible.py
Ansible.creator
def creator(entry, config): """Creator function for creating an instance of an Ansible script.""" ansible_playbook = "ansible.playbook.dry.run.see.comment" ansible_inventory = "ansible.inventory.dry.run.see.comment" ansible_playbook_content = render(config.script, model=config.model, en...
python
def creator(entry, config): """Creator function for creating an instance of an Ansible script.""" ansible_playbook = "ansible.playbook.dry.run.see.comment" ansible_inventory = "ansible.inventory.dry.run.see.comment" ansible_playbook_content = render(config.script, model=config.model, en...
[ "def", "creator", "(", "entry", ",", "config", ")", ":", "ansible_playbook", "=", "\"ansible.playbook.dry.run.see.comment\"", "ansible_inventory", "=", "\"ansible.inventory.dry.run.see.comment\"", "ansible_playbook_content", "=", "render", "(", "config", ".", "script", ",",...
Creator function for creating an instance of an Ansible script.
[ "Creator", "function", "for", "creating", "an", "instance", "of", "an", "Ansible", "script", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/ansible.py#L37-L64
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid_life.py
GameOfLife.update_gol
def update_gol(self): """ Function that performs one step of the Game of Life """ updated_grid = [[self.update_cell(row, col) \ for col in range(self.get_grid_width())] \ for row in range(self.get_grid_height())] ...
python
def update_gol(self): """ Function that performs one step of the Game of Life """ updated_grid = [[self.update_cell(row, col) \ for col in range(self.get_grid_width())] \ for row in range(self.get_grid_height())] ...
[ "def", "update_gol", "(", "self", ")", ":", "updated_grid", "=", "[", "[", "self", ".", "update_cell", "(", "row", ",", "col", ")", "for", "col", "in", "range", "(", "self", ".", "get_grid_width", "(", ")", ")", "]", "for", "row", "in", "range", "(...
Function that performs one step of the Game of Life
[ "Function", "that", "performs", "one", "step", "of", "the", "Game", "of", "Life" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid_life.py#L19-L28
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid_life.py
GameOfLife.update_cell
def update_cell(self, row, col): """ Function that computes the update for one cell in the Game of Life """ # compute number of living neighbors neighbors = self.eight_neighbors(row, col) living_neighbors = 0 for neighbor in neighbors: if not self.is_e...
python
def update_cell(self, row, col): """ Function that computes the update for one cell in the Game of Life """ # compute number of living neighbors neighbors = self.eight_neighbors(row, col) living_neighbors = 0 for neighbor in neighbors: if not self.is_e...
[ "def", "update_cell", "(", "self", ",", "row", ",", "col", ")", ":", "neighbors", "=", "self", ".", "eight_neighbors", "(", "row", ",", "col", ")", "living_neighbors", "=", "0", "for", "neighbor", "in", "neighbors", ":", "if", "not", "self", ".", "is_e...
Function that computes the update for one cell in the Game of Life
[ "Function", "that", "computes", "the", "update", "for", "one", "cell", "in", "the", "Game", "of", "Life" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid_life.py#L31-L46
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid_life.py
GameOfLifePatterns.random_offset
def random_offset(self, lst): """ offsets a pattern list generated below to a random position in the grid """ res = [] x = random.randint(4,self.max_x - 42) y = random.randint(4,self.max_y - 10) for itm in lst: res.append([itm[0] + y, itm[1] +...
python
def random_offset(self, lst): """ offsets a pattern list generated below to a random position in the grid """ res = [] x = random.randint(4,self.max_x - 42) y = random.randint(4,self.max_y - 10) for itm in lst: res.append([itm[0] + y, itm[1] +...
[ "def", "random_offset", "(", "self", ",", "lst", ")", ":", "res", "=", "[", "]", "x", "=", "random", ".", "randint", "(", "4", ",", "self", ".", "max_x", "-", "42", ")", "y", "=", "random", ".", "randint", "(", "4", ",", "self", ".", "max_y", ...
offsets a pattern list generated below to a random position in the grid
[ "offsets", "a", "pattern", "list", "generated", "below", "to", "a", "random", "position", "in", "the", "grid" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid_life.py#L100-L110
train
JelleAalbers/multihist
multihist.py
Hist1d.get_random
def get_random(self, size=10): """Returns random variates from the histogram. Note this assumes the histogram is an 'events per bin', not a pdf. Inside the bins, a uniform distribution is assumed. """ bin_i = np.random.choice(np.arange(len(self.bin_centers)), size=size, p=self.no...
python
def get_random(self, size=10): """Returns random variates from the histogram. Note this assumes the histogram is an 'events per bin', not a pdf. Inside the bins, a uniform distribution is assumed. """ bin_i = np.random.choice(np.arange(len(self.bin_centers)), size=size, p=self.no...
[ "def", "get_random", "(", "self", ",", "size", "=", "10", ")", ":", "bin_i", "=", "np", ".", "random", ".", "choice", "(", "np", ".", "arange", "(", "len", "(", "self", ".", "bin_centers", ")", ")", ",", "size", "=", "size", ",", "p", "=", "sel...
Returns random variates from the histogram. Note this assumes the histogram is an 'events per bin', not a pdf. Inside the bins, a uniform distribution is assumed.
[ "Returns", "random", "variates", "from", "the", "histogram", ".", "Note", "this", "assumes", "the", "histogram", "is", "an", "events", "per", "bin", "not", "a", "pdf", ".", "Inside", "the", "bins", "a", "uniform", "distribution", "is", "assumed", "." ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L187-L193
train
JelleAalbers/multihist
multihist.py
Hist1d.std
def std(self, bessel_correction=True): """Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin.""" if bessel_correction: n = self.n bc = n / (n - 1) else: bc = 1 return np.sqrt(np.average((self.bin_centers - se...
python
def std(self, bessel_correction=True): """Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin.""" if bessel_correction: n = self.n bc = n / (n - 1) else: bc = 1 return np.sqrt(np.average((self.bin_centers - se...
[ "def", "std", "(", "self", ",", "bessel_correction", "=", "True", ")", ":", "if", "bessel_correction", ":", "n", "=", "self", ".", "n", "bc", "=", "n", "/", "(", "n", "-", "1", ")", "else", ":", "bc", "=", "1", "return", "np", ".", "sqrt", "(",...
Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin.
[ "Estimates", "std", "of", "underlying", "data", "assuming", "each", "datapoint", "was", "exactly", "in", "the", "center", "of", "its", "bin", "." ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L205-L212
train
JelleAalbers/multihist
multihist.py
Hist1d.percentile
def percentile(self, percentile): """Return bin center nearest to percentile""" return self.bin_centers[np.argmin(np.abs(self.cumulative_density * 100 - percentile))]
python
def percentile(self, percentile): """Return bin center nearest to percentile""" return self.bin_centers[np.argmin(np.abs(self.cumulative_density * 100 - percentile))]
[ "def", "percentile", "(", "self", ",", "percentile", ")", ":", "return", "self", ".", "bin_centers", "[", "np", ".", "argmin", "(", "np", ".", "abs", "(", "self", ".", "cumulative_density", "*", "100", "-", "percentile", ")", ")", "]" ]
Return bin center nearest to percentile
[ "Return", "bin", "center", "nearest", "to", "percentile" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L238-L240
train
JelleAalbers/multihist
multihist.py
Histdd._data_to_hist
def _data_to_hist(self, data, **kwargs): """Return bin_edges, histogram array""" if hasattr(self, 'bin_edges'): kwargs.setdefault('bins', self.bin_edges) if len(data) == 1 and isinstance(data[0], COLUMNAR_DATA_SOURCES): data = data[0] if self.axis_names is N...
python
def _data_to_hist(self, data, **kwargs): """Return bin_edges, histogram array""" if hasattr(self, 'bin_edges'): kwargs.setdefault('bins', self.bin_edges) if len(data) == 1 and isinstance(data[0], COLUMNAR_DATA_SOURCES): data = data[0] if self.axis_names is N...
[ "def", "_data_to_hist", "(", "self", ",", "data", ",", "**", "kwargs", ")", ":", "if", "hasattr", "(", "self", ",", "'bin_edges'", ")", ":", "kwargs", ".", "setdefault", "(", "'bins'", ",", "self", ".", "bin_edges", ")", "if", "len", "(", "data", ")"...
Return bin_edges, histogram array
[ "Return", "bin_edges", "histogram", "array" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L302-L345
train
JelleAalbers/multihist
multihist.py
Histdd.axis_names_without
def axis_names_without(self, axis): """Return axis names without axis, or None if axis_names is None""" if self.axis_names is None: return None return itemgetter(*self.other_axes(axis))(self.axis_names)
python
def axis_names_without(self, axis): """Return axis names without axis, or None if axis_names is None""" if self.axis_names is None: return None return itemgetter(*self.other_axes(axis))(self.axis_names)
[ "def", "axis_names_without", "(", "self", ",", "axis", ")", ":", "if", "self", ".", "axis_names", "is", "None", ":", "return", "None", "return", "itemgetter", "(", "*", "self", ".", "other_axes", "(", "axis", ")", ")", "(", "self", ".", "axis_names", "...
Return axis names without axis, or None if axis_names is None
[ "Return", "axis", "names", "without", "axis", "or", "None", "if", "axis_names", "is", "None" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L369-L373
train
JelleAalbers/multihist
multihist.py
Histdd.bin_centers
def bin_centers(self, axis=None): """Return bin centers along an axis, or if axis=None, list of bin_centers along each axis""" if axis is None: return np.array([self.bin_centers(axis=i) for i in range(self.dimensions)]) axis = self.get_axis_number(axis) return 0.5 * (self.bin...
python
def bin_centers(self, axis=None): """Return bin centers along an axis, or if axis=None, list of bin_centers along each axis""" if axis is None: return np.array([self.bin_centers(axis=i) for i in range(self.dimensions)]) axis = self.get_axis_number(axis) return 0.5 * (self.bin...
[ "def", "bin_centers", "(", "self", ",", "axis", "=", "None", ")", ":", "if", "axis", "is", "None", ":", "return", "np", ".", "array", "(", "[", "self", ".", "bin_centers", "(", "axis", "=", "i", ")", "for", "i", "in", "range", "(", "self", ".", ...
Return bin centers along an axis, or if axis=None, list of bin_centers along each axis
[ "Return", "bin", "centers", "along", "an", "axis", "or", "if", "axis", "=", "None", "list", "of", "bin_centers", "along", "each", "axis" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L378-L383
train
JelleAalbers/multihist
multihist.py
Histdd.get_axis_bin_index
def get_axis_bin_index(self, value, axis): """Returns index along axis of bin in histogram which contains value Inclusive on both endpoints """ axis = self.get_axis_number(axis) bin_edges = self.bin_edges[axis] # The right bin edge of np.histogram is inclusive: if...
python
def get_axis_bin_index(self, value, axis): """Returns index along axis of bin in histogram which contains value Inclusive on both endpoints """ axis = self.get_axis_number(axis) bin_edges = self.bin_edges[axis] # The right bin edge of np.histogram is inclusive: if...
[ "def", "get_axis_bin_index", "(", "self", ",", "value", ",", "axis", ")", ":", "axis", "=", "self", ".", "get_axis_number", "(", "axis", ")", "bin_edges", "=", "self", ".", "bin_edges", "[", "axis", "]", "if", "value", "==", "bin_edges", "[", "-", "1",...
Returns index along axis of bin in histogram which contains value Inclusive on both endpoints
[ "Returns", "index", "along", "axis", "of", "bin", "in", "histogram", "which", "contains", "value", "Inclusive", "on", "both", "endpoints" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L385-L400
train
JelleAalbers/multihist
multihist.py
Histdd.get_bin_indices
def get_bin_indices(self, values): """Returns index tuple in histogram of bin which contains value""" return tuple([self.get_axis_bin_index(values[ax_i], ax_i) for ax_i in range(self.dimensions)])
python
def get_bin_indices(self, values): """Returns index tuple in histogram of bin which contains value""" return tuple([self.get_axis_bin_index(values[ax_i], ax_i) for ax_i in range(self.dimensions)])
[ "def", "get_bin_indices", "(", "self", ",", "values", ")", ":", "return", "tuple", "(", "[", "self", ".", "get_axis_bin_index", "(", "values", "[", "ax_i", "]", ",", "ax_i", ")", "for", "ax_i", "in", "range", "(", "self", ".", "dimensions", ")", "]", ...
Returns index tuple in histogram of bin which contains value
[ "Returns", "index", "tuple", "in", "histogram", "of", "bin", "which", "contains", "value" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L402-L405
train
JelleAalbers/multihist
multihist.py
Histdd.all_axis_bin_centers
def all_axis_bin_centers(self, axis): """Return ndarray of same shape as histogram containing bin center value along axis at each point""" # Arcane hack that seems to work, at least in 3d... hope axis = self.get_axis_number(axis) return np.meshgrid(*self.bin_centers(), indexing='ij')[axi...
python
def all_axis_bin_centers(self, axis): """Return ndarray of same shape as histogram containing bin center value along axis at each point""" # Arcane hack that seems to work, at least in 3d... hope axis = self.get_axis_number(axis) return np.meshgrid(*self.bin_centers(), indexing='ij')[axi...
[ "def", "all_axis_bin_centers", "(", "self", ",", "axis", ")", ":", "axis", "=", "self", ".", "get_axis_number", "(", "axis", ")", "return", "np", ".", "meshgrid", "(", "*", "self", ".", "bin_centers", "(", ")", ",", "indexing", "=", "'ij'", ")", "[", ...
Return ndarray of same shape as histogram containing bin center value along axis at each point
[ "Return", "ndarray", "of", "same", "shape", "as", "histogram", "containing", "bin", "center", "value", "along", "axis", "at", "each", "point" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L407-L411
train
JelleAalbers/multihist
multihist.py
Histdd.sum
def sum(self, axis): """Sums all data along axis, returns d-1 dimensional histogram""" axis = self.get_axis_number(axis) if self.dimensions == 2: new_hist = Hist1d else: new_hist = Histdd return new_hist.from_histogram(np.sum(self.histogram, axis=axis), ...
python
def sum(self, axis): """Sums all data along axis, returns d-1 dimensional histogram""" axis = self.get_axis_number(axis) if self.dimensions == 2: new_hist = Hist1d else: new_hist = Histdd return new_hist.from_histogram(np.sum(self.histogram, axis=axis), ...
[ "def", "sum", "(", "self", ",", "axis", ")", ":", "axis", "=", "self", ".", "get_axis_number", "(", "axis", ")", "if", "self", ".", "dimensions", "==", "2", ":", "new_hist", "=", "Hist1d", "else", ":", "new_hist", "=", "Histdd", "return", "new_hist", ...
Sums all data along axis, returns d-1 dimensional histogram
[ "Sums", "all", "data", "along", "axis", "returns", "d", "-", "1", "dimensional", "histogram" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L416-L425
train
JelleAalbers/multihist
multihist.py
Histdd.slicesum
def slicesum(self, start, stop=None, axis=0): """Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram""" return self.slice(start, stop, axis).sum(axis)
python
def slicesum(self, start, stop=None, axis=0): """Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram""" return self.slice(start, stop, axis).sum(axis)
[ "def", "slicesum", "(", "self", ",", "start", ",", "stop", "=", "None", ",", "axis", "=", "0", ")", ":", "return", "self", ".", "slice", "(", "start", ",", "stop", ",", "axis", ")", ".", "sum", "(", "axis", ")" ]
Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram
[ "Slices", "the", "histogram", "along", "axis", "then", "sums", "over", "that", "slice", "returning", "a", "d", "-", "1", "dimensional", "histogram" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L442-L444
train
JelleAalbers/multihist
multihist.py
Histdd.projection
def projection(self, axis): """Sums all data along all other axes, then return Hist1D""" axis = self.get_axis_number(axis) projected_hist = np.sum(self.histogram, axis=self.other_axes(axis)) return Hist1d.from_histogram(projected_hist, bin_edges=self.bin_edges[axis])
python
def projection(self, axis): """Sums all data along all other axes, then return Hist1D""" axis = self.get_axis_number(axis) projected_hist = np.sum(self.histogram, axis=self.other_axes(axis)) return Hist1d.from_histogram(projected_hist, bin_edges=self.bin_edges[axis])
[ "def", "projection", "(", "self", ",", "axis", ")", ":", "axis", "=", "self", ".", "get_axis_number", "(", "axis", ")", "projected_hist", "=", "np", ".", "sum", "(", "self", ".", "histogram", ",", "axis", "=", "self", ".", "other_axes", "(", "axis", ...
Sums all data along all other axes, then return Hist1D
[ "Sums", "all", "data", "along", "all", "other", "axes", "then", "return", "Hist1D" ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L446-L450
train
JelleAalbers/multihist
multihist.py
Histdd.cumulate
def cumulate(self, axis): """Returns new histogram with all data cumulated along axis.""" axis = self.get_axis_number(axis) return Histdd.from_histogram(np.cumsum(self.histogram, axis=axis), bin_edges=self.bin_edges, axis_...
python
def cumulate(self, axis): """Returns new histogram with all data cumulated along axis.""" axis = self.get_axis_number(axis) return Histdd.from_histogram(np.cumsum(self.histogram, axis=axis), bin_edges=self.bin_edges, axis_...
[ "def", "cumulate", "(", "self", ",", "axis", ")", ":", "axis", "=", "self", ".", "get_axis_number", "(", "axis", ")", "return", "Histdd", ".", "from_histogram", "(", "np", ".", "cumsum", "(", "self", ".", "histogram", ",", "axis", "=", "axis", ")", "...
Returns new histogram with all data cumulated along axis.
[ "Returns", "new", "histogram", "with", "all", "data", "cumulated", "along", "axis", "." ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L456-L461
train
JelleAalbers/multihist
multihist.py
Histdd.central_likelihood
def central_likelihood(self, axis): """Returns new histogram with all values replaced by their central likelihoods along axis.""" result = self.cumulative_density(axis) result.histogram = 1 - 2 * np.abs(result.histogram - 0.5) return result
python
def central_likelihood(self, axis): """Returns new histogram with all values replaced by their central likelihoods along axis.""" result = self.cumulative_density(axis) result.histogram = 1 - 2 * np.abs(result.histogram - 0.5) return result
[ "def", "central_likelihood", "(", "self", ",", "axis", ")", ":", "result", "=", "self", ".", "cumulative_density", "(", "axis", ")", "result", ".", "histogram", "=", "1", "-", "2", "*", "np", ".", "abs", "(", "result", ".", "histogram", "-", "0.5", "...
Returns new histogram with all values replaced by their central likelihoods along axis.
[ "Returns", "new", "histogram", "with", "all", "values", "replaced", "by", "their", "central", "likelihoods", "along", "axis", "." ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L482-L486
train
JelleAalbers/multihist
multihist.py
Histdd.lookup_hist
def lookup_hist(self, mh): """Return histogram within binning of Histdd mh, with values looked up in this histogram. This is not rebinning: no interpolation /renormalization is performed. It's just a lookup. """ result = mh.similar_blank_histogram() points = np.stack([mh...
python
def lookup_hist(self, mh): """Return histogram within binning of Histdd mh, with values looked up in this histogram. This is not rebinning: no interpolation /renormalization is performed. It's just a lookup. """ result = mh.similar_blank_histogram() points = np.stack([mh...
[ "def", "lookup_hist", "(", "self", ",", "mh", ")", ":", "result", "=", "mh", ".", "similar_blank_histogram", "(", ")", "points", "=", "np", ".", "stack", "(", "[", "mh", ".", "all_axis_bin_centers", "(", "i", ")", "for", "i", "in", "range", "(", "mh"...
Return histogram within binning of Histdd mh, with values looked up in this histogram. This is not rebinning: no interpolation /renormalization is performed. It's just a lookup.
[ "Return", "histogram", "within", "binning", "of", "Histdd", "mh", "with", "values", "looked", "up", "in", "this", "histogram", "." ]
072288277f807e7e388fdf424c3921c80576f3ab
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L685-L696
train
acutesoftware/AIKIF
scripts/examples/doc_roadmap.py
create_roadmap_doc
def create_roadmap_doc(dat, opFile): """ takes a dictionary read from a yaml file and converts it to the roadmap documentation """ op = format_title('Roadmap for AIKIF') for h1 in dat['projects']: op += format_h1(h1) if dat[h1] is None: op += '(No details)\n' ...
python
def create_roadmap_doc(dat, opFile): """ takes a dictionary read from a yaml file and converts it to the roadmap documentation """ op = format_title('Roadmap for AIKIF') for h1 in dat['projects']: op += format_h1(h1) if dat[h1] is None: op += '(No details)\n' ...
[ "def", "create_roadmap_doc", "(", "dat", ",", "opFile", ")", ":", "op", "=", "format_title", "(", "'Roadmap for AIKIF'", ")", "for", "h1", "in", "dat", "[", "'projects'", "]", ":", "op", "+=", "format_h1", "(", "h1", ")", "if", "dat", "[", "h1", "]", ...
takes a dictionary read from a yaml file and converts it to the roadmap documentation
[ "takes", "a", "dictionary", "read", "from", "a", "yaml", "file", "and", "converts", "it", "to", "the", "roadmap", "documentation" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/doc_roadmap.py#L20-L41
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.clear
def clear(self): """ Clears grid to be EMPTY """ self.grid = [[EMPTY for dummy_col in range(self.grid_width)] for dummy_row in range(self.grid_height)]
python
def clear(self): """ Clears grid to be EMPTY """ self.grid = [[EMPTY for dummy_col in range(self.grid_width)] for dummy_row in range(self.grid_height)]
[ "def", "clear", "(", "self", ")", ":", "self", ".", "grid", "=", "[", "[", "EMPTY", "for", "dummy_col", "in", "range", "(", "self", ".", "grid_width", ")", "]", "for", "dummy_row", "in", "range", "(", "self", ".", "grid_height", ")", "]" ]
Clears grid to be EMPTY
[ "Clears", "grid", "to", "be", "EMPTY" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L34-L38
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.save
def save(self, fname): """ saves a grid to file as ASCII text """ try: with open(fname, "w") as f: f.write(str(self)) except Exception as ex: print('ERROR = cant save grid results to ' + fname + str(ex))
python
def save(self, fname): """ saves a grid to file as ASCII text """ try: with open(fname, "w") as f: f.write(str(self)) except Exception as ex: print('ERROR = cant save grid results to ' + fname + str(ex))
[ "def", "save", "(", "self", ",", "fname", ")", ":", "try", ":", "with", "open", "(", "fname", ",", "\"w\"", ")", "as", "f", ":", "f", ".", "write", "(", "str", "(", "self", ")", ")", "except", "Exception", "as", "ex", ":", "print", "(", "'ERROR...
saves a grid to file as ASCII text
[ "saves", "a", "grid", "to", "file", "as", "ASCII", "text" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L52-L58
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.load
def load(self, fname): """ loads a ASCII text file grid to self """ # get height and width of grid from file self.grid_width = 4 self.grid_height = 4 # re-read the file and load it self.grid = [[0 for dummy_l in range(self.grid_width)] for dummy_l in ra...
python
def load(self, fname): """ loads a ASCII text file grid to self """ # get height and width of grid from file self.grid_width = 4 self.grid_height = 4 # re-read the file and load it self.grid = [[0 for dummy_l in range(self.grid_width)] for dummy_l in ra...
[ "def", "load", "(", "self", ",", "fname", ")", ":", "self", ".", "grid_width", "=", "4", "self", ".", "grid_height", "=", "4", "self", ".", "grid", "=", "[", "[", "0", "for", "dummy_l", "in", "range", "(", "self", ".", "grid_width", ")", "]", "fo...
loads a ASCII text file grid to self
[ "loads", "a", "ASCII", "text", "file", "grid", "to", "self" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L62-L76
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.extract_col
def extract_col(self, col): """ get column number 'col' """ new_col = [row[col] for row in self.grid] return new_col
python
def extract_col(self, col): """ get column number 'col' """ new_col = [row[col] for row in self.grid] return new_col
[ "def", "extract_col", "(", "self", ",", "col", ")", ":", "new_col", "=", "[", "row", "[", "col", "]", "for", "row", "in", "self", ".", "grid", "]", "return", "new_col" ]
get column number 'col'
[ "get", "column", "number", "col" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L103-L108
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.extract_row
def extract_row(self, row): """ get row number 'row' """ new_row = [] for col in range(self.get_grid_width()): new_row.append(self.get_tile(row, col)) return new_row
python
def extract_row(self, row): """ get row number 'row' """ new_row = [] for col in range(self.get_grid_width()): new_row.append(self.get_tile(row, col)) return new_row
[ "def", "extract_row", "(", "self", ",", "row", ")", ":", "new_row", "=", "[", "]", "for", "col", "in", "range", "(", "self", ".", "get_grid_width", "(", ")", ")", ":", "new_row", ".", "append", "(", "self", ".", "get_tile", "(", "row", ",", "col", ...
get row number 'row'
[ "get", "row", "number", "row" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L110-L117
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.replace_row
def replace_row(self, line, ndx): """ replace a grids row at index 'ndx' with 'line' """ for col in range(len(line)): self.set_tile(ndx, col, line[col])
python
def replace_row(self, line, ndx): """ replace a grids row at index 'ndx' with 'line' """ for col in range(len(line)): self.set_tile(ndx, col, line[col])
[ "def", "replace_row", "(", "self", ",", "line", ",", "ndx", ")", ":", "for", "col", "in", "range", "(", "len", "(", "line", ")", ")", ":", "self", ".", "set_tile", "(", "ndx", ",", "col", ",", "line", "[", "col", "]", ")" ]
replace a grids row at index 'ndx' with 'line'
[ "replace", "a", "grids", "row", "at", "index", "ndx", "with", "line" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L119-L124
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.replace_col
def replace_col(self, line, ndx): """ replace a grids column at index 'ndx' with 'line' """ for row in range(len(line)): self.set_tile(row, ndx, line[row])
python
def replace_col(self, line, ndx): """ replace a grids column at index 'ndx' with 'line' """ for row in range(len(line)): self.set_tile(row, ndx, line[row])
[ "def", "replace_col", "(", "self", ",", "line", ",", "ndx", ")", ":", "for", "row", "in", "range", "(", "len", "(", "line", ")", ")", ":", "self", ".", "set_tile", "(", "row", ",", "ndx", ",", "line", "[", "row", "]", ")" ]
replace a grids column at index 'ndx' with 'line'
[ "replace", "a", "grids", "column", "at", "index", "ndx", "with", "line" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L126-L131
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.new_tile
def new_tile(self, num=1): """ Create a new tile in a randomly selected empty square. The tile should be 2 90% of the time and 4 10% of the time. """ for _ in range(num): if random.random() > .5: new_tile = self.pieces[0] ...
python
def new_tile(self, num=1): """ Create a new tile in a randomly selected empty square. The tile should be 2 90% of the time and 4 10% of the time. """ for _ in range(num): if random.random() > .5: new_tile = self.pieces[0] ...
[ "def", "new_tile", "(", "self", ",", "num", "=", "1", ")", ":", "for", "_", "in", "range", "(", "num", ")", ":", "if", "random", ".", "random", "(", ")", ">", ".5", ":", "new_tile", "=", "self", ".", "pieces", "[", "0", "]", "else", ":", "new...
Create a new tile in a randomly selected empty square. The tile should be 2 90% of the time and 4 10% of the time.
[ "Create", "a", "new", "tile", "in", "a", "randomly", "selected", "empty", "square", ".", "The", "tile", "should", "be", "2", "90%", "of", "the", "time", "and", "4", "10%", "of", "the", "time", "." ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L140-L161
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.set_tile
def set_tile(self, row, col, value): """ Set the tile at position row, col to have the given value. """ #print('set_tile: y=', row, 'x=', col) if col < 0: print("ERROR - x less than zero", col) col = 0 #return if col > s...
python
def set_tile(self, row, col, value): """ Set the tile at position row, col to have the given value. """ #print('set_tile: y=', row, 'x=', col) if col < 0: print("ERROR - x less than zero", col) col = 0 #return if col > s...
[ "def", "set_tile", "(", "self", ",", "row", ",", "col", ",", "value", ")", ":", "if", "col", "<", "0", ":", "print", "(", "\"ERROR - x less than zero\"", ",", "col", ")", "col", "=", "0", "if", "col", ">", "self", ".", "grid_width", "-", "1", ":", ...
Set the tile at position row, col to have the given value.
[ "Set", "the", "tile", "at", "position", "row", "col", "to", "have", "the", "given", "value", "." ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L196-L220
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.replace_grid
def replace_grid(self, updated_grid): """ replace all cells in current grid with updated grid """ for col in range(self.get_grid_width()): for row in range(self.get_grid_height()): if updated_grid[row][col] == EMPTY: self.set_empty(row, col...
python
def replace_grid(self, updated_grid): """ replace all cells in current grid with updated grid """ for col in range(self.get_grid_width()): for row in range(self.get_grid_height()): if updated_grid[row][col] == EMPTY: self.set_empty(row, col...
[ "def", "replace_grid", "(", "self", ",", "updated_grid", ")", ":", "for", "col", "in", "range", "(", "self", ".", "get_grid_width", "(", ")", ")", ":", "for", "row", "in", "range", "(", "self", ".", "get_grid_height", "(", ")", ")", ":", "if", "updat...
replace all cells in current grid with updated grid
[ "replace", "all", "cells", "in", "current", "grid", "with", "updated", "grid" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L289-L298
train
acutesoftware/AIKIF
aikif/toolbox/cls_grid.py
Grid.find_safe_starting_point
def find_safe_starting_point(self): """ finds a place on the grid which is clear on all sides to avoid starting in the middle of a blockage """ y = random.randint(2,self.grid_height-4) x = random.randint(2,self.grid_width-4) return y, x
python
def find_safe_starting_point(self): """ finds a place on the grid which is clear on all sides to avoid starting in the middle of a blockage """ y = random.randint(2,self.grid_height-4) x = random.randint(2,self.grid_width-4) return y, x
[ "def", "find_safe_starting_point", "(", "self", ")", ":", "y", "=", "random", ".", "randint", "(", "2", ",", "self", ".", "grid_height", "-", "4", ")", "x", "=", "random", ".", "randint", "(", "2", ",", "self", ".", "grid_width", "-", "4", ")", "re...
finds a place on the grid which is clear on all sides to avoid starting in the middle of a blockage
[ "finds", "a", "place", "on", "the", "grid", "which", "is", "clear", "on", "all", "sides", "to", "avoid", "starting", "in", "the", "middle", "of", "a", "blockage" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/cls_grid.py#L300-L307
train
acutesoftware/AIKIF
aikif/toolbox/image_tools.py
resize
def resize(fname, basewidth, opFilename): """ resize an image to basewidth """ if basewidth == 0: basewidth = 300 img = Image.open(fname) wpercent = (basewidth/float(img.size[0])) hsize = int((float(img.size[1])*float(wpercent))) img = img.resize((basewidth,hsize), Image.ANTIALIAS) i...
python
def resize(fname, basewidth, opFilename): """ resize an image to basewidth """ if basewidth == 0: basewidth = 300 img = Image.open(fname) wpercent = (basewidth/float(img.size[0])) hsize = int((float(img.size[1])*float(wpercent))) img = img.resize((basewidth,hsize), Image.ANTIALIAS) i...
[ "def", "resize", "(", "fname", ",", "basewidth", ",", "opFilename", ")", ":", "if", "basewidth", "==", "0", ":", "basewidth", "=", "300", "img", "=", "Image", ".", "open", "(", "fname", ")", "wpercent", "=", "(", "basewidth", "/", "float", "(", "img"...
resize an image to basewidth
[ "resize", "an", "image", "to", "basewidth" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L103-L111
train
acutesoftware/AIKIF
aikif/toolbox/image_tools.py
print_stats
def print_stats(img): """ prints stats, remember that img should already have been loaded """ stat = ImageStat.Stat(img) print("extrema : ", stat.extrema) print("count : ", stat.count) print("sum : ", stat.sum) print("sum2 : ", stat.sum2) print("mean : ", stat.mean...
python
def print_stats(img): """ prints stats, remember that img should already have been loaded """ stat = ImageStat.Stat(img) print("extrema : ", stat.extrema) print("count : ", stat.count) print("sum : ", stat.sum) print("sum2 : ", stat.sum2) print("mean : ", stat.mean...
[ "def", "print_stats", "(", "img", ")", ":", "stat", "=", "ImageStat", ".", "Stat", "(", "img", ")", "print", "(", "\"extrema : \"", ",", "stat", ".", "extrema", ")", "print", "(", "\"count : \"", ",", "stat", ".", "count", ")", "print", "(", "\...
prints stats, remember that img should already have been loaded
[ "prints", "stats", "remember", "that", "img", "should", "already", "have", "been", "loaded" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L114-L125
train
acutesoftware/AIKIF
aikif/toolbox/image_tools.py
print_all_metadata
def print_all_metadata(fname): """ high level that prints all as long list """ print("Filename :", fname ) print("Basename :", os.path.basename(fname)) print("Path :", os.path.dirname(fname)) print("Size :", os.path.getsize(fname)) img = Image.open(fname) # get the image's wi...
python
def print_all_metadata(fname): """ high level that prints all as long list """ print("Filename :", fname ) print("Basename :", os.path.basename(fname)) print("Path :", os.path.dirname(fname)) print("Size :", os.path.getsize(fname)) img = Image.open(fname) # get the image's wi...
[ "def", "print_all_metadata", "(", "fname", ")", ":", "print", "(", "\"Filename :\"", ",", "fname", ")", "print", "(", "\"Basename :\"", ",", "os", ".", "path", ".", "basename", "(", "fname", ")", ")", "print", "(", "\"Path :\"", ",", "os", ".", ...
high level that prints all as long list
[ "high", "level", "that", "prints", "all", "as", "long", "list" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L152-L173
train
acutesoftware/AIKIF
aikif/toolbox/image_tools.py
get_metadata_as_dict
def get_metadata_as_dict(fname): """ Gets all metadata and puts into dictionary """ imgdict = {} try: imgdict['filename'] = fname imgdict['size'] = str(os.path.getsize(fname)) imgdict['basename'] = os.path.basename(fname) imgdict['path'] = os.path.dirname(fname) img ...
python
def get_metadata_as_dict(fname): """ Gets all metadata and puts into dictionary """ imgdict = {} try: imgdict['filename'] = fname imgdict['size'] = str(os.path.getsize(fname)) imgdict['basename'] = os.path.basename(fname) imgdict['path'] = os.path.dirname(fname) img ...
[ "def", "get_metadata_as_dict", "(", "fname", ")", ":", "imgdict", "=", "{", "}", "try", ":", "imgdict", "[", "'filename'", "]", "=", "fname", "imgdict", "[", "'size'", "]", "=", "str", "(", "os", ".", "path", ".", "getsize", "(", "fname", ")", ")", ...
Gets all metadata and puts into dictionary
[ "Gets", "all", "metadata", "and", "puts", "into", "dictionary" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L198-L235
train
acutesoftware/AIKIF
aikif/toolbox/image_tools.py
get_metadata_as_csv
def get_metadata_as_csv(fname): """ Gets all metadata and puts into CSV format """ q = chr(34) d = "," res = q + fname + q + d res = res + q + os.path.basename(fname) + q + d res = res + q + os.path.dirname(fname) + q + d try: res = res + q + str(os.path.getsize(fname)) + q + d ...
python
def get_metadata_as_csv(fname): """ Gets all metadata and puts into CSV format """ q = chr(34) d = "," res = q + fname + q + d res = res + q + os.path.basename(fname) + q + d res = res + q + os.path.dirname(fname) + q + d try: res = res + q + str(os.path.getsize(fname)) + q + d ...
[ "def", "get_metadata_as_csv", "(", "fname", ")", ":", "q", "=", "chr", "(", "34", ")", "d", "=", "\",\"", "res", "=", "q", "+", "fname", "+", "q", "+", "d", "res", "=", "res", "+", "q", "+", "os", ".", "path", ".", "basename", "(", "fname", "...
Gets all metadata and puts into CSV format
[ "Gets", "all", "metadata", "and", "puts", "into", "CSV", "format" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_tools.py#L237-L271
train