partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | PopupError | Popup with colored button and 'Error' as button text
:param args:
:param button_color:
:param background_color:
:param text_color:
:param auto_close:
:param auto_close_duration:
:param non_blocking:
:param icon:
:param line_width:
:param font:
:param no_titlebar:
:param g... | PySimpleGUI27.py | def PopupError(*args, **_3to2kwargs):
if 'location' in _3to2kwargs: location = _3to2kwargs['location']; del _3to2kwargs['location']
else: location = (None, None)
if 'keep_on_top' in _3to2kwargs: keep_on_top = _3to2kwargs['keep_on_top']; del _3to2kwargs['keep_on_top']
else: keep_on_top = False
if 'gr... | def PopupError(*args, **_3to2kwargs):
if 'location' in _3to2kwargs: location = _3to2kwargs['location']; del _3to2kwargs['location']
else: location = (None, None)
if 'keep_on_top' in _3to2kwargs: keep_on_top = _3to2kwargs['keep_on_top']; del _3to2kwargs['keep_on_top']
else: keep_on_top = False
if 'gr... | [
"Popup",
"with",
"colored",
"button",
"and",
"Error",
"as",
"button",
"text",
":",
"param",
"args",
":",
":",
"param",
"button_color",
":",
":",
"param",
"background_color",
":",
":",
"param",
"text_color",
":",
":",
"param",
"auto_close",
":",
":",
"param... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L7522-L7573 | [
"def",
"PopupError",
"(",
"*",
"args",
",",
"*",
"*",
"_3to2kwargs",
")",
":",
"if",
"'location'",
"in",
"_3to2kwargs",
":",
"location",
"=",
"_3to2kwargs",
"[",
"'location'",
"]",
"del",
"_3to2kwargs",
"[",
"'location'",
"]",
"else",
":",
"location",
"=",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TkScrollableFrame.set_scrollregion | Set the scroll region on the canvas | PySimpleGUI27.py | def set_scrollregion(self, event=None):
""" Set the scroll region on the canvas"""
self.canvas.configure(scrollregion=self.canvas.bbox('all')) | def set_scrollregion(self, event=None):
""" Set the scroll region on the canvas"""
self.canvas.configure(scrollregion=self.canvas.bbox('all')) | [
"Set",
"the",
"scroll",
"region",
"on",
"the",
"canvas"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L2769-L2771 | [
"def",
"set_scrollregion",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"self",
".",
"canvas",
".",
"configure",
"(",
"scrollregion",
"=",
"self",
".",
"canvas",
".",
"bbox",
"(",
"'all'",
")",
")"
] | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TKCalendar._show_selection | Configure canvas for a new selection. | PySimpleGUI27.py | def _show_selection(self, text, bbox):
"""Configure canvas for a new selection."""
x, y, width, height = bbox
textw = self._font.measure(text)
canvas = self._canvas
canvas.configure(width=width, height=height)
canvas.coords(canvas.text, width - textw, height / 2 - 1)
... | def _show_selection(self, text, bbox):
"""Configure canvas for a new selection."""
x, y, width, height = bbox
textw = self._font.measure(text)
canvas = self._canvas
canvas.configure(width=width, height=height)
canvas.coords(canvas.text, width - textw, height / 2 - 1)
... | [
"Configure",
"canvas",
"for",
"a",
"new",
"selection",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L3052-L3062 | [
"def",
"_show_selection",
"(",
"self",
",",
"text",
",",
"bbox",
")",
":",
"x",
",",
"y",
",",
"width",
",",
"height",
"=",
"bbox",
"textw",
"=",
"self",
".",
"_font",
".",
"measure",
"(",
"text",
")",
"canvas",
"=",
"self",
".",
"_canvas",
"canvas... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TKCalendar._pressed | Clicked somewhere in the calendar. | PySimpleGUI27.py | def _pressed(self, evt):
"""Clicked somewhere in the calendar."""
x, y, widget = evt.x, evt.y, evt.widget
item = widget.identify_row(y)
column = widget.identify_column(x)
if not column or not item in self._items:
# clicked in the weekdays row or just outside the colu... | def _pressed(self, evt):
"""Clicked somewhere in the calendar."""
x, y, widget = evt.x, evt.y, evt.widget
item = widget.identify_row(y)
column = widget.identify_column(x)
if not column or not item in self._items:
# clicked in the weekdays row or just outside the colu... | [
"Clicked",
"somewhere",
"in",
"the",
"calendar",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L3066-L3102 | [
"def",
"_pressed",
"(",
"self",
",",
"evt",
")",
":",
"x",
",",
"y",
",",
"widget",
"=",
"evt",
".",
"x",
",",
"evt",
".",
"y",
",",
"evt",
".",
"widget",
"item",
"=",
"widget",
".",
"identify_row",
"(",
"y",
")",
"column",
"=",
"widget",
".",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TKCalendar._prev_month | Updated calendar to show the previous month. | PySimpleGUI27.py | def _prev_month(self):
"""Updated calendar to show the previous month."""
self._canvas.place_forget()
self._date = self._date - self.timedelta(days=1)
self._date = self.datetime(self._date.year, self._date.month, 1)
self._build_calendar() | def _prev_month(self):
"""Updated calendar to show the previous month."""
self._canvas.place_forget()
self._date = self._date - self.timedelta(days=1)
self._date = self.datetime(self._date.year, self._date.month, 1)
self._build_calendar() | [
"Updated",
"calendar",
"to",
"show",
"the",
"previous",
"month",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L3104-L3110 | [
"def",
"_prev_month",
"(",
"self",
")",
":",
"self",
".",
"_canvas",
".",
"place_forget",
"(",
")",
"self",
".",
"_date",
"=",
"self",
".",
"_date",
"-",
"self",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"self",
".",
"_date",
"=",
"self",
".",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TKCalendar._next_month | Update calendar to show the next month. | PySimpleGUI27.py | def _next_month(self):
"""Update calendar to show the next month."""
self._canvas.place_forget()
year, month = self._date.year, self._date.month
self._date = self._date + self.timedelta(
days=calendar.monthrange(year, month)[1] + 1)
self._date = self.datetime(self._d... | def _next_month(self):
"""Update calendar to show the next month."""
self._canvas.place_forget()
year, month = self._date.year, self._date.month
self._date = self._date + self.timedelta(
days=calendar.monthrange(year, month)[1] + 1)
self._date = self.datetime(self._d... | [
"Update",
"calendar",
"to",
"show",
"the",
"next",
"month",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L3112-L3120 | [
"def",
"_next_month",
"(",
"self",
")",
":",
"self",
".",
"_canvas",
".",
"place_forget",
"(",
")",
"year",
",",
"month",
"=",
"self",
".",
"_date",
".",
"year",
",",
"self",
".",
"_date",
".",
"month",
"self",
".",
"_date",
"=",
"self",
".",
"_dat... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TKCalendar.selection | Return a datetime representing the current selected date. | PySimpleGUI27.py | def selection(self):
"""Return a datetime representing the current selected date."""
if not self._selection:
return None
year, month = self._date.year, self._date.month
return self.datetime(year, month, int(self._selection[0])) | def selection(self):
"""Return a datetime representing the current selected date."""
if not self._selection:
return None
year, month = self._date.year, self._date.month
return self.datetime(year, month, int(self._selection[0])) | [
"Return",
"a",
"datetime",
"representing",
"the",
"current",
"selected",
"date",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L3125-L3131 | [
"def",
"selection",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_selection",
":",
"return",
"None",
"year",
",",
"month",
"=",
"self",
".",
"_date",
".",
"year",
",",
"self",
".",
"_date",
".",
"month",
"return",
"self",
".",
"datetime",
"(",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | Window.AddRow | Parms are a variable number of Elements | PySimpleGUI27.py | def AddRow(self, *args):
''' Parms are a variable number of Elements '''
NumRows = len(self.Rows) # number of existing rows is our row number
CurrentRowNumber = NumRows # this row's number
CurrentRow = [] # start with a blank row and build up
# ------------------------- Add t... | def AddRow(self, *args):
''' Parms are a variable number of Elements '''
NumRows = len(self.Rows) # number of existing rows is our row number
CurrentRowNumber = NumRows # this row's number
CurrentRow = [] # start with a blank row and build up
# ------------------------- Add t... | [
"Parms",
"are",
"a",
"variable",
"number",
"of",
"Elements"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L3638-L3649 | [
"def",
"AddRow",
"(",
"self",
",",
"*",
"args",
")",
":",
"NumRows",
"=",
"len",
"(",
"self",
".",
"Rows",
")",
"# number of existing rows is our row number",
"CurrentRowNumber",
"=",
"NumRows",
"# this row's number",
"CurrentRow",
"=",
"[",
"]",
"# start with a b... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | Window.SetAlpha | Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return: | PySimpleGUI27.py | def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self._AlphaChannel = alpha
self.TKroot.attributes('-alpha', alpha) | def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self._AlphaChannel = alpha
self.TKroot.attributes('-alpha', alpha) | [
"Change",
"the",
"window",
"s",
"transparency",
":",
"param",
"alpha",
":",
"From",
"0",
"to",
"1",
"with",
"0",
"being",
"completely",
"transparent",
":",
"return",
":"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUI27.py#L4079-L4086 | [
"def",
"SetAlpha",
"(",
"self",
",",
"alpha",
")",
":",
"self",
".",
"_AlphaChannel",
"=",
"alpha",
"self",
".",
"TKroot",
".",
"attributes",
"(",
"'-alpha'",
",",
"alpha",
")"
] | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | Card.setColor | Sets Card's color and escape code. | DemoPrograms/Demo_Uno_Card_Game.py | def setColor(self, color):
'''Sets Card's color and escape code.'''
if color == 'blue':
self.color = 'blue'
self.colorCode = self.colors['blue']
self.colorCodeDark = self.colors['dblue']
elif color == 'red':
self.color = 'red'
self.colo... | def setColor(self, color):
'''Sets Card's color and escape code.'''
if color == 'blue':
self.color = 'blue'
self.colorCode = self.colors['blue']
self.colorCodeDark = self.colors['dblue']
elif color == 'red':
self.color = 'red'
self.colo... | [
"Sets",
"Card",
"s",
"color",
"and",
"escape",
"code",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Uno_Card_Game.py#L633-L655 | [
"def",
"setColor",
"(",
"self",
",",
"color",
")",
":",
"if",
"color",
"==",
"'blue'",
":",
"self",
".",
"color",
"=",
"'blue'",
"self",
".",
"colorCode",
"=",
"self",
".",
"colors",
"[",
"'blue'",
"]",
"self",
".",
"colorCodeDark",
"=",
"self",
".",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | get_img_data | Generate image data using PIL | DemoPrograms/Demo_Img_Viewer.py | def get_img_data(f, maxsize = (1200, 850), first = False):
"""Generate image data using PIL
"""
img = Image.open(f)
img.thumbnail(maxsize)
if first: # tkinter is inactive the first time
bio = io.BytesIO()
img.save(bio, format = "PNG")
del img
retur... | def get_img_data(f, maxsize = (1200, 850), first = False):
"""Generate image data using PIL
"""
img = Image.open(f)
img.thumbnail(maxsize)
if first: # tkinter is inactive the first time
bio = io.BytesIO()
img.save(bio, format = "PNG")
del img
retur... | [
"Generate",
"image",
"data",
"using",
"PIL"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Img_Viewer.py#L50-L60 | [
"def",
"get_img_data",
"(",
"f",
",",
"maxsize",
"=",
"(",
"1200",
",",
"850",
")",
",",
"first",
"=",
"False",
")",
":",
"img",
"=",
"Image",
".",
"open",
"(",
"f",
")",
"img",
".",
"thumbnail",
"(",
"maxsize",
")",
"if",
"first",
":",
"# tkinte... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | do_one | Returns either the delay (in ms) or None on timeout. | DemoPrograms/Demo_Matplotlib_Ping_Graph.py | def do_one(myStats, destIP, hostname, timeout, mySeqNumber, packet_size, quiet=False):
"""
Returns either the delay (in ms) or None on timeout.
"""
delay = None
try: # One could use UDP here, but it's obscure
mySocket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("... | def do_one(myStats, destIP, hostname, timeout, mySeqNumber, packet_size, quiet=False):
"""
Returns either the delay (in ms) or None on timeout.
"""
delay = None
try: # One could use UDP here, but it's obscure
mySocket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("... | [
"Returns",
"either",
"the",
"delay",
"(",
"in",
"ms",
")",
"or",
"None",
"on",
"timeout",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Matplotlib_Ping_Graph.py#L315-L356 | [
"def",
"do_one",
"(",
"myStats",
",",
"destIP",
",",
"hostname",
",",
"timeout",
",",
"mySeqNumber",
",",
"packet_size",
",",
"quiet",
"=",
"False",
")",
":",
"delay",
"=",
"None",
"try",
":",
"# One could use UDP here, but it's obscure",
"mySocket",
"=",
"soc... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | quiet_ping | Same as verbose_ping, but the results are returned as tuple | DemoPrograms/Demo_Matplotlib_Ping_Graph.py | def quiet_ping(hostname, timeout=WAIT_TIMEOUT, count=NUM_PACKETS,
packet_size=PACKET_SIZE, path_finder=False):
"""
Same as verbose_ping, but the results are returned as tuple
"""
myStats = MyStats() # Reset the stats
mySeqNumber = 0 # Starting value
try:
destIP = socket.g... | def quiet_ping(hostname, timeout=WAIT_TIMEOUT, count=NUM_PACKETS,
packet_size=PACKET_SIZE, path_finder=False):
"""
Same as verbose_ping, but the results are returned as tuple
"""
myStats = MyStats() # Reset the stats
mySeqNumber = 0 # Starting value
try:
destIP = socket.g... | [
"Same",
"as",
"verbose_ping",
"but",
"the",
"results",
"are",
"returned",
"as",
"tuple"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Matplotlib_Ping_Graph.py#L527-L570 | [
"def",
"quiet_ping",
"(",
"hostname",
",",
"timeout",
"=",
"WAIT_TIMEOUT",
",",
"count",
"=",
"NUM_PACKETS",
",",
"packet_size",
"=",
"PACKET_SIZE",
",",
"path_finder",
"=",
"False",
")",
":",
"myStats",
"=",
"MyStats",
"(",
")",
"# Reset the stats",
"mySeqNum... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | get_page | Return a PNG image for a document page number. | DemoPrograms/Demo_DOC_Viewer_PIL.py | def get_page(pno, zoom = False, max_size = None, first = False):
"""Return a PNG image for a document page number.
"""
dlist = dlist_tab[pno] # get display list of page number
if not dlist: # create if not yet there
dlist_tab[pno] = doc[pno].getDisplayList()
dlist = dlist_ta... | def get_page(pno, zoom = False, max_size = None, first = False):
"""Return a PNG image for a document page number.
"""
dlist = dlist_tab[pno] # get display list of page number
if not dlist: # create if not yet there
dlist_tab[pno] = doc[pno].getDisplayList()
dlist = dlist_ta... | [
"Return",
"a",
"PNG",
"image",
"for",
"a",
"document",
"page",
"number",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_DOC_Viewer_PIL.py#L75-L118 | [
"def",
"get_page",
"(",
"pno",
",",
"zoom",
"=",
"False",
",",
"max_size",
"=",
"None",
",",
"first",
"=",
"False",
")",
":",
"dlist",
"=",
"dlist_tab",
"[",
"pno",
"]",
"# get display list of page number",
"if",
"not",
"dlist",
":",
"# create if not yet the... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | GameOfLife.live_neighbours | Count the number of live neighbours around point (i, j). | DemoPrograms/Demo_Conways_Game_of_Life.py | def live_neighbours(self, i, j):
""" Count the number of live neighbours around point (i, j). """
s = 0 # The total number of live neighbours.
# Loop over all the neighbours.
for x in [i - 1, i, i + 1]:
for y in [j - 1, j, j + 1]:
if (x == i and y == j):
... | def live_neighbours(self, i, j):
""" Count the number of live neighbours around point (i, j). """
s = 0 # The total number of live neighbours.
# Loop over all the neighbours.
for x in [i - 1, i, i + 1]:
for y in [j - 1, j, j + 1]:
if (x == i and y == j):
... | [
"Count",
"the",
"number",
"of",
"live",
"neighbours",
"around",
"point",
"(",
"i",
"j",
")",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Conways_Game_of_Life.py#L49-L67 | [
"def",
"live_neighbours",
"(",
"self",
",",
"i",
",",
"j",
")",
":",
"s",
"=",
"0",
"# The total number of live neighbours.",
"# Loop over all the neighbours.",
"for",
"x",
"in",
"[",
"i",
"-",
"1",
",",
"i",
",",
"i",
"+",
"1",
"]",
":",
"for",
"y",
"... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | GameOfLife.play | Play Conway's Game of Life. | DemoPrograms/Demo_Conways_Game_of_Life.py | def play(self):
""" Play Conway's Game of Life. """
# Write the initial configuration to file.
self.t = 1 # Current time level
while self.t <= self.T: # Evolve!
# print( "At time level %d" % t)
# Loop over each cell of the grid and apply Conway's rules.
... | def play(self):
""" Play Conway's Game of Life. """
# Write the initial configuration to file.
self.t = 1 # Current time level
while self.t <= self.T: # Evolve!
# print( "At time level %d" % t)
# Loop over each cell of the grid and apply Conway's rules.
... | [
"Play",
"Conway",
"s",
"Game",
"of",
"Life",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Conways_Game_of_Life.py#L69-L97 | [
"def",
"play",
"(",
"self",
")",
":",
"# Write the initial configuration to file.",
"self",
".",
"t",
"=",
"1",
"# Current time level",
"while",
"self",
".",
"t",
"<=",
"self",
".",
"T",
":",
"# Evolve!",
"# print( \"At time level %d\" % t)",
"# Loop over each cell of... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | human_size | Returns a human readable string reprentation of bytes | DemoPrograms/Demo_Desktop_Widget_psutil_Dashboard.py | def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']):
""" Returns a human readable string reprentation of bytes"""
return str(bytes) + units[0] if bytes < 1024 else human_size(bytes>>10, units[1:]) | def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']):
""" Returns a human readable string reprentation of bytes"""
return str(bytes) + units[0] if bytes < 1024 else human_size(bytes>>10, units[1:]) | [
"Returns",
"a",
"human",
"readable",
"string",
"reprentation",
"of",
"bytes"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Desktop_Widget_psutil_Dashboard.py#L51-L53 | [
"def",
"human_size",
"(",
"bytes",
",",
"units",
"=",
"[",
"' bytes'",
",",
"'KB'",
",",
"'MB'",
",",
"'GB'",
",",
"'TB'",
",",
"'PB'",
",",
"'EB'",
"]",
")",
":",
"return",
"str",
"(",
"bytes",
")",
"+",
"units",
"[",
"0",
"]",
"if",
"bytes",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | HowDoI | Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but do... | PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py | def HowDoI():
'''
Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with... | def HowDoI():
'''
Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with... | [
"Make",
"and",
"show",
"a",
"window",
"(",
"PySimpleGUI",
"form",
")",
"that",
"takes",
"user",
"input",
"and",
"sends",
"to",
"the",
"HowDoI",
"web",
"oracle",
"Excellent",
"example",
"of",
"2",
"GUI",
"concepts",
"1",
".",
"Output",
"Element",
"that",
... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py#L14-L68 | [
"def",
"HowDoI",
"(",
")",
":",
"# ------- Make a new Window ------- #",
"sg",
".",
"ChangeLookAndFeel",
"(",
"'GreenTan'",
")",
"# give our form a spiffy set of colors",
"layout",
"=",
"[",
"[",
"sg",
".",
"Text",
"(",
"'Ask and your answer will appear here....'",
",",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | QueryHowDoI | Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window
:param Query: text english question to ask the HowDoI web engine
:return: nothing | PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py | def QueryHowDoI(Query, num_answers, full_text, window:sg.Window):
'''
Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window
:param Query: text english question to ask the HowDoI web engine
:return: nothing
'''
howdoi_com... | def QueryHowDoI(Query, num_answers, full_text, window:sg.Window):
'''
Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window
:param Query: text english question to ask the HowDoI web engine
:return: nothing
'''
howdoi_com... | [
"Kicks",
"off",
"a",
"subprocess",
"to",
"send",
"the",
"Query",
"to",
"HowDoI",
"Prints",
"the",
"result",
"which",
"in",
"this",
"program",
"will",
"route",
"to",
"a",
"gooeyGUI",
"window",
":",
"param",
"Query",
":",
"text",
"english",
"question",
"to",... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py#L70-L84 | [
"def",
"QueryHowDoI",
"(",
"Query",
",",
"num_answers",
",",
"full_text",
",",
"window",
":",
"sg",
".",
"Window",
")",
":",
"howdoi_command",
"=",
"HOW_DO_I_COMMAND",
"full_text_option",
"=",
"' -a'",
"if",
"full_text",
"else",
"''",
"t",
"=",
"subprocess",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | MyApp.list_view_on_selected | The selection event of the listView, returns a key of the clicked event.
You can retrieve the item rapidly | PySimpleGUIWeb/Demo Programs/widgets_overview_app.py | def list_view_on_selected(self, widget, selected_item_key):
""" The selection event of the listView, returns a key of the clicked event.
You can retrieve the item rapidly
"""
self.lbl.set_text('List selection: ' + self.listView.children[selected_item_key].get_text()) | def list_view_on_selected(self, widget, selected_item_key):
""" The selection event of the listView, returns a key of the clicked event.
You can retrieve the item rapidly
"""
self.lbl.set_text('List selection: ' + self.listView.children[selected_item_key].get_text()) | [
"The",
"selection",
"event",
"of",
"the",
"listView",
"returns",
"a",
"key",
"of",
"the",
"clicked",
"event",
".",
"You",
"can",
"retrieve",
"the",
"item",
"rapidly"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/Demo Programs/widgets_overview_app.py#L281-L285 | [
"def",
"list_view_on_selected",
"(",
"self",
",",
"widget",
",",
"selected_item_key",
")",
":",
"self",
".",
"lbl",
".",
"set_text",
"(",
"'List selection: '",
"+",
"self",
".",
"listView",
".",
"children",
"[",
"selected_item_key",
"]",
".",
"get_text",
"(",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PyplotHistogram | =============================================================
Demo of the histogram (hist) function with multiple data sets
=============================================================
Plot histogram with multiple sample sets and demonstrate:
* Use of legend with multiple sample sets
* St... | DemoPrograms/Demo_Matplotlib_Browser_Paned.py | def PyplotHistogram():
"""
=============================================================
Demo of the histogram (hist) function with multiple data sets
=============================================================
Plot histogram with multiple sample sets and demonstrate:
* Use of legend wit... | def PyplotHistogram():
"""
=============================================================
Demo of the histogram (hist) function with multiple data sets
=============================================================
Plot histogram with multiple sample sets and demonstrate:
* Use of legend wit... | [
"=============================================================",
"Demo",
"of",
"the",
"histogram",
"(",
"hist",
")",
"function",
"with",
"multiple",
"data",
"sets",
"============================================================="
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Matplotlib_Browser_Paned.py#L44-L91 | [
"def",
"PyplotHistogram",
"(",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"np",
".",
"random",
".",
"seed",
"(",
"0",
")",
"n_bins",
"=",
"10",
"x",
"=",
"np",
".",
"random",
".",
"randn",
"(",
"100... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PyplotArtistBoxPlots | =========================================
Demo of artist customization in box plots
=========================================
This example demonstrates how to use the various kwargs
to fully customize box plots. The first figure demonstrates
how to remove and add individual components (note that th... | DemoPrograms/Demo_Matplotlib_Browser_Paned.py | def PyplotArtistBoxPlots():
"""
=========================================
Demo of artist customization in box plots
=========================================
This example demonstrates how to use the various kwargs
to fully customize box plots. The first figure demonstrates
how to remove and... | def PyplotArtistBoxPlots():
"""
=========================================
Demo of artist customization in box plots
=========================================
This example demonstrates how to use the various kwargs
to fully customize box plots. The first figure demonstrates
how to remove and... | [
"=========================================",
"Demo",
"of",
"artist",
"customization",
"in",
"box",
"plots",
"========================================="
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Matplotlib_Browser_Paned.py#L93-L147 | [
"def",
"PyplotArtistBoxPlots",
"(",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"# fake data",
"np",
".",
"random",
".",
"seed",
"(",
"937",
")",
"data",
"=",
"np",
".",
"random",
".",
"lognormal",
"(",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PyplotLineStyles | ==========
Linestyles
==========
This examples showcases different linestyles copying those of Tikz/PGF. | DemoPrograms/Demo_Matplotlib_Browser_Paned.py | def PyplotLineStyles():
"""
==========
Linestyles
==========
This examples showcases different linestyles copying those of Tikz/PGF.
"""
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
from matplotlib.transforms import blended_transform_fac... | def PyplotLineStyles():
"""
==========
Linestyles
==========
This examples showcases different linestyles copying those of Tikz/PGF.
"""
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
from matplotlib.transforms import blended_transform_fac... | [
"==========",
"Linestyles",
"=========="
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Matplotlib_Browser_Paned.py#L211-L262 | [
"def",
"PyplotLineStyles",
"(",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"from",
"collections",
"import",
"OrderedDict",
"from",
"matplotlib",
".",
"transforms",
"import",
"blended_transform_factory",
"linestyles",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | convert_tkinter_size_to_Qt | Converts size in characters to size in pixels
:param size: size in characters, rows
:return: size in pixels, pixels | PySimpleGUIQt/PySimpleGUIQt.py | def convert_tkinter_size_to_Qt(size):
"""
Converts size in characters to size in pixels
:param size: size in characters, rows
:return: size in pixels, pixels
"""
qtsize = size
if size[1] is not None and size[1] < DEFAULT_PIXEL_TO_CHARS_CUTOFF: # change from character based size to pi... | def convert_tkinter_size_to_Qt(size):
"""
Converts size in characters to size in pixels
:param size: size in characters, rows
:return: size in pixels, pixels
"""
qtsize = size
if size[1] is not None and size[1] < DEFAULT_PIXEL_TO_CHARS_CUTOFF: # change from character based size to pi... | [
"Converts",
"size",
"in",
"characters",
"to",
"size",
"in",
"pixels",
":",
"param",
"size",
":",
"size",
"in",
"characters",
"rows",
":",
"return",
":",
"size",
"in",
"pixels",
"pixels"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L3730-L3739 | [
"def",
"convert_tkinter_size_to_Qt",
"(",
"size",
")",
":",
"qtsize",
"=",
"size",
"if",
"size",
"[",
"1",
"]",
"is",
"not",
"None",
"and",
"size",
"[",
"1",
"]",
"<",
"DEFAULT_PIXEL_TO_CHARS_CUTOFF",
":",
"# change from character based size to pixels (roughly)",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | create_style_from_font | Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings | PySimpleGUIQt/PySimpleGUIQt.py | def create_style_from_font(font):
"""
Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings
"""
if font is None:
return ''
if type(font) is str:
_... | def create_style_from_font(font):
"""
Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings
"""
if font is None:
return ''
if type(font) is str:
_... | [
"Convert",
"from",
"font",
"string",
"/",
"tyuple",
"into",
"a",
"Qt",
"style",
"sheet",
"string",
":",
"param",
"font",
":",
"Arial",
"10",
"Bold",
"or",
"(",
"Arial",
"10",
"Bold",
")",
":",
"return",
":",
"style",
"string",
"that",
"can",
"be",
"c... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L3756-L3782 | [
"def",
"create_style_from_font",
"(",
"font",
")",
":",
"if",
"font",
"is",
"None",
":",
"return",
"''",
"if",
"type",
"(",
"font",
")",
"is",
"str",
":",
"_font",
"=",
"font",
".",
"split",
"(",
"' '",
")",
"else",
":",
"_font",
"=",
"font",
"styl... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetFolder | Display popup with text entry field and browse button. Browse for folder
:param message:
:param default_path:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon:
:param font:
:param no_titlebar:
:param grab_anywhere:
... | PySimpleGUIQt/PySimpleGUIQt.py | def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_fol... | def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_fol... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"folder",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"no_window",
":",
":",
"param",
"size",
":",
":",
"param",
"bu... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L7025-L7070 | [
"def",
"PopupGetFolder",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_path",
"=",
"''",
",",
"no_window",
"=",
"False",
",",
"size",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetFile | Display popup with text entry field and browse button. Browse for file
:param message:
:param default_path:
:param default_extension:
:param save_as:
:param file_types:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon... | PySimpleGUIQt/PySimpleGUIQt.py | def PopupGetFile(message, title=None, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*"),),
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anyw... | def PopupGetFile(message, title=None, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*"),),
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anyw... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"file",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"default_extension",
":",
":",
"param",
"save_as",
":",
":",
"para... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L7075-L7132 | [
"def",
"PopupGetFile",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_path",
"=",
"''",
",",
"default_extension",
"=",
"''",
",",
"save_as",
"=",
"False",
",",
"file_types",
"=",
"(",
"(",
"\"ALL Files\"",
",",
"\"*\"",
")",
",",
")",
",",
"n... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetText | Display Popup with text entry field
:param message:
:param default_text:
:param password_char:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon:
:param font:
:param no_titlebar:
:param grab_anywhere:
:param keep_on_top:
:param ... | PySimpleGUIQt/PySimpleGUIQt.py | def PopupGetText(message, title=None, default_text='', password_char='', size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None)):
"""
Dis... | def PopupGetText(message, title=None, default_text='', password_char='', size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None)):
"""
Dis... | [
"Display",
"Popup",
"with",
"text",
"entry",
"field",
":",
"param",
"message",
":",
":",
"param",
"default_text",
":",
":",
"param",
"password_char",
":",
":",
"param",
"size",
":",
":",
"param",
"button_color",
":",
":",
"param",
"background_color",
":",
... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L7137-L7173 | [
"def",
"PopupGetText",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_text",
"=",
"''",
",",
"password_char",
"=",
"''",
",",
"size",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | SystemTray.Read | Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return: | PySimpleGUIQt/PySimpleGUIQt.py | def Read(self, timeout=None):
'''
Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return:
'''
if not self.Shown:
self.Shown = True
self.TrayIcon.show()
if timeout is None:
... | def Read(self, timeout=None):
'''
Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return:
'''
if not self.Shown:
self.Shown = True
self.TrayIcon.show()
if timeout is None:
... | [
"Reads",
"the",
"context",
"menu",
":",
"param",
"timeout",
":",
"Optional",
".",
"Any",
"value",
"other",
"than",
"None",
"indicates",
"a",
"non",
"-",
"blocking",
"read",
":",
"return",
":"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L2953-L2975 | [
"def",
"Read",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"Shown",
":",
"self",
".",
"Shown",
"=",
"True",
"self",
".",
"TrayIcon",
".",
"show",
"(",
")",
"if",
"timeout",
"is",
"None",
":",
"self",
".",
"App",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | SystemTray.ShowMessage | Shows a balloon above icon in system tray
:param title: Title shown in balloon
:param message: Message to be displayed
:param filename: Optional icon filename
:param data: Optional in-ram icon
:param data_base64: Optional base64 icon
:param time: How long to display mess... | PySimpleGUIQt/PySimpleGUIQt.py | def ShowMessage(self, title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000):
'''
Shows a balloon above icon in system tray
:param title: Title shown in balloon
:param message: Message to be displayed
:param filename: Optional icon filename
... | def ShowMessage(self, title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000):
'''
Shows a balloon above icon in system tray
:param title: Title shown in balloon
:param message: Message to be displayed
:param filename: Optional icon filename
... | [
"Shows",
"a",
"balloon",
"above",
"icon",
"in",
"system",
"tray",
":",
"param",
"title",
":",
"Title",
"shown",
"in",
"balloon",
":",
"param",
"message",
":",
"Message",
"to",
"be",
"displayed",
":",
"param",
"filename",
":",
"Optional",
"icon",
"filename"... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L2988-L3022 | [
"def",
"ShowMessage",
"(",
"self",
",",
"title",
",",
"message",
",",
"filename",
"=",
"None",
",",
"data",
"=",
"None",
",",
"data_base64",
"=",
"None",
",",
"messageicon",
"=",
"None",
",",
"time",
"=",
"10000",
")",
":",
"qicon",
"=",
"None",
"if"... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | SystemTray.Update | Updates the menu, tooltip or icon
:param menu: menu defintion
:param tooltip: string representing tooltip
:param filename: icon filename
:param data: icon raw image
:param data_base64: icon base 64 image
:return: | PySimpleGUIQt/PySimpleGUIQt.py | def Update(self, menu=None, tooltip=None,filename=None, data=None, data_base64=None,):
'''
Updates the menu, tooltip or icon
:param menu: menu defintion
:param tooltip: string representing tooltip
:param filename: icon filename
:param data: icon raw image
:param... | def Update(self, menu=None, tooltip=None,filename=None, data=None, data_base64=None,):
'''
Updates the menu, tooltip or icon
:param menu: menu defintion
:param tooltip: string representing tooltip
:param filename: icon filename
:param data: icon raw image
:param... | [
"Updates",
"the",
"menu",
"tooltip",
"or",
"icon",
":",
"param",
"menu",
":",
"menu",
"defintion",
":",
"param",
"tooltip",
":",
"string",
"representing",
"tooltip",
":",
"param",
"filename",
":",
"icon",
"filename",
":",
"param",
"data",
":",
"icon",
"raw... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L3034-L3069 | [
"def",
"Update",
"(",
"self",
",",
"menu",
"=",
"None",
",",
"tooltip",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"data",
"=",
"None",
",",
"data_base64",
"=",
"None",
",",
")",
":",
"# Menu",
"if",
"menu",
"is",
"not",
"None",
":",
"self",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | Window.SetAlpha | Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return: | PySimpleGUIQt/PySimpleGUIQt.py | def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self._AlphaChannel = alpha
if self._AlphaChannel is not None:
self.QT_QMainWindow.setWindowOpacity(self._AlphaCha... | def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self._AlphaChannel = alpha
if self._AlphaChannel is not None:
self.QT_QMainWindow.setWindowOpacity(self._AlphaCha... | [
"Change",
"the",
"window",
"s",
"transparency",
":",
"param",
"alpha",
":",
"From",
"0",
"to",
"1",
"with",
"0",
"being",
"completely",
"transparent",
":",
"return",
":"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIQt/PySimpleGUIQt.py#L3576-L3584 | [
"def",
"SetAlpha",
"(",
"self",
",",
"alpha",
")",
":",
"self",
".",
"_AlphaChannel",
"=",
"alpha",
"if",
"self",
".",
"_AlphaChannel",
"is",
"not",
"None",
":",
"self",
".",
"QT_QMainWindow",
".",
"setWindowOpacity",
"(",
"self",
".",
"_AlphaChannel",
")"... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | convert_tkinter_size_to_Wx | Converts size in characters to size in pixels
:param size: size in characters, rows
:return: size in pixels, pixels | PySimpleGUIWx/PySimpleGUIWx.py | def convert_tkinter_size_to_Wx(size):
"""
Converts size in characters to size in pixels
:param size: size in characters, rows
:return: size in pixels, pixels
"""
qtsize = size
if size[1] is not None and size[1] < DEFAULT_PIXEL_TO_CHARS_CUTOFF: # change from character based size to pi... | def convert_tkinter_size_to_Wx(size):
"""
Converts size in characters to size in pixels
:param size: size in characters, rows
:return: size in pixels, pixels
"""
qtsize = size
if size[1] is not None and size[1] < DEFAULT_PIXEL_TO_CHARS_CUTOFF: # change from character based size to pi... | [
"Converts",
"size",
"in",
"characters",
"to",
"size",
"in",
"pixels",
":",
"param",
"size",
":",
"size",
"in",
"characters",
"rows",
":",
"return",
":",
"size",
"in",
"pixels",
"pixels"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L3570-L3579 | [
"def",
"convert_tkinter_size_to_Wx",
"(",
"size",
")",
":",
"qtsize",
"=",
"size",
"if",
"size",
"[",
"1",
"]",
"is",
"not",
"None",
"and",
"size",
"[",
"1",
"]",
"<",
"DEFAULT_PIXEL_TO_CHARS_CUTOFF",
":",
"# change from character based size to pixels (roughly)",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | font_to_wx_font | Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings | PySimpleGUIWx/PySimpleGUIWx.py | def font_to_wx_font(font):
"""
Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings
"""
if font is None:
return ''
if type(font) is str:
_font = ... | def font_to_wx_font(font):
"""
Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings
"""
if font is None:
return ''
if type(font) is str:
_font = ... | [
"Convert",
"from",
"font",
"string",
"/",
"tyuple",
"into",
"a",
"Qt",
"style",
"sheet",
"string",
":",
"param",
"font",
":",
"Arial",
"10",
"Bold",
"or",
"(",
"Arial",
"10",
"Bold",
")",
":",
"return",
":",
"style",
"string",
"that",
"can",
"be",
"c... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L3582-L3612 | [
"def",
"font_to_wx_font",
"(",
"font",
")",
":",
"if",
"font",
"is",
"None",
":",
"return",
"''",
"if",
"type",
"(",
"font",
")",
"is",
"str",
":",
"_font",
"=",
"font",
".",
"split",
"(",
"' '",
")",
"else",
":",
"_font",
"=",
"font",
"name",
"=... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupError | Popup with colored button and 'Error' as button text
:param args:
:param button_color:
:param background_color:
:param text_color:
:param auto_close:
:param auto_close_duration:
:param non_blocking:
:param icon:
:param line_width:
:param font:
:param no_titlebar:
:param g... | PySimpleGUIWx/PySimpleGUIWx.py | def PopupError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, background_color=None, text_color=None, auto_close=False,
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(... | def PopupError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, background_color=None, text_color=None, auto_close=False,
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(... | [
"Popup",
"with",
"colored",
"button",
"and",
"Error",
"as",
"button",
"text",
":",
"param",
"args",
":",
":",
"param",
"button_color",
":",
":",
"param",
"background_color",
":",
":",
"param",
"text_color",
":",
":",
"param",
"auto_close",
":",
":",
"param... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L6621-L6645 | [
"def",
"PopupError",
"(",
"*",
"args",
",",
"button_color",
"=",
"DEFAULT_ERROR_BUTTON_COLOR",
",",
"background_color",
"=",
"None",
",",
"text_color",
"=",
"None",
",",
"auto_close",
"=",
"False",
",",
"auto_close_duration",
"=",
"None",
",",
"non_blocking",
"=... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetFolder | Display popup with text entry field and browse button. Browse for folder
:param message:
:param default_path:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon:
:param font:
:param no_titlebar:
:param grab_anywhere:
... | PySimpleGUIWx/PySimpleGUIWx.py | def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_fol... | def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_fol... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"folder",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"no_window",
":",
":",
"param",
"size",
":",
":",
"param",
"bu... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L6768-L6821 | [
"def",
"PopupGetFolder",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_path",
"=",
"''",
",",
"no_window",
"=",
"False",
",",
"size",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetFile | Display popup with text entry field and browse button. Browse for file
:param message:
:param default_path:
:param default_extension:
:param save_as:
:param file_types:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon... | PySimpleGUIWx/PySimpleGUIWx.py | def PopupGetFile(message, title=None, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*"),),
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anyw... | def PopupGetFile(message, title=None, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*"),),
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anyw... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"file",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"default_extension",
":",
":",
"param",
"save_as",
":",
":",
"para... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L6826-L6888 | [
"def",
"PopupGetFile",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_path",
"=",
"''",
",",
"default_extension",
"=",
"''",
",",
"save_as",
"=",
"False",
",",
"file_types",
"=",
"(",
"(",
"\"ALL Files\"",
",",
"\"*\"",
")",
",",
")",
",",
"n... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | SystemTray.Read | Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return: | PySimpleGUIWx/PySimpleGUIWx.py | def Read(self, timeout=None):
'''
Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return:
'''
# if not self.Shown:
# self.Shown = True
# self.TrayIcon.show()
timeout1 = timeout
... | def Read(self, timeout=None):
'''
Reads the context menu
:param timeout: Optional. Any value other than None indicates a non-blocking read
:return:
'''
# if not self.Shown:
# self.Shown = True
# self.TrayIcon.show()
timeout1 = timeout
... | [
"Reads",
"the",
"context",
"menu",
":",
"param",
"timeout",
":",
"Optional",
".",
"Any",
"value",
"other",
"than",
"None",
"indicates",
"a",
"non",
"-",
"blocking",
"read",
":",
"return",
":"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L2817-L2847 | [
"def",
"Read",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# if not self.Shown:",
"# self.Shown = True",
"# self.TrayIcon.show()",
"timeout1",
"=",
"timeout",
"# if timeout1 == 0:",
"# timeout1 = 1",
"# if wx.GetApp():",
"# wx.GetApp().ProcessPendingEve... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | SystemTray.ShowMessage | Shows a balloon above icon in system tray
:param title: Title shown in balloon
:param message: Message to be displayed
:param filename: Optional icon filename
:param data: Optional in-ram icon
:param data_base64: Optional base64 icon
:param time: How long to display mess... | PySimpleGUIWx/PySimpleGUIWx.py | def ShowMessage(self, title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000):
'''
Shows a balloon above icon in system tray
:param title: Title shown in balloon
:param message: Message to be displayed
:param filename: Optional icon filename
... | def ShowMessage(self, title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000):
'''
Shows a balloon above icon in system tray
:param title: Title shown in balloon
:param message: Message to be displayed
:param filename: Optional icon filename
... | [
"Shows",
"a",
"balloon",
"above",
"icon",
"in",
"system",
"tray",
":",
"param",
"title",
":",
"Title",
"shown",
"in",
"balloon",
":",
"param",
"message",
":",
"Message",
"to",
"be",
"displayed",
":",
"param",
"filename",
":",
"Optional",
"icon",
"filename"... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L2863-L2879 | [
"def",
"ShowMessage",
"(",
"self",
",",
"title",
",",
"message",
",",
"filename",
"=",
"None",
",",
"data",
"=",
"None",
",",
"data_base64",
"=",
"None",
",",
"messageicon",
"=",
"None",
",",
"time",
"=",
"10000",
")",
":",
"if",
"messageicon",
"is",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | SystemTray.Update | Updates the menu, tooltip or icon
:param menu: menu defintion
:param tooltip: string representing tooltip
:param filename: icon filename
:param data: icon raw image
:param data_base64: icon base 64 image
:return: | PySimpleGUIWx/PySimpleGUIWx.py | def Update(self, menu=None, tooltip=None,filename=None, data=None, data_base64=None,):
'''
Updates the menu, tooltip or icon
:param menu: menu defintion
:param tooltip: string representing tooltip
:param filename: icon filename
:param data: icon raw image
:param... | def Update(self, menu=None, tooltip=None,filename=None, data=None, data_base64=None,):
'''
Updates the menu, tooltip or icon
:param menu: menu defintion
:param tooltip: string representing tooltip
:param filename: icon filename
:param data: icon raw image
:param... | [
"Updates",
"the",
"menu",
"tooltip",
"or",
"icon",
":",
"param",
"menu",
":",
"menu",
"defintion",
":",
"param",
"tooltip",
":",
"string",
"representing",
"tooltip",
":",
"param",
"filename",
":",
"icon",
"filename",
":",
"param",
"data",
":",
"icon",
"raw... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L2894-L2915 | [
"def",
"Update",
"(",
"self",
",",
"menu",
"=",
"None",
",",
"tooltip",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"data",
"=",
"None",
",",
"data_base64",
"=",
"None",
",",
")",
":",
"# Menu",
"if",
"menu",
"is",
"not",
"None",
":",
"self",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | DragFrame.on_mouse | implement dragging | PySimpleGUIWx/PySimpleGUIWx.py | def on_mouse(self, event):
'''
implement dragging
'''
# print('on_mouse')
if not event.Dragging():
self._dragPos = None
return
# self.CaptureMouse()
if not self._dragPos:
self._dragPos = event.GetPosition()
else:
... | def on_mouse(self, event):
'''
implement dragging
'''
# print('on_mouse')
if not event.Dragging():
self._dragPos = None
return
# self.CaptureMouse()
if not self._dragPos:
self._dragPos = event.GetPosition()
else:
... | [
"implement",
"dragging"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L2947-L2961 | [
"def",
"on_mouse",
"(",
"self",
",",
"event",
")",
":",
"# print('on_mouse')",
"if",
"not",
"event",
".",
"Dragging",
"(",
")",
":",
"self",
".",
"_dragPos",
"=",
"None",
"return",
"# self.CaptureMouse()",
"if",
"not",
"self",
".",
"_dragPos",
":",
"self",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | Window.SetAlpha | Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return: | PySimpleGUIWx/PySimpleGUIWx.py | def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self._AlphaChannel = alpha * 255
if self._AlphaChannel is not None:
self.MasterFrame.SetTransparent(self._AlphaCh... | def SetAlpha(self, alpha):
'''
Change the window's transparency
:param alpha: From 0 to 1 with 0 being completely transparent
:return:
'''
self._AlphaChannel = alpha * 255
if self._AlphaChannel is not None:
self.MasterFrame.SetTransparent(self._AlphaCh... | [
"Change",
"the",
"window",
"s",
"transparency",
":",
"param",
"alpha",
":",
"From",
"0",
"to",
"1",
"with",
"0",
"being",
"completely",
"transparent",
":",
"return",
":"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L3460-L3468 | [
"def",
"SetAlpha",
"(",
"self",
",",
"alpha",
")",
":",
"self",
".",
"_AlphaChannel",
"=",
"alpha",
"*",
"255",
"if",
"self",
".",
"_AlphaChannel",
"is",
"not",
"None",
":",
"self",
".",
"MasterFrame",
".",
"SetTransparent",
"(",
"self",
".",
"_AlphaChan... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | worker_thread | A worker thrread that communicates with the GUI
These threads can call functions that block withouth affecting the GUI (a good thing)
Note that this function is the code started as each thread. All threads are identical in this way
:param thread_name: Text name used for displaying info
:param run_freq:... | DemoPrograms/Demo_Multithreaded_Queued.py | def worker_thread(thread_name, run_freq, gui_queue):
"""
A worker thrread that communicates with the GUI
These threads can call functions that block withouth affecting the GUI (a good thing)
Note that this function is the code started as each thread. All threads are identical in this way
:param thr... | def worker_thread(thread_name, run_freq, gui_queue):
"""
A worker thrread that communicates with the GUI
These threads can call functions that block withouth affecting the GUI (a good thing)
Note that this function is the code started as each thread. All threads are identical in this way
:param thr... | [
"A",
"worker",
"thrread",
"that",
"communicates",
"with",
"the",
"GUI",
"These",
"threads",
"can",
"call",
"functions",
"that",
"block",
"withouth",
"affecting",
"the",
"GUI",
"(",
"a",
"good",
"thing",
")",
"Note",
"that",
"this",
"function",
"is",
"the",
... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Multithreaded_Queued.py#L44-L58 | [
"def",
"worker_thread",
"(",
"thread_name",
",",
"run_freq",
",",
"gui_queue",
")",
":",
"print",
"(",
"'Starting thread - {} that runds every {} ms'",
".",
"format",
"(",
"thread_name",
",",
"run_freq",
")",
")",
"for",
"i",
"in",
"itertools",
".",
"count",
"("... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | the_gui | Starts and executes the GUI
Reads data from a Queue and displays the data to the window
Returns when the user exits / closes the window
(that means it does NOT return until the user exits the window)
:param gui_queue: Queue the GUI should read from
:return: | DemoPrograms/Demo_Multithreaded_Queued.py | def the_gui(gui_queue):
"""
Starts and executes the GUI
Reads data from a Queue and displays the data to the window
Returns when the user exits / closes the window
(that means it does NOT return until the user exits the window)
:param gui_queue: Queue the GUI should read from
:return:
... | def the_gui(gui_queue):
"""
Starts and executes the GUI
Reads data from a Queue and displays the data to the window
Returns when the user exits / closes the window
(that means it does NOT return until the user exits the window)
:param gui_queue: Queue the GUI should read from
:return:
... | [
"Starts",
"and",
"executes",
"the",
"GUI",
"Reads",
"data",
"from",
"a",
"Queue",
"and",
"displays",
"the",
"data",
"to",
"the",
"window",
"Returns",
"when",
"the",
"user",
"exits",
"/",
"closes",
"the",
"window",
"(",
"that",
"means",
"it",
"does",
"NOT... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Multithreaded_Queued.py#L68-L100 | [
"def",
"the_gui",
"(",
"gui_queue",
")",
":",
"layout",
"=",
"[",
"[",
"sg",
".",
"Text",
"(",
"'Multithreaded Window Example'",
")",
"]",
",",
"[",
"sg",
".",
"Text",
"(",
"''",
",",
"size",
"=",
"(",
"15",
",",
"1",
")",
",",
"key",
"=",
"'_OUT... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | send_one_ping | Send one ping to the given >destIP<. | DemoPrograms/ping.py | def send_one_ping(mySocket, destIP, myID, mySeqNumber, packet_size):
"""
Send one ping to the given >destIP<.
"""
#destIP = socket.gethostbyname(destIP)
# Header is type (8), code (8), checksum (16), id (16), sequence (16)
# (packet_size - 8) - Remove header size from packet size
myChecks... | def send_one_ping(mySocket, destIP, myID, mySeqNumber, packet_size):
"""
Send one ping to the given >destIP<.
"""
#destIP = socket.gethostbyname(destIP)
# Header is type (8), code (8), checksum (16), id (16), sequence (16)
# (packet_size - 8) - Remove header size from packet size
myChecks... | [
"Send",
"one",
"ping",
"to",
"the",
"given",
">",
"destIP<",
"."
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/ping.py#L337-L387 | [
"def",
"send_one_ping",
"(",
"mySocket",
",",
"destIP",
",",
"myID",
",",
"mySeqNumber",
",",
"packet_size",
")",
":",
"#destIP = socket.gethostbyname(destIP)",
"# Header is type (8), code (8), checksum (16), id (16), sequence (16)",
"# (packet_size - 8) - Remove header size from p... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | receive_one_ping | Receive the ping from the socket. Timeout = in ms | DemoPrograms/ping.py | def receive_one_ping(mySocket, myID, timeout):
"""
Receive the ping from the socket. Timeout = in ms
"""
timeLeft = timeout/1000
while True: # Loop while waiting for packet or timeout
startedSelect = default_timer()
whatReady = select.select([mySocket], [], [], timeLeft)
how... | def receive_one_ping(mySocket, myID, timeout):
"""
Receive the ping from the socket. Timeout = in ms
"""
timeLeft = timeout/1000
while True: # Loop while waiting for packet or timeout
startedSelect = default_timer()
whatReady = select.select([mySocket], [], [], timeLeft)
how... | [
"Receive",
"the",
"ping",
"from",
"the",
"socket",
".",
"Timeout",
"=",
"in",
"ms"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/ping.py#L390-L427 | [
"def",
"receive_one_ping",
"(",
"mySocket",
",",
"myID",
",",
"timeout",
")",
":",
"timeLeft",
"=",
"timeout",
"/",
"1000",
"while",
"True",
":",
"# Loop while waiting for packet or timeout",
"startedSelect",
"=",
"default_timer",
"(",
")",
"whatReady",
"=",
"sele... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | runCommand | run shell command
@param cmd: command to execute
@param timeout: timeout for command execution
@param window: the PySimpleGUI window that the output is going to (needed to do refresh on)
@return: (return code from command, command output) | DemoPrograms/Demo_Script_Launcher_Realtime_Output.py | def runCommand(cmd, timeout=None, window=None):
""" run shell command
@param cmd: command to execute
@param timeout: timeout for command execution
@param window: the PySimpleGUI window that the output is going to (needed to do refresh on)
@return: (return code from command, command output)
"""
p = subproce... | def runCommand(cmd, timeout=None, window=None):
""" run shell command
@param cmd: command to execute
@param timeout: timeout for command execution
@param window: the PySimpleGUI window that the output is going to (needed to do refresh on)
@return: (return code from command, command output)
"""
p = subproce... | [
"run",
"shell",
"command"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Script_Launcher_Realtime_Output.py#L29-L45 | [
"def",
"runCommand",
"(",
"cmd",
",",
"timeout",
"=",
"None",
",",
"window",
"=",
"None",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"sub... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | font_parse_string | Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings | PySimpleGUIWeb/PySimpleGUIWeb.py | def font_parse_string(font):
"""
Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings
"""
if font is None:
return ''
if type(font) is str:
_font ... | def font_parse_string(font):
"""
Convert from font string/tyuple into a Qt style sheet string
:param font: "Arial 10 Bold" or ('Arial', 10, 'Bold)
:return: style string that can be combined with other style strings
"""
if font is None:
return ''
if type(font) is str:
_font ... | [
"Convert",
"from",
"font",
"string",
"/",
"tyuple",
"into",
"a",
"Qt",
"style",
"sheet",
"string",
":",
"param",
"font",
":",
"Arial",
"10",
"Bold",
"or",
"(",
"Arial",
"10",
"Bold",
")",
":",
"return",
":",
"style",
"string",
"that",
"can",
"be",
"c... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L3449-L3471 | [
"def",
"font_parse_string",
"(",
"font",
")",
":",
"if",
"font",
"is",
"None",
":",
"return",
"''",
"if",
"type",
"(",
"font",
")",
"is",
"str",
":",
"_font",
"=",
"font",
".",
"split",
"(",
"' '",
")",
"else",
":",
"_font",
"=",
"font",
"family",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | _ProgressMeter | Create and show a form on tbe caller's behalf.
:param title:
:param max_value:
:param args: ANY number of arguments the caller wants to display
:param orientation:
:param bar_color:
:param size:
:param Style:
:param StyleOffset:
:return: ProgressBar object that is in the form | PySimpleGUIWeb/PySimpleGUIWeb.py | def _ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None, None), button_color=None,
size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None, grab_anywhere=False):
'''
Create and show a form on tbe caller's behalf.
:param title:
:param max_value:
:param args: ANY num... | def _ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None, None), button_color=None,
size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None, grab_anywhere=False):
'''
Create and show a form on tbe caller's behalf.
:param title:
:param max_value:
:param args: ANY num... | [
"Create",
"and",
"show",
"a",
"form",
"on",
"tbe",
"caller",
"s",
"behalf",
".",
":",
"param",
"title",
":",
":",
"param",
"max_value",
":",
":",
"param",
"args",
":",
"ANY",
"number",
"of",
"arguments",
"the",
"caller",
"wants",
"to",
"display",
":",
... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L5237-L5279 | [
"def",
"_ProgressMeter",
"(",
"title",
",",
"max_value",
",",
"*",
"args",
",",
"orientation",
"=",
"None",
",",
"bar_color",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"size",
"=",
"DEFAULT_PROGRESS_BAR_SIZE",
",",
"border_... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | _ProgressMeterUpdate | Update the progress meter for a form
:param form: class ProgressBar
:param value: int
:return: True if not cancelled, OK....False if Error | PySimpleGUIWeb/PySimpleGUIWeb.py | def _ProgressMeterUpdate(bar, value, text_elem, *args):
'''
Update the progress meter for a form
:param form: class ProgressBar
:param value: int
:return: True if not cancelled, OK....False if Error
'''
global _my_windows
if bar == None: return False
if bar.BarExpired: return False
... | def _ProgressMeterUpdate(bar, value, text_elem, *args):
'''
Update the progress meter for a form
:param form: class ProgressBar
:param value: int
:return: True if not cancelled, OK....False if Error
'''
global _my_windows
if bar == None: return False
if bar.BarExpired: return False
... | [
"Update",
"the",
"progress",
"meter",
"for",
"a",
"form",
":",
"param",
"form",
":",
"class",
"ProgressBar",
":",
"param",
"value",
":",
"int",
":",
"return",
":",
"True",
"if",
"not",
"cancelled",
"OK",
"....",
"False",
"if",
"Error"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L5283-L5320 | [
"def",
"_ProgressMeterUpdate",
"(",
"bar",
",",
"value",
",",
"text_elem",
",",
"*",
"args",
")",
":",
"global",
"_my_windows",
"if",
"bar",
"==",
"None",
":",
"return",
"False",
"if",
"bar",
".",
"BarExpired",
":",
"return",
"False",
"message",
",",
"w"... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | EasyProgressMeter | A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second
function call before your loop. You've got enough code to write!
:param title: Title will be shown on the window
:param current_value: Current count of your items
:param max_value: Max value your count will eve... | PySimpleGUIWeb/PySimpleGUIWeb.py | def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=(None, None),
button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None):
'''
A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second
function call... | def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=(None, None),
button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, border_width=None):
'''
A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second
function call... | [
"A",
"ONE",
"-",
"LINE",
"progress",
"meter",
".",
"Add",
"to",
"your",
"code",
"where",
"ever",
"you",
"need",
"a",
"meter",
".",
"No",
"need",
"for",
"a",
"second",
"function",
"call",
"before",
"your",
"loop",
".",
"You",
"ve",
"got",
"enough",
"c... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L5367-L5432 | [
"def",
"EasyProgressMeter",
"(",
"title",
",",
"current_value",
",",
"max_value",
",",
"*",
"args",
",",
"orientation",
"=",
"None",
",",
"bar_color",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"size",
"=",
"DEFAULT_PROGRESS... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupNonBlocking | Show Popup box and immediately return (does not block)
:param args:
:param button_type:
:param button_color:
:param background_color:
:param text_color:
:param auto_close:
:param auto_close_duration:
:param non_blocking:
:param icon:
:param line_width:
:param font:
:param... | PySimpleGUIWeb/PySimpleGUIWeb.py | def PopupNonBlocking(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
auto_close=False, auto_close_duration=None, non_blocking=True, icon=DEFAULT_WINDOW_ICON,
line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep... | def PopupNonBlocking(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
auto_close=False, auto_close_duration=None, non_blocking=True, icon=DEFAULT_WINDOW_ICON,
line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep... | [
"Show",
"Popup",
"box",
"and",
"immediately",
"return",
"(",
"does",
"not",
"block",
")",
":",
"param",
"args",
":",
":",
"param",
"button_type",
":",
":",
"param",
"button_color",
":",
":",
"param",
"background_color",
":",
":",
"param",
"text_color",
":"... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L6286-L6313 | [
"def",
"PopupNonBlocking",
"(",
"*",
"args",
",",
"button_type",
"=",
"POPUP_BUTTONS_OK",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
",",
"text_color",
"=",
"None",
",",
"auto_close",
"=",
"False",
",",
"auto_close_duration",
"=",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetFolder | Display popup with text entry field and browse button. Browse for folder
:param message:
:param default_path:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon:
:param font:
:param no_titlebar:
:param grab_anywhere:
... | PySimpleGUIWeb/PySimpleGUIWeb.py | def PopupGetFolder(message, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_folder=None):
... | def PopupGetFolder(message, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_folder=None):
... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"folder",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"no_window",
":",
":",
"param",
"size",
":",
":",
"param",
"bu... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L6596-L6647 | [
"def",
"PopupGetFolder",
"(",
"message",
",",
"default_path",
"=",
"''",
",",
"no_window",
"=",
"False",
",",
"size",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
",",
"text_color",
"=",
"Non... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | PopupGetFile | Display popup with text entry field and browse button. Browse for file
:param message:
:param default_path:
:param default_extension:
:param save_as:
:param file_types:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon... | PySimpleGUIWeb/PySimpleGUIWeb.py | def PopupGetFile(message, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*.*"),),
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anywhere=False... | def PopupGetFile(message, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*.*"),),
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anywhere=False... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"file",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"default_extension",
":",
":",
"param",
"save_as",
":",
":",
"para... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/PySimpleGUIWeb.py#L6652-L6714 | [
"def",
"PopupGetFile",
"(",
"message",
",",
"default_path",
"=",
"''",
",",
"default_extension",
"=",
"''",
",",
"save_as",
"=",
"False",
",",
"file_types",
"=",
"(",
"(",
"\"ALL Files\"",
",",
"\"*.*\"",
")",
",",
")",
",",
"no_window",
"=",
"False",
",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | TableSimulation | Display data in a table format | DemoPrograms/Demo_Table_Simulation.py | def TableSimulation():
"""
Display data in a table format
"""
sg.SetOptions(element_padding=(0,0))
menu_def = [['File', ['Open', 'Save', 'Exit']],
['Edit', ['Paste', ['Special', 'Normal',], 'Undo'],],
['Help', 'About...'],]
columm_layout = [[]]
MAX_ROWS = 2... | def TableSimulation():
"""
Display data in a table format
"""
sg.SetOptions(element_padding=(0,0))
menu_def = [['File', ['Open', 'Save', 'Exit']],
['Edit', ['Paste', ['Special', 'Normal',], 'Undo'],],
['Help', 'About...'],]
columm_layout = [[]]
MAX_ROWS = 2... | [
"Display",
"data",
"in",
"a",
"table",
"format"
] | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Table_Simulation.py#L10-L78 | [
"def",
"TableSimulation",
"(",
")",
":",
"sg",
".",
"SetOptions",
"(",
"element_padding",
"=",
"(",
"0",
",",
"0",
")",
")",
"menu_def",
"=",
"[",
"[",
"'File'",
",",
"[",
"'Open'",
",",
"'Save'",
",",
"'Exit'",
"]",
"]",
",",
"[",
"'Edit'",
",",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | HowDoI | Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but do... | HowDoI/PySimpleGUI-HowDoI.py | def HowDoI():
'''
Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with... | def HowDoI():
'''
Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with... | [
"Make",
"and",
"show",
"a",
"window",
"(",
"PySimpleGUI",
"form",
")",
"that",
"takes",
"user",
"input",
"and",
"sends",
"to",
"the",
"HowDoI",
"web",
"oracle",
"Excellent",
"example",
"of",
"2",
"GUI",
"concepts",
"1",
".",
"Output",
"Element",
"that",
... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/HowDoI/PySimpleGUI-HowDoI.py#L16-L69 | [
"def",
"HowDoI",
"(",
")",
":",
"# ------- Make a new Window ------- #",
"sg",
".",
"ChangeLookAndFeel",
"(",
"'GreenTan'",
")",
"# give our form a spiffy set of colors",
"layout",
"=",
"[",
"[",
"sg",
".",
"Text",
"(",
"'Ask and your answer will appear here....'",
",",... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | QueryHowDoI | Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window
:param Query: text english question to ask the HowDoI web engine
:return: nothing | HowDoI/PySimpleGUI-HowDoI.py | def QueryHowDoI(Query, num_answers, full_text):
'''
Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window
:param Query: text english question to ask the HowDoI web engine
:return: nothing
'''
howdoi_command = HOW_DO_I_CO... | def QueryHowDoI(Query, num_answers, full_text):
'''
Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window
:param Query: text english question to ask the HowDoI web engine
:return: nothing
'''
howdoi_command = HOW_DO_I_CO... | [
"Kicks",
"off",
"a",
"subprocess",
"to",
"send",
"the",
"Query",
"to",
"HowDoI",
"Prints",
"the",
"result",
"which",
"in",
"this",
"program",
"will",
"route",
"to",
"a",
"gooeyGUI",
"window",
":",
"param",
"Query",
":",
"text",
"english",
"question",
"to",... | PySimpleGUI/PySimpleGUI | python | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/HowDoI/PySimpleGUI-HowDoI.py#L72-L86 | [
"def",
"QueryHowDoI",
"(",
"Query",
",",
"num_answers",
",",
"full_text",
")",
":",
"howdoi_command",
"=",
"HOW_DO_I_COMMAND",
"full_text_option",
"=",
"' -a'",
"if",
"full_text",
"else",
"''",
"t",
"=",
"subprocess",
".",
"Popen",
"(",
"howdoi_command",
"+",
... | 08184197f5bd4580ab5e5aca28bdda30f87b86fc |
train | ModuleSpec.export | Exports a ModuleSpec with weights taken from a checkpoint.
This is an helper to export modules directly from a ModuleSpec
without having to create a session and set the variables to the
intended values.
Example usage:
```python
spec = hub.create_module_spec(module_fn)
spec.export("/path/t... | tensorflow_hub/module_spec.py | def export(self, path, _sentinel=None, # pylint: disable=invalid-name
checkpoint_path=None, name_transform_fn=None):
"""Exports a ModuleSpec with weights taken from a checkpoint.
This is an helper to export modules directly from a ModuleSpec
without having to create a session and set the vari... | def export(self, path, _sentinel=None, # pylint: disable=invalid-name
checkpoint_path=None, name_transform_fn=None):
"""Exports a ModuleSpec with weights taken from a checkpoint.
This is an helper to export modules directly from a ModuleSpec
without having to create a session and set the vari... | [
"Exports",
"a",
"ModuleSpec",
"with",
"weights",
"taken",
"from",
"a",
"checkpoint",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module_spec.py#L41-L77 | [
"def",
"export",
"(",
"self",
",",
"path",
",",
"_sentinel",
"=",
"None",
",",
"# pylint: disable=invalid-name",
"checkpoint_path",
"=",
"None",
",",
"name_transform_fn",
"=",
"None",
")",
":",
"from",
"tensorflow_hub",
".",
"module",
"import",
"export_module_spec... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | ModuleSpec.get_attached_message | Returns the message attached to the module under the given key, or None.
Module publishers can attach protocol messages to modules at creation time
to provide module consumers with additional information, e.g., on module
usage or provenance (see see hub.attach_message()). A typical use would be
to stor... | tensorflow_hub/module_spec.py | def get_attached_message(self, key, message_type, tags=None, required=False):
"""Returns the message attached to the module under the given key, or None.
Module publishers can attach protocol messages to modules at creation time
to provide module consumers with additional information, e.g., on module
u... | def get_attached_message(self, key, message_type, tags=None, required=False):
"""Returns the message attached to the module under the given key, or None.
Module publishers can attach protocol messages to modules at creation time
to provide module consumers with additional information, e.g., on module
u... | [
"Returns",
"the",
"message",
"attached",
"to",
"the",
"module",
"under",
"the",
"given",
"key",
"or",
"None",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module_spec.py#L129-L169 | [
"def",
"get_attached_message",
"(",
"self",
",",
"key",
",",
"message_type",
",",
"tags",
"=",
"None",
",",
"required",
"=",
"False",
")",
":",
"attached_bytes",
"=",
"self",
".",
"_get_attached_bytes",
"(",
"key",
",",
"tags",
")",
"if",
"attached_bytes",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | create_image_lists | Builds a list of training images from the file system.
Analyzes the sub folders in the image directory, splits them into stable
training, testing, and validation sets, and returns a data structure
describing the lists of images for each label and their paths.
Args:
image_dir: String path to a folder conta... | examples/image_retraining/retrain.py | def create_image_lists(image_dir, testing_percentage, validation_percentage):
"""Builds a list of training images from the file system.
Analyzes the sub folders in the image directory, splits them into stable
training, testing, and validation sets, and returns a data structure
describing the lists of images fo... | def create_image_lists(image_dir, testing_percentage, validation_percentage):
"""Builds a list of training images from the file system.
Analyzes the sub folders in the image directory, splits them into stable
training, testing, and validation sets, and returns a data structure
describing the lists of images fo... | [
"Builds",
"a",
"list",
"of",
"training",
"images",
"from",
"the",
"file",
"system",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L147-L234 | [
"def",
"create_image_lists",
"(",
"image_dir",
",",
"testing_percentage",
",",
"validation_percentage",
")",
":",
"if",
"not",
"tf",
".",
"gfile",
".",
"Exists",
"(",
"image_dir",
")",
":",
"tf",
".",
"logging",
".",
"error",
"(",
"\"Image directory '\"",
"+",... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_image_path | Returns a path to an image for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image for.
index: Int offset of the image we want. This will be moduloed by the
available number of images for the label, so it can b... | examples/image_retraining/retrain.py | def get_image_path(image_lists, label_name, index, image_dir, category):
"""Returns a path to an image for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image for.
index: Int offset of the image we want. This wil... | def get_image_path(image_lists, label_name, index, image_dir, category):
"""Returns a path to an image for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image for.
index: Int offset of the image we want. This wil... | [
"Returns",
"a",
"path",
"to",
"an",
"image",
"for",
"a",
"label",
"at",
"the",
"given",
"index",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L237-L267 | [
"def",
"get_image_path",
"(",
"image_lists",
",",
"label_name",
",",
"index",
",",
"image_dir",
",",
"category",
")",
":",
"if",
"label_name",
"not",
"in",
"image_lists",
":",
"tf",
".",
"logging",
".",
"fatal",
"(",
"'Label does not exist %s.'",
",",
"label_n... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_bottleneck_path | Returns a path to a bottleneck file for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image for.
index: Integer offset of the image we want. This will be moduloed by the
available number of images for the label... | examples/image_retraining/retrain.py | def get_bottleneck_path(image_lists, label_name, index, bottleneck_dir,
category, module_name):
"""Returns a path to a bottleneck file for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image f... | def get_bottleneck_path(image_lists, label_name, index, bottleneck_dir,
category, module_name):
"""Returns a path to a bottleneck file for a label at the given index.
Args:
image_lists: OrderedDict of training images for each label.
label_name: Label string we want to get an image f... | [
"Returns",
"a",
"path",
"to",
"a",
"bottleneck",
"file",
"for",
"a",
"label",
"at",
"the",
"given",
"index",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L270-L291 | [
"def",
"get_bottleneck_path",
"(",
"image_lists",
",",
"label_name",
",",
"index",
",",
"bottleneck_dir",
",",
"category",
",",
"module_name",
")",
":",
"module_name",
"=",
"(",
"module_name",
".",
"replace",
"(",
"'://'",
",",
"'~'",
")",
"# URL scheme.",
"."... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | create_module_graph | Creates a graph and loads Hub Module into it.
Args:
module_spec: the hub.ModuleSpec for the image module being used.
Returns:
graph: the tf.Graph that was created.
bottleneck_tensor: the bottleneck values output by the module.
resized_input_tensor: the input images, resized as expected by the modu... | examples/image_retraining/retrain.py | def create_module_graph(module_spec):
"""Creates a graph and loads Hub Module into it.
Args:
module_spec: the hub.ModuleSpec for the image module being used.
Returns:
graph: the tf.Graph that was created.
bottleneck_tensor: the bottleneck values output by the module.
resized_input_tensor: the in... | def create_module_graph(module_spec):
"""Creates a graph and loads Hub Module into it.
Args:
module_spec: the hub.ModuleSpec for the image module being used.
Returns:
graph: the tf.Graph that was created.
bottleneck_tensor: the bottleneck values output by the module.
resized_input_tensor: the in... | [
"Creates",
"a",
"graph",
"and",
"loads",
"Hub",
"Module",
"into",
"it",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L294-L314 | [
"def",
"create_module_graph",
"(",
"module_spec",
")",
":",
"height",
",",
"width",
"=",
"hub",
".",
"get_expected_image_size",
"(",
"module_spec",
")",
"with",
"tf",
".",
"Graph",
"(",
")",
".",
"as_default",
"(",
")",
"as",
"graph",
":",
"resized_input_ten... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | run_bottleneck_on_image | Runs inference on an image to extract the 'bottleneck' summary layer.
Args:
sess: Current active TensorFlow Session.
image_data: String of raw JPEG data.
image_data_tensor: Input data layer in the graph.
decoded_image_tensor: Output of initial image resizing and preprocessing.
resized_input_tenso... | examples/image_retraining/retrain.py | def run_bottleneck_on_image(sess, image_data, image_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor):
"""Runs inference on an image to extract the 'bottleneck' summary layer.
Args:
sess: Current active TensorFlow Session.
im... | def run_bottleneck_on_image(sess, image_data, image_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor):
"""Runs inference on an image to extract the 'bottleneck' summary layer.
Args:
sess: Current active TensorFlow Session.
im... | [
"Runs",
"inference",
"on",
"an",
"image",
"to",
"extract",
"the",
"bottleneck",
"summary",
"layer",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L317-L340 | [
"def",
"run_bottleneck_on_image",
"(",
"sess",
",",
"image_data",
",",
"image_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
")",
":",
"# First decode the JPEG image, resize it, and rescale the pixel values.",
"resized_input_values... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | create_bottleneck_file | Create a single bottleneck file. | examples/image_retraining/retrain.py | def create_bottleneck_file(bottleneck_path, image_lists, label_name, index,
image_dir, category, sess, jpeg_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor):
"""Create a single bottleneck file."""
tf.logging.... | def create_bottleneck_file(bottleneck_path, image_lists, label_name, index,
image_dir, category, sess, jpeg_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor):
"""Create a single bottleneck file."""
tf.logging.... | [
"Create",
"a",
"single",
"bottleneck",
"file",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L353-L373 | [
"def",
"create_bottleneck_file",
"(",
"bottleneck_path",
",",
"image_lists",
",",
"label_name",
",",
"index",
",",
"image_dir",
",",
"category",
",",
"sess",
",",
"jpeg_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
"... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_or_create_bottleneck | Retrieves or calculates bottleneck values for an image.
If a cached version of the bottleneck data exists on-disk, return that,
otherwise calculate the data and save it to disk for future use.
Args:
sess: The current active TensorFlow Session.
image_lists: OrderedDict of training images for each label.
... | examples/image_retraining/retrain.py | def get_or_create_bottleneck(sess, image_lists, label_name, index, image_dir,
category, bottleneck_dir, jpeg_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor, module_name):
"""Retrieves or calculates bottl... | def get_or_create_bottleneck(sess, image_lists, label_name, index, image_dir,
category, bottleneck_dir, jpeg_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor, module_name):
"""Retrieves or calculates bottl... | [
"Retrieves",
"or",
"calculates",
"bottleneck",
"values",
"for",
"an",
"image",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L376-L434 | [
"def",
"get_or_create_bottleneck",
"(",
"sess",
",",
"image_lists",
",",
"label_name",
",",
"index",
",",
"image_dir",
",",
"category",
",",
"bottleneck_dir",
",",
"jpeg_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | cache_bottlenecks | Ensures all the training, testing, and validation bottlenecks are cached.
Because we're likely to read the same image multiple times (if there are no
distortions applied during training) it can speed things up a lot if we
calculate the bottleneck layer values once for each image during
preprocessing, and then ... | examples/image_retraining/retrain.py | def cache_bottlenecks(sess, image_lists, image_dir, bottleneck_dir,
jpeg_data_tensor, decoded_image_tensor,
resized_input_tensor, bottleneck_tensor, module_name):
"""Ensures all the training, testing, and validation bottlenecks are cached.
Because we're likely to read th... | def cache_bottlenecks(sess, image_lists, image_dir, bottleneck_dir,
jpeg_data_tensor, decoded_image_tensor,
resized_input_tensor, bottleneck_tensor, module_name):
"""Ensures all the training, testing, and validation bottlenecks are cached.
Because we're likely to read th... | [
"Ensures",
"all",
"the",
"training",
"testing",
"and",
"validation",
"bottlenecks",
"are",
"cached",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L437-L478 | [
"def",
"cache_bottlenecks",
"(",
"sess",
",",
"image_lists",
",",
"image_dir",
",",
"bottleneck_dir",
",",
"jpeg_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
",",
"module_name",
")",
":",
"how_many_bottlenecks",
"=",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_random_cached_bottlenecks | Retrieves bottleneck values for cached images.
If no distortions are being applied, this function can retrieve the cached
bottleneck values directly from disk for images. It picks a random set of
images from the specified category.
Args:
sess: Current TensorFlow Session.
image_lists: OrderedDict of tr... | examples/image_retraining/retrain.py | def get_random_cached_bottlenecks(sess, image_lists, how_many, category,
bottleneck_dir, image_dir, jpeg_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor, module_name):
"""Retrieves bottlene... | def get_random_cached_bottlenecks(sess, image_lists, how_many, category,
bottleneck_dir, image_dir, jpeg_data_tensor,
decoded_image_tensor, resized_input_tensor,
bottleneck_tensor, module_name):
"""Retrieves bottlene... | [
"Retrieves",
"bottleneck",
"values",
"for",
"cached",
"images",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L481-L544 | [
"def",
"get_random_cached_bottlenecks",
"(",
"sess",
",",
"image_lists",
",",
"how_many",
",",
"category",
",",
"bottleneck_dir",
",",
"image_dir",
",",
"jpeg_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
",",
"module_... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_random_distorted_bottlenecks | Retrieves bottleneck values for training images, after distortions.
If we're training with distortions like crops, scales, or flips, we have to
recalculate the full model for every image, and so we can't use cached
bottleneck values. Instead we find random images for the requested category,
run them through th... | examples/image_retraining/retrain.py | def get_random_distorted_bottlenecks(
sess, image_lists, how_many, category, image_dir, input_jpeg_tensor,
distorted_image, resized_input_tensor, bottleneck_tensor):
"""Retrieves bottleneck values for training images, after distortions.
If we're training with distortions like crops, scales, or flips, we ha... | def get_random_distorted_bottlenecks(
sess, image_lists, how_many, category, image_dir, input_jpeg_tensor,
distorted_image, resized_input_tensor, bottleneck_tensor):
"""Retrieves bottleneck values for training images, after distortions.
If we're training with distortions like crops, scales, or flips, we ha... | [
"Retrieves",
"bottleneck",
"values",
"for",
"training",
"images",
"after",
"distortions",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L547-L596 | [
"def",
"get_random_distorted_bottlenecks",
"(",
"sess",
",",
"image_lists",
",",
"how_many",
",",
"category",
",",
"image_dir",
",",
"input_jpeg_tensor",
",",
"distorted_image",
",",
"resized_input_tensor",
",",
"bottleneck_tensor",
")",
":",
"class_count",
"=",
"len"... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | add_input_distortions | Creates the operations to apply the specified distortions.
During training it can help to improve the results if we run the images
through simple distortions like crops, scales, and flips. These reflect the
kind of variations we expect in the real world, and so can help train the
model to cope with natural dat... | examples/image_retraining/retrain.py | def add_input_distortions(flip_left_right, random_crop, random_scale,
random_brightness, module_spec):
"""Creates the operations to apply the specified distortions.
During training it can help to improve the results if we run the images
through simple distortions like crops, scales, and... | def add_input_distortions(flip_left_right, random_crop, random_scale,
random_brightness, module_spec):
"""Creates the operations to apply the specified distortions.
During training it can help to improve the results if we run the images
through simple distortions like crops, scales, and... | [
"Creates",
"the",
"operations",
"to",
"apply",
"the",
"specified",
"distortions",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L617-L706 | [
"def",
"add_input_distortions",
"(",
"flip_left_right",
",",
"random_crop",
",",
"random_scale",
",",
"random_brightness",
",",
"module_spec",
")",
":",
"input_height",
",",
"input_width",
"=",
"hub",
".",
"get_expected_image_size",
"(",
"module_spec",
")",
"input_dep... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | variable_summaries | Attach a lot of summaries to a Tensor (for TensorBoard visualization). | examples/image_retraining/retrain.py | def variable_summaries(var):
"""Attach a lot of summaries to a Tensor (for TensorBoard visualization)."""
with tf.name_scope('summaries'):
mean = tf.reduce_mean(var)
tf.summary.scalar('mean', mean)
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
tf.summary... | def variable_summaries(var):
"""Attach a lot of summaries to a Tensor (for TensorBoard visualization)."""
with tf.name_scope('summaries'):
mean = tf.reduce_mean(var)
tf.summary.scalar('mean', mean)
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
tf.summary... | [
"Attach",
"a",
"lot",
"of",
"summaries",
"to",
"a",
"Tensor",
"(",
"for",
"TensorBoard",
"visualization",
")",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L709-L719 | [
"def",
"variable_summaries",
"(",
"var",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"'summaries'",
")",
":",
"mean",
"=",
"tf",
".",
"reduce_mean",
"(",
"var",
")",
"tf",
".",
"summary",
".",
"scalar",
"(",
"'mean'",
",",
"mean",
")",
"with",
"t... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | add_final_retrain_ops | Adds a new softmax and fully-connected layer for training and eval.
We need to retrain the top layer to identify our new classes, so this function
adds the right operations to the graph, along with some variables to hold the
weights, and then sets up all the gradients for the backward pass.
The set up for the... | examples/image_retraining/retrain.py | def add_final_retrain_ops(class_count, final_tensor_name, bottleneck_tensor,
quantize_layer, is_training):
"""Adds a new softmax and fully-connected layer for training and eval.
We need to retrain the top layer to identify our new classes, so this function
adds the right operations to t... | def add_final_retrain_ops(class_count, final_tensor_name, bottleneck_tensor,
quantize_layer, is_training):
"""Adds a new softmax and fully-connected layer for training and eval.
We need to retrain the top layer to identify our new classes, so this function
adds the right operations to t... | [
"Adds",
"a",
"new",
"softmax",
"and",
"fully",
"-",
"connected",
"layer",
"for",
"training",
"and",
"eval",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L722-L804 | [
"def",
"add_final_retrain_ops",
"(",
"class_count",
",",
"final_tensor_name",
",",
"bottleneck_tensor",
",",
"quantize_layer",
",",
"is_training",
")",
":",
"batch_size",
",",
"bottleneck_tensor_size",
"=",
"bottleneck_tensor",
".",
"get_shape",
"(",
")",
".",
"as_lis... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | add_evaluation_step | Inserts the operations we need to evaluate the accuracy of our results.
Args:
result_tensor: The new final node that produces results.
ground_truth_tensor: The node we feed ground truth data
into.
Returns:
Tuple of (evaluation step, prediction). | examples/image_retraining/retrain.py | def add_evaluation_step(result_tensor, ground_truth_tensor):
"""Inserts the operations we need to evaluate the accuracy of our results.
Args:
result_tensor: The new final node that produces results.
ground_truth_tensor: The node we feed ground truth data
into.
Returns:
Tuple of (evaluation step,... | def add_evaluation_step(result_tensor, ground_truth_tensor):
"""Inserts the operations we need to evaluate the accuracy of our results.
Args:
result_tensor: The new final node that produces results.
ground_truth_tensor: The node we feed ground truth data
into.
Returns:
Tuple of (evaluation step,... | [
"Inserts",
"the",
"operations",
"we",
"need",
"to",
"evaluate",
"the",
"accuracy",
"of",
"our",
"results",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L807-L825 | [
"def",
"add_evaluation_step",
"(",
"result_tensor",
",",
"ground_truth_tensor",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"'accuracy'",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"'correct_prediction'",
")",
":",
"prediction",
"=",
"tf",
".",
"argma... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | run_final_eval | Runs a final evaluation on an eval graph using the test data set.
Args:
train_session: Session for the train graph with the tensors below.
module_spec: The hub.ModuleSpec for the image module being used.
class_count: Number of classes
image_lists: OrderedDict of training images for each label.
jp... | examples/image_retraining/retrain.py | def run_final_eval(train_session, module_spec, class_count, image_lists,
jpeg_data_tensor, decoded_image_tensor,
resized_image_tensor, bottleneck_tensor):
"""Runs a final evaluation on an eval graph using the test data set.
Args:
train_session: Session for the train graph ... | def run_final_eval(train_session, module_spec, class_count, image_lists,
jpeg_data_tensor, decoded_image_tensor,
resized_image_tensor, bottleneck_tensor):
"""Runs a final evaluation on an eval graph using the test data set.
Args:
train_session: Session for the train graph ... | [
"Runs",
"a",
"final",
"evaluation",
"on",
"an",
"eval",
"graph",
"using",
"the",
"test",
"data",
"set",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L828-L867 | [
"def",
"run_final_eval",
"(",
"train_session",
",",
"module_spec",
",",
"class_count",
",",
"image_lists",
",",
"jpeg_data_tensor",
",",
"decoded_image_tensor",
",",
"resized_image_tensor",
",",
"bottleneck_tensor",
")",
":",
"test_bottlenecks",
",",
"test_ground_truth",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | build_eval_session | Builds an restored eval session without train operations for exporting.
Args:
module_spec: The hub.ModuleSpec for the image module being used.
class_count: Number of classes
Returns:
Eval session containing the restored eval graph.
The bottleneck input, ground truth, eval step, and prediction tens... | examples/image_retraining/retrain.py | def build_eval_session(module_spec, class_count):
"""Builds an restored eval session without train operations for exporting.
Args:
module_spec: The hub.ModuleSpec for the image module being used.
class_count: Number of classes
Returns:
Eval session containing the restored eval graph.
The bottlen... | def build_eval_session(module_spec, class_count):
"""Builds an restored eval session without train operations for exporting.
Args:
module_spec: The hub.ModuleSpec for the image module being used.
class_count: Number of classes
Returns:
Eval session containing the restored eval graph.
The bottlen... | [
"Builds",
"an",
"restored",
"eval",
"session",
"without",
"train",
"operations",
"for",
"exporting",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L870-L901 | [
"def",
"build_eval_session",
"(",
"module_spec",
",",
"class_count",
")",
":",
"# If quantized, we need to create the correct eval graph for exporting.",
"eval_graph",
",",
"bottleneck_tensor",
",",
"resized_input_tensor",
",",
"wants_quantization",
"=",
"(",
"create_module_graph... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | save_graph_to_file | Saves an graph to file, creating a valid quantized one if necessary. | examples/image_retraining/retrain.py | def save_graph_to_file(graph_file_name, module_spec, class_count):
"""Saves an graph to file, creating a valid quantized one if necessary."""
sess, _, _, _, _, _ = build_eval_session(module_spec, class_count)
graph = sess.graph
output_graph_def = tf.graph_util.convert_variables_to_constants(
sess, graph.... | def save_graph_to_file(graph_file_name, module_spec, class_count):
"""Saves an graph to file, creating a valid quantized one if necessary."""
sess, _, _, _, _, _ = build_eval_session(module_spec, class_count)
graph = sess.graph
output_graph_def = tf.graph_util.convert_variables_to_constants(
sess, graph.... | [
"Saves",
"an",
"graph",
"to",
"file",
"creating",
"a",
"valid",
"quantized",
"one",
"if",
"necessary",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L904-L913 | [
"def",
"save_graph_to_file",
"(",
"graph_file_name",
",",
"module_spec",
",",
"class_count",
")",
":",
"sess",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"build_eval_session",
"(",
"module_spec",
",",
"class_count",
")",
"graph",
"=",
"sess",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | add_jpeg_decoding | Adds operations that perform JPEG decoding and resizing to the graph..
Args:
module_spec: The hub.ModuleSpec for the image module being used.
Returns:
Tensors for the node to feed JPEG data into, and the output of the
preprocessing steps. | examples/image_retraining/retrain.py | def add_jpeg_decoding(module_spec):
"""Adds operations that perform JPEG decoding and resizing to the graph..
Args:
module_spec: The hub.ModuleSpec for the image module being used.
Returns:
Tensors for the node to feed JPEG data into, and the output of the
preprocessing steps.
"""
input_height... | def add_jpeg_decoding(module_spec):
"""Adds operations that perform JPEG decoding and resizing to the graph..
Args:
module_spec: The hub.ModuleSpec for the image module being used.
Returns:
Tensors for the node to feed JPEG data into, and the output of the
preprocessing steps.
"""
input_height... | [
"Adds",
"operations",
"that",
"perform",
"JPEG",
"decoding",
"and",
"resizing",
"to",
"the",
"graph",
".."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L926-L948 | [
"def",
"add_jpeg_decoding",
"(",
"module_spec",
")",
":",
"input_height",
",",
"input_width",
"=",
"hub",
".",
"get_expected_image_size",
"(",
"module_spec",
")",
"input_depth",
"=",
"hub",
".",
"get_num_image_channels",
"(",
"module_spec",
")",
"jpeg_data",
"=",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | export_model | Exports model for serving.
Args:
module_spec: The hub.ModuleSpec for the image module being used.
class_count: The number of classes.
saved_model_dir: Directory in which to save exported model and variables. | examples/image_retraining/retrain.py | def export_model(module_spec, class_count, saved_model_dir):
"""Exports model for serving.
Args:
module_spec: The hub.ModuleSpec for the image module being used.
class_count: The number of classes.
saved_model_dir: Directory in which to save exported model and variables.
"""
# The SavedModel should... | def export_model(module_spec, class_count, saved_model_dir):
"""Exports model for serving.
Args:
module_spec: The hub.ModuleSpec for the image module being used.
class_count: The number of classes.
saved_model_dir: Directory in which to save exported model and variables.
"""
# The SavedModel should... | [
"Exports",
"model",
"for",
"serving",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L951-L968 | [
"def",
"export_model",
"(",
"module_spec",
",",
"class_count",
",",
"saved_model_dir",
")",
":",
"# The SavedModel should hold the eval graph.",
"sess",
",",
"in_image",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"build_eval_session",
"(",
"module_spec",
",",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | logging_level_verbosity | Converts logging_level into TensorFlow logging verbosity value
Args:
logging_level: String value representing logging level: 'DEBUG', 'INFO',
'WARN', 'ERROR', 'FATAL' | examples/image_retraining/retrain.py | def logging_level_verbosity(logging_verbosity):
"""Converts logging_level into TensorFlow logging verbosity value
Args:
logging_level: String value representing logging level: 'DEBUG', 'INFO',
'WARN', 'ERROR', 'FATAL'
"""
name_to_level = {
'FATAL': tf.logging.FATAL,
'ERROR': tf.logging.ERROR,
... | def logging_level_verbosity(logging_verbosity):
"""Converts logging_level into TensorFlow logging verbosity value
Args:
logging_level: String value representing logging level: 'DEBUG', 'INFO',
'WARN', 'ERROR', 'FATAL'
"""
name_to_level = {
'FATAL': tf.logging.FATAL,
'ERROR': tf.logging.ERROR,
... | [
"Converts",
"logging_level",
"into",
"TensorFlow",
"logging",
"verbosity",
"value"
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/image_retraining/retrain.py#L971-L990 | [
"def",
"logging_level_verbosity",
"(",
"logging_verbosity",
")",
":",
"name_to_level",
"=",
"{",
"'FATAL'",
":",
"tf",
".",
"logging",
".",
"FATAL",
",",
"'ERROR'",
":",
"tf",
".",
"logging",
".",
"ERROR",
",",
"'WARN'",
":",
"tf",
".",
"logging",
".",
"... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_image_module_info | Returns the module's attached ImageModuleInfo message, or None. | tensorflow_hub/image_util.py | def get_image_module_info(module_or_spec, required=False):
"""Returns the module's attached ImageModuleInfo message, or None."""
return module_or_spec.get_attached_message(
IMAGE_MODULE_INFO_KEY, ImageModuleInfo, required=required) | def get_image_module_info(module_or_spec, required=False):
"""Returns the module's attached ImageModuleInfo message, or None."""
return module_or_spec.get_attached_message(
IMAGE_MODULE_INFO_KEY, ImageModuleInfo, required=required) | [
"Returns",
"the",
"module",
"s",
"attached",
"ImageModuleInfo",
"message",
"or",
"None",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/image_util.py#L39-L42 | [
"def",
"get_image_module_info",
"(",
"module_or_spec",
",",
"required",
"=",
"False",
")",
":",
"return",
"module_or_spec",
".",
"get_attached_message",
"(",
"IMAGE_MODULE_INFO_KEY",
",",
"ImageModuleInfo",
",",
"required",
"=",
"required",
")"
] | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_expected_image_size | Returns expected [height, width] dimensions of an image input.
Args:
module_or_spec: a Module or ModuleSpec that accepts image inputs.
signature: a string with the key of the signature in question.
If None, the default signature is used.
input_name: a string with the input name for images. If None,... | tensorflow_hub/image_util.py | def get_expected_image_size(module_or_spec, signature=None, input_name=None):
"""Returns expected [height, width] dimensions of an image input.
Args:
module_or_spec: a Module or ModuleSpec that accepts image inputs.
signature: a string with the key of the signature in question.
If None, the default s... | def get_expected_image_size(module_or_spec, signature=None, input_name=None):
"""Returns expected [height, width] dimensions of an image input.
Args:
module_or_spec: a Module or ModuleSpec that accepts image inputs.
signature: a string with the key of the signature in question.
If None, the default s... | [
"Returns",
"expected",
"[",
"height",
"width",
"]",
"dimensions",
"of",
"an",
"image",
"input",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/image_util.py#L45-L86 | [
"def",
"get_expected_image_size",
"(",
"module_or_spec",
",",
"signature",
"=",
"None",
",",
"input_name",
"=",
"None",
")",
":",
"# First see if an attached ImageModuleInfo provides this information.",
"image_module_info",
"=",
"get_image_module_info",
"(",
"module_or_spec",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | get_num_image_channels | Returns expected num_channels dimensions of an image input.
This is for advanced users only who expect to handle modules with
image inputs that might not have the 3 usual RGB channels.
Args:
module_or_spec: a Module or ModuleSpec that accepts image inputs.
signature: a string with the key of the signatu... | tensorflow_hub/image_util.py | def get_num_image_channels(module_or_spec, signature=None, input_name=None):
"""Returns expected num_channels dimensions of an image input.
This is for advanced users only who expect to handle modules with
image inputs that might not have the 3 usual RGB channels.
Args:
module_or_spec: a Module or ModuleS... | def get_num_image_channels(module_or_spec, signature=None, input_name=None):
"""Returns expected num_channels dimensions of an image input.
This is for advanced users only who expect to handle modules with
image inputs that might not have the 3 usual RGB channels.
Args:
module_or_spec: a Module or ModuleS... | [
"Returns",
"expected",
"num_channels",
"dimensions",
"of",
"an",
"image",
"input",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/image_util.py#L89-L125 | [
"def",
"get_num_image_channels",
"(",
"module_or_spec",
",",
"signature",
"=",
"None",
",",
"input_name",
"=",
"None",
")",
":",
"if",
"input_name",
"is",
"None",
":",
"input_name",
"=",
"\"images\"",
"input_info_dict",
"=",
"module_or_spec",
".",
"get_input_info_... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | _parse_tensor_info_proto | Returns a ParsedTensorInfo instance from a TensorInfo proto. | tensorflow_hub/tensor_info.py | def _parse_tensor_info_proto(tensor_info):
"""Returns a ParsedTensorInfo instance from a TensorInfo proto."""
encoding = tensor_info.WhichOneof("encoding")
dtype = tf.DType(tensor_info.dtype)
shape = tf.TensorShape(tensor_info.tensor_shape)
if encoding == "name":
return ParsedTensorInfo(dtype=dtype, shape... | def _parse_tensor_info_proto(tensor_info):
"""Returns a ParsedTensorInfo instance from a TensorInfo proto."""
encoding = tensor_info.WhichOneof("encoding")
dtype = tf.DType(tensor_info.dtype)
shape = tf.TensorShape(tensor_info.tensor_shape)
if encoding == "name":
return ParsedTensorInfo(dtype=dtype, shape... | [
"Returns",
"a",
"ParsedTensorInfo",
"instance",
"from",
"a",
"TensorInfo",
"proto",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L65-L75 | [
"def",
"_parse_tensor_info_proto",
"(",
"tensor_info",
")",
":",
"encoding",
"=",
"tensor_info",
".",
"WhichOneof",
"(",
"\"encoding\"",
")",
"dtype",
"=",
"tf",
".",
"DType",
"(",
"tensor_info",
".",
"dtype",
")",
"shape",
"=",
"tf",
".",
"TensorShape",
"("... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | _is_sparse | Returns whether x is a SparseTensor or a parsed sparse tensor info. | tensorflow_hub/tensor_info.py | def _is_sparse(x):
"""Returns whether x is a SparseTensor or a parsed sparse tensor info."""
return (
isinstance(x, (tf.SparseTensor, tf_v1.SparseTensorValue)) or
(hasattr(x, "is_sparse") and x.is_sparse)) | def _is_sparse(x):
"""Returns whether x is a SparseTensor or a parsed sparse tensor info."""
return (
isinstance(x, (tf.SparseTensor, tf_v1.SparseTensorValue)) or
(hasattr(x, "is_sparse") and x.is_sparse)) | [
"Returns",
"whether",
"x",
"is",
"a",
"SparseTensor",
"or",
"a",
"parsed",
"sparse",
"tensor",
"info",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L97-L101 | [
"def",
"_is_sparse",
"(",
"x",
")",
":",
"return",
"(",
"isinstance",
"(",
"x",
",",
"(",
"tf",
".",
"SparseTensor",
",",
"tf_v1",
".",
"SparseTensorValue",
")",
")",
"or",
"(",
"hasattr",
"(",
"x",
",",
"\"is_sparse\"",
")",
"and",
"x",
".",
"is_spa... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | _convert_to_compatible_tensor | Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeErrors.
Raises:
TypeError: If it fails to convert.
Returns:
... | tensorflow_hub/tensor_info.py | def _convert_to_compatible_tensor(value, target, error_prefix):
"""Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeError... | def _convert_to_compatible_tensor(value, target, error_prefix):
"""Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeError... | [
"Converts",
"value",
"into",
"a",
"tensor",
"that",
"can",
"be",
"feed",
"into",
"tensor_info",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L104-L130 | [
"def",
"_convert_to_compatible_tensor",
"(",
"value",
",",
"target",
",",
"error_prefix",
")",
":",
"try",
":",
"tensor",
"=",
"tf_v1",
".",
"convert_to_tensor_or_indexed_slices",
"(",
"value",
",",
"target",
".",
"dtype",
")",
"except",
"TypeError",
"as",
"e",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | convert_dict_to_compatible_tensor | Converts dict `values` in tensors that are compatible with `targets`.
Args:
values: A dict to objects to convert with same keys as `targets`.
targets: A dict returned by `parse_tensor_info_map`.
Returns:
A map with the same keys as `values` but values converted into
Tensor/SparseTensors that can b... | tensorflow_hub/tensor_info.py | def convert_dict_to_compatible_tensor(values, targets):
"""Converts dict `values` in tensors that are compatible with `targets`.
Args:
values: A dict to objects to convert with same keys as `targets`.
targets: A dict returned by `parse_tensor_info_map`.
Returns:
A map with the same keys as `values` ... | def convert_dict_to_compatible_tensor(values, targets):
"""Converts dict `values` in tensors that are compatible with `targets`.
Args:
values: A dict to objects to convert with same keys as `targets`.
targets: A dict returned by `parse_tensor_info_map`.
Returns:
A map with the same keys as `values` ... | [
"Converts",
"dict",
"values",
"in",
"tensors",
"that",
"are",
"compatible",
"with",
"targets",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L133-L151 | [
"def",
"convert_dict_to_compatible_tensor",
"(",
"values",
",",
"targets",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"values",
".",
"items",
"(",
")",
")",
":",
"result",
"[",
"key",
"]",
"=",
"_convert_to_compat... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | build_input_map | Builds a map to feed tensors in `protomap` using `inputs`.
Args:
protomap: A proto map<string,TensorInfo>.
inputs: A map with same keys as `protomap` of Tensors and SparseTensors.
Returns:
A map from nodes refered by TensorInfo protos to corresponding input
tensors.
Raises:
ValueError: if a... | tensorflow_hub/tensor_info.py | def build_input_map(protomap, inputs):
"""Builds a map to feed tensors in `protomap` using `inputs`.
Args:
protomap: A proto map<string,TensorInfo>.
inputs: A map with same keys as `protomap` of Tensors and SparseTensors.
Returns:
A map from nodes refered by TensorInfo protos to corresponding input
... | def build_input_map(protomap, inputs):
"""Builds a map to feed tensors in `protomap` using `inputs`.
Args:
protomap: A proto map<string,TensorInfo>.
inputs: A map with same keys as `protomap` of Tensors and SparseTensors.
Returns:
A map from nodes refered by TensorInfo protos to corresponding input
... | [
"Builds",
"a",
"map",
"to",
"feed",
"tensors",
"in",
"protomap",
"using",
"inputs",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L154-L183 | [
"def",
"build_input_map",
"(",
"protomap",
",",
"inputs",
")",
":",
"if",
"set",
"(",
"protomap",
".",
"keys",
"(",
")",
")",
"!=",
"set",
"(",
"inputs",
".",
"keys",
"(",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"build_input_map: keys do not match.\""... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | build_output_map | Builds a map of tensors from `protomap` using `get_tensor_by_name`.
Args:
protomap: A proto map<string,TensorInfo>.
get_tensor_by_name: A lambda that receives a tensor name and returns a
Tensor instance.
Returns:
A map from string to Tensor or SparseTensor instances built from `protomap`
and... | tensorflow_hub/tensor_info.py | def build_output_map(protomap, get_tensor_by_name):
"""Builds a map of tensors from `protomap` using `get_tensor_by_name`.
Args:
protomap: A proto map<string,TensorInfo>.
get_tensor_by_name: A lambda that receives a tensor name and returns a
Tensor instance.
Returns:
A map from string to Tenso... | def build_output_map(protomap, get_tensor_by_name):
"""Builds a map of tensors from `protomap` using `get_tensor_by_name`.
Args:
protomap: A proto map<string,TensorInfo>.
get_tensor_by_name: A lambda that receives a tensor name and returns a
Tensor instance.
Returns:
A map from string to Tenso... | [
"Builds",
"a",
"map",
"of",
"tensors",
"from",
"protomap",
"using",
"get_tensor_by_name",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L186-L217 | [
"def",
"build_output_map",
"(",
"protomap",
",",
"get_tensor_by_name",
")",
":",
"def",
"get_output_from_tensor_info",
"(",
"tensor_info",
")",
":",
"encoding",
"=",
"tensor_info",
".",
"WhichOneof",
"(",
"\"encoding\"",
")",
"if",
"encoding",
"==",
"\"name\"",
":... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | tensor_info_proto_maps_match | Whether two signature inputs/outputs match in dtype, shape and sparsity.
Args:
map_a: A proto map<string,TensorInfo>.
map_b: A proto map<string,TensorInfo>.
Returns:
A boolean whether `map_a` and `map_b` tensors have the same dtype, shape and
sparsity. | tensorflow_hub/tensor_info.py | def tensor_info_proto_maps_match(map_a, map_b):
"""Whether two signature inputs/outputs match in dtype, shape and sparsity.
Args:
map_a: A proto map<string,TensorInfo>.
map_b: A proto map<string,TensorInfo>.
Returns:
A boolean whether `map_a` and `map_b` tensors have the same dtype, shape and
sp... | def tensor_info_proto_maps_match(map_a, map_b):
"""Whether two signature inputs/outputs match in dtype, shape and sparsity.
Args:
map_a: A proto map<string,TensorInfo>.
map_b: A proto map<string,TensorInfo>.
Returns:
A boolean whether `map_a` and `map_b` tensors have the same dtype, shape and
sp... | [
"Whether",
"two",
"signature",
"inputs",
"/",
"outputs",
"match",
"in",
"dtype",
"shape",
"and",
"sparsity",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L230-L254 | [
"def",
"tensor_info_proto_maps_match",
"(",
"map_a",
",",
"map_b",
")",
":",
"iter_a",
"=",
"sorted",
"(",
"parse_tensor_info_map",
"(",
"map_a",
")",
".",
"items",
"(",
")",
")",
"iter_b",
"=",
"sorted",
"(",
"parse_tensor_info_map",
"(",
"map_b",
")",
".",... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | parse_line | Parses a line of a text embedding file.
Args:
line: (str) One line of the text embedding file.
Returns:
A token string and its embedding vector in floats. | examples/text_embeddings/export.py | def parse_line(line):
"""Parses a line of a text embedding file.
Args:
line: (str) One line of the text embedding file.
Returns:
A token string and its embedding vector in floats.
"""
columns = line.split()
token = columns.pop(0)
values = [float(column) for column in columns]
return token, val... | def parse_line(line):
"""Parses a line of a text embedding file.
Args:
line: (str) One line of the text embedding file.
Returns:
A token string and its embedding vector in floats.
"""
columns = line.split()
token = columns.pop(0)
values = [float(column) for column in columns]
return token, val... | [
"Parses",
"a",
"line",
"of",
"a",
"text",
"embedding",
"file",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L47-L59 | [
"def",
"parse_line",
"(",
"line",
")",
":",
"columns",
"=",
"line",
".",
"split",
"(",
")",
"token",
"=",
"columns",
".",
"pop",
"(",
"0",
")",
"values",
"=",
"[",
"float",
"(",
"column",
")",
"for",
"column",
"in",
"columns",
"]",
"return",
"token... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | load | Loads a text embedding into memory as a numpy matrix.
Args:
file_path: Path to the text embedding file.
parse_line_fn: callback function to parse each file line.
Returns:
A tuple of (list of vocabulary tokens, numpy matrix of embedding vectors).
Raises:
ValueError: if the data in the sstable is... | examples/text_embeddings/export.py | def load(file_path, parse_line_fn):
"""Loads a text embedding into memory as a numpy matrix.
Args:
file_path: Path to the text embedding file.
parse_line_fn: callback function to parse each file line.
Returns:
A tuple of (list of vocabulary tokens, numpy matrix of embedding vectors).
Raises:
... | def load(file_path, parse_line_fn):
"""Loads a text embedding into memory as a numpy matrix.
Args:
file_path: Path to the text embedding file.
parse_line_fn: callback function to parse each file line.
Returns:
A tuple of (list of vocabulary tokens, numpy matrix of embedding vectors).
Raises:
... | [
"Loads",
"a",
"text",
"embedding",
"into",
"memory",
"as",
"a",
"numpy",
"matrix",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L62-L90 | [
"def",
"load",
"(",
"file_path",
",",
"parse_line_fn",
")",
":",
"vocabulary",
"=",
"[",
"]",
"embeddings",
"=",
"[",
"]",
"embeddings_dim",
"=",
"None",
"for",
"line",
"in",
"tf",
".",
"gfile",
".",
"GFile",
"(",
"file_path",
")",
":",
"token",
",",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | make_module_spec | Makes a module spec to simply perform token to embedding lookups.
Input of this module is a 1-D list of string tokens. For T tokens input and
an M dimensional embedding table, the lookup result is a [T, M] shaped Tensor.
Args:
vocabulary_file: Text file where each line is a key in the vocabulary.
vocab_... | examples/text_embeddings/export.py | def make_module_spec(vocabulary_file, vocab_size, embeddings_dim,
num_oov_buckets, preprocess_text):
"""Makes a module spec to simply perform token to embedding lookups.
Input of this module is a 1-D list of string tokens. For T tokens input and
an M dimensional embedding table, the lookup r... | def make_module_spec(vocabulary_file, vocab_size, embeddings_dim,
num_oov_buckets, preprocess_text):
"""Makes a module spec to simply perform token to embedding lookups.
Input of this module is a 1-D list of string tokens. For T tokens input and
an M dimensional embedding table, the lookup r... | [
"Makes",
"a",
"module",
"spec",
"to",
"simply",
"perform",
"token",
"to",
"embedding",
"lookups",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L93-L177 | [
"def",
"make_module_spec",
"(",
"vocabulary_file",
",",
"vocab_size",
",",
"embeddings_dim",
",",
"num_oov_buckets",
",",
"preprocess_text",
")",
":",
"def",
"module_fn",
"(",
")",
":",
"\"\"\"Spec function for a token embedding module.\"\"\"",
"tokens",
"=",
"tf",
".",... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | export | Exports a TF-Hub module that performs embedding lookups.
Args:
export_path: Location to export the module.
vocabulary: List of the N tokens in the vocabulary.
embeddings: Numpy array of shape [N+K,M] the first N rows are the
M dimensional embeddings for the respective tokens and the next K
ro... | examples/text_embeddings/export.py | def export(export_path, vocabulary, embeddings, num_oov_buckets,
preprocess_text):
"""Exports a TF-Hub module that performs embedding lookups.
Args:
export_path: Location to export the module.
vocabulary: List of the N tokens in the vocabulary.
embeddings: Numpy array of shape [N+K,M] the fi... | def export(export_path, vocabulary, embeddings, num_oov_buckets,
preprocess_text):
"""Exports a TF-Hub module that performs embedding lookups.
Args:
export_path: Location to export the module.
vocabulary: List of the N tokens in the vocabulary.
embeddings: Numpy array of shape [N+K,M] the fi... | [
"Exports",
"a",
"TF",
"-",
"Hub",
"module",
"that",
"performs",
"embedding",
"lookups",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L180-L219 | [
"def",
"export",
"(",
"export_path",
",",
"vocabulary",
",",
"embeddings",
",",
"num_oov_buckets",
",",
"preprocess_text",
")",
":",
"# Write temporary vocab file for module construction.",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"vocabulary_file",
"=",
"... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | maybe_append_oov_vectors | Adds zero vectors for oov buckets if num_oov_buckets > 0.
Since we are assigning zero vectors, adding more that one oov bucket is only
meaningful if we perform fine-tuning.
Args:
embeddings: Embeddings to extend.
num_oov_buckets: Number of OOV buckets in the extended embedding. | examples/text_embeddings/export.py | def maybe_append_oov_vectors(embeddings, num_oov_buckets):
"""Adds zero vectors for oov buckets if num_oov_buckets > 0.
Since we are assigning zero vectors, adding more that one oov bucket is only
meaningful if we perform fine-tuning.
Args:
embeddings: Embeddings to extend.
num_oov_buckets: Number of ... | def maybe_append_oov_vectors(embeddings, num_oov_buckets):
"""Adds zero vectors for oov buckets if num_oov_buckets > 0.
Since we are assigning zero vectors, adding more that one oov bucket is only
meaningful if we perform fine-tuning.
Args:
embeddings: Embeddings to extend.
num_oov_buckets: Number of ... | [
"Adds",
"zero",
"vectors",
"for",
"oov",
"buckets",
"if",
"num_oov_buckets",
">",
"0",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L222-L235 | [
"def",
"maybe_append_oov_vectors",
"(",
"embeddings",
",",
"num_oov_buckets",
")",
":",
"num_embeddings",
"=",
"np",
".",
"shape",
"(",
"embeddings",
")",
"[",
"0",
"]",
"embedding_dim",
"=",
"np",
".",
"shape",
"(",
"embeddings",
")",
"[",
"1",
"]",
"embe... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | create_module_spec_from_saved_model | Experimental: Create a ModuleSpec out of a SavedModel.
Define a ModuleSpec from a SavedModel. Note that this is not guaranteed to
work in all cases and it assumes the SavedModel has followed some conventions:
- The serialized SaverDef can be ignored and instead can be reconstructed.
- The init op and main op ... | tensorflow_hub/saved_model_module.py | def create_module_spec_from_saved_model(saved_model_path,
drop_collections=None):
"""Experimental: Create a ModuleSpec out of a SavedModel.
Define a ModuleSpec from a SavedModel. Note that this is not guaranteed to
work in all cases and it assumes the SavedModel has follow... | def create_module_spec_from_saved_model(saved_model_path,
drop_collections=None):
"""Experimental: Create a ModuleSpec out of a SavedModel.
Define a ModuleSpec from a SavedModel. Note that this is not guaranteed to
work in all cases and it assumes the SavedModel has follow... | [
"Experimental",
":",
"Create",
"a",
"ModuleSpec",
"out",
"of",
"a",
"SavedModel",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_module.py#L56-L91 | [
"def",
"create_module_spec_from_saved_model",
"(",
"saved_model_path",
",",
"drop_collections",
"=",
"None",
")",
":",
"saved_model_handler",
"=",
"saved_model_lib",
".",
"load",
"(",
"saved_model_path",
")",
"checkpoint_filename",
"=",
"saved_model_lib",
".",
"get_variab... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | register_module_for_export | Register a Module to be exported under `export_name`.
This function registers `module` to be exported by `LatestModuleExporter`
under a subdirectory named `export_name`.
Note that `export_name` must be unique for each module exported from the
current graph. It only controls the export subdirectory name and i... | tensorflow_hub/estimator.py | def register_module_for_export(module, export_name):
"""Register a Module to be exported under `export_name`.
This function registers `module` to be exported by `LatestModuleExporter`
under a subdirectory named `export_name`.
Note that `export_name` must be unique for each module exported from the
current ... | def register_module_for_export(module, export_name):
"""Register a Module to be exported under `export_name`.
This function registers `module` to be exported by `LatestModuleExporter`
under a subdirectory named `export_name`.
Note that `export_name` must be unique for each module exported from the
current ... | [
"Register",
"a",
"Module",
"to",
"be",
"exported",
"under",
"export_name",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/estimator.py#L37-L60 | [
"def",
"register_module_for_export",
"(",
"module",
",",
"export_name",
")",
":",
"for",
"used_name",
",",
"_",
"in",
"tf_v1",
".",
"get_collection",
"(",
"_EXPORT_MODULES_COLLECTION",
")",
":",
"if",
"used_name",
"==",
"export_name",
":",
"raise",
"ValueError",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | _make_estimator_serving_session | Returns a session constructed using `estimator` and `serving_input_fn`.
The Estimator API does not provide an API to construct a graph and session,
making it necessary for this function to replicate how an estimator builds
a graph.
This code is based on `Estimator.export_savedmodel` (another function that
h... | tensorflow_hub/estimator.py | def _make_estimator_serving_session(estimator, serving_input_fn,
checkpoint_path):
"""Returns a session constructed using `estimator` and `serving_input_fn`.
The Estimator API does not provide an API to construct a graph and session,
making it necessary for this function to re... | def _make_estimator_serving_session(estimator, serving_input_fn,
checkpoint_path):
"""Returns a session constructed using `estimator` and `serving_input_fn`.
The Estimator API does not provide an API to construct a graph and session,
making it necessary for this function to re... | [
"Returns",
"a",
"session",
"constructed",
"using",
"estimator",
"and",
"serving_input_fn",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/estimator.py#L171-L214 | [
"def",
"_make_estimator_serving_session",
"(",
"estimator",
",",
"serving_input_fn",
",",
"checkpoint_path",
")",
":",
"with",
"tf",
".",
"Graph",
"(",
")",
".",
"as_default",
"(",
")",
"as",
"g",
":",
"mode",
"=",
"tf_v1",
".",
"estimator",
".",
"ModeKeys",... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | create_module_spec | Creates a ModuleSpec from a function that builds the module's graph.
The `module_fn` is called on a new graph (not the current one) to build the
graph of the module and define its signatures via `hub.add_signature()`.
Example:
```python
# Define a text embedding module.
def my_text_module_fn():
text_i... | tensorflow_hub/native_module.py | def create_module_spec(module_fn, tags_and_args=None, drop_collections=None):
"""Creates a ModuleSpec from a function that builds the module's graph.
The `module_fn` is called on a new graph (not the current one) to build the
graph of the module and define its signatures via `hub.add_signature()`.
Example:
... | def create_module_spec(module_fn, tags_and_args=None, drop_collections=None):
"""Creates a ModuleSpec from a function that builds the module's graph.
The `module_fn` is called on a new graph (not the current one) to build the
graph of the module and define its signatures via `hub.add_signature()`.
Example:
... | [
"Creates",
"a",
"ModuleSpec",
"from",
"a",
"function",
"that",
"builds",
"the",
"module",
"s",
"graph",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/native_module.py#L121-L195 | [
"def",
"create_module_spec",
"(",
"module_fn",
",",
"tags_and_args",
"=",
"None",
",",
"drop_collections",
"=",
"None",
")",
":",
"if",
"not",
"drop_collections",
":",
"drop_collections",
"=",
"[",
"]",
"report_tags",
"=",
"True",
"if",
"not",
"tags_and_args",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | add_signature | Adds a signature to the module definition.
NOTE: This must be called within a `module_fn` that is defining a Module.
Args:
name: Signature name as a string. If omitted, it is interpreted as 'default'
and is the signature used when `Module.__call__` `signature` is not
specified.
inputs: A dict ... | tensorflow_hub/native_module.py | def add_signature(name=None, inputs=None, outputs=None):
"""Adds a signature to the module definition.
NOTE: This must be called within a `module_fn` that is defining a Module.
Args:
name: Signature name as a string. If omitted, it is interpreted as 'default'
and is the signature used when `Module.__c... | def add_signature(name=None, inputs=None, outputs=None):
"""Adds a signature to the module definition.
NOTE: This must be called within a `module_fn` that is defining a Module.
Args:
name: Signature name as a string. If omitted, it is interpreted as 'default'
and is the signature used when `Module.__c... | [
"Adds",
"a",
"signature",
"to",
"the",
"module",
"definition",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/native_module.py#L198-L231 | [
"def",
"add_signature",
"(",
"name",
"=",
"None",
",",
"inputs",
"=",
"None",
",",
"outputs",
"=",
"None",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"\"default\"",
"if",
"inputs",
"is",
"None",
":",
"inputs",
"=",
"{",
"}",
"if",
"outputs",
... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
train | attach_message | Adds an attached message to the module definition.
NOTE: This must be called within a `module_fn` that is defining a Module.
See ModuleSpec.get_attached_message() for an introduction to attached messages
and the API for module consumers.
To define a new type of attached message:
* Select a reasonably de... | tensorflow_hub/native_module.py | def attach_message(key, message):
"""Adds an attached message to the module definition.
NOTE: This must be called within a `module_fn` that is defining a Module.
See ModuleSpec.get_attached_message() for an introduction to attached messages
and the API for module consumers.
To define a new type of attached... | def attach_message(key, message):
"""Adds an attached message to the module definition.
NOTE: This must be called within a `module_fn` that is defining a Module.
See ModuleSpec.get_attached_message() for an introduction to attached messages
and the API for module consumers.
To define a new type of attached... | [
"Adds",
"an",
"attached",
"message",
"to",
"the",
"module",
"definition",
"."
] | tensorflow/hub | python | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/native_module.py#L234-L276 | [
"def",
"attach_message",
"(",
"key",
",",
"message",
")",
":",
"if",
"not",
"re",
".",
"match",
"(",
"r\"[a-zA-Z][a-zA-Z0-9_]*$\"",
",",
"key",
")",
":",
"raise",
"ValueError",
"(",
"\"hub.attach_message() called with malformed key '%s'\"",
"%",
"key",
")",
"saved... | 09f45963f6787322967b6fec61459f3ac56fbb27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.