hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a05d69796af433efd0fe16c3508b7216834f4240 | jscheytt/endo-loc | debug/debug.py | [
"Apache-2.0"
] | Python | write_list_to_file | null | def write_list_to_file(l, filename):
"""
Write a list object to a text file
:param l: list object
:param filename: path to text file
:return:
"""
with open(filename, 'w') as textfile:
text = '\n'.join(map(str, l))
textfile.write(text) |
Write a list object to a text file
:param l: list object
:param filename: path to text file
:return:
| Write a list object to a text file | [
"Write",
"a",
"list",
"object",
"to",
"a",
"text",
"file"
] | def write_list_to_file(l, filename):
with open(filename, 'w') as textfile:
text = '\n'.join(map(str, l))
textfile.write(text) | [
"def",
"write_list_to_file",
"(",
"l",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"textfile",
":",
"text",
"=",
"'\\n'",
".",
"join",
"(",
"map",
"(",
"str",
",",
"l",
")",
")",
"textfile",
".",
"write",
"(",... | Write a list object to a text file | [
"Write",
"a",
"list",
"object",
"to",
"a",
"text",
"file"
] | [
"\"\"\"\n Write a list object to a text file\n :param l: list object\n :param filename: path to text file\n :return:\n \"\"\""
] | [
{
"param": "l",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "l",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is... |
a05d69796af433efd0fe16c3508b7216834f4240 | jscheytt/endo-loc | debug/debug.py | [
"Apache-2.0"
] | Python | write_list_to_dir | null | def write_list_to_dir(directory, y, filename):
"""
Convenience method for writing a file to a directory.
:param directory:
:param y: list
:param filename:
:return:
"""
textfile = os.path.join(directory, filename)
write_list_to_file(y, textfile) |
Convenience method for writing a file to a directory.
:param directory:
:param y: list
:param filename:
:return:
| Convenience method for writing a file to a directory. | [
"Convenience",
"method",
"for",
"writing",
"a",
"file",
"to",
"a",
"directory",
"."
] | def write_list_to_dir(directory, y, filename):
textfile = os.path.join(directory, filename)
write_list_to_file(y, textfile) | [
"def",
"write_list_to_dir",
"(",
"directory",
",",
"y",
",",
"filename",
")",
":",
"textfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"filename",
")",
"write_list_to_file",
"(",
"y",
",",
"textfile",
")"
] | Convenience method for writing a file to a directory. | [
"Convenience",
"method",
"for",
"writing",
"a",
"file",
"to",
"a",
"directory",
"."
] | [
"\"\"\"\n Convenience method for writing a file to a directory.\n :param directory:\n :param y: list\n :param filename:\n :return:\n \"\"\""
] | [
{
"param": "directory",
"type": null
},
{
"param": "y",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
a29188d83f327d43cf1c3315b6700c59b636fe70 | jscheytt/endo-loc | vis/display.py | [
"Apache-2.0"
] | Python | display_video | null | def display_video(filename):
"""
Display a video in a window. A wrapper for process_video with show_frame.
:param filename: Path to video file
:return:
"""
process_video(filename, show_frame) |
Display a video in a window. A wrapper for process_video with show_frame.
:param filename: Path to video file
:return:
| Display a video in a window. | [
"Display",
"a",
"video",
"in",
"a",
"window",
"."
] | def display_video(filename):
process_video(filename, show_frame) | [
"def",
"display_video",
"(",
"filename",
")",
":",
"process_video",
"(",
"filename",
",",
"show_frame",
")"
] | Display a video in a window. | [
"Display",
"a",
"video",
"in",
"a",
"window",
"."
] | [
"\"\"\"\n Display a video in a window. A wrapper for process_video with show_frame.\n :param filename: Path to video file\n :return: \n \"\"\""
] | [
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": "Path to video file",
"docstring_tokens": [
"Path",
"to",
... |
a29188d83f327d43cf1c3315b6700c59b636fe70 | jscheytt/endo-loc | vis/display.py | [
"Apache-2.0"
] | Python | process_video | null | def process_video(src, action, skip_frames=0):
"""
Process a video frame by frame, executing the action on every frame.
:param src: Path to the video file OR int signifying camera
:param action: Function to be called, must have 2 parameters (frame and skip_frames)
:param skip_frames:
:return:
... |
Process a video frame by frame, executing the action on every frame.
:param src: Path to the video file OR int signifying camera
:param action: Function to be called, must have 2 parameters (frame and skip_frames)
:param skip_frames:
:return:
| Process a video frame by frame, executing the action on every frame. | [
"Process",
"a",
"video",
"frame",
"by",
"frame",
"executing",
"the",
"action",
"on",
"every",
"frame",
"."
] | def process_video(src, action, skip_frames=0):
cap = cv2.VideoCapture()
if not cap.isOpened():
cap.open(src)
global FRAME_COUNT
FRAME_COUNT = 0
while cap.isOpened():
ret, frame = cap.read()
FRAME_COUNT += 1
action(frame, skip_frames)
if cv2.waitKey(1) & 0xFF =... | [
"def",
"process_video",
"(",
"src",
",",
"action",
",",
"skip_frames",
"=",
"0",
")",
":",
"cap",
"=",
"cv2",
".",
"VideoCapture",
"(",
")",
"if",
"not",
"cap",
".",
"isOpened",
"(",
")",
":",
"cap",
".",
"open",
"(",
"src",
")",
"global",
"FRAME_C... | Process a video frame by frame, executing the action on every frame. | [
"Process",
"a",
"video",
"frame",
"by",
"frame",
"executing",
"the",
"action",
"on",
"every",
"frame",
"."
] | [
"\"\"\"\n Process a video frame by frame, executing the action on every frame.\n :param src: Path to the video file OR int signifying camera\n :param action: Function to be called, must have 2 parameters (frame and skip_frames)\n :param skip_frames: \n :return: \n \"\"\""
] | [
{
"param": "src",
"type": null
},
{
"param": "action",
"type": null
},
{
"param": "skip_frames",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "src",
"type": null,
"docstring": "Path to the video file OR int signifying camera",
"docstring_tokens": [
"... |
a29188d83f327d43cf1c3315b6700c59b636fe70 | jscheytt/endo-loc | vis/display.py | [
"Apache-2.0"
] | Python | show_frame | null | def show_frame(frame, fullscreen=False):
"""
Action function for process_video: Simply display the frame.
:param frame: video frame to be displayed
:param fullscreen: Show frame in fullscreen window
:return:
"""
if fullscreen:
cv2.namedWindow(WINDOW_TITLE, cv2.WND_PROP_FULLSCREEN)
... |
Action function for process_video: Simply display the frame.
:param frame: video frame to be displayed
:param fullscreen: Show frame in fullscreen window
:return:
| Action function for process_video: Simply display the frame. | [
"Action",
"function",
"for",
"process_video",
":",
"Simply",
"display",
"the",
"frame",
"."
] | def show_frame(frame, fullscreen=False):
if fullscreen:
cv2.namedWindow(WINDOW_TITLE, cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty(WINDOW_TITLE, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
cv2.imshow(WINDOW_TITLE, frame) | [
"def",
"show_frame",
"(",
"frame",
",",
"fullscreen",
"=",
"False",
")",
":",
"if",
"fullscreen",
":",
"cv2",
".",
"namedWindow",
"(",
"WINDOW_TITLE",
",",
"cv2",
".",
"WND_PROP_FULLSCREEN",
")",
"cv2",
".",
"setWindowProperty",
"(",
"WINDOW_TITLE",
",",
"cv... | Action function for process_video: Simply display the frame. | [
"Action",
"function",
"for",
"process_video",
":",
"Simply",
"display",
"the",
"frame",
"."
] | [
"\"\"\"\n Action function for process_video: Simply display the frame.\n :param frame: video frame to be displayed\n :param fullscreen: Show frame in fullscreen window\n :return: \n \"\"\""
] | [
{
"param": "frame",
"type": null
},
{
"param": "fullscreen",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "frame",
"type": null,
"docstring": "video frame to be displayed",
"docstring_tokens": [
"video",
"f... |
a29188d83f327d43cf1c3315b6700c59b636fe70 | jscheytt/endo-loc | vis/display.py | [
"Apache-2.0"
] | Python | load_image | <not_specific> | def load_image(filepath):
"""
Read an image from disk.
:param filepath:
:return:
"""
return cv2.imread(filepath, cv2.IMREAD_COLOR) |
Read an image from disk.
:param filepath:
:return:
| Read an image from disk. | [
"Read",
"an",
"image",
"from",
"disk",
"."
] | def load_image(filepath):
return cv2.imread(filepath, cv2.IMREAD_COLOR) | [
"def",
"load_image",
"(",
"filepath",
")",
":",
"return",
"cv2",
".",
"imread",
"(",
"filepath",
",",
"cv2",
".",
"IMREAD_COLOR",
")"
] | Read an image from disk. | [
"Read",
"an",
"image",
"from",
"disk",
"."
] | [
"\"\"\"\n Read an image from disk.\n :param filepath: \n :return: \n \"\"\""
] | [
{
"param": "filepath",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
a29188d83f327d43cf1c3315b6700c59b636fe70 | jscheytt/endo-loc | vis/display.py | [
"Apache-2.0"
] | Python | process_image | null | def process_image(img, action):
"""
Process an image and display it in a window.
Window closes after pressing any key.
:param img:
:param action: name of the function to be executed upon img
:return:
"""
action(img)
cv2.waitKey(0)
cv2.destroyAllWindows() |
Process an image and display it in a window.
Window closes after pressing any key.
:param img:
:param action: name of the function to be executed upon img
:return:
| Process an image and display it in a window.
Window closes after pressing any key. | [
"Process",
"an",
"image",
"and",
"display",
"it",
"in",
"a",
"window",
".",
"Window",
"closes",
"after",
"pressing",
"any",
"key",
"."
] | def process_image(img, action):
action(img)
cv2.waitKey(0)
cv2.destroyAllWindows() | [
"def",
"process_image",
"(",
"img",
",",
"action",
")",
":",
"action",
"(",
"img",
")",
"cv2",
".",
"waitKey",
"(",
"0",
")",
"cv2",
".",
"destroyAllWindows",
"(",
")"
] | Process an image and display it in a window. | [
"Process",
"an",
"image",
"and",
"display",
"it",
"in",
"a",
"window",
"."
] | [
"\"\"\"\n Process an image and display it in a window.\n Window closes after pressing any key.\n :param img: \n :param action: name of the function to be executed upon img\n :return: \n \"\"\""
] | [
{
"param": "img",
"type": null
},
{
"param": "action",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"... |
42d87771294b25c0b541d7d10c509285134b9e73 | jscheytt/endo-loc | feature_extraction/ft_descriptor.py | [
"Apache-2.0"
] | Python | add_frame | null | def add_frame(self, frame):
"""
Add a vframe obj to the list of frames of a video.
:param frame: VFrame obj to be appended
:return:
"""
assert isinstance(frame, VFrame)
self.frames.append(frame) |
Add a vframe obj to the list of frames of a video.
:param frame: VFrame obj to be appended
:return:
| Add a vframe obj to the list of frames of a video. | [
"Add",
"a",
"vframe",
"obj",
"to",
"the",
"list",
"of",
"frames",
"of",
"a",
"video",
"."
] | def add_frame(self, frame):
assert isinstance(frame, VFrame)
self.frames.append(frame) | [
"def",
"add_frame",
"(",
"self",
",",
"frame",
")",
":",
"assert",
"isinstance",
"(",
"frame",
",",
"VFrame",
")",
"self",
".",
"frames",
".",
"append",
"(",
"frame",
")"
] | Add a vframe obj to the list of frames of a video. | [
"Add",
"a",
"vframe",
"obj",
"to",
"the",
"list",
"of",
"frames",
"of",
"a",
"video",
"."
] | [
"\"\"\"\n Add a vframe obj to the list of frames of a video.\n :param frame: VFrame obj to be appended\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "frame",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
42d87771294b25c0b541d7d10c509285134b9e73 | jscheytt/endo-loc | feature_extraction/ft_descriptor.py | [
"Apache-2.0"
] | Python | fill_label_list | null | def fill_label_list(self):
"""
Get all labels as an exhaustive list, i. e. with as many entries as there are frames.
This label_list is also added as an attribute of the Video object.
:return: 1D list of ILabel objs
"""
if not self.label_list:
import label_imp... |
Get all labels as an exhaustive list, i. e. with as many entries as there are frames.
This label_list is also added as an attribute of the Video object.
:return: 1D list of ILabel objs
| Get all labels as an exhaustive list, i. e. with as many entries as there are frames.
This label_list is also added as an attribute of the Video object. | [
"Get",
"all",
"labels",
"as",
"an",
"exhaustive",
"list",
"i",
".",
"e",
".",
"with",
"as",
"many",
"entries",
"as",
"there",
"are",
"frames",
".",
"This",
"label_list",
"is",
"also",
"added",
"as",
"an",
"attribute",
"of",
"the",
"Video",
"object",
".... | def fill_label_list(self):
if not self.label_list:
import label_import.timestamp as ts
last_label = self.labels[-1]
last_timestamp = last_label.end
last_frameidx = last_timestamp.get_frameidx(self.fps)
for idx in range(0, last_frameidx, 1):
... | [
"def",
"fill_label_list",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"label_list",
":",
"import",
"label_import",
".",
"timestamp",
"as",
"ts",
"last_label",
"=",
"self",
".",
"labels",
"[",
"-",
"1",
"]",
"last_timestamp",
"=",
"last_label",
".",
... | Get all labels as an exhaustive list, i. e. with as many entries as there are frames. | [
"Get",
"all",
"labels",
"as",
"an",
"exhaustive",
"list",
"i",
".",
"e",
".",
"with",
"as",
"many",
"entries",
"as",
"there",
"are",
"frames",
"."
] | [
"\"\"\"\n Get all labels as an exhaustive list, i. e. with as many entries as there are frames.\n This label_list is also added as an attribute of the Video object.\n :return: 1D list of ILabel objs\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "1D list of ILabel objs",
"docstring_tokens": [
"1D",
"list",
"of",
"ILabel",
"objs"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,... |
42d87771294b25c0b541d7d10c509285134b9e73 | jscheytt/endo-loc | feature_extraction/ft_descriptor.py | [
"Apache-2.0"
] | Python | adjust_list_lengths | null | def adjust_list_lengths(self):
"""
Validate label list length. Truncate or extend if necessary.
:return:
"""
if self.frames:
if len(self.label_list) > len(self.frames):
del self.label_list[len(self.frames):]
elif len(self.label_list) < len(... |
Validate label list length. Truncate or extend if necessary.
:return:
| Validate label list length. Truncate or extend if necessary. | [
"Validate",
"label",
"list",
"length",
".",
"Truncate",
"or",
"extend",
"if",
"necessary",
"."
] | def adjust_list_lengths(self):
if self.frames:
if len(self.label_list) > len(self.frames):
del self.label_list[len(self.frames):]
elif len(self.label_list) < len(self.frames):
last_elem = self.label_list[-1]
while len(self.label_list) < len... | [
"def",
"adjust_list_lengths",
"(",
"self",
")",
":",
"if",
"self",
".",
"frames",
":",
"if",
"len",
"(",
"self",
".",
"label_list",
")",
">",
"len",
"(",
"self",
".",
"frames",
")",
":",
"del",
"self",
".",
"label_list",
"[",
"len",
"(",
"self",
".... | Validate label list length. | [
"Validate",
"label",
"list",
"length",
"."
] | [
"\"\"\"\n Validate label list length. Truncate or extend if necessary.\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
42d87771294b25c0b541d7d10c509285134b9e73 | jscheytt/endo-loc | feature_extraction/ft_descriptor.py | [
"Apache-2.0"
] | Python | discard_obsolete_frames | null | def discard_obsolete_frames(self):
"""
Delete frames with ADS label.
:return:
"""
import label_import.label as l
for idx in reversed(range(len(self.label_list))):
if self.label_list[idx] == l.ILabelValue.ADS.value:
del self.frames[idx]
... |
Delete frames with ADS label.
:return:
| Delete frames with ADS label. | [
"Delete",
"frames",
"with",
"ADS",
"label",
"."
] | def discard_obsolete_frames(self):
import label_import.label as l
for idx in reversed(range(len(self.label_list))):
if self.label_list[idx] == l.ILabelValue.ADS.value:
del self.frames[idx]
del self.label_list[idx] | [
"def",
"discard_obsolete_frames",
"(",
"self",
")",
":",
"import",
"label_import",
".",
"label",
"as",
"l",
"for",
"idx",
"in",
"reversed",
"(",
"range",
"(",
"len",
"(",
"self",
".",
"label_list",
")",
")",
")",
":",
"if",
"self",
".",
"label_list",
"... | Delete frames with ADS label. | [
"Delete",
"frames",
"with",
"ADS",
"label",
"."
] | [
"\"\"\"\n Delete frames with ADS label.\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
42d87771294b25c0b541d7d10c509285134b9e73 | jscheytt/endo-loc | feature_extraction/ft_descriptor.py | [
"Apache-2.0"
] | Python | write_label_list | null | def write_label_list(self, filename):
"""
Write label list to a CSV file.
:param filename: file to write to
:return:
"""
import csv
from debug.debug import LogCont
with LogCont("Write label list to CSV file"):
with open(filename, 'w', newline='... |
Write label list to a CSV file.
:param filename: file to write to
:return:
| Write label list to a CSV file. | [
"Write",
"label",
"list",
"to",
"a",
"CSV",
"file",
"."
] | def write_label_list(self, filename):
import csv
from debug.debug import LogCont
with LogCont("Write label list to CSV file"):
with open(filename, 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=hlp.VAL_SEP, quotechar='|', quoting=csv.QUOTE_MINIMAL... | [
"def",
"write_label_list",
"(",
"self",
",",
"filename",
")",
":",
"import",
"csv",
"from",
"debug",
".",
"debug",
"import",
"LogCont",
"with",
"LogCont",
"(",
"\"Write label list to CSV file\"",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
",",
"n... | Write label list to a CSV file. | [
"Write",
"label",
"list",
"to",
"a",
"CSV",
"file",
"."
] | [
"\"\"\"\n Write label list to a CSV file.\n :param filename: file to write to\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7c68284767f4ffb04699f7edf54ae78a3447dbdc | jscheytt/endo-loc | label_import/label_importer.py | [
"Apache-2.0"
] | Python | reduce_label_value | <not_specific> | def reduce_label_value(label_value):
"""
For binary classification, reduce the 7 labels to only 2.
:param label_value: ILabelValue obj
:return: ILabelValue obj of IN or OUT only
"""
switcher = {
lb.ILabelValue.MOVING_IN: lb.ILabelValue.IN,
lb.ILabelValue.MOVING_OUT: lb.ILabelValu... |
For binary classification, reduce the 7 labels to only 2.
:param label_value: ILabelValue obj
:return: ILabelValue obj of IN or OUT only
| For binary classification, reduce the 7 labels to only 2. | [
"For",
"binary",
"classification",
"reduce",
"the",
"7",
"labels",
"to",
"only",
"2",
"."
] | def reduce_label_value(label_value):
switcher = {
lb.ILabelValue.MOVING_IN: lb.ILabelValue.IN,
lb.ILabelValue.MOVING_OUT: lb.ILabelValue.IN,
lb.ILabelValue.IN_BETWEEN: lb.ILabelValue.IN,
lb.ILabelValue.EXIT: lb.ILabelValue.IN,
}
return switcher.get(label_value, label_value) | [
"def",
"reduce_label_value",
"(",
"label_value",
")",
":",
"switcher",
"=",
"{",
"lb",
".",
"ILabelValue",
".",
"MOVING_IN",
":",
"lb",
".",
"ILabelValue",
".",
"IN",
",",
"lb",
".",
"ILabelValue",
".",
"MOVING_OUT",
":",
"lb",
".",
"ILabelValue",
".",
"... | For binary classification, reduce the 7 labels to only 2. | [
"For",
"binary",
"classification",
"reduce",
"the",
"7",
"labels",
"to",
"only",
"2",
"."
] | [
"\"\"\"\n For binary classification, reduce the 7 labels to only 2.\n :param label_value: ILabelValue obj\n :return: ILabelValue obj of IN or OUT only\n \"\"\""
] | [
{
"param": "label_value",
"type": null
}
] | {
"returns": [
{
"docstring": "ILabelValue obj of IN or OUT only",
"docstring_tokens": [
"ILabelValue",
"obj",
"of",
"IN",
"or",
"OUT",
"only"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "label_v... |
7c68284767f4ffb04699f7edf54ae78a3447dbdc | jscheytt/endo-loc | label_import/label_importer.py | [
"Apache-2.0"
] | Python | read_labels | <not_specific> | def read_labels(filename):
"""
Retrieve all labels from a textfile.
:param filename: Path to textfile
:return: List of ILabel objs
"""
file_cont = get_textfile_as_str(filename)
ilabels = get_labels_from_mlstring(file_cont)
return ilabels |
Retrieve all labels from a textfile.
:param filename: Path to textfile
:return: List of ILabel objs
| Retrieve all labels from a textfile. | [
"Retrieve",
"all",
"labels",
"from",
"a",
"textfile",
"."
] | def read_labels(filename):
file_cont = get_textfile_as_str(filename)
ilabels = get_labels_from_mlstring(file_cont)
return ilabels | [
"def",
"read_labels",
"(",
"filename",
")",
":",
"file_cont",
"=",
"get_textfile_as_str",
"(",
"filename",
")",
"ilabels",
"=",
"get_labels_from_mlstring",
"(",
"file_cont",
")",
"return",
"ilabels"
] | Retrieve all labels from a textfile. | [
"Retrieve",
"all",
"labels",
"from",
"a",
"textfile",
"."
] | [
"\"\"\"\n Retrieve all labels from a textfile.\n :param filename: Path to textfile\n :return: List of ILabel objs\n \"\"\""
] | [
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": "List of ILabel objs",
"docstring_tokens": [
"List",
"of",
"ILabel",
"objs"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": "Path to textfile"... |
7c68284767f4ffb04699f7edf54ae78a3447dbdc | jscheytt/endo-loc | label_import/label_importer.py | [
"Apache-2.0"
] | Python | read_label_list | <not_specific> | def read_label_list(filename):
"""
Read a list of label values from a CSV file.
:param filename: Path to the CSV file
:return: 1D list of label values
"""
import helper.helper as hlp
label_list = []
with LogCont("Read labels from CSV"):
with open(filename, newline='') as csvfile:... |
Read a list of label values from a CSV file.
:param filename: Path to the CSV file
:return: 1D list of label values
| Read a list of label values from a CSV file. | [
"Read",
"a",
"list",
"of",
"label",
"values",
"from",
"a",
"CSV",
"file",
"."
] | def read_label_list(filename):
import helper.helper as hlp
label_list = []
with LogCont("Read labels from CSV"):
with open(filename, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=hlp.VAL_SEP, quotechar='|')
for row in reader:
label_list.append... | [
"def",
"read_label_list",
"(",
"filename",
")",
":",
"import",
"helper",
".",
"helper",
"as",
"hlp",
"label_list",
"=",
"[",
"]",
"with",
"LogCont",
"(",
"\"Read labels from CSV\"",
")",
":",
"with",
"open",
"(",
"filename",
",",
"newline",
"=",
"''",
")",... | Read a list of label values from a CSV file. | [
"Read",
"a",
"list",
"of",
"label",
"values",
"from",
"a",
"CSV",
"file",
"."
] | [
"\"\"\"\n Read a list of label values from a CSV file.\n :param filename: Path to the CSV file\n :return: 1D list of label values\n \"\"\""
] | [
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": "1D list of label values",
"docstring_tokens": [
"1D",
"list",
"of",
"label",
"values"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring":... |
6fc7c422b45d089f732fd8a446417b0acf09b5ee | jscheytt/endo-loc | vis/geometry.py | [
"Apache-2.0"
] | Python | resize_img | <not_specific> | def resize_img(img, fx=.5, fy=.5, interpolation=cv2.INTER_LINEAR):
"""
Resize an image so e. g. it can be displayed fully on the screen.
:param img:
:param fx: scaling factor in x
:param fy: scaling factor in y
:param interpolation:
:return:
"""
return cv2.resize(img, None, fx=fx,... |
Resize an image so e. g. it can be displayed fully on the screen.
:param img:
:param fx: scaling factor in x
:param fy: scaling factor in y
:param interpolation:
:return:
| Resize an image so e. g. it can be displayed fully on the screen. | [
"Resize",
"an",
"image",
"so",
"e",
".",
"g",
".",
"it",
"can",
"be",
"displayed",
"fully",
"on",
"the",
"screen",
"."
] | def resize_img(img, fx=.5, fy=.5, interpolation=cv2.INTER_LINEAR):
return cv2.resize(img, None, fx=fx, fy=fy, interpolation=interpolation) | [
"def",
"resize_img",
"(",
"img",
",",
"fx",
"=",
".5",
",",
"fy",
"=",
".5",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_LINEAR",
")",
":",
"return",
"cv2",
".",
"resize",
"(",
"img",
",",
"None",
",",
"fx",
"=",
"fx",
",",
"fy",
"=",
"fy",
"... | Resize an image so e. g. it can be displayed fully on the screen. | [
"Resize",
"an",
"image",
"so",
"e",
".",
"g",
".",
"it",
"can",
"be",
"displayed",
"fully",
"on",
"the",
"screen",
"."
] | [
"\"\"\"\n Resize an image so e. g. it can be displayed fully on the screen.\n :param img: \n :param fx: scaling factor in x\n :param fy: scaling factor in y\n :param interpolation: \n :return: \n \"\"\""
] | [
{
"param": "img",
"type": null
},
{
"param": "fx",
"type": null
},
{
"param": "fy",
"type": null
},
{
"param": "interpolation",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"... |
6fc7c422b45d089f732fd8a446417b0acf09b5ee | jscheytt/endo-loc | vis/geometry.py | [
"Apache-2.0"
] | Python | fill_img_for_fullscreen | <not_specific> | def fill_img_for_fullscreen(img):
"""
Add black borders to top/bottom or left/right so as to scale to fullscreen
keeping the image aspect ratio.
:param img:
:return:
"""
screen_width, screen_height = dsp.get_screen_dims()
img_width, img_height = get_img_dims(img)
ratio_screen = scr... |
Add black borders to top/bottom or left/right so as to scale to fullscreen
keeping the image aspect ratio.
:param img:
:return:
| Add black borders to top/bottom or left/right so as to scale to fullscreen
keeping the image aspect ratio. | [
"Add",
"black",
"borders",
"to",
"top",
"/",
"bottom",
"or",
"left",
"/",
"right",
"so",
"as",
"to",
"scale",
"to",
"fullscreen",
"keeping",
"the",
"image",
"aspect",
"ratio",
"."
] | def fill_img_for_fullscreen(img):
screen_width, screen_height = dsp.get_screen_dims()
img_width, img_height = get_img_dims(img)
ratio_screen = screen_width / screen_height
ratio_img = img_width / img_height
ratio_of_ratios = ratio_screen / ratio_img
if ratio_of_ratios >= 1.0:
new_width =... | [
"def",
"fill_img_for_fullscreen",
"(",
"img",
")",
":",
"screen_width",
",",
"screen_height",
"=",
"dsp",
".",
"get_screen_dims",
"(",
")",
"img_width",
",",
"img_height",
"=",
"get_img_dims",
"(",
"img",
")",
"ratio_screen",
"=",
"screen_width",
"/",
"screen_he... | Add black borders to top/bottom or left/right so as to scale to fullscreen
keeping the image aspect ratio. | [
"Add",
"black",
"borders",
"to",
"top",
"/",
"bottom",
"or",
"left",
"/",
"right",
"so",
"as",
"to",
"scale",
"to",
"fullscreen",
"keeping",
"the",
"image",
"aspect",
"ratio",
"."
] | [
"\"\"\"\n Add black borders to top/bottom or left/right so as to scale to fullscreen\n keeping the image aspect ratio.\n :param img: \n :return: \n \"\"\""
] | [
{
"param": "img",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"... |
47d9b783e176331b8d305ae3819e566add6c7459 | jscheytt/endo-loc | vis/classify_live.py | [
"Apache-2.0"
] | Python | display_predict_on_frame | null | def display_predict_on_frame(frame, skip_frames=0, predict_downscaled=True, display_downscaled=False,
h_c=True, s_c=True, v_c=True):
"""
Display a video stream and classify each frame live.
:param frame:
:param skip_frames:
:param predict_downscaled: predict on a downsca... |
Display a video stream and classify each frame live.
:param frame:
:param skip_frames:
:param predict_downscaled: predict on a downscaled version of the frame
:param display_downscaled: display a downscaled version of the frame
:param h_c: predict on hue channel
:param s_c: predict on satur... | Display a video stream and classify each frame live. | [
"Display",
"a",
"video",
"stream",
"and",
"classify",
"each",
"frame",
"live",
"."
] | def display_predict_on_frame(frame, skip_frames=0, predict_downscaled=True, display_downscaled=False,
h_c=True, s_c=True, v_c=True):
global PREV_LABEL
label = PREV_LABEL
prepped = geom.fill_img_for_fullscreen(frame)
dst = prepped
if skip_frames == 0 or (skip_frames > 0 a... | [
"def",
"display_predict_on_frame",
"(",
"frame",
",",
"skip_frames",
"=",
"0",
",",
"predict_downscaled",
"=",
"True",
",",
"display_downscaled",
"=",
"False",
",",
"h_c",
"=",
"True",
",",
"s_c",
"=",
"True",
",",
"v_c",
"=",
"True",
")",
":",
"global",
... | Display a video stream and classify each frame live. | [
"Display",
"a",
"video",
"stream",
"and",
"classify",
"each",
"frame",
"live",
"."
] | [
"\"\"\"\n Display a video stream and classify each frame live.\n :param frame:\n :param skip_frames:\n :param predict_downscaled: predict on a downscaled version of the frame\n :param display_downscaled: display a downscaled version of the frame\n :param h_c: predict on hue channel\n :param s_c... | [
{
"param": "frame",
"type": null
},
{
"param": "skip_frames",
"type": null
},
{
"param": "predict_downscaled",
"type": null
},
{
"param": "display_downscaled",
"type": null
},
{
"param": "h_c",
"type": null
},
{
"param": "s_c",
"type": null
},
... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "frame",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
47d9b783e176331b8d305ae3819e566add6c7459 | jscheytt/endo-loc | vis/classify_live.py | [
"Apache-2.0"
] | Python | predict_label | <not_specific> | def predict_label(classifier, ft_vec):
"""
Predict the class label of the incoming feature vector
based on the input classifier.
:param classifier: sklearn classifier
:param ft_vec: normalized feature vector
:return: ILabelValue.IN or .OUT
"""
value = s.predict_single_ft_vec(classifier,... |
Predict the class label of the incoming feature vector
based on the input classifier.
:param classifier: sklearn classifier
:param ft_vec: normalized feature vector
:return: ILabelValue.IN or .OUT
| Predict the class label of the incoming feature vector
based on the input classifier. | [
"Predict",
"the",
"class",
"label",
"of",
"the",
"incoming",
"feature",
"vector",
"based",
"on",
"the",
"input",
"classifier",
"."
] | def predict_label(classifier, ft_vec):
value = s.predict_single_ft_vec(classifier, ft_vec)
return ll.ILabelValue(value) | [
"def",
"predict_label",
"(",
"classifier",
",",
"ft_vec",
")",
":",
"value",
"=",
"s",
".",
"predict_single_ft_vec",
"(",
"classifier",
",",
"ft_vec",
")",
"return",
"ll",
".",
"ILabelValue",
"(",
"value",
")"
] | Predict the class label of the incoming feature vector
based on the input classifier. | [
"Predict",
"the",
"class",
"label",
"of",
"the",
"incoming",
"feature",
"vector",
"based",
"on",
"the",
"input",
"classifier",
"."
] | [
"\"\"\"\n Predict the class label of the incoming feature vector\n based on the input classifier.\n :param classifier: sklearn classifier \n :param ft_vec: normalized feature vector\n :return: ILabelValue.IN or .OUT\n \"\"\""
] | [
{
"param": "classifier",
"type": null
},
{
"param": "ft_vec",
"type": null
}
] | {
"returns": [
{
"docstring": "ILabelValue.IN or .OUT",
"docstring_tokens": [
"ILabelValue",
".",
"IN",
"or",
".",
"OUT"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "classifier",
"type": null,
... |
47d9b783e176331b8d305ae3819e566add6c7459 | jscheytt/endo-loc | vis/classify_live.py | [
"Apache-2.0"
] | Python | draw_label | null | def draw_label(img, label):
"""
Draw a text showing which label has been detected.
:param img: image to be drawn on
:param label: ILabelValue
:return:
"""
width, height = geom.get_img_dims(img)
font_scale = 0.003 * height
position = (int(0.04 * width), int(0.12 * height))
font ... |
Draw a text showing which label has been detected.
:param img: image to be drawn on
:param label: ILabelValue
:return:
| Draw a text showing which label has been detected. | [
"Draw",
"a",
"text",
"showing",
"which",
"label",
"has",
"been",
"detected",
"."
] | def draw_label(img, label):
width, height = geom.get_img_dims(img)
font_scale = 0.003 * height
position = (int(0.04 * width), int(0.12 * height))
font = cv2.FONT_HERSHEY_SIMPLEX
thickness_inline = int(3 * font_scale)
line_type = cv2.LINE_AA
color_outline = (0, 0, 0)
thickness_outline = i... | [
"def",
"draw_label",
"(",
"img",
",",
"label",
")",
":",
"width",
",",
"height",
"=",
"geom",
".",
"get_img_dims",
"(",
"img",
")",
"font_scale",
"=",
"0.003",
"*",
"height",
"position",
"=",
"(",
"int",
"(",
"0.04",
"*",
"width",
")",
",",
"int",
... | Draw a text showing which label has been detected. | [
"Draw",
"a",
"text",
"showing",
"which",
"label",
"has",
"been",
"detected",
"."
] | [
"\"\"\"\n Draw a text showing which label has been detected.\n :param img: image to be drawn on\n :param label: ILabelValue\n :return: \n \"\"\""
] | [
{
"param": "img",
"type": null
},
{
"param": "label",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": "image to be drawn on",
"docstring_tokens": [
"image",
"to",
... |
47d9b783e176331b8d305ae3819e566add6c7459 | jscheytt/endo-loc | vis/classify_live.py | [
"Apache-2.0"
] | Python | draw_menu | null | def draw_menu(img):
"""
Draw the menu. So far this is only a text in the right corner about 'Q for quit'.
:param img: image to be drawn on
:return:
"""
width, height = geom.get_img_dims(img)
font_scale = 0.0012 * height
position = (int(0.8 * width), int(0.07 * height))
font = cv2.F... |
Draw the menu. So far this is only a text in the right corner about 'Q for quit'.
:param img: image to be drawn on
:return:
| Draw the menu. So far this is only a text in the right corner about 'Q for quit'. | [
"Draw",
"the",
"menu",
".",
"So",
"far",
"this",
"is",
"only",
"a",
"text",
"in",
"the",
"right",
"corner",
"about",
"'",
"Q",
"for",
"quit",
"'",
"."
] | def draw_menu(img):
width, height = geom.get_img_dims(img)
font_scale = 0.0012 * height
position = (int(0.8 * width), int(0.07 * height))
font = cv2.FONT_HERSHEY_SIMPLEX
thickness = int(2 * font_scale)
line_type = cv2.LINE_AA
text = "Press 'Q' to quit"
color = (255, 255, 255)
cv2.put... | [
"def",
"draw_menu",
"(",
"img",
")",
":",
"width",
",",
"height",
"=",
"geom",
".",
"get_img_dims",
"(",
"img",
")",
"font_scale",
"=",
"0.0012",
"*",
"height",
"position",
"=",
"(",
"int",
"(",
"0.8",
"*",
"width",
")",
",",
"int",
"(",
"0.07",
"*... | Draw the menu. | [
"Draw",
"the",
"menu",
"."
] | [
"\"\"\"\n Draw the menu. So far this is only a text in the right corner about 'Q for quit'.\n :param img: image to be drawn on\n :return: \n \"\"\""
] | [
{
"param": "img",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": "image to be drawn on",
"docstring_tokens": [
"image",
"to",
... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | clamp | <not_specific> | def clamp(n, minn, maxn):
"""
Clamp an integer to a certain range.
:param n: int to be clamped
:param minn: lower bound
:param maxn: upper bound
:return: clamped int
"""
return min(max(n, minn), maxn) |
Clamp an integer to a certain range.
:param n: int to be clamped
:param minn: lower bound
:param maxn: upper bound
:return: clamped int
| Clamp an integer to a certain range. | [
"Clamp",
"an",
"integer",
"to",
"a",
"certain",
"range",
"."
] | def clamp(n, minn, maxn):
return min(max(n, minn), maxn) | [
"def",
"clamp",
"(",
"n",
",",
"minn",
",",
"maxn",
")",
":",
"return",
"min",
"(",
"max",
"(",
"n",
",",
"minn",
")",
",",
"maxn",
")"
] | Clamp an integer to a certain range. | [
"Clamp",
"an",
"integer",
"to",
"a",
"certain",
"range",
"."
] | [
"\"\"\"\n Clamp an integer to a certain range.\n :param n: int to be clamped\n :param minn: lower bound\n :param maxn: upper bound\n :return: clamped int\n \"\"\""
] | [
{
"param": "n",
"type": null
},
{
"param": "minn",
"type": null
},
{
"param": "maxn",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "n",
"type": null,
"docstring": "int to be clamped",
"docstring_tokens": [
"int",
"to",
"be"... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | flatten_int | <not_specific> | def flatten_int(l):
"""
Flatten a multi-dimensional list to a one-dimensional and convert all values to integers.
:param l: list of lists with values that can be cast to int
:return: flattened int list
"""
return [int(item) for sublist in l for item in sublist] |
Flatten a multi-dimensional list to a one-dimensional and convert all values to integers.
:param l: list of lists with values that can be cast to int
:return: flattened int list
| Flatten a multi-dimensional list to a one-dimensional and convert all values to integers. | [
"Flatten",
"a",
"multi",
"-",
"dimensional",
"list",
"to",
"a",
"one",
"-",
"dimensional",
"and",
"convert",
"all",
"values",
"to",
"integers",
"."
] | def flatten_int(l):
return [int(item) for sublist in l for item in sublist] | [
"def",
"flatten_int",
"(",
"l",
")",
":",
"return",
"[",
"int",
"(",
"item",
")",
"for",
"sublist",
"in",
"l",
"for",
"item",
"in",
"sublist",
"]"
] | Flatten a multi-dimensional list to a one-dimensional and convert all values to integers. | [
"Flatten",
"a",
"multi",
"-",
"dimensional",
"list",
"to",
"a",
"one",
"-",
"dimensional",
"and",
"convert",
"all",
"values",
"to",
"integers",
"."
] | [
"\"\"\"\n Flatten a multi-dimensional list to a one-dimensional and convert all values to integers.\n :param l: list of lists with values that can be cast to int\n :return: flattened int list\n \"\"\""
] | [
{
"param": "l",
"type": null
}
] | {
"returns": [
{
"docstring": "flattened int list",
"docstring_tokens": [
"flattened",
"int",
"list"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "l",
"type": null,
"docstring": "list of lists with values that can be... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | file_length | <not_specific> | def file_length(filename):
"""
Get byte length of a file.
:param filename: Path to file
:return: Byte length of file
"""
try:
f = open(filename)
ret = int(os.fstat(f.fileno()).st_size)
except FileNotFoundError:
ret = -1
return ret |
Get byte length of a file.
:param filename: Path to file
:return: Byte length of file
| Get byte length of a file. | [
"Get",
"byte",
"length",
"of",
"a",
"file",
"."
] | def file_length(filename):
try:
f = open(filename)
ret = int(os.fstat(f.fileno()).st_size)
except FileNotFoundError:
ret = -1
return ret | [
"def",
"file_length",
"(",
"filename",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"filename",
")",
"ret",
"=",
"int",
"(",
"os",
".",
"fstat",
"(",
"f",
".",
"fileno",
"(",
")",
")",
".",
"st_size",
")",
"except",
"FileNotFoundError",
":",
"ret",... | Get byte length of a file. | [
"Get",
"byte",
"length",
"of",
"a",
"file",
"."
] | [
"\"\"\"\n Get byte length of a file.\n :param filename: Path to file\n :return: Byte length of file\n \"\"\""
] | [
{
"param": "filename",
"type": null
}
] | {
"returns": [
{
"docstring": "Byte length of file",
"docstring_tokens": [
"Byte",
"length",
"of",
"file"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": "Path to file",
... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | xml_elements_equal | <not_specific> | def xml_elements_equal(e1, e2):
"""
Compare 2 XML elements by content.
:param e1: first XML element
:param e2: second XML element
:return: True if two xml elements are the same by content
"""
if e1.tag != e2.tag:
return False
if e1.text != e2.text:
return False
if e1.... |
Compare 2 XML elements by content.
:param e1: first XML element
:param e2: second XML element
:return: True if two xml elements are the same by content
| Compare 2 XML elements by content. | [
"Compare",
"2",
"XML",
"elements",
"by",
"content",
"."
] | def xml_elements_equal(e1, e2):
if e1.tag != e2.tag:
return False
if e1.text != e2.text:
return False
if e1.tail != e2.tail:
return False
if e1.attrib != e2.attrib:
return False
if len(e1) != len(e2):
return False
return all(xml_elements_equal(c1, c2) for ... | [
"def",
"xml_elements_equal",
"(",
"e1",
",",
"e2",
")",
":",
"if",
"e1",
".",
"tag",
"!=",
"e2",
".",
"tag",
":",
"return",
"False",
"if",
"e1",
".",
"text",
"!=",
"e2",
".",
"text",
":",
"return",
"False",
"if",
"e1",
".",
"tail",
"!=",
"e2",
... | Compare 2 XML elements by content. | [
"Compare",
"2",
"XML",
"elements",
"by",
"content",
"."
] | [
"\"\"\"\n Compare 2 XML elements by content.\n :param e1: first XML element\n :param e2: second XML element\n :return: True if two xml elements are the same by content\n \"\"\""
] | [
{
"param": "e1",
"type": null
},
{
"param": "e2",
"type": null
}
] | {
"returns": [
{
"docstring": "True if two xml elements are the same by content",
"docstring_tokens": [
"True",
"if",
"two",
"xml",
"elements",
"are",
"the",
"same",
"by",
"content"
],
"type": null
}
],
... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | maxval_of_2dlist | <not_specific> | def maxval_of_2dlist(ll):
"""
Get maximum value in a list of lists.
:param ll: 2D list
:return: max value in the 2D list
"""
maxval = 0
for l in ll:
maxval = max(l)
return maxval |
Get maximum value in a list of lists.
:param ll: 2D list
:return: max value in the 2D list
| Get maximum value in a list of lists. | [
"Get",
"maximum",
"value",
"in",
"a",
"list",
"of",
"lists",
"."
] | def maxval_of_2dlist(ll):
maxval = 0
for l in ll:
maxval = max(l)
return maxval | [
"def",
"maxval_of_2dlist",
"(",
"ll",
")",
":",
"maxval",
"=",
"0",
"for",
"l",
"in",
"ll",
":",
"maxval",
"=",
"max",
"(",
"l",
")",
"return",
"maxval"
] | Get maximum value in a list of lists. | [
"Get",
"maximum",
"value",
"in",
"a",
"list",
"of",
"lists",
"."
] | [
"\"\"\"\n Get maximum value in a list of lists.\n :param ll: 2D list\n :return: max value in the 2D list\n \"\"\""
] | [
{
"param": "ll",
"type": null
}
] | {
"returns": [
{
"docstring": "max value in the 2D list",
"docstring_tokens": [
"max",
"value",
"in",
"the",
"2D",
"list"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "ll",
"type": null,
"docs... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | reverse_enum | null | def reverse_enum(l):
"""
Generator for reverse traversal with access to the index.
:param l:
:return:
"""
for index in reversed(range(len(l))):
yield index, l[index] |
Generator for reverse traversal with access to the index.
:param l:
:return:
| Generator for reverse traversal with access to the index. | [
"Generator",
"for",
"reverse",
"traversal",
"with",
"access",
"to",
"the",
"index",
"."
] | def reverse_enum(l):
for index in reversed(range(len(l))):
yield index, l[index] | [
"def",
"reverse_enum",
"(",
"l",
")",
":",
"for",
"index",
"in",
"reversed",
"(",
"range",
"(",
"len",
"(",
"l",
")",
")",
")",
":",
"yield",
"index",
",",
"l",
"[",
"index",
"]"
] | Generator for reverse traversal with access to the index. | [
"Generator",
"for",
"reverse",
"traversal",
"with",
"access",
"to",
"the",
"index",
"."
] | [
"\"\"\"\n Generator for reverse traversal with access to the index.\n :param l: \n :return: \n \"\"\""
] | [
{
"param": "l",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "l",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | log | null | def log(message):
"""
Log an info message to the standard loggers.
:param message:
:return:
"""
logging.info(message) |
Log an info message to the standard loggers.
:param message:
:return:
| Log an info message to the standard loggers. | [
"Log",
"an",
"info",
"message",
"to",
"the",
"standard",
"loggers",
"."
] | def log(message):
logging.info(message) | [
"def",
"log",
"(",
"message",
")",
":",
"logging",
".",
"info",
"(",
"message",
")"
] | Log an info message to the standard loggers. | [
"Log",
"an",
"info",
"message",
"to",
"the",
"standard",
"loggers",
"."
] | [
"\"\"\"\n Log an info message to the standard loggers.\n :param message: \n :return: \n \"\"\""
] | [
{
"param": "message",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | compare_imgs_by_hist | <not_specific> | def compare_imgs_by_hist(img1, img2):
"""
Compare two images by their histograms.
The histograms are compared by their correlation.
:param img1:
:param img2:
:return: 1.0 if images are identical, <1.0 if not, 0 if histograms
have different shapes (e. g. because of gray to RGB comparison)
... |
Compare two images by their histograms.
The histograms are compared by their correlation.
:param img1:
:param img2:
:return: 1.0 if images are identical, <1.0 if not, 0 if histograms
have different shapes (e. g. because of gray to RGB comparison)
| Compare two images by their histograms.
The histograms are compared by their correlation. | [
"Compare",
"two",
"images",
"by",
"their",
"histograms",
".",
"The",
"histograms",
"are",
"compared",
"by",
"their",
"correlation",
"."
] | def compare_imgs_by_hist(img1, img2):
hist1 = get_histogram(img1)
hist2 = get_histogram(img2)
if hist1.shape != hist2.shape:
return 0
return cv2.compareHist(hist1, hist2, cv2.HISTCMP_CORREL) | [
"def",
"compare_imgs_by_hist",
"(",
"img1",
",",
"img2",
")",
":",
"hist1",
"=",
"get_histogram",
"(",
"img1",
")",
"hist2",
"=",
"get_histogram",
"(",
"img2",
")",
"if",
"hist1",
".",
"shape",
"!=",
"hist2",
".",
"shape",
":",
"return",
"0",
"return",
... | Compare two images by their histograms. | [
"Compare",
"two",
"images",
"by",
"their",
"histograms",
"."
] | [
"\"\"\"\n Compare two images by their histograms.\n The histograms are compared by their correlation.\n :param img1: \n :param img2: \n :return: 1.0 if images are identical, <1.0 if not, 0 if histograms\n have different shapes (e. g. because of gray to RGB comparison)\n \"\"\""
] | [
{
"param": "img1",
"type": null
},
{
"param": "img2",
"type": null
}
] | {
"returns": [
{
"docstring": "1.0 if images are identical, <1.0 if not, 0 if histograms\nhave different shapes (e. g. because of gray to RGB comparison)",
"docstring_tokens": [
"1",
".",
"0",
"if",
"images",
"are",
"identical",
"<1",
... |
785a224e2eb8d95a3a27404c5232c053889be4e6 | jscheytt/endo-loc | helper/helper.py | [
"Apache-2.0"
] | Python | imgs_different | <not_specific> | def imgs_different(img1, img2):
"""
Compares two images by their histogram correlation.
:param img1:
:param img2:
:return: True if different, False if identical
"""
return compare_imgs_by_hist(img1, img2) != 1.0 |
Compares two images by their histogram correlation.
:param img1:
:param img2:
:return: True if different, False if identical
| Compares two images by their histogram correlation. | [
"Compares",
"two",
"images",
"by",
"their",
"histogram",
"correlation",
"."
] | def imgs_different(img1, img2):
return compare_imgs_by_hist(img1, img2) != 1.0 | [
"def",
"imgs_different",
"(",
"img1",
",",
"img2",
")",
":",
"return",
"compare_imgs_by_hist",
"(",
"img1",
",",
"img2",
")",
"!=",
"1.0"
] | Compares two images by their histogram correlation. | [
"Compares",
"two",
"images",
"by",
"their",
"histogram",
"correlation",
"."
] | [
"\"\"\"\n Compares two images by their histogram correlation.\n :param img1: \n :param img2: \n :return: True if different, False if identical\n \"\"\""
] | [
{
"param": "img1",
"type": null
},
{
"param": "img2",
"type": null
}
] | {
"returns": [
{
"docstring": "True if different, False if identical",
"docstring_tokens": [
"True",
"if",
"different",
"False",
"if",
"identical"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "img1",
... |
86e09dcb1f7bc9fbf72ece3ec3349bffac818f78 | GoSz/tf-skelcode | text_model/utils.py | [
"Apache-2.0"
] | Python | position_embedding | <not_specific> | def position_embedding(seq_batch, pos_embed_size):
"""
Generate position embedding with tensorflow, using Transformer pos_embed.
Args:
seq_batch: sequence batch => [batch_size, max_seq_len, embedding_size].
pos_embed_size: dimension of position embeddings.
Returns:
Tensor of po... |
Generate position embedding with tensorflow, using Transformer pos_embed.
Args:
seq_batch: sequence batch => [batch_size, max_seq_len, embedding_size].
pos_embed_size: dimension of position embeddings.
Returns:
Tensor of position embedding => [batch_size, max_seq_len, pos_embed_si... | Generate position embedding with tensorflow, using Transformer pos_embed. | [
"Generate",
"position",
"embedding",
"with",
"tensorflow",
"using",
"Transformer",
"pos_embed",
"."
] | def position_embedding(seq_batch, pos_embed_size):
with tf.name_scope("position_embedding"):
assert (pos_embed_size % 2 == 0), "position embedding size must be 2x"
batch_shape = seq_batch.get_shape().as_list()
batch_size = tf.shape(seq_batch)[0]
max_seq_len = batch_shape[1]
... | [
"def",
"position_embedding",
"(",
"seq_batch",
",",
"pos_embed_size",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"\"position_embedding\"",
")",
":",
"assert",
"(",
"pos_embed_size",
"%",
"2",
"==",
"0",
")",
",",
"\"position embedding size must be 2x\"",
"bat... | Generate position embedding with tensorflow, using Transformer pos_embed. | [
"Generate",
"position",
"embedding",
"with",
"tensorflow",
"using",
"Transformer",
"pos_embed",
"."
] | [
"\"\"\"\n Generate position embedding with tensorflow, using Transformer pos_embed.\n\n Args:\n seq_batch: sequence batch => [batch_size, max_seq_len, embedding_size].\n pos_embed_size: dimension of position embeddings.\n\n Returns:\n Tensor of position embedding => [batch_size, max_se... | [
{
"param": "seq_batch",
"type": null
},
{
"param": "pos_embed_size",
"type": null
}
] | {
"returns": [
{
"docstring": "Tensor of position embedding => [batch_size, max_seq_len, pos_embed_size].",
"docstring_tokens": [
"Tensor",
"of",
"position",
"embedding",
"=",
">",
"[",
"batch_size",
"max_seq_len",
"pos_em... |
9abe85b0a650679dacec8fc64bd7e82517d778fe | GoSz/tf-skelcode | text_model/data.py | [
"Apache-2.0"
] | Python | encode | <not_specific> | def encode(self, sentence, add_bos_eos=False, max_len=None, split=None):
"""
Convert a sentence to a list of ids, with special tokens added.
Args:
sentence: If `split` is `None`, sentence is a list of tokens.
Else sentence is a single string with tokens separated by ... |
Convert a sentence to a list of ids, with special tokens added.
Args:
sentence: If `split` is `None`, sentence is a list of tokens.
Else sentence is a single string with tokens separated by `split`
add_bos_eos: If `True`, BOS/EOS will be added.
max_l... | Convert a sentence to a list of ids, with special tokens added. | [
"Convert",
"a",
"sentence",
"to",
"a",
"list",
"of",
"ids",
"with",
"special",
"tokens",
"added",
"."
] | def encode(self, sentence, add_bos_eos=False, max_len=None, split=None):
if split:
sentence = sentence.split(split)
if add_bos_eos:
sentence = [Vocabulary.BOS] + sentence + [Vocabulary.EOS]
word_ids = [ self.word_to_id(word) for word in sentence ]
return np.array(... | [
"def",
"encode",
"(",
"self",
",",
"sentence",
",",
"add_bos_eos",
"=",
"False",
",",
"max_len",
"=",
"None",
",",
"split",
"=",
"None",
")",
":",
"if",
"split",
":",
"sentence",
"=",
"sentence",
".",
"split",
"(",
"split",
")",
"if",
"add_bos_eos",
... | Convert a sentence to a list of ids, with special tokens added. | [
"Convert",
"a",
"sentence",
"to",
"a",
"list",
"of",
"ids",
"with",
"special",
"tokens",
"added",
"."
] | [
"\"\"\"\n Convert a sentence to a list of ids, with special tokens added.\n\n Args:\n sentence: If `split` is `None`, sentence is a list of tokens.\n Else sentence is a single string with tokens separated by `split`\n add_bos_eos: If `True`, BOS/EOS will be added.\... | [
{
"param": "self",
"type": null
},
{
"param": "sentence",
"type": null
},
{
"param": "add_bos_eos",
"type": null
},
{
"param": "max_len",
"type": null
},
{
"param": "split",
"type": null
}
] | {
"returns": [
{
"docstring": "A numpy array of token ids for the input sentence.",
"docstring_tokens": [
"A",
"numpy",
"array",
"of",
"token",
"ids",
"for",
"the",
"input",
"sentence",
"."
],
"type": n... |
9abe85b0a650679dacec8fc64bd7e82517d778fe | GoSz/tf-skelcode | text_model/data.py | [
"Apache-2.0"
] | Python | read_wembed | <not_specific> | def read_wembed(wembed_file):
"""
Read word embedding from file.
Args:
wembed_file: file path of word embedding.
Returns:
Numpy array of word embeddings.
"""
if wembed_file.find(".hdf5") != -1:
return read_wembed_hdf5(wembed_file)
else:
return read_wembed_tx... |
Read word embedding from file.
Args:
wembed_file: file path of word embedding.
Returns:
Numpy array of word embeddings.
| Read word embedding from file. | [
"Read",
"word",
"embedding",
"from",
"file",
"."
] | def read_wembed(wembed_file):
if wembed_file.find(".hdf5") != -1:
return read_wembed_hdf5(wembed_file)
else:
return read_wembed_txt(wembed_file) | [
"def",
"read_wembed",
"(",
"wembed_file",
")",
":",
"if",
"wembed_file",
".",
"find",
"(",
"\".hdf5\"",
")",
"!=",
"-",
"1",
":",
"return",
"read_wembed_hdf5",
"(",
"wembed_file",
")",
"else",
":",
"return",
"read_wembed_txt",
"(",
"wembed_file",
")"
] | Read word embedding from file. | [
"Read",
"word",
"embedding",
"from",
"file",
"."
] | [
"\"\"\"\n Read word embedding from file.\n\n Args:\n wembed_file: file path of word embedding.\n\n Returns:\n Numpy array of word embeddings.\n \"\"\""
] | [
{
"param": "wembed_file",
"type": null
}
] | {
"returns": [
{
"docstring": "Numpy array of word embeddings.",
"docstring_tokens": [
"Numpy",
"array",
"of",
"word",
"embeddings",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "wembed_file",
"... |
9abe85b0a650679dacec8fc64bd7e82517d778fe | GoSz/tf-skelcode | text_model/data.py | [
"Apache-2.0"
] | Python | read_wembed_hdf5 | <not_specific> | def read_wembed_hdf5(wembed_file, name="word_embeddings"):
"""
Read word embedding from HDF5 file.
Args:
name: name of hdf5 dataset.
"""
import h5py
print("Reading word embeddings from hdf5 file: %s" % (wembed_file))
with h5py.File(wembed_file, 'r') as fin:
dataset = fin[nam... |
Read word embedding from HDF5 file.
Args:
name: name of hdf5 dataset.
| Read word embedding from HDF5 file. | [
"Read",
"word",
"embedding",
"from",
"HDF5",
"file",
"."
] | def read_wembed_hdf5(wembed_file, name="word_embeddings"):
import h5py
print("Reading word embeddings from hdf5 file: %s" % (wembed_file))
with h5py.File(wembed_file, 'r') as fin:
dataset = fin[name]
embeddings = np.zeros([dataset.shape[0], dataset.shape[1]], dtype=NP_DTYPE)
embeddin... | [
"def",
"read_wembed_hdf5",
"(",
"wembed_file",
",",
"name",
"=",
"\"word_embeddings\"",
")",
":",
"import",
"h5py",
"print",
"(",
"\"Reading word embeddings from hdf5 file: %s\"",
"%",
"(",
"wembed_file",
")",
")",
"with",
"h5py",
".",
"File",
"(",
"wembed_file",
... | Read word embedding from HDF5 file. | [
"Read",
"word",
"embedding",
"from",
"HDF5",
"file",
"."
] | [
"\"\"\"\n Read word embedding from HDF5 file.\n\n Args:\n name: name of hdf5 dataset.\n \"\"\""
] | [
{
"param": "wembed_file",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wembed_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": "name of hdf5 dataset.",
... |
9abe85b0a650679dacec8fc64bd7e82517d778fe | GoSz/tf-skelcode | text_model/data.py | [
"Apache-2.0"
] | Python | read_wembed_txt | <not_specific> | def read_wembed_txt(wembed_file, sep=" "):
"""
Read word embedding from text file.
Args:
sep: seperate character within a single line.
"""
print("Reading word embeddings from txt file: %s" % (wembed_file))
with open(wembed_file) as fin:
header = fin.readline().strip('\n').split(... |
Read word embedding from text file.
Args:
sep: seperate character within a single line.
| Read word embedding from text file. | [
"Read",
"word",
"embedding",
"from",
"text",
"file",
"."
] | def read_wembed_txt(wembed_file, sep=" "):
print("Reading word embeddings from txt file: %s" % (wembed_file))
with open(wembed_file) as fin:
header = fin.readline().strip('\n').split(sep)
num = int(header[0])
dim = int(header[1])
embeddings = np.zeros(shape=[num, dim], dtype=NP_D... | [
"def",
"read_wembed_txt",
"(",
"wembed_file",
",",
"sep",
"=",
"\" \"",
")",
":",
"print",
"(",
"\"Reading word embeddings from txt file: %s\"",
"%",
"(",
"wembed_file",
")",
")",
"with",
"open",
"(",
"wembed_file",
")",
"as",
"fin",
":",
"header",
"=",
"fin",... | Read word embedding from text file. | [
"Read",
"word",
"embedding",
"from",
"text",
"file",
"."
] | [
"\"\"\"\n Read word embedding from text file.\n\n Args:\n sep: seperate character within a single line.\n \"\"\""
] | [
{
"param": "wembed_file",
"type": null
},
{
"param": "sep",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "wembed_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sep",
"type": null,
"docstring": "seperate character within ... |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | _init_tfrec_dataset | <not_specific> | def _init_tfrec_dataset(self, data_file, need_shuffle):
"""
Get dataset from tf record file.
"""
dataset = tf.data.TFRecordDataset(data_file)
def parse_func(example_proto):
## NOTE define proto parse function for tfrecord here
proto_dict = {}
p... |
Get dataset from tf record file.
| Get dataset from tf record file. | [
"Get",
"dataset",
"from",
"tf",
"record",
"file",
"."
] | def _init_tfrec_dataset(self, data_file, need_shuffle):
dataset = tf.data.TFRecordDataset(data_file)
def parse_func(example_proto):
proto_dict = {}
parsed_features = tf.parse_single_example(example_proto, proto_dict)
return parsed_features
dataset = dataset.pr... | [
"def",
"_init_tfrec_dataset",
"(",
"self",
",",
"data_file",
",",
"need_shuffle",
")",
":",
"dataset",
"=",
"tf",
".",
"data",
".",
"TFRecordDataset",
"(",
"data_file",
")",
"def",
"parse_func",
"(",
"example_proto",
")",
":",
"proto_dict",
"=",
"{",
"}",
... | Get dataset from tf record file. | [
"Get",
"dataset",
"from",
"tf",
"record",
"file",
"."
] | [
"\"\"\"\n Get dataset from tf record file.\n \"\"\"",
"## NOTE define proto parse function for tfrecord here"
] | [
{
"param": "self",
"type": null
},
{
"param": "data_file",
"type": null
},
{
"param": "need_shuffle",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_file",
"type": null,
"docstring": null,
"docstring_token... |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | _init_word_embedding | null | def _init_word_embedding(self):
"""
Init word embeddings for text token ids.
"""
## use pre-trained word embedding or not
self.pre_trained_wembed = self.options.get("pre_trained_wembed", None)
shape = [self.vocab_size, self.wembed_dim]
with tf.variable_scope("word... |
Init word embeddings for text token ids.
| Init word embeddings for text token ids. | [
"Init",
"word",
"embeddings",
"for",
"text",
"token",
"ids",
"."
] | def _init_word_embedding(self):
self.pre_trained_wembed = self.options.get("pre_trained_wembed", None)
shape = [self.vocab_size, self.wembed_dim]
with tf.variable_scope("word_embeddings"), tf.device("/cpu:0"):
if self.pre_trained_wembed:
self.wembed_init = tf.placehol... | [
"def",
"_init_word_embedding",
"(",
"self",
")",
":",
"self",
".",
"pre_trained_wembed",
"=",
"self",
".",
"options",
".",
"get",
"(",
"\"pre_trained_wembed\"",
",",
"None",
")",
"shape",
"=",
"[",
"self",
".",
"vocab_size",
",",
"self",
".",
"wembed_dim",
... | Init word embeddings for text token ids. | [
"Init",
"word",
"embeddings",
"for",
"text",
"token",
"ids",
"."
] | [
"\"\"\"\n Init word embeddings for text token ids.\n \"\"\"",
"## use pre-trained word embedding or not",
"## finetune pre-trained wembed or not"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | _build_tf_graph | null | def _build_tf_graph(self):
"""
Build the whole task defined model graph.
"""
## NOTE get model input from dataset
self._init_input()
## NOTE build model graph
self.model_output = self.inference(self.model_input)
## NOTE build loss function
if sel... |
Build the whole task defined model graph.
| Build the whole task defined model graph. | [
"Build",
"the",
"whole",
"task",
"defined",
"model",
"graph",
"."
] | def _build_tf_graph(self):
self._init_input()
self.model_output = self.inference(self.model_input)
if self.is_training:
self.loss_out = self.get_loss(self.model_output, self.model_label) | [
"def",
"_build_tf_graph",
"(",
"self",
")",
":",
"self",
".",
"_init_input",
"(",
")",
"self",
".",
"model_output",
"=",
"self",
".",
"inference",
"(",
"self",
".",
"model_input",
")",
"if",
"self",
".",
"is_training",
":",
"self",
".",
"loss_out",
"=",
... | Build the whole task defined model graph. | [
"Build",
"the",
"whole",
"task",
"defined",
"model",
"graph",
"."
] | [
"\"\"\"\n Build the whole task defined model graph.\n \"\"\"",
"## NOTE get model input from dataset",
"## NOTE build model graph",
"## NOTE build loss function"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | inference | <not_specific> | def inference(self, *args, **kwargs):
"""
Build model graph, run model inference with inputs.
"""
self.model_output = self._inference(*args, **kwargs)
return self.model_output |
Build model graph, run model inference with inputs.
| Build model graph, run model inference with inputs. | [
"Build",
"model",
"graph",
"run",
"model",
"inference",
"with",
"inputs",
"."
] | def inference(self, *args, **kwargs):
self.model_output = self._inference(*args, **kwargs)
return self.model_output | [
"def",
"inference",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"model_output",
"=",
"self",
".",
"_inference",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"return",
"self",
".",
"model_output"
] | Build model graph, run model inference with inputs. | [
"Build",
"model",
"graph",
"run",
"model",
"inference",
"with",
"inputs",
"."
] | [
"\"\"\"\n Build model graph, run model inference with inputs.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | _init_input | null | def _init_input(self):
"""
Get model input from dataset.
"""
## NOTE manage model inputs with dataset
self.model_input, self.model_label = self.dataset.iterator.get_next() |
Get model input from dataset.
| Get model input from dataset. | [
"Get",
"model",
"input",
"from",
"dataset",
"."
] | def _init_input(self):
self.model_input, self.model_label = self.dataset.iterator.get_next() | [
"def",
"_init_input",
"(",
"self",
")",
":",
"self",
".",
"model_input",
",",
"self",
".",
"model_label",
"=",
"self",
".",
"dataset",
".",
"iterator",
".",
"get_next",
"(",
")"
] | Get model input from dataset. | [
"Get",
"model",
"input",
"from",
"dataset",
"."
] | [
"\"\"\"\n Get model input from dataset.\n \"\"\"",
"## NOTE manage model inputs with dataset"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | _inference | <not_specific> | def _inference(self, model_input):
"""
Run model inference with inputs.
"""
## NOTE put model inference logic here
return { "pred" : None } |
Run model inference with inputs.
| Run model inference with inputs. | [
"Run",
"model",
"inference",
"with",
"inputs",
"."
] | def _inference(self, model_input):
return { "pred" : None } | [
"def",
"_inference",
"(",
"self",
",",
"model_input",
")",
":",
"return",
"{",
"\"pred\"",
":",
"None",
"}"
] | Run model inference with inputs. | [
"Run",
"model",
"inference",
"with",
"inputs",
"."
] | [
"\"\"\"\n Run model inference with inputs.\n \"\"\"",
"## NOTE put model inference logic here"
] | [
{
"param": "self",
"type": null
},
{
"param": "model_input",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_input",
"type": null,
"docstring": null,
"docstring_tok... |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | _get_loss | <not_specific> | def _get_loss(self, model_out, label):
"""
Get model loss with inference results and labels.
"""
## NOTE put model loss logic here
return { "loss" : None } |
Get model loss with inference results and labels.
| Get model loss with inference results and labels. | [
"Get",
"model",
"loss",
"with",
"inference",
"results",
"and",
"labels",
"."
] | def _get_loss(self, model_out, label):
return { "loss" : None } | [
"def",
"_get_loss",
"(",
"self",
",",
"model_out",
",",
"label",
")",
":",
"return",
"{",
"\"loss\"",
":",
"None",
"}"
] | Get model loss with inference results and labels. | [
"Get",
"model",
"loss",
"with",
"inference",
"results",
"and",
"labels",
"."
] | [
"\"\"\"\n Get model loss with inference results and labels.\n \"\"\"",
"## NOTE put model loss logic here"
] | [
{
"param": "self",
"type": null
},
{
"param": "model_out",
"type": null
},
{
"param": "label",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_out",
"type": null,
"docstring": null,
"docstring_token... |
e9f9e52ca11318363abf7e76a8bbfca6b40588a6 | GoSz/tf-skelcode | text_model/model_skeleton.py | [
"Apache-2.0"
] | Python | predict | null | def predict(option_file, model_path, input_file, output_file):
"""
Predict with pre-trained tf model.
Args:
option_file: json option file for model.
model_path: tf model file path.
input_file: predict inputs.
output_file: predict results.
Returns:
None
"""
... |
Predict with pre-trained tf model.
Args:
option_file: json option file for model.
model_path: tf model file path.
input_file: predict inputs.
output_file: predict results.
Returns:
None
| Predict with pre-trained tf model. | [
"Predict",
"with",
"pre",
"-",
"trained",
"tf",
"model",
"."
] | def predict(option_file, model_path, input_file, output_file):
options = load_options(option_file)
options["train_file"] = input_file
options["need_evaluate"] = False
gpu_num = 1
with tf.device("/cpu:0"):
dataset = TextModelDataset(options, is_training=False, gpu_num=gpu_num)
assert ... | [
"def",
"predict",
"(",
"option_file",
",",
"model_path",
",",
"input_file",
",",
"output_file",
")",
":",
"options",
"=",
"load_options",
"(",
"option_file",
")",
"options",
"[",
"\"train_file\"",
"]",
"=",
"input_file",
"options",
"[",
"\"need_evaluate\"",
"]",... | Predict with pre-trained tf model. | [
"Predict",
"with",
"pre",
"-",
"trained",
"tf",
"model",
"."
] | [
"\"\"\"\n Predict with pre-trained tf model.\n\n Args:\n option_file: json option file for model.\n model_path: tf model file path.\n input_file: predict inputs.\n output_file: predict results.\n\n Returns:\n None\n \"\"\"",
"## modify options for predict",
"## pre... | [
{
"param": "option_file",
"type": null
},
{
"param": "model_path",
"type": null
},
{
"param": "input_file",
"type": null
},
{
"param": "output_file",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "option_file",
"type": null,
"docstring": "json option file for model.",
"docstring_tokens": [
"json",
... |
7857b1d345f9729862576ebd3d0ede0462522d90 | GoSz/tf-skelcode | utils/common.py | [
"Apache-2.0"
] | Python | clip_grad | <not_specific> | def clip_grad(grads_and_vars, clip):
"""
Clip gradients by global norm.
Args:
grads_and_vars: list of (gradient, variable) tuples.
clip: global norm.
Returns:
Clipped grad_and_vars.
"""
grad_list = [g for g, v in grads_and_vars]
var_list = [v for g, v in grads_and_... |
Clip gradients by global norm.
Args:
grads_and_vars: list of (gradient, variable) tuples.
clip: global norm.
Returns:
Clipped grad_and_vars.
| Clip gradients by global norm. | [
"Clip",
"gradients",
"by",
"global",
"norm",
"."
] | def clip_grad(grads_and_vars, clip):
grad_list = [g for g, v in grads_and_vars]
var_list = [v for g, v in grads_and_vars]
clipped_grads, norm = tf.clip_by_global_norm(grad_list, clip)
return list(zip(clipped_grads, var_list)) | [
"def",
"clip_grad",
"(",
"grads_and_vars",
",",
"clip",
")",
":",
"grad_list",
"=",
"[",
"g",
"for",
"g",
",",
"v",
"in",
"grads_and_vars",
"]",
"var_list",
"=",
"[",
"v",
"for",
"g",
",",
"v",
"in",
"grads_and_vars",
"]",
"clipped_grads",
",",
"norm",... | Clip gradients by global norm. | [
"Clip",
"gradients",
"by",
"global",
"norm",
"."
] | [
"\"\"\"\n Clip gradients by global norm.\n\n Args:\n grads_and_vars: list of (gradient, variable) tuples.\n clip: global norm.\n\n Returns:\n Clipped grad_and_vars.\n \"\"\""
] | [
{
"param": "grads_and_vars",
"type": null
},
{
"param": "clip",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "grads_and_vars",
"type": null,
"docstring": "list of (gradient, variable) tuples.",
"docstring_tokens": [
"... |
d4572335487558a332dbb0e9a763540393cbd600 | GoSz/tf-skelcode | text_model/example/simple_text_clf.py | [
"Apache-2.0"
] | Python | _init_tfrec_dataset | <not_specific> | def _init_tfrec_dataset(self, data_file, need_shuffle):
"""
Get dataset from tf record file.
"""
dataset = tf.data.TFRecordDataset(data_file)
def parse_func(example_proto):
proto_dict = { "label" : tf.FixedLenFeature(shape=[self.class_num], dtype=tf.int64),
... |
Get dataset from tf record file.
| Get dataset from tf record file. | [
"Get",
"dataset",
"from",
"tf",
"record",
"file",
"."
] | def _init_tfrec_dataset(self, data_file, need_shuffle):
dataset = tf.data.TFRecordDataset(data_file)
def parse_func(example_proto):
proto_dict = { "label" : tf.FixedLenFeature(shape=[self.class_num], dtype=tf.int64),
"txt_ids" : tf.FixedLenFeature(shape=[self.max... | [
"def",
"_init_tfrec_dataset",
"(",
"self",
",",
"data_file",
",",
"need_shuffle",
")",
":",
"dataset",
"=",
"tf",
".",
"data",
".",
"TFRecordDataset",
"(",
"data_file",
")",
"def",
"parse_func",
"(",
"example_proto",
")",
":",
"proto_dict",
"=",
"{",
"\"labe... | Get dataset from tf record file. | [
"Get",
"dataset",
"from",
"tf",
"record",
"file",
"."
] | [
"\"\"\"\n Get dataset from tf record file.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data_file",
"type": null
},
{
"param": "need_shuffle",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_file",
"type": null,
"docstring": null,
"docstring_token... |
d4572335487558a332dbb0e9a763540393cbd600 | GoSz/tf-skelcode | text_model/example/simple_text_clf.py | [
"Apache-2.0"
] | Python | _build_tf_graph | null | def _build_tf_graph(self):
"""
Build the whole task defined model graph.
"""
self._init_input()
self.inference(self.txt_token_ids, self.txt_len)
if self.is_training:
self.get_loss(self.model_output, self.model_label) |
Build the whole task defined model graph.
| Build the whole task defined model graph. | [
"Build",
"the",
"whole",
"task",
"defined",
"model",
"graph",
"."
] | def _build_tf_graph(self):
self._init_input()
self.inference(self.txt_token_ids, self.txt_len)
if self.is_training:
self.get_loss(self.model_output, self.model_label) | [
"def",
"_build_tf_graph",
"(",
"self",
")",
":",
"self",
".",
"_init_input",
"(",
")",
"self",
".",
"inference",
"(",
"self",
".",
"txt_token_ids",
",",
"self",
".",
"txt_len",
")",
"if",
"self",
".",
"is_training",
":",
"self",
".",
"get_loss",
"(",
"... | Build the whole task defined model graph. | [
"Build",
"the",
"whole",
"task",
"defined",
"model",
"graph",
"."
] | [
"\"\"\"\n Build the whole task defined model graph.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d4572335487558a332dbb0e9a763540393cbd600 | GoSz/tf-skelcode | text_model/example/simple_text_clf.py | [
"Apache-2.0"
] | Python | inference | <not_specific> | def inference(self, *args, **kwargs):
"""
Build model graph, run model inference with inputs.
"""
self.model_output = self._text_clf(*args, **kwargs)
return self.model_output |
Build model graph, run model inference with inputs.
| Build model graph, run model inference with inputs. | [
"Build",
"model",
"graph",
"run",
"model",
"inference",
"with",
"inputs",
"."
] | def inference(self, *args, **kwargs):
self.model_output = self._text_clf(*args, **kwargs)
return self.model_output | [
"def",
"inference",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"model_output",
"=",
"self",
".",
"_text_clf",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"return",
"self",
".",
"model_output"
] | Build model graph, run model inference with inputs. | [
"Build",
"model",
"graph",
"run",
"model",
"inference",
"with",
"inputs",
"."
] | [
"\"\"\"\n Build model graph, run model inference with inputs.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d4572335487558a332dbb0e9a763540393cbd600 | GoSz/tf-skelcode | text_model/example/simple_text_clf.py | [
"Apache-2.0"
] | Python | _init_input | null | def _init_input(self):
"""
Get model input from dataset.
"""
self.txt_label, self.txt_token_ids, self.txt_len = self.dataset.iterator.get_next() |
Get model input from dataset.
| Get model input from dataset. | [
"Get",
"model",
"input",
"from",
"dataset",
"."
] | def _init_input(self):
self.txt_label, self.txt_token_ids, self.txt_len = self.dataset.iterator.get_next() | [
"def",
"_init_input",
"(",
"self",
")",
":",
"self",
".",
"txt_label",
",",
"self",
".",
"txt_token_ids",
",",
"self",
".",
"txt_len",
"=",
"self",
".",
"dataset",
".",
"iterator",
".",
"get_next",
"(",
")"
] | Get model input from dataset. | [
"Get",
"model",
"input",
"from",
"dataset",
"."
] | [
"\"\"\"\n Get model input from dataset.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d4572335487558a332dbb0e9a763540393cbd600 | GoSz/tf-skelcode | text_model/example/simple_text_clf.py | [
"Apache-2.0"
] | Python | _softmax_log_loss | <not_specific> | def _softmax_log_loss(self, clf_out, label):
"""
Softmax log-likelihood loss.
Args:
clf_out: output of the classifier.
label: one-hot label of sentences, tensor => [batch_size, class_num].
Returns:
A dict of all outputs.
"""
label = t... |
Softmax log-likelihood loss.
Args:
clf_out: output of the classifier.
label: one-hot label of sentences, tensor => [batch_size, class_num].
Returns:
A dict of all outputs.
| Softmax log-likelihood loss. | [
"Softmax",
"log",
"-",
"likelihood",
"loss",
"."
] | def _softmax_log_loss(self, clf_out, label):
label = tf.cast(label, dtype=TF_DTYPE)
max_x = tf.reduce_max(clf_out["fc_out"], axis=1, keep_dims=True)
log_likelihood = tf.reduce_sum(label * (clf_out["fc_out"] - max_x), axis=1) - \
tf.log(tf.reduce_sum(tf.exp(clf_out["fc_ou... | [
"def",
"_softmax_log_loss",
"(",
"self",
",",
"clf_out",
",",
"label",
")",
":",
"label",
"=",
"tf",
".",
"cast",
"(",
"label",
",",
"dtype",
"=",
"TF_DTYPE",
")",
"max_x",
"=",
"tf",
".",
"reduce_max",
"(",
"clf_out",
"[",
"\"fc_out\"",
"]",
",",
"a... | Softmax log-likelihood loss. | [
"Softmax",
"log",
"-",
"likelihood",
"loss",
"."
] | [
"\"\"\"\n Softmax log-likelihood loss.\n\n Args:\n clf_out: output of the classifier.\n label: one-hot label of sentences, tensor => [batch_size, class_num].\n\n Returns:\n A dict of all outputs.\n \"\"\"",
"## get regular term"
] | [
{
"param": "self",
"type": null
},
{
"param": "clf_out",
"type": null
},
{
"param": "label",
"type": null
}
] | {
"returns": [
{
"docstring": "A dict of all outputs.",
"docstring_tokens": [
"A",
"dict",
"of",
"all",
"outputs",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docst... |
d4572335487558a332dbb0e9a763540393cbd600 | GoSz/tf-skelcode | text_model/example/simple_text_clf.py | [
"Apache-2.0"
] | Python | predict | null | def predict(option_file, model_path, input_file, output_file):
"""
Predict with pre-trained tf model.
Args:
option_file: json option file for model.
model_path: tf model file path.
input_file: predict inputs.
output_file: predict results.
Returns:
None
"""
... |
Predict with pre-trained tf model.
Args:
option_file: json option file for model.
model_path: tf model file path.
input_file: predict inputs.
output_file: predict results.
Returns:
None
| Predict with pre-trained tf model. | [
"Predict",
"with",
"pre",
"-",
"trained",
"tf",
"model",
"."
] | def predict(option_file, model_path, input_file, output_file):
options = load_options(option_file)
options["train_file"] = input_file
options["need_evaluate"] = False
gpu_num = 1
with tf.device("/cpu:0"):
dataset = TextClfDataset(options, is_training=False, gpu_num=gpu_num)
assert op... | [
"def",
"predict",
"(",
"option_file",
",",
"model_path",
",",
"input_file",
",",
"output_file",
")",
":",
"options",
"=",
"load_options",
"(",
"option_file",
")",
"options",
"[",
"\"train_file\"",
"]",
"=",
"input_file",
"options",
"[",
"\"need_evaluate\"",
"]",... | Predict with pre-trained tf model. | [
"Predict",
"with",
"pre",
"-",
"trained",
"tf",
"model",
"."
] | [
"\"\"\"\n Predict with pre-trained tf model.\n\n Args:\n option_file: json option file for model.\n model_path: tf model file path.\n input_file: predict inputs.\n output_file: predict results.\n\n Returns:\n None\n \"\"\"",
"## modify options for predict",
"## pre... | [
{
"param": "option_file",
"type": null
},
{
"param": "model_path",
"type": null
},
{
"param": "input_file",
"type": null
},
{
"param": "output_file",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "option_file",
"type": null,
"docstring": "json option file for model.",
"docstring_tokens": [
"json",
... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_pse | <not_specific> | def read_pse(filepath, variable_name, url, headers):
"""
Read a .csv file from PSE into a DataFrame.
Parameters
----------
filepath : str
Directory path of file to be read
variable_name : str
Name of variable, e.g. ``solar``
url : str
URL linking to the source websit... |
Read a .csv file from PSE into a DataFrame.
Parameters
----------
filepath : str
Directory path of file to be read
variable_name : str
Name of variable, e.g. ``solar``
url : str
URL linking to the source website where this data comes from
headers : list
List... | Read a .csv file from PSE into a DataFrame.
Parameters
filepath : str
Directory path of file to be read
variable_name : str
Name of variable, e.g. ``solar``
url : str
URL linking to the source website where this data comes from
headers : list
List of strings indicating the level names of the pandas.MultiIndex
for the ... | [
"Read",
"a",
".",
"csv",
"file",
"from",
"PSE",
"into",
"a",
"DataFrame",
".",
"Parameters",
"filepath",
":",
"str",
"Directory",
"path",
"of",
"file",
"to",
"be",
"read",
"variable_name",
":",
"str",
"Name",
"of",
"variable",
"e",
".",
"g",
".",
"`",
... | def read_pse(filepath, variable_name, url, headers):
df = pd.read_csv(
filepath,
sep=';',
encoding='cp1250',
header=0,
index_col=None,
parse_dates=None,
date_parser=None,
dayfirst=False,
decimal=',',
thousands=None,
converters={... | [
"def",
"read_pse",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"encoding",
"=",
"'cp1250'",
",",
"header",
"=",
"0",
",",
"index_col",
"=... | Read a .csv file from PSE into a DataFrame. | [
"Read",
"a",
".",
"csv",
"file",
"from",
"PSE",
"into",
"a",
"DataFrame",
"."
] | [
"\"\"\"\n Read a .csv file from PSE into a DataFrame.\n\n Parameters\n ----------\n filepath : str\n Directory path of file to be read\n variable_name : str\n Name of variable, e.g. ``solar``\n url : str\n URL linking to the source website where this data comes from\n heade... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_ceps | <not_specific> | def read_ceps(filepath, variable_name, url, headers):
'''Read a file from CEPS into a DataFrame'''
df = pd.read_excel(
io=filepath,
header=2,
skiprows=None,
index_col=0,
parse_cols=[0, 1, 2]
)
df.index = pd.to_datetime(df.index.rename('timestamp'))
df.index ... | Read a file from CEPS into a DataFrame | Read a file from CEPS into a DataFrame | [
"Read",
"a",
"file",
"from",
"CEPS",
"into",
"a",
"DataFrame"
] | def read_ceps(filepath, variable_name, url, headers):
df = pd.read_excel(
io=filepath,
header=2,
skiprows=None,
index_col=0,
parse_cols=[0, 1, 2]
)
df.index = pd.to_datetime(df.index.rename('timestamp'))
df.index = df.index.tz_localize('Europe/Brussels', ambiguous... | [
"def",
"read_ceps",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_excel",
"(",
"io",
"=",
"filepath",
",",
"header",
"=",
"2",
",",
"skiprows",
"=",
"None",
",",
"index_col",
"=",
"0",
",",
... | Read a file from CEPS into a DataFrame | [
"Read",
"a",
"file",
"from",
"CEPS",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from CEPS into a DataFrame'''",
"# Translate columns",
"# Create the MultiIndex"
] | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_elia | <not_specific> | def read_elia(filepath, variable_name, url, headers):
'''Read a file from Elia into a DataFrame'''
df = pd.read_excel(
io=filepath,
header=None,
skiprows=4,
index_col=0,
parse_cols=None
)
colmap = {
'Day-Ahead forecast [MW]': {
'region': 'BE',... | Read a file from Elia into a DataFrame | Read a file from Elia into a DataFrame | [
"Read",
"a",
"file",
"from",
"Elia",
"into",
"a",
"DataFrame"
] | def read_elia(filepath, variable_name, url, headers):
df = pd.read_excel(
io=filepath,
header=None,
skiprows=4,
index_col=0,
parse_cols=None
)
colmap = {
'Day-Ahead forecast [MW]': {
'region': 'BE',
'variable': variable,
'at... | [
"def",
"read_elia",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_excel",
"(",
"io",
"=",
"filepath",
",",
"header",
"=",
"None",
",",
"skiprows",
"=",
"4",
",",
"index_col",
"=",
"0",
",",
... | Read a file from Elia into a DataFrame | [
"Read",
"a",
"file",
"from",
"Elia",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from Elia into a DataFrame'''",
"# Drop any column not in colmap",
"# Create the MultiIndex"
] | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_energinet_dk | <not_specific> | def read_energinet_dk(filepath, url, headers):
'''Read a file from energinet.dk into a DataFrame'''
df = pd.read_excel(
io=filepath,
header=2, # the column headers are taken from 3rd row.
# 2nd row also contains header info like in a multiindex,
# i.e. wether the colums are pric... | Read a file from energinet.dk into a DataFrame | Read a file from energinet.dk into a DataFrame | [
"Read",
"a",
"file",
"from",
"energinet",
".",
"dk",
"into",
"a",
"DataFrame"
] | def read_energinet_dk(filepath, url, headers):
df = pd.read_excel(
io=filepath,
header=2,
skiprows=None,
index_col=None,
parse_cols=None,
thousands=','
)
df.index.rename(['date', 'hour'], inplace=True)
df.reset_index(inplace=True)
df['timestamp'] =... | [
"def",
"read_energinet_dk",
"(",
"filepath",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_excel",
"(",
"io",
"=",
"filepath",
",",
"header",
"=",
"2",
",",
"skiprows",
"=",
"None",
",",
"index_col",
"=",
"None",
",",
"parse_cols",
... | Read a file from energinet.dk into a DataFrame | [
"Read",
"a",
"file",
"from",
"energinet",
".",
"dk",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from energinet.dk into a DataFrame'''",
"# the column headers are taken from 3rd row.",
"# 2nd row also contains header info like in a multiindex,",
"# i.e. wether the colums are price or generation data.",
"# However, we will make our own columnnames below.",
"# Row 3 is enough to unambig... | [
{
"param": "filepath",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens"... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_entso_e_portal | <not_specific> | def read_entso_e_portal(filepath, url, headers):
'''Read a file from ENTSO-E into a DataFrame'''
df = pd.read_excel(
io=filepath,
header=9, # 0 indexed, so the column names are actually in the 10th row
skiprows=None,
# create MultiIndex from first 2 columns ['Country', 'Day']
... | Read a file from ENTSO-E into a DataFrame | Read a file from ENTSO-E into a DataFrame | [
"Read",
"a",
"file",
"from",
"ENTSO",
"-",
"E",
"into",
"a",
"DataFrame"
] | def read_entso_e_portal(filepath, url, headers):
df = pd.read_excel(
io=filepath,
header=9,
skiprows=None,
index_col=[0, 1],
parse_cols=None,
na_values=['n.a.']
)
df.columns.names = ['raw_hour']
df = df.stack(level='raw_hour').unstack(level='Country').... | [
"def",
"read_entso_e_portal",
"(",
"filepath",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_excel",
"(",
"io",
"=",
"filepath",
",",
"header",
"=",
"9",
",",
"skiprows",
"=",
"None",
",",
"index_col",
"=",
"[",
"0",
",",
"1",
"... | Read a file from ENTSO-E into a DataFrame | [
"Read",
"a",
"file",
"from",
"ENTSO",
"-",
"E",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from ENTSO-E into a DataFrame'''",
"# 0 indexed, so the column names are actually in the 10th row",
"# create MultiIndex from first 2 columns ['Country', 'Day']",
"# None means: parse all columns",
"# The original data has days and countries in the rows and hours in the",
"# columns. This... | [
{
"param": "filepath",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens"... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_hertz | <not_specific> | def read_hertz(filepath, variable_name, url, headers):
'''Read a file from 50Hertz into a DataFrame'''
df = pd.read_csv(
filepath,
sep=';',
header=3,
index_col='timestamp',
parse_dates={'timestamp': ['Datum', 'Von']},
date_parser=None,
dayfirst=True,
... | Read a file from 50Hertz into a DataFrame | Read a file from 50Hertz into a DataFrame | [
"Read",
"a",
"file",
"from",
"50Hertz",
"into",
"a",
"DataFrame"
] | def read_hertz(filepath, variable_name, url, headers):
df = pd.read_csv(
filepath,
sep=';',
header=3,
index_col='timestamp',
parse_dates={'timestamp': ['Datum', 'Von']},
date_parser=None,
dayfirst=True,
decimal=',',
thousands='.',
conve... | [
"def",
"read_hertz",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"header",
"=",
"3",
",",
"index_col",
"=",
"'timestamp'",
",",
"parse_date... | Read a file from 50Hertz into a DataFrame | [
"Read",
"a",
"file",
"from",
"50Hertz",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from 50Hertz into a DataFrame'''",
"# truncate values in 'time' column after 5th character",
"# Until 2006, and in 2015 (except for wind_generation_pre-offshore),",
"# during the fall dst-transistion, only the",
"# wintertime hour (marked by a B in the data) is reported, the summertime",
"... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_amprion | <not_specific> | def read_amprion(filepath, variable_name, url, headers):
'''Read a file from Amprion into a DataFrame'''
df = pd.read_csv(
filepath,
sep=';',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['Datum', 'Uhrzeit']},
date_parser=None,
dayfirst=True,... | Read a file from Amprion into a DataFrame | Read a file from Amprion into a DataFrame | [
"Read",
"a",
"file",
"from",
"Amprion",
"into",
"a",
"DataFrame"
] | def read_amprion(filepath, variable_name, url, headers):
df = pd.read_csv(
filepath,
sep=';',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['Datum', 'Uhrzeit']},
date_parser=None,
dayfirst=True,
decimal=',',
thousands=None,
... | [
"def",
"read_amprion",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"header",
"=",
"0",
",",
"index_col",
"=",
"'timestamp'",
",",
"parse_da... | Read a file from Amprion into a DataFrame | [
"Read",
"a",
"file",
"from",
"Amprion",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from Amprion into a DataFrame'''",
"# Truncate values in 'time' column after 5th character.",
"# In the years after 2009, during the fall dst-transistion, only the",
"# summertime hour is reported, the wintertime hour is missing in the data.",
"# dst_arr is a boolean array consisting only of... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_tennet | <not_specific> | def read_tennet(filepath, variable_name, url, headers):
'''Read a file from TenneT into a DataFrame'''
df = pd.read_csv(
filepath,
sep=';',
encoding='latin_1',
header=3,
index_col=False,
parse_dates=False,
date_parser=None,
dayfirst=True,
t... | Read a file from TenneT into a DataFrame | Read a file from TenneT into a DataFrame | [
"Read",
"a",
"file",
"from",
"TenneT",
"into",
"a",
"DataFrame"
] | def read_tennet(filepath, variable_name, url, headers):
df = pd.read_csv(
filepath,
sep=';',
encoding='latin_1',
header=3,
index_col=False,
parse_dates=False,
date_parser=None,
dayfirst=True,
thousands=None,
converters=None,
)
r... | [
"def",
"read_tennet",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"encoding",
"=",
"'latin_1'",
",",
"header",
"=",
"3",
",",
"index_col",
... | Read a file from TenneT into a DataFrame | [
"Read",
"a",
"file",
"from",
"TenneT",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from TenneT into a DataFrame'''",
"# Check the rows for irregularities",
"# On the day in March when summertime begins, shift the data forward by",
"# 1 hour, beginning with the 9th quarter-hour, so the index runs again",
"# up to 96",
"# True when summertime ends in October",
"# Instead... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_transnetbw | <not_specific> | def read_transnetbw(filepath, variable_name, url, headers):
'''Read a file from TransnetBW into a DataFrame'''
df = pd.read_csv(
filepath,
sep=';',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['Datum bis', 'Uhrzeit bis']},
date_parser=None,
... | Read a file from TransnetBW into a DataFrame | Read a file from TransnetBW into a DataFrame | [
"Read",
"a",
"file",
"from",
"TransnetBW",
"into",
"a",
"DataFrame"
] | def read_transnetbw(filepath, variable_name, url, headers):
df = pd.read_csv(
filepath,
sep=';',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['Datum bis', 'Uhrzeit bis']},
date_parser=None,
dayfirst=True,
decimal=',',
thousands=N... | [
"def",
"read_transnetbw",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"header",
"=",
"0",
",",
"index_col",
"=",
"'timestamp'",
",",
"parse... | Read a file from TransnetBW into a DataFrame | [
"Read",
"a",
"file",
"from",
"TransnetBW",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from TransnetBW into a DataFrame'''",
"# DST-transistion is conducted 2 hours too late in the data",
"# (hour 4:00-5:00 is repeated instead of 2:00-3:00)",
"# The 2nd column represents the start and the 4th the end of the respective",
"# period. The former has some errors, so we use the latt... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_opsd | <not_specific> | def read_opsd(filepath, url, headers):
'''Read a file from OPSD into a DataFrame'''
df = pd.read_csv(
filepath,
sep=',',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['day']},
date_parser=None,
dayfirst=False,
decimal='.',
tho... | Read a file from OPSD into a DataFrame | Read a file from OPSD into a DataFrame | [
"Read",
"a",
"file",
"from",
"OPSD",
"into",
"a",
"DataFrame"
] | def read_opsd(filepath, url, headers):
df = pd.read_csv(
filepath,
sep=',',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['day']},
date_parser=None,
dayfirst=False,
decimal='.',
thousands=None,
converters=None,
)
l... | [
"def",
"read_opsd",
"(",
"filepath",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"','",
",",
"header",
"=",
"0",
",",
"index_col",
"=",
"'timestamp'",
",",
"parse_dates",
"=",
"{",
"'times... | Read a file from OPSD into a DataFrame | [
"Read",
"a",
"file",
"from",
"OPSD",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from OPSD into a DataFrame'''",
"# The capacities data only has one entry per day, which pandas",
"# interprets as 00:00h. We will broadcast the dayly data for",
"# all quarter-hours of the day until the next given data point.",
"# For this, we we expand the index so it reaches to 23:59 of",... | [
{
"param": "filepath",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens"... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_apg | <not_specific> | def read_apg(filepath, url, headers):
'''Read a file from APG into a DataFrame'''
df = pd.read_csv(
filepath,
sep=';',
encoding='latin_1',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['Von']},
dayfirst=True,
decimal=',',
thou... | Read a file from APG into a DataFrame | Read a file from APG into a DataFrame | [
"Read",
"a",
"file",
"from",
"APG",
"into",
"a",
"DataFrame"
] | def read_apg(filepath, url, headers):
df = pd.read_csv(
filepath,
sep=';',
encoding='latin_1',
header=0,
index_col='timestamp',
parse_dates={'timestamp': ['Von']},
dayfirst=True,
decimal=',',
thousands='.',
converters={'Von': lambda x: ... | [
"def",
"read_apg",
"(",
"filepath",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"encoding",
"=",
"'latin_1'",
",",
"header",
"=",
"0",
",",
"index_col",
"=",
"'timestamp'",
","... | Read a file from APG into a DataFrame | [
"Read",
"a",
"file",
"from",
"APG",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from APG into a DataFrame'''",
"# Format of the raw_hour-column is normally is 01:00:00, 02:00:00 etc.",
"# during the year, but 3A:00:00, 3B:00:00 for the (possibely",
"# DST-transgressing) 3rd hour of every day in October, we truncate the",
"# hours column after 2 characters and replace le... | [
{
"param": "filepath",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens"... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_rte | <not_specific> | def read_rte(filepath, variable_name, url, headers):
'''Read a file from RTE into a DataFrame'''
# pandas.read_csv infers the table dimensions from the header row.
# Since the first row uses only one column, it needs to be read separately
# in order not to mess up the DataFrame
df1 = pd.read_csv(
... | Read a file from RTE into a DataFrame | Read a file from RTE into a DataFrame | [
"Read",
"a",
"file",
"from",
"RTE",
"into",
"a",
"DataFrame"
] | def read_rte(filepath, variable_name, url, headers):
df1 = pd.read_csv(
filepath,
sep='\t',
encoding='cp1252',
compression='zip',
nrows=1,
header=None
)
df2 = pd.read_csv(
filepath,
sep='\t',
encoding='cp1252',
compression='zip'... | [
"def",
"read_rte",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"df1",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"'\\t'",
",",
"encoding",
"=",
"'cp1252'",
",",
"compression",
"=",
"'zip'",
",",
"nrow... | Read a file from RTE into a DataFrame | [
"Read",
"a",
"file",
"from",
"RTE",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from RTE into a DataFrame'''",
"# pandas.read_csv infers the table dimensions from the header row.",
"# Since the first row uses only one column, it needs to be read separately",
"# in order not to mess up the DataFrame",
"# Glue the DataFrames together",
"# set column names",
"# strip t... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read | <not_specific> | def read(data_path, areas, source_name, variable_name, url, res_key,
headers, start_from_user=None, end_from_user=None):
"""
For the sources specified in the sources.yml file, pass each downloaded
file to the correct read function.
Parameters
----------
source_name : str
Name o... |
For the sources specified in the sources.yml file, pass each downloaded
file to the correct read function.
Parameters
----------
source_name : str
Name of source to read files from
variable_name : str
Indicator for subset of data available together in the same files
url : s... | For the sources specified in the sources.yml file, pass each downloaded
file to the correct read function.
Parameters
source_name : str
Name of source to read files from
variable_name : str
Indicator for subset of data available together in the same files
url : str
URL of the Source to be placed in the column-MultiIn... | [
"For",
"the",
"sources",
"specified",
"in",
"the",
"sources",
".",
"yml",
"file",
"pass",
"each",
"downloaded",
"file",
"to",
"the",
"correct",
"read",
"function",
".",
"Parameters",
"source_name",
":",
"str",
"Name",
"of",
"source",
"to",
"read",
"files",
... | def read(data_path, areas, source_name, variable_name, url, res_key,
headers, start_from_user=None, end_from_user=None):
data_set = pd.DataFrame()
variable_dir = os.path.join(data_path, source_name, variable_name)
logger.info('reading %s - %s', source_name, variable_name)
files_existing = sum([... | [
"def",
"read",
"(",
"data_path",
",",
"areas",
",",
"source_name",
",",
"variable_name",
",",
"url",
",",
"res_key",
",",
"headers",
",",
"start_from_user",
"=",
"None",
",",
"end_from_user",
"=",
"None",
")",
":",
"data_set",
"=",
"pd",
".",
"DataFrame",
... | For the sources specified in the sources.yml file, pass each downloaded
file to the correct read function. | [
"For",
"the",
"sources",
"specified",
"in",
"the",
"sources",
".",
"yml",
"file",
"pass",
"each",
"downloaded",
"file",
"to",
"the",
"correct",
"read",
"function",
"."
] | [
"\"\"\"\n For the sources specified in the sources.yml file, pass each downloaded\n file to the correct read function.\n\n Parameters\n ----------\n source_name : str\n Name of source to read files from\n variable_name : str\n Indicator for subset of data available together in the sa... | [
{
"param": "data_path",
"type": null
},
{
"param": "areas",
"type": null
},
{
"param": "source_name",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "res_key",
"type": null
},
{
"par... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "areas",
"type": null,
"docstring": null,
"docstring_toke... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | update_progress | <not_specific> | def update_progress(count, total):
'''
Display or updates a console progress bar.
Parameters
----------
count : int
number of files that have been read so far
total : int
total number aif files
Returns
----------
None
'''
barLength = 50 # Modify this to c... |
Display or updates a console progress bar.
Parameters
----------
count : int
number of files that have been read so far
total : int
total number aif files
Returns
----------
None
| Display or updates a console progress bar.
Parameters
count : int
number of files that have been read so far
total : int
total number aif files
Returns
None | [
"Display",
"or",
"updates",
"a",
"console",
"progress",
"bar",
".",
"Parameters",
"count",
":",
"int",
"number",
"of",
"files",
"that",
"have",
"been",
"read",
"so",
"far",
"total",
":",
"int",
"total",
"number",
"aif",
"files",
"Returns",
"None"
] | def update_progress(count, total):
barLength = 50
status = ""
progress = count / total
if isinstance(progress, int):
progress = float(progress)
if progress >= 1:
progress = 1
status = "Done...\r\n"
block = int(round(barLength * progress))
text = "\rProgress: [{0}] {... | [
"def",
"update_progress",
"(",
"count",
",",
"total",
")",
":",
"barLength",
"=",
"50",
"status",
"=",
"\"\"",
"progress",
"=",
"count",
"/",
"total",
"if",
"isinstance",
"(",
"progress",
",",
"int",
")",
":",
"progress",
"=",
"float",
"(",
"progress",
... | Display or updates a console progress bar. | [
"Display",
"or",
"updates",
"a",
"console",
"progress",
"bar",
"."
] | [
"'''\n Display or updates a console progress bar.\n\n Parameters\n ----------\n count : int\n number of files that have been read so far\n total : int\n total number aif files\n\n Returns\n ----------\n None\n\n '''",
"# Modify this to change the length of the progress bar... | [
{
"param": "count",
"type": null
},
{
"param": "total",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "count",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "total",
"type": null,
"docstring": null,
"docstring_tokens":... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_apg | <not_specific> | def read_apg(filepath, url, headers):
'''Read a file from APG into a DataFrame'''
df = pd.read_csv(
filepath,
sep=';',
encoding='iso-8859-1',
header=0,
index_col=None,
parse_dates=None,
decimal=',',
thousands='.',
)
# Form... | Read a file from APG into a DataFrame | Read a file from APG into a DataFrame | [
"Read",
"a",
"file",
"from",
"APG",
"into",
"a",
"DataFrame"
] | def read_apg(filepath, url, headers):
df = pd.read_csv(
filepath,
sep=';',
encoding='iso-8859-1',
header=0,
index_col=None,
parse_dates=None,
decimal=',',
thousands='.',
)
df['Von'] = df['Von'].str.replace(
'A', '').str.replac... | [
"def",
"read_apg",
"(",
"filepath",
",",
"url",
",",
"headers",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filepath",
",",
"sep",
"=",
"';'",
",",
"encoding",
"=",
"'iso-8859-1'",
",",
"header",
"=",
"0",
",",
"index_col",
"=",
"None",
",",
... | Read a file from APG into a DataFrame | [
"Read",
"a",
"file",
"from",
"APG",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from APG into a DataFrame'''",
"# Format of the raw_hour-column is normally is 01:00:00, 02:00:00 etc.",
"# during the year, but 3A:00:00, 3B:00:00 for the (possibely",
"# DST-transgressing) 3rd hour of every day in October, we truncate the",
"# hours column after 2 characters and replace le... | [
{
"param": "filepath",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens"... |
6599b6bcf0e367281ad6e93694deae296a348004 | ccmonsalve43/Open-System-Data | timeseries_scripts/read.py | [
"MIT"
] | Python | read_rte | <not_specific> | def read_rte(filepath, variable_name, url, headers):
'''Read a file from RTE into a DataFrame'''
#open zip
myzipfile = zipfile.ZipFile(filepath, mode='r')
myzipfile.extractall(path=(os.path.split(filepath)[0]))
#change path from zip to excel
from os import walk
f = []
for (dirpa... | Read a file from RTE into a DataFrame | Read a file from RTE into a DataFrame | [
"Read",
"a",
"file",
"from",
"RTE",
"into",
"a",
"DataFrame"
] | def read_rte(filepath, variable_name, url, headers):
myzipfile = zipfile.ZipFile(filepath, mode='r')
myzipfile.extractall(path=(os.path.split(filepath)[0]))
from os import walk
f = []
for (dirpath, dirnames, filenames) in walk((os.path.split(filepath)[0])):
f.extend(filenames)
br... | [
"def",
"read_rte",
"(",
"filepath",
",",
"variable_name",
",",
"url",
",",
"headers",
")",
":",
"myzipfile",
"=",
"zipfile",
".",
"ZipFile",
"(",
"filepath",
",",
"mode",
"=",
"'r'",
")",
"myzipfile",
".",
"extractall",
"(",
"path",
"=",
"(",
"os",
"."... | Read a file from RTE into a DataFrame | [
"Read",
"a",
"file",
"from",
"RTE",
"into",
"a",
"DataFrame"
] | [
"'''Read a file from RTE into a DataFrame'''",
"#open zip",
"#change path from zip to excel",
"#open excel which is actually tsv",
"#delete the excel as read() throws exception if there are two files in one download directory",
"#this means multiple runthroughs of this script would otherwise not be possib... | [
{
"param": "filepath",
"type": null
},
{
"param": "variable_name",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_name",
"type": null,
"docstring": null,
"docstri... |
b980e94894bd92760ba12b0f19fb670e5d6de067 | ccmonsalve43/Open-System-Data | timeseries_scripts/imputation.py | [
"MIT"
] | Python | find_nan | <not_specific> | def find_nan(df, res_key, headers, patch=False):
'''
Search for missing values in a DataFrame and optionally apply further
functions on each column.
Parameters
----------
df : pandas.DataFrame
DataFrame to inspect and possibly patch
headers : list
List of strings indica... |
Search for missing values in a DataFrame and optionally apply further
functions on each column.
Parameters
----------
df : pandas.DataFrame
DataFrame to inspect and possibly patch
headers : list
List of strings indicating the level names of the pandas.MultiIndex
fo... | Search for missing values in a DataFrame and optionally apply further
functions on each column. | [
"Search",
"for",
"missing",
"values",
"in",
"a",
"DataFrame",
"and",
"optionally",
"apply",
"further",
"functions",
"on",
"each",
"column",
"."
] | def find_nan(df, res_key, headers, patch=False):
nan_table = pd.DataFrame()
patched = pd.DataFrame()
marker_col = pd.Series(np.nan, index=df.index)
if df.empty:
return patched, nan_table
one_period = pd.Timedelta(res_key)
for col_name, col in df.iteritems():
col = col.to_frame()
... | [
"def",
"find_nan",
"(",
"df",
",",
"res_key",
",",
"headers",
",",
"patch",
"=",
"False",
")",
":",
"nan_table",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"patched",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"marker_col",
"=",
"pd",
".",
"Series",
"(",
"... | Search for missing values in a DataFrame and optionally apply further
functions on each column. | [
"Search",
"for",
"missing",
"values",
"in",
"a",
"DataFrame",
"and",
"optionally",
"apply",
"further",
"functions",
"on",
"each",
"column",
"."
] | [
"'''\n Search for missing values in a DataFrame and optionally apply further \n functions on each column.\n\n Parameters\n ---------- \n df : pandas.DataFrame\n DataFrame to inspect and possibly patch\n headers : list\n List of strings indicating the level names of the pandas.Mult... | [
{
"param": "df",
"type": null
},
{
"param": "res_key",
"type": null
},
{
"param": "headers",
"type": null
},
{
"param": "patch",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": "DataFrame to inspect and possibly patch",
"docstring_tokens": [
"DataFrame",
"to",
"inspect",
"and",
"possibly",
"patch"
],
"default"... |
b980e94894bd92760ba12b0f19fb670e5d6de067 | ccmonsalve43/Open-System-Data | timeseries_scripts/imputation.py | [
"MIT"
] | Python | choose_fill_method | <not_specific> | def choose_fill_method(
message, col, col_name, nan_regs, df, marker_col, one_period):
'''
Choose the appropriate function for filling a region of missing values.
Parameters
----------
col : pandas.DataFrame
A column from frame as a separate DataFrame
col_name : tuple
... |
Choose the appropriate function for filling a region of missing values.
Parameters
----------
col : pandas.DataFrame
A column from frame as a separate DataFrame
col_name : tuple
tuple of header levels of column to inspect
nan_regs : pandas.DataFrame
DataFrame with ea... | Choose the appropriate function for filling a region of missing values. | [
"Choose",
"the",
"appropriate",
"function",
"for",
"filling",
"a",
"region",
"of",
"missing",
"values",
"."
] | def choose_fill_method(
message, col, col_name, nan_regs, df, marker_col, one_period):
for i, nan_region in nan_regs.iterrows():
j = 0
if nan_region['span'] <= timedelta(hours=2):
col, marker_col = my_interpolate(
i, j, nan_region, col, col_name, marker_col, nan_r... | [
"def",
"choose_fill_method",
"(",
"message",
",",
"col",
",",
"col_name",
",",
"nan_regs",
",",
"df",
",",
"marker_col",
",",
"one_period",
")",
":",
"for",
"i",
",",
"nan_region",
"in",
"nan_regs",
".",
"iterrows",
"(",
")",
":",
"j",
"=",
"0",
"if",
... | Choose the appropriate function for filling a region of missing values. | [
"Choose",
"the",
"appropriate",
"function",
"for",
"filling",
"a",
"region",
"of",
"missing",
"values",
"."
] | [
"'''\n Choose the appropriate function for filling a region of missing values.\n\n Parameters\n ---------- \n col : pandas.DataFrame\n A column from frame as a separate DataFrame \n col_name : tuple\n tuple of header levels of column to inspect\n nan_regs : pandas.DataFrame\n ... | [
{
"param": "message",
"type": null
},
{
"param": "col",
"type": null
},
{
"param": "col_name",
"type": null
},
{
"param": "nan_regs",
"type": null
},
{
"param": "df",
"type": null
},
{
"param": "marker_col",
"type": null
},
{
"param": "one_... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": null,
"docstring": "An n*1 DataFrame containing co... |
b980e94894bd92760ba12b0f19fb670e5d6de067 | ccmonsalve43/Open-System-Data | timeseries_scripts/imputation.py | [
"MIT"
] | Python | my_interpolate | <not_specific> | def my_interpolate(
i, j, nan_region, col, col_name, marker_col, nan_regs, one_period, message):
'''
Interpolate one missing value region in one column as described by
nan_region.
The default pd.Series.interpolate() function does not work if
interpolation is to be restricted to periods of ... |
Interpolate one missing value region in one column as described by
nan_region.
The default pd.Series.interpolate() function does not work if
interpolation is to be restricted to periods of a certain length.
(A limit-argument can be specified, but it results in longer periods
of missing data ... | Interpolate one missing value region in one column as described by
nan_region.
The default pd.Series.interpolate() function does not work if
interpolation is to be restricted to periods of a certain length.
(A limit-argument can be specified, but it results in longer periods
of missing data to be filled parcially)
Pa... | [
"Interpolate",
"one",
"missing",
"value",
"region",
"in",
"one",
"column",
"as",
"described",
"by",
"nan_region",
".",
"The",
"default",
"pd",
".",
"Series",
".",
"interpolate",
"()",
"function",
"does",
"not",
"work",
"if",
"interpolation",
"is",
"to",
"be"... | def my_interpolate(
i, j, nan_region, col, col_name, marker_col, nan_regs, one_period, message):
if i + 1 == len(nan_regs):
treated = i + 1 - j
logger.info(message + 'interpolated %s up-to-2-hour-span(s) of NaNs',
treated)
to_fill = slice(nan_region['start_idx'] - one... | [
"def",
"my_interpolate",
"(",
"i",
",",
"j",
",",
"nan_region",
",",
"col",
",",
"col_name",
",",
"marker_col",
",",
"nan_regs",
",",
"one_period",
",",
"message",
")",
":",
"if",
"i",
"+",
"1",
"==",
"len",
"(",
"nan_regs",
")",
":",
"treated",
"=",... | Interpolate one missing value region in one column as described by
nan_region. | [
"Interpolate",
"one",
"missing",
"value",
"region",
"in",
"one",
"column",
"as",
"described",
"by",
"nan_region",
"."
] | [
"'''\n Interpolate one missing value region in one column as described by \n nan_region.\n\n The default pd.Series.interpolate() function does not work if\n interpolation is to be restricted to periods of a certain length.\n (A limit-argument can be specified, but it results in longer periods \n o... | [
{
"param": "i",
"type": null
},
{
"param": "j",
"type": null
},
{
"param": "nan_region",
"type": null
},
{
"param": "col",
"type": null
},
{
"param": "col_name",
"type": null
},
{
"param": "marker_col",
"type": null
},
{
"param": "nan_regs"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "i",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "j",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
b980e94894bd92760ba12b0f19fb670e5d6de067 | ccmonsalve43/Open-System-Data | timeseries_scripts/imputation.py | [
"MIT"
] | Python | impute | <not_specific> | def impute(nan_region, col, col_name, nan_regs, df, one_period):
'''
Impute missing value spans longer than one hour based on other TSOs.
Parameters
----------
nan_region : pandas.Series
Contains information on one region of missing data in col
col : pandas.DataFrame
A column fr... |
Impute missing value spans longer than one hour based on other TSOs.
Parameters
----------
nan_region : pandas.Series
Contains information on one region of missing data in col
col : pandas.DataFrame
A column from df as a separate DataFrame
col_name : tuple
tuple of hea... | Impute missing value spans longer than one hour based on other TSOs.
Parameters
| [
"Impute",
"missing",
"value",
"spans",
"longer",
"than",
"one",
"hour",
"based",
"on",
"other",
"TSOs",
".",
"Parameters"
] | def impute(nan_region, col, col_name, nan_regs, df, one_period):
day_before = pd.DatetimeIndex(
freq='15min',
start=nan_region['start_idx'] - timedelta(hours=24),
end=nan_region['start_idx'] - one_period)
to_fill = pd.DatetimeIndex(
freq='15min',
start=nan_region['start_i... | [
"def",
"impute",
"(",
"nan_region",
",",
"col",
",",
"col_name",
",",
"nan_regs",
",",
"df",
",",
"one_period",
")",
":",
"day_before",
"=",
"pd",
".",
"DatetimeIndex",
"(",
"freq",
"=",
"'15min'",
",",
"start",
"=",
"nan_region",
"[",
"'start_idx'",
"]"... | Impute missing value spans longer than one hour based on other TSOs. | [
"Impute",
"missing",
"value",
"spans",
"longer",
"than",
"one",
"hour",
"based",
"on",
"other",
"TSOs",
"."
] | [
"'''\n Impute missing value spans longer than one hour based on other TSOs.\n\n Parameters\n ----------\n nan_region : pandas.Series\n Contains information on one region of missing data in col\n col : pandas.DataFrame\n A column from df as a separate DataFrame \n col_name : tuple\n ... | [
{
"param": "nan_region",
"type": null
},
{
"param": "col",
"type": null
},
{
"param": "col_name",
"type": null
},
{
"param": "nan_regs",
"type": null
},
{
"param": "df",
"type": null
},
{
"param": "one_period",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "nan_region",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col",
"type": null,
"docstring": null,
"docstring_token... |
b980e94894bd92760ba12b0f19fb670e5d6de067 | ccmonsalve43/Open-System-Data | timeseries_scripts/imputation.py | [
"MIT"
] | Python | resample_markers | <not_specific> | def resample_markers(group):
'''Resample marker column from 15 to 60 min
Parameters
----------
group: pd.Series
Series of 4 succeeding quarter-hourly values from the marker column
that have to be combined into one.
Returns
----------
aggregated_marker : str or np.nan
... | Resample marker column from 15 to 60 min
Parameters
----------
group: pd.Series
Series of 4 succeeding quarter-hourly values from the marker column
that have to be combined into one.
Returns
----------
aggregated_marker : str or np.nan
If there were any markers in group... | Resample marker column from 15 to 60 min
Parameters
pd.Series
Series of 4 succeeding quarter-hourly values from the marker column
that have to be combined into one.
Returns
aggregated_marker : str or np.nan
If there were any markers in group: the unique values from the marker
column group joined together in one stri... | [
"Resample",
"marker",
"column",
"from",
"15",
"to",
"60",
"min",
"Parameters",
"pd",
".",
"Series",
"Series",
"of",
"4",
"succeeding",
"quarter",
"-",
"hourly",
"values",
"from",
"the",
"marker",
"column",
"that",
"have",
"to",
"be",
"combined",
"into",
"o... | def resample_markers(group):
if group.notnull().values.any():
unpacked = [mark for line in group if type(line) is str
for mark in line.split(' | ')]
aggregated_marker = ' | '.join(set(unpacked))
else:
aggregated_marker = np.nan
return aggregated_marker | [
"def",
"resample_markers",
"(",
"group",
")",
":",
"if",
"group",
".",
"notnull",
"(",
")",
".",
"values",
".",
"any",
"(",
")",
":",
"unpacked",
"=",
"[",
"mark",
"for",
"line",
"in",
"group",
"if",
"type",
"(",
"line",
")",
"is",
"str",
"for",
... | Resample marker column from 15 to 60 min
Parameters | [
"Resample",
"marker",
"column",
"from",
"15",
"to",
"60",
"min",
"Parameters"
] | [
"'''Resample marker column from 15 to 60 min\n\n Parameters\n ----------\n group: pd.Series\n Series of 4 succeeding quarter-hourly values from the marker column\n that have to be combined into one.\n\n Returns\n ----------\n aggregated_marker : str or np.nan\n If there were a... | [
{
"param": "group",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "group",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8fe0ddc4ce579cccbdad53264fa5ed76f4f27e5d | ccmonsalve43/Open-System-Data | timeseries_scripts/make_json.py | [
"MIT"
] | Python | make_json | <not_specific> | def make_json(data_sets, info_cols, version, changes, headers, areas):
'''
Create a datapackage.json file that complies with the Frictionless
data JSON Table Schema from the information in the column-MultiIndex.
Parameters
----------
data_sets: dict of pandas.DataFrames
A dict with keys... |
Create a datapackage.json file that complies with the Frictionless
data JSON Table Schema from the information in the column-MultiIndex.
Parameters
----------
data_sets: dict of pandas.DataFrames
A dict with keys '15min' and '60min' and values the respective
DataFrames
info_col... | Create a datapackage.json file that complies with the Frictionless
data JSON Table Schema from the information in the column-MultiIndex.
Parameters
dict of pandas.DataFrames
A dict with keys '15min' and '60min' and values the respective
DataFrames
info_cols : dict of strings
Names for non-data columns such as for the... | [
"Create",
"a",
"datapackage",
".",
"json",
"file",
"that",
"complies",
"with",
"the",
"Frictionless",
"data",
"JSON",
"Table",
"Schema",
"from",
"the",
"information",
"in",
"the",
"column",
"-",
"MultiIndex",
".",
"Parameters",
"dict",
"of",
"pandas",
".",
"... | def make_json(data_sets, info_cols, version, changes, headers, areas):
resource_list = '''
- mediatype: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
format: xlsx
path: time_series.xlsx
'''
source_list = ''
schemas_dict = ''
for res_key, df in data_sets.items():
field... | [
"def",
"make_json",
"(",
"data_sets",
",",
"info_cols",
",",
"version",
",",
"changes",
",",
"headers",
",",
"areas",
")",
":",
"resource_list",
"=",
"'''\n- mediatype: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n format: xlsx\n path: time_series.xlsx\n''... | Create a datapackage.json file that complies with the Frictionless
data JSON Table Schema from the information in the column-MultiIndex. | [
"Create",
"a",
"datapackage",
".",
"json",
"file",
"that",
"complies",
"with",
"the",
"Frictionless",
"data",
"JSON",
"Table",
"Schema",
"from",
"the",
"information",
"in",
"the",
"column",
"-",
"MultiIndex",
"."
] | [
"'''\n Create a datapackage.json file that complies with the Frictionless\n data JSON Table Schema from the information in the column-MultiIndex.\n\n Parameters\n ----------\n data_sets: dict of pandas.DataFrames\n A dict with keys '15min' and '60min' and values the respective\n DataFra... | [
{
"param": "data_sets",
"type": null
},
{
"param": "info_cols",
"type": null
},
{
"param": "version",
"type": null
},
{
"param": "changes",
"type": null
},
{
"param": "headers",
"type": null
},
{
"param": "areas",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_sets",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info_cols",
"type": null,
"docstring": null,
"docstring_... |
a65c2c34fba8452fd4707b15841fd5c0632051c3 | ccmonsalve43/Open-System-Data | timeseries_scripts/download.py | [
"MIT"
] | Python | download | <not_specific> | def download(sources, out_path, archive_version=None,
start_from_user=None, end_from_user=None):
"""
Load YAML file with sources from disk, and download all files for each
source into the given out_path.
Parameters
----------
sources : dict
Dict of download parameters speci... |
Load YAML file with sources from disk, and download all files for each
source into the given out_path.
Parameters
----------
sources : dict
Dict of download parameters specific to each source.
out_path : str
Base download directory in which to save all downloaded files.
arc... | Load YAML file with sources from disk, and download all files for each
source into the given out_path.
Parameters
sources : dict
Dict of download parameters specific to each source.
out_path : str
Base download directory in which to save all downloaded files.
archive_version: str, default None
OPSD Data Package Versi... | [
"Load",
"YAML",
"file",
"with",
"sources",
"from",
"disk",
"and",
"download",
"all",
"files",
"for",
"each",
"source",
"into",
"the",
"given",
"out_path",
".",
"Parameters",
"sources",
":",
"dict",
"Dict",
"of",
"download",
"parameters",
"specific",
"to",
"e... | def download(sources, out_path, archive_version=None,
start_from_user=None, end_from_user=None):
for name, date in {'end_from_user': end_from_user,
'start_from_user': start_from_user}.items():
if date and date > datetime.now().date():
logger.info('%s given was... | [
"def",
"download",
"(",
"sources",
",",
"out_path",
",",
"archive_version",
"=",
"None",
",",
"start_from_user",
"=",
"None",
",",
"end_from_user",
"=",
"None",
")",
":",
"for",
"name",
",",
"date",
"in",
"{",
"'end_from_user'",
":",
"end_from_user",
",",
... | Load YAML file with sources from disk, and download all files for each
source into the given out_path. | [
"Load",
"YAML",
"file",
"with",
"sources",
"from",
"disk",
"and",
"download",
"all",
"files",
"for",
"each",
"source",
"into",
"the",
"given",
"out_path",
"."
] | [
"\"\"\"\n Load YAML file with sources from disk, and download all files for each\n source into the given out_path.\n\n Parameters\n ----------\n sources : dict\n Dict of download parameters specific to each source.\n out_path : str\n Base download directory in which to save all downl... | [
{
"param": "sources",
"type": null
},
{
"param": "out_path",
"type": null
},
{
"param": "archive_version",
"type": null
},
{
"param": "start_from_user",
"type": null
},
{
"param": "end_from_user",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sources",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "out_path",
"type": null,
"docstring": null,
"docstring_tok... |
a65c2c34fba8452fd4707b15841fd5c0632051c3 | ccmonsalve43/Open-System-Data | timeseries_scripts/download.py | [
"MIT"
] | Python | download_archive | <not_specific> | def download_archive(archive_version):
"""
Download archived data from the OPSD server. See download()
for info on parameter.
"""
filepath = 'original_data.zip'
if not os.path.exists(filepath):
url = ('http://data.open-power-system-data.org/time_series/'
'{}/original_da... |
Download archived data from the OPSD server. See download()
for info on parameter.
| Download archived data from the OPSD server. See download()
for info on parameter. | [
"Download",
"archived",
"data",
"from",
"the",
"OPSD",
"server",
".",
"See",
"download",
"()",
"for",
"info",
"on",
"parameter",
"."
] | def download_archive(archive_version):
filepath = 'original_data.zip'
if not os.path.exists(filepath):
url = ('http://data.open-power-system-data.org/time_series/'
'{}/original_data/{}'.format(archive_version, filepath))
logger.info('Downloading and extracting archived data from %... | [
"def",
"download_archive",
"(",
"archive_version",
")",
":",
"filepath",
"=",
"'original_data.zip'",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"url",
"=",
"(",
"'http://data.open-power-system-data.org/time_series/'",
"'{}/original_data/... | Download archived data from the OPSD server. | [
"Download",
"archived",
"data",
"from",
"the",
"OPSD",
"server",
"."
] | [
"\"\"\"\n Download archived data from the OPSD server. See download()\n for info on parameter.\n\n \"\"\""
] | [
{
"param": "archive_version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "archive_version",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a65c2c34fba8452fd4707b15841fd5c0632051c3 | ccmonsalve43/Open-System-Data | timeseries_scripts/download.py | [
"MIT"
] | Python | download_request | <not_specific> | def download_request(
source_name,
start,
end,
session,
filename,
container,
url_template,
url_params_template,
second=None):
"""
Download a single file via HTTP get.
Build the url from parameters and save the file to dsik under it's or... |
Download a single file via HTTP get.
Build the url from parameters and save the file to dsik under it's original
filename
Parameters
----------
container : str
unique filepath for the file to be saved
url_template :
stem of URL
url_params_template : dict
dict... | Download a single file via HTTP get.
Build the url from parameters and save the file to dsik under it's original
filename
Parameters
container : str
unique filepath for the file to be saved
url_template :
stem of URL
url_params_template : dict
dict of parameter names and values to paste into URL
Returns
downloaded ... | [
"Download",
"a",
"single",
"file",
"via",
"HTTP",
"get",
".",
"Build",
"the",
"url",
"from",
"parameters",
"and",
"save",
"the",
"file",
"to",
"dsik",
"under",
"it",
"'",
"s",
"original",
"filename",
"Parameters",
"container",
":",
"str",
"unique",
"filepa... | def download_request(
source_name,
start,
end,
session,
filename,
container,
url_template,
url_params_template,
second=None):
url_params = {}
if url_params_template:
for key, value in url_params_template.items():
url_p... | [
"def",
"download_request",
"(",
"source_name",
",",
"start",
",",
"end",
",",
"session",
",",
"filename",
",",
"container",
",",
"url_template",
",",
"url_params_template",
",",
"second",
"=",
"None",
")",
":",
"url_params",
"=",
"{",
"}",
"if",
"url_params_... | Download a single file via HTTP get. | [
"Download",
"a",
"single",
"file",
"via",
"HTTP",
"get",
"."
] | [
"\"\"\"\n Download a single file via HTTP get.\n Build the url from parameters and save the file to dsik under it's original\n filename \n\n Parameters\n ----------\n container : str\n unique filepath for the file to be saved\n url_template : \n stem of URL \n url_params_templa... | [
{
"param": "source_name",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "end",
"type": null
},
{
"param": "session",
"type": null
},
{
"param": "filename",
"type": null
},
{
"param": "container",
"type": null
},
{
"param": ... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start",
"type": null,
"docstring": null,
"docstring_to... |
a65c2c34fba8452fd4707b15841fd5c0632051c3 | ccmonsalve43/Open-System-Data | timeseries_scripts/download.py | [
"MIT"
] | Python | update_progress | <not_specific> | def update_progress(progress, total):
'''
Display or updates a console progress bar.
Parameters
----------
progress : float
fraction of file already downloades
total : int
total number of files
Returns
----------
None
'''
barLength = 50 # Modify this to ... |
Display or updates a console progress bar.
Parameters
----------
progress : float
fraction of file already downloades
total : int
total number of files
Returns
----------
None
| Display or updates a console progress bar.
Parameters
progress : float
fraction of file already downloades
total : int
total number of files
Returns
None | [
"Display",
"or",
"updates",
"a",
"console",
"progress",
"bar",
".",
"Parameters",
"progress",
":",
"float",
"fraction",
"of",
"file",
"already",
"downloades",
"total",
":",
"int",
"total",
"number",
"of",
"files",
"Returns",
"None"
] | def update_progress(progress, total):
barLength = 50
status = ""
block = int(round(barLength * progress))
text = "\rProgress: [{0}] {1:.0%} of {2} {3}".format(
"#" * block + "-" * (barLength - block),
progress, convert_size(total), status)
sys.stdout.write(text)
sys.stdout.flus... | [
"def",
"update_progress",
"(",
"progress",
",",
"total",
")",
":",
"barLength",
"=",
"50",
"status",
"=",
"\"\"",
"block",
"=",
"int",
"(",
"round",
"(",
"barLength",
"*",
"progress",
")",
")",
"text",
"=",
"\"\\rProgress: [{0}] {1:.0%} of {2} {3}\"",
".",
"... | Display or updates a console progress bar. | [
"Display",
"or",
"updates",
"a",
"console",
"progress",
"bar",
"."
] | [
"'''\n Display or updates a console progress bar.\n\n Parameters\n ----------\n progress : float\n fraction of file already downloades \n total : int\n total number of files\n\n Returns\n ----------\n None\n\n '''",
"# Modify this to change the length of the progress bar"
... | [
{
"param": "progress",
"type": null
},
{
"param": "total",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "progress",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "total",
"type": null,
"docstring": null,
"docstring_token... |
b2d0c8b45f575083d603c28b6cab02c7074e7cfb | aws-samples/serverless-websocket-chat | websocket_demo/libs/aws.py | [
"MIT-0"
] | Python | delete_connection_id | null | def delete_connection_id(connection_id, channel='general'):
"""Delete an item from DynamoDB which represents a client being connected"""
table = get_table()
conn_key = _get_channel_connections_key(channel)
coll_name = _get_connection_column_name(connection_id)
update_expr = 'REMOVE {}'.format(coll_... | Delete an item from DynamoDB which represents a client being connected | Delete an item from DynamoDB which represents a client being connected | [
"Delete",
"an",
"item",
"from",
"DynamoDB",
"which",
"represents",
"a",
"client",
"being",
"connected"
] | def delete_connection_id(connection_id, channel='general'):
table = get_table()
conn_key = _get_channel_connections_key(channel)
coll_name = _get_connection_column_name(connection_id)
update_expr = 'REMOVE {}'.format(coll_name)
table.update_item(
Key=conn_key,
UpdateExpression=update... | [
"def",
"delete_connection_id",
"(",
"connection_id",
",",
"channel",
"=",
"'general'",
")",
":",
"table",
"=",
"get_table",
"(",
")",
"conn_key",
"=",
"_get_channel_connections_key",
"(",
"channel",
")",
"coll_name",
"=",
"_get_connection_column_name",
"(",
"connect... | Delete an item from DynamoDB which represents a client being connected | [
"Delete",
"an",
"item",
"from",
"DynamoDB",
"which",
"represents",
"a",
"client",
"being",
"connected"
] | [
"\"\"\"Delete an item from DynamoDB which represents a client being connected\"\"\""
] | [
{
"param": "connection_id",
"type": null
},
{
"param": "channel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "connection_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "channel",
"type": null,
"docstring": null,
"docstrin... |
b2d0c8b45f575083d603c28b6cab02c7074e7cfb | aws-samples/serverless-websocket-chat | websocket_demo/libs/aws.py | [
"MIT-0"
] | Python | save_message | null | def save_message(connection_id, epoch, message, channel='general'):
"""Save a message from a user"""
item = {
'pk': channel,
'epoch': epoch,
'connectionId': connection_id,
'channel': channel,
'message': message,
}
table = get_table()
table.put_item(Item=item) | Save a message from a user | Save a message from a user | [
"Save",
"a",
"message",
"from",
"a",
"user"
] | def save_message(connection_id, epoch, message, channel='general'):
item = {
'pk': channel,
'epoch': epoch,
'connectionId': connection_id,
'channel': channel,
'message': message,
}
table = get_table()
table.put_item(Item=item) | [
"def",
"save_message",
"(",
"connection_id",
",",
"epoch",
",",
"message",
",",
"channel",
"=",
"'general'",
")",
":",
"item",
"=",
"{",
"'pk'",
":",
"channel",
",",
"'epoch'",
":",
"epoch",
",",
"'connectionId'",
":",
"connection_id",
",",
"'channel'",
":... | Save a message from a user | [
"Save",
"a",
"message",
"from",
"a",
"user"
] | [
"\"\"\"Save a message from a user\"\"\""
] | [
{
"param": "connection_id",
"type": null
},
{
"param": "epoch",
"type": null
},
{
"param": "message",
"type": null
},
{
"param": "channel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "connection_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "epoch",
"type": null,
"docstring": null,
"docstring_... |
b2d0c8b45f575083d603c28b6cab02c7074e7cfb | aws-samples/serverless-websocket-chat | websocket_demo/libs/aws.py | [
"MIT-0"
] | Python | invoke_lambda_async | <not_specific> | def invoke_lambda_async(function_name, payload):
"""Invoke a Lambda function with an Event invocation type"""
_lambda = boto3.client('lambda')
return _lambda.invoke(
FunctionName=function_name,
Payload=safe_dumps(payload),
InvocationType='Event',
) | Invoke a Lambda function with an Event invocation type | Invoke a Lambda function with an Event invocation type | [
"Invoke",
"a",
"Lambda",
"function",
"with",
"an",
"Event",
"invocation",
"type"
] | def invoke_lambda_async(function_name, payload):
_lambda = boto3.client('lambda')
return _lambda.invoke(
FunctionName=function_name,
Payload=safe_dumps(payload),
InvocationType='Event',
) | [
"def",
"invoke_lambda_async",
"(",
"function_name",
",",
"payload",
")",
":",
"_lambda",
"=",
"boto3",
".",
"client",
"(",
"'lambda'",
")",
"return",
"_lambda",
".",
"invoke",
"(",
"FunctionName",
"=",
"function_name",
",",
"Payload",
"=",
"safe_dumps",
"(",
... | Invoke a Lambda function with an Event invocation type | [
"Invoke",
"a",
"Lambda",
"function",
"with",
"an",
"Event",
"invocation",
"type"
] | [
"\"\"\"Invoke a Lambda function with an Event invocation type\"\"\""
] | [
{
"param": "function_name",
"type": null
},
{
"param": "payload",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "function_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "payload",
"type": null,
"docstring": null,
"docstrin... |
d82a0f1716402370b50846afb2d60853afd3d021 | srishti77/convolution-attention | convolutional_attention/f1_evaluator.py | [
"BSD-3-Clause"
] | Python | compute_names_f1 | <not_specific> | def compute_names_f1(self, features, real_targets, token_dictionary):
"""
Compute the top X predictions for each paragraph vector.
:param features:
:param token_dictionary: contains all the non-unk words
:rtype: PointSuggestionEvaluator
"""
result_accumulator = Po... |
Compute the top X predictions for each paragraph vector.
:param features:
:param token_dictionary: contains all the non-unk words
:rtype: PointSuggestionEvaluator
| Compute the top X predictions for each paragraph vector. | [
"Compute",
"the",
"top",
"X",
"predictions",
"for",
"each",
"paragraph",
"vector",
"."
] | def compute_names_f1(self, features, real_targets, token_dictionary):
result_accumulator = PointSuggestionEvaluator()
for i in xrange(features.shape[0]):
result = self.model.predict_name(np.atleast_2d(features[i]))
confidences = [suggestion[1] for suggestion in result]
... | [
"def",
"compute_names_f1",
"(",
"self",
",",
"features",
",",
"real_targets",
",",
"token_dictionary",
")",
":",
"result_accumulator",
"=",
"PointSuggestionEvaluator",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"features",
".",
"shape",
"[",
"0",
"]",
")",
"... | Compute the top X predictions for each paragraph vector. | [
"Compute",
"the",
"top",
"X",
"predictions",
"for",
"each",
"paragraph",
"vector",
"."
] | [
"\"\"\"\n Compute the top X predictions for each paragraph vector.\n :param features:\n :param token_dictionary: contains all the non-unk words\n :rtype: PointSuggestionEvaluator\n \"\"\"",
"#print real_targets[i], result"
] | [
{
"param": "self",
"type": null
},
{
"param": "features",
"type": null
},
{
"param": "real_targets",
"type": null
},
{
"param": "token_dictionary",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "PointSuggestionEvaluator"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
... |
d82a0f1716402370b50846afb2d60853afd3d021 | srishti77/convolution-attention | convolutional_attention/f1_evaluator.py | [
"BSD-3-Clause"
] | Python | add_result | <not_specific> | def add_result(self, confidence, is_correct, is_unk, precision_recall, unk_word_accuracy):
"""
Add a single point suggestion as a result.
"""
confidence = np.array(confidence)
is_correct = np.array(is_correct, dtype=np.bool)
is_unk = np.array(is_unk, dtype=np.bool)
... |
Add a single point suggestion as a result.
| Add a single point suggestion as a result. | [
"Add",
"a",
"single",
"point",
"suggestion",
"as",
"a",
"result",
"."
] | def add_result(self, confidence, is_correct, is_unk, precision_recall, unk_word_accuracy):
confidence = np.array(confidence)
is_correct = np.array(is_correct, dtype=np.bool)
is_unk = np.array(is_unk, dtype=np.bool)
self.num_points += 1
if len(is_unk) == 0 or is_unk[0]:
... | [
"def",
"add_result",
"(",
"self",
",",
"confidence",
",",
"is_correct",
",",
"is_unk",
",",
"precision_recall",
",",
"unk_word_accuracy",
")",
":",
"confidence",
"=",
"np",
".",
"array",
"(",
"confidence",
")",
"is_correct",
"=",
"np",
".",
"array",
"(",
"... | Add a single point suggestion as a result. | [
"Add",
"a",
"single",
"point",
"suggestion",
"as",
"a",
"result",
"."
] | [
"\"\"\"\n Add a single point suggestion as a result.\n \"\"\"",
"# No suggestions",
"# Beyond our current number of suggestions",
"# There is at least one UNK here"
] | [
{
"param": "self",
"type": null
},
{
"param": "confidence",
"type": null
},
{
"param": "is_correct",
"type": null
},
{
"param": "is_unk",
"type": null
},
{
"param": "precision_recall",
"type": null
},
{
"param": "unk_word_accuracy",
"type": null
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "confidence",
"type": null,
"docstring": null,
"docstring_toke... |
d82a0f1716402370b50846afb2d60853afd3d021 | srishti77/convolution-attention | convolutional_attention/f1_evaluator.py | [
"BSD-3-Clause"
] | Python | token_precision_recall | <not_specific> | def token_precision_recall(predicted_parts, gold_set_parts):
"""
Get the precision/recall for the given token.
:param predicted_parts: a list of predicted parts
:param gold_set_parts: a list of the golden parts
:return: precision, recall, f1 as floats
"""
ground = [tok.lower() for tok in go... |
Get the precision/recall for the given token.
:param predicted_parts: a list of predicted parts
:param gold_set_parts: a list of the golden parts
:return: precision, recall, f1 as floats
| Get the precision/recall for the given token. | [
"Get",
"the",
"precision",
"/",
"recall",
"for",
"the",
"given",
"token",
"."
] | def token_precision_recall(predicted_parts, gold_set_parts):
ground = [tok.lower() for tok in gold_set_parts]
tp = 0
for subtoken in set(predicted_parts):
if subtoken == "***" or subtoken is None:
continue
if subtoken.lower() in ground:
ground.remove(subtoken.lower(... | [
"def",
"token_precision_recall",
"(",
"predicted_parts",
",",
"gold_set_parts",
")",
":",
"ground",
"=",
"[",
"tok",
".",
"lower",
"(",
")",
"for",
"tok",
"in",
"gold_set_parts",
"]",
"tp",
"=",
"0",
"for",
"subtoken",
"in",
"set",
"(",
"predicted_parts",
... | Get the precision/recall for the given token. | [
"Get",
"the",
"precision",
"/",
"recall",
"for",
"the",
"given",
"token",
"."
] | [
"\"\"\"\n Get the precision/recall for the given token.\n\n :param predicted_parts: a list of predicted parts\n :param gold_set_parts: a list of the golden parts\n :return: precision, recall, f1 as floats\n \"\"\"",
"# Ignore UNKs"
] | [
{
"param": "predicted_parts",
"type": null
},
{
"param": "gold_set_parts",
"type": null
}
] | {
"returns": [
{
"docstring": "precision, recall, f1 as floats",
"docstring_tokens": [
"precision",
"recall",
"f1",
"as",
"floats"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "predicted_parts",
"type": nul... |
a82c200cd117a48cc9a2ebacd146f50b56baabcf | srishti77/convolution-attention | convolutional_attention/token_naming_data.py | [
"BSD-3-Clause"
] | Python | __get_empirical_distribution | <not_specific> | def __get_empirical_distribution(element_dict, elements, dirichlet_alpha=10.):
"""
Retrive te empirical distribution of tokens
:param element_dict: a dictionary that can convert the elements to their respective ids.
:param elements: an iterable of all the elements
:return:
... |
Retrive te empirical distribution of tokens
:param element_dict: a dictionary that can convert the elements to their respective ids.
:param elements: an iterable of all the elements
:return:
| Retrive te empirical distribution of tokens | [
"Retrive",
"te",
"empirical",
"distribution",
"of",
"tokens"
] | def __get_empirical_distribution(element_dict, elements, dirichlet_alpha=10.):
targets = np.array([element_dict.get_id_or_unk(t) for t in elements])
empirical_distribution = np.bincount(targets, minlength=len(element_dict)).astype(float)
empirical_distribution += dirichlet_alpha / len(empirical_... | [
"def",
"__get_empirical_distribution",
"(",
"element_dict",
",",
"elements",
",",
"dirichlet_alpha",
"=",
"10.",
")",
":",
"targets",
"=",
"np",
".",
"array",
"(",
"[",
"element_dict",
".",
"get_id_or_unk",
"(",
"t",
")",
"for",
"t",
"in",
"elements",
"]",
... | Retrive te empirical distribution of tokens | [
"Retrive",
"te",
"empirical",
"distribution",
"of",
"tokens"
] | [
"\"\"\"\n Retrive te empirical distribution of tokens\n :param element_dict: a dictionary that can convert the elements to their respective ids.\n :param elements: an iterable of all the elements\n :return:\n \"\"\""
] | [
{
"param": "element_dict",
"type": null
},
{
"param": "elements",
"type": null
},
{
"param": "dirichlet_alpha",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "element_dict",
"type": null,
"docstring": "a dictionary that can convert the elements to their respective ids.",
"d... |
a82c200cd117a48cc9a2ebacd146f50b56baabcf | srishti77/convolution-attention | convolutional_attention/token_naming_data.py | [
"BSD-3-Clause"
] | Python | __get_data_in_forward_format | <not_specific> | def __get_data_in_forward_format(self, names, code, name_cx_size):
"""
Get the data in a "forward" model format.
:param data:
:param name_cx_size:
:return:
"""
assert len(names) == len(code), (len(names), len(code), code.shape)
# Keep only identifiers in c... |
Get the data in a "forward" model format.
:param data:
:param name_cx_size:
:return:
| Get the data in a "forward" model format. | [
"Get",
"the",
"data",
"in",
"a",
"\"",
"forward",
"\"",
"model",
"format",
"."
] | def __get_data_in_forward_format(self, names, code, name_cx_size):
assert len(names) == len(code), (len(names), len(code), code.shape)
name_targets = []
name_contexts = []
original_names_ids = []
id_xs = []
id_ys = []
k = 0
for i, name in enumerate(names):... | [
"def",
"__get_data_in_forward_format",
"(",
"self",
",",
"names",
",",
"code",
",",
"name_cx_size",
")",
":",
"assert",
"len",
"(",
"names",
")",
"==",
"len",
"(",
"code",
")",
",",
"(",
"len",
"(",
"names",
")",
",",
"len",
"(",
"code",
")",
",",
... | Get the data in a "forward" model format. | [
"Get",
"the",
"data",
"in",
"a",
"\"",
"forward",
"\"",
"model",
"format",
"."
] | [
"\"\"\"\n Get the data in a \"forward\" model format.\n :param data:\n :param name_cx_size:\n :return:\n \"\"\"",
"# Keep only identifiers in code",
"#code = self.keep_identifiers_only(code)",
"# First element should always be predictable (ie sentence start)"
] | [
{
"param": "self",
"type": null
},
{
"param": "names",
"type": null
},
{
"param": "code",
"type": null
},
{
"param": "name_cx_size",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
aaac57b30dd4a374249d4b2675ea72e698257713 | srishti77/convolution-attention | analysis/synthetic_dset_generator.py | [
"BSD-3-Clause"
] | Python | generate_synthetic_no_order | <not_specific> | def generate_synthetic_no_order(num_samples, p_noise=.8):
"""
Generate a random synthetic dataset using the above mapping
:param num_samples:
:param p_noise:
:return:
"""
samples = []
for i in xrange(num_samples):
current_elements = target_names_no_order.keys()[random.randint(0, ... |
Generate a random synthetic dataset using the above mapping
:param num_samples:
:param p_noise:
:return:
| Generate a random synthetic dataset using the above mapping | [
"Generate",
"a",
"random",
"synthetic",
"dataset",
"using",
"the",
"above",
"mapping"
] | def generate_synthetic_no_order(num_samples, p_noise=.8):
samples = []
for i in xrange(num_samples):
current_elements = target_names_no_order.keys()[random.randint(0, len(target_names_no_order) - 1)]
name = target_names_no_order[current_elements]
tokens = []
included_elements = s... | [
"def",
"generate_synthetic_no_order",
"(",
"num_samples",
",",
"p_noise",
"=",
".8",
")",
":",
"samples",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"num_samples",
")",
":",
"current_elements",
"=",
"target_names_no_order",
".",
"keys",
"(",
")",
"[",
... | Generate a random synthetic dataset using the above mapping | [
"Generate",
"a",
"random",
"synthetic",
"dataset",
"using",
"the",
"above",
"mapping"
] | [
"\"\"\"\n Generate a random synthetic dataset using the above mapping\n :param num_samples:\n :param p_noise:\n :return:\n \"\"\""
] | [
{
"param": "num_samples",
"type": null
},
{
"param": "p_noise",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "num_samples",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,... |
aaac57b30dd4a374249d4b2675ea72e698257713 | srishti77/convolution-attention | analysis/synthetic_dset_generator.py | [
"BSD-3-Clause"
] | Python | generate_synthetic_with_order | <not_specific> | def generate_synthetic_with_order(num_samples, p_noise=.7):
"""
Generate a random synthetic dataset using the above mapping
:param num_samples:
:param p_noise:
:return:
"""
samples = []
for i in xrange(num_samples):
current_elements = target_names_order.keys()[random.randint(0, l... |
Generate a random synthetic dataset using the above mapping
:param num_samples:
:param p_noise:
:return:
| Generate a random synthetic dataset using the above mapping | [
"Generate",
"a",
"random",
"synthetic",
"dataset",
"using",
"the",
"above",
"mapping"
] | def generate_synthetic_with_order(num_samples, p_noise=.7):
samples = []
for i in xrange(num_samples):
current_elements = target_names_order.keys()[random.randint(0, len(target_names_order) - 1)]
name = target_names_order[current_elements]
tokens = []
current_idx = 0
add_... | [
"def",
"generate_synthetic_with_order",
"(",
"num_samples",
",",
"p_noise",
"=",
".7",
")",
":",
"samples",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"num_samples",
")",
":",
"current_elements",
"=",
"target_names_order",
".",
"keys",
"(",
")",
"[",
... | Generate a random synthetic dataset using the above mapping | [
"Generate",
"a",
"random",
"synthetic",
"dataset",
"using",
"the",
"above",
"mapping"
] | [
"\"\"\"\n Generate a random synthetic dataset using the above mapping\n :param num_samples:\n :param p_noise:\n :return:\n \"\"\""
] | [
{
"param": "num_samples",
"type": null
},
{
"param": "p_noise",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "num_samples",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,... |
1b917d5d1646cb73ec255757eedf5236efc0e9a6 | srishti77/convolution-attention | convolutional_attention/abstract_representation_learner.py | [
"BSD-3-Clause"
] | Python | train | null | def train(self, input_file):
"""
Train the learner for the given input file.
:param input_file: the file directory
:return:
"""
raise NotImplementedError() |
Train the learner for the given input file.
:param input_file: the file directory
:return:
| Train the learner for the given input file. | [
"Train",
"the",
"learner",
"for",
"the",
"given",
"input",
"file",
"."
] | def train(self, input_file):
raise NotImplementedError() | [
"def",
"train",
"(",
"self",
",",
"input_file",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Train the learner for the given input file. | [
"Train",
"the",
"learner",
"for",
"the",
"given",
"input",
"file",
"."
] | [
"\"\"\"\n Train the learner for the given input file.\n :param input_file: the file directory\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "input_file",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
1b917d5d1646cb73ec255757eedf5236efc0e9a6 | srishti77/convolution-attention | convolutional_attention/abstract_representation_learner.py | [
"BSD-3-Clause"
] | Python | predict_name | null | def predict_name(self, representation):
"""
Predict the name, given the representation.
:param context:
:param representation:
:return: a list of all possible suggestions
"""
raise NotImplemented() |
Predict the name, given the representation.
:param context:
:param representation:
:return: a list of all possible suggestions
| Predict the name, given the representation. | [
"Predict",
"the",
"name",
"given",
"the",
"representation",
"."
] | def predict_name(self, representation):
raise NotImplemented() | [
"def",
"predict_name",
"(",
"self",
",",
"representation",
")",
":",
"raise",
"NotImplemented",
"(",
")"
] | Predict the name, given the representation. | [
"Predict",
"the",
"name",
"given",
"the",
"representation",
"."
] | [
"\"\"\"\n Predict the name, given the representation.\n :param context:\n :param representation:\n :return: a list of all possible suggestions\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "representation",
"type": null
}
] | {
"returns": [
{
"docstring": "a list of all possible suggestions",
"docstring_tokens": [
"a",
"list",
"of",
"all",
"possible",
"suggestions"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"ty... |
e059957885610b957f9c43d0f3d53f90a1d2a5c9 | giambajt/24-Tkinter | src/m5_tkinter_practice.py | [
"MIT"
] | Python | main | null | def main():
""" Constructs a GUI with stuff on it. """
# -------------------------------------------------------------------------
# Done: 2. After reading and understanding the m1e module,
# ** make a window that shows up. **
# ---------------------------------------------------------------------... | Constructs a GUI with stuff on it. | Constructs a GUI with stuff on it. | [
"Constructs",
"a",
"GUI",
"with",
"stuff",
"on",
"it",
"."
] | def main():
root = tkinter.Tk()
root.title("Work Please")
main_frame = ttk.Frame(root, padding=100, relief='groove')
main_frame.grid()
go_forward_button = ttk.Button(main_frame, text='Hello')
go_forward_button.grid(row = 1, column = 2)
go_forward_button['command'] = (lambda: print_hello())
... | [
"def",
"main",
"(",
")",
":",
"root",
"=",
"tkinter",
".",
"Tk",
"(",
")",
"root",
".",
"title",
"(",
"\"Work Please\"",
")",
"main_frame",
"=",
"ttk",
".",
"Frame",
"(",
"root",
",",
"padding",
"=",
"100",
",",
"relief",
"=",
"'groove'",
")",
"mai... | Constructs a GUI with stuff on it. | [
"Constructs",
"a",
"GUI",
"with",
"stuff",
"on",
"it",
"."
] | [
"\"\"\" Constructs a GUI with stuff on it. \"\"\"",
"# -------------------------------------------------------------------------",
"# Done: 2. After reading and understanding the m1e module,",
"# ** make a window that shows up. **",
"# ----------------------------------------------------------------------... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.