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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
40accda727b0a65823adfd7b2d111a5d7a680ee2 | Hephaest/ComputerNetworkApplications | Web Server/WebServer.py | [
"MIT"
] | Python | start_server | null | def start_server(server_port, server_address):
"""Create a socket and wait for TCP connection at port [serverPort].
The server is created as a multithreaded server and has a capacity of
handling multiple concurrent connections.
:param server_port: Configurable port, defined as an optional argument.
... | Create a socket and wait for TCP connection at port [serverPort].
The server is created as a multithreaded server and has a capacity of
handling multiple concurrent connections.
:param server_port: Configurable port, defined as an optional argument.
| Create a socket and wait for TCP connection at port [serverPort].
The server is created as a multithreaded server and has a capacity of
handling multiple concurrent connections. | [
"Create",
"a",
"socket",
"and",
"wait",
"for",
"TCP",
"connection",
"at",
"port",
"[",
"serverPort",
"]",
".",
"The",
"server",
"is",
"created",
"as",
"a",
"multithreaded",
"server",
"and",
"has",
"a",
"capacity",
"of",
"handling",
"multiple",
"concurrent",
... | def start_server(server_port, server_address):
print("you can test the web server by accessing: ", end="")
print("http://" + server_address + ":" + str(server_port) + "/hello.html")
print('Wait for TCP clients...')
server_socket = socket(AF_INET, SOCK_STREAM)
server_socket.bind(("", server_port))
... | [
"def",
"start_server",
"(",
"server_port",
",",
"server_address",
")",
":",
"print",
"(",
"\"you can test the web server by accessing: \"",
",",
"end",
"=",
"\"\"",
")",
"print",
"(",
"\"http://\"",
"+",
"server_address",
"+",
"\":\"",
"+",
"str",
"(",
"server_por... | Create a socket and wait for TCP connection at port [serverPort]. | [
"Create",
"a",
"socket",
"and",
"wait",
"for",
"TCP",
"connection",
"at",
"port",
"[",
"serverPort",
"]",
"."
] | [
"\"\"\"Create a socket and wait for TCP connection at port [serverPort].\n\n The server is created as a multithreaded server and has a capacity of\n handling multiple concurrent connections.\n\n :param server_port: Configurable port, defined as an optional argument.\n \"\"\"",
"# For test",
"# 1. Cr... | [
{
"param": "server_port",
"type": null
},
{
"param": "server_address",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "server_port",
"type": null,
"docstring": "Configurable port, defined as an optional argument.",
"docstring_tokens": [
"Configurable",
"port",
"defined",
"as",
"an",
"optional",
... |
2ea4b8fad940240cb7ebc98d80bfff689495e259 | Hephaest/ComputerNetworkApplications | Traceroute/Traceroute.py | [
"MIT"
] | Python | checksum | <not_specific> | def checksum(string):
"""Fetch string and calculate the checksum.
This function is copied from sample code file.
Args:
:param string: A string of the time in seconds since the epoch.
Returns:
:return: The value of checksum (integer type).
"""
csum = 0
count_to = (len(strin... | Fetch string and calculate the checksum.
This function is copied from sample code file.
Args:
:param string: A string of the time in seconds since the epoch.
Returns:
:return: The value of checksum (integer type).
| Fetch string and calculate the checksum.
This function is copied from sample code file. | [
"Fetch",
"string",
"and",
"calculate",
"the",
"checksum",
".",
"This",
"function",
"is",
"copied",
"from",
"sample",
"code",
"file",
"."
] | def checksum(string):
csum = 0
count_to = (len(string) // 2) * 2
count = 0
while count < count_to:
thisVal = string[count + 1] * 256 + string[count]
csum = csum + thisVal
csum = csum & 0xffffffff
count = count + 2
if count_to < len(string):
csum = csum + strin... | [
"def",
"checksum",
"(",
"string",
")",
":",
"csum",
"=",
"0",
"count_to",
"=",
"(",
"len",
"(",
"string",
")",
"//",
"2",
")",
"*",
"2",
"count",
"=",
"0",
"while",
"count",
"<",
"count_to",
":",
"thisVal",
"=",
"string",
"[",
"count",
"+",
"1",
... | Fetch string and calculate the checksum. | [
"Fetch",
"string",
"and",
"calculate",
"the",
"checksum",
"."
] | [
"\"\"\"Fetch string and calculate the checksum.\n\n This function is copied from sample code file.\n\n Args:\n :param string: A string of the time in seconds since the epoch.\n\n Returns:\n :return: The value of checksum (integer type).\n \"\"\""
] | [
{
"param": "string",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: The value of checksum (integer type).",
"docstring_tokens": [
":",
"return",
":",
"The",
"value",
"of",
"checksum",
"(",
"integer",
"type",
")",
"."
],
"t... |
2ea4b8fad940240cb7ebc98d80bfff689495e259 | Hephaest/ComputerNetworkApplications | Traceroute/Traceroute.py | [
"MIT"
] | Python | receive_one_trace | <not_specific> | def receive_one_trace(icmp_socket, send_time, timeout):
"""The socket waits for a reply and calculate latency for each node.
This function will measure and report different packet loss.
Args:
:param icmp_socket: the socket which is created from do_three_trace function.
:par... | The socket waits for a reply and calculate latency for each node.
This function will measure and report different packet loss.
Args:
:param icmp_socket: the socket which is created from do_three_trace function.
:param timeout: configurable timeout, set using an optional argumen... | The socket waits for a reply and calculate latency for each node.
This function will measure and report different packet loss. | [
"The",
"socket",
"waits",
"for",
"a",
"reply",
"and",
"calculate",
"latency",
"for",
"each",
"node",
".",
"This",
"function",
"will",
"measure",
"and",
"report",
"different",
"packet",
"loss",
"."
] | def receive_one_trace(icmp_socket, send_time, timeout):
print_str = ""
retr_addr = ""
try:
start_time = time.time()
wait_for_data = select.select([icmp_socket], [], [], timeout)
end_time = time.time()
if end_time == start_time:
time.sleep(0.001)
data_recei... | [
"def",
"receive_one_trace",
"(",
"icmp_socket",
",",
"send_time",
",",
"timeout",
")",
":",
"print_str",
"=",
"\"\"",
"retr_addr",
"=",
"\"\"",
"try",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"wait_for_data",
"=",
"select",
".",
"select",
"("... | The socket waits for a reply and calculate latency for each node. | [
"The",
"socket",
"waits",
"for",
"a",
"reply",
"and",
"calculate",
"latency",
"for",
"each",
"node",
"."
] | [
"\"\"\"The socket waits for a reply and calculate latency for each node.\n\n This function will measure and report different packet loss.\n\n Args:\n :param icmp_socket: the socket which is created from do_three_trace function.\n :param timeout: configurable timeout, set using an... | [
{
"param": "icmp_socket",
"type": null
},
{
"param": "send_time",
"type": null
},
{
"param": "timeout",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [
{
"docstring": "An error occurred when a packet cannot be received within\na given time range.",
"docstring_tokens": [
"An",
"error",
"o... |
2ea4b8fad940240cb7ebc98d80bfff689495e259 | Hephaest/ComputerNetworkApplications | Traceroute/Traceroute.py | [
"MIT"
] | Python | send_one_trace | <not_specific> | def send_one_trace(icmp_socket, dest_addr, port_id, sequence):
"""Build, pack and send the ICMP packet using socket.
Args:
:param icmp_socket: the socket which is created from do_three_trace function.
:param dest_addr: the IP address of the current node.
:param port_id: current process ... | Build, pack and send the ICMP packet using socket.
Args:
:param icmp_socket: the socket which is created from do_three_trace function.
:param dest_addr: the IP address of the current node.
:param port_id: current process id.
:param sequence: the nth times of the current node latency... | Build, pack and send the ICMP packet using socket. | [
"Build",
"pack",
"and",
"send",
"the",
"ICMP",
"packet",
"using",
"socket",
"."
] | def send_one_trace(icmp_socket, dest_addr, port_id, sequence):
icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, 0, port_id, sequence)
payload_data = struct.pack("!f", time.time())
packet_checksum = checksum(icmp_header + payload_data)
icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, pa... | [
"def",
"send_one_trace",
"(",
"icmp_socket",
",",
"dest_addr",
",",
"port_id",
",",
"sequence",
")",
":",
"icmp_header",
"=",
"struct",
".",
"pack",
"(",
"\"!bbHHh\"",
",",
"ICMP_ECHO_REQUEST",
",",
"0",
",",
"0",
",",
"port_id",
",",
"sequence",
")",
"pay... | Build, pack and send the ICMP packet using socket. | [
"Build",
"pack",
"and",
"send",
"the",
"ICMP",
"packet",
"using",
"socket",
"."
] | [
"\"\"\"Build, pack and send the ICMP packet using socket.\n\n Args:\n :param icmp_socket: the socket which is created from do_three_trace function.\n :param dest_addr: the IP address of the current node.\n :param port_id: current process id.\n :param sequence: the nth times of the cur... | [
{
"param": "icmp_socket",
"type": null
},
{
"param": "dest_addr",
"type": null
},
{
"param": "port_id",
"type": null
},
{
"param": "sequence",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: the time when packet is sent.",
"docstring_tokens": [
":",
"return",
":",
"the",
"time",
"when",
"packet",
"is",
"sent",
"."
],
"type": null
}
],
"raises": [],
... |
2ea4b8fad940240cb7ebc98d80bfff689495e259 | Hephaest/ComputerNetworkApplications | Traceroute/Traceroute.py | [
"MIT"
] | Python | do_three_trace | <not_specific> | def do_three_trace(dest_addr, ttl, sequence, time_out):
"""Create ICMP socket, send it and receive IP address of the current node.
After extracting the current node IP address from receiveOneTrace function,
we need to close the socket in order to cut the connection.
Args:
:param dest_addr: the... | Create ICMP socket, send it and receive IP address of the current node.
After extracting the current node IP address from receiveOneTrace function,
we need to close the socket in order to cut the connection.
Args:
:param dest_addr: the IP address of the current node.
:param ttl: Time To Li... | Create ICMP socket, send it and receive IP address of the current node.
After extracting the current node IP address from receiveOneTrace function,
we need to close the socket in order to cut the connection. | [
"Create",
"ICMP",
"socket",
"send",
"it",
"and",
"receive",
"IP",
"address",
"of",
"the",
"current",
"node",
".",
"After",
"extracting",
"the",
"current",
"node",
"IP",
"address",
"from",
"receiveOneTrace",
"function",
"we",
"need",
"to",
"close",
"the",
"so... | def do_three_trace(dest_addr, ttl, sequence, time_out):
port_id = os.getpid()
record_addr =""
record = False
for i in range(TIMES):
client_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, 1)
client_socket.setsockopt(socket.IPPROTO_IP, socket.IP_TTL, struct.pack('I', ttl))
... | [
"def",
"do_three_trace",
"(",
"dest_addr",
",",
"ttl",
",",
"sequence",
",",
"time_out",
")",
":",
"port_id",
"=",
"os",
".",
"getpid",
"(",
")",
"record_addr",
"=",
"\"\"",
"record",
"=",
"False",
"for",
"i",
"in",
"range",
"(",
"TIMES",
")",
":",
"... | Create ICMP socket, send it and receive IP address of the current node. | [
"Create",
"ICMP",
"socket",
"send",
"it",
"and",
"receive",
"IP",
"address",
"of",
"the",
"current",
"node",
"."
] | [
"\"\"\"Create ICMP socket, send it and receive IP address of the current node.\n\n After extracting the current node IP address from receiveOneTrace function,\n we need to close the socket in order to cut the connection.\n\n Args:\n :param dest_addr: the IP address of the current node.\n :par... | [
{
"param": "dest_addr",
"type": null
},
{
"param": "ttl",
"type": null
},
{
"param": "sequence",
"type": null
},
{
"param": "time_out",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: the IP address of the current node or a string (\"Request timeout\").",
"docstring_tokens": [
":",
"return",
":",
"the",
"IP",
"address",
"of",
"the",
"current",
"node",
"or"... |
2ea4b8fad940240cb7ebc98d80bfff689495e259 | Hephaest/ComputerNetworkApplications | Traceroute/Traceroute.py | [
"MIT"
] | Python | start_trace | null | def start_trace(*fuzzy_search_list):
"""Enter the tracert command, start test and catch the exceptions.
This function simulates tracert, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning.
Args:
:param fuzzy_search_list: I... | Enter the tracert command, start test and catch the exceptions.
This function simulates tracert, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning.
Args:
:param fuzzy_search_list: Ignore case to find the correct command.
... | Enter the tracert command, start test and catch the exceptions.
This function simulates tracert, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning. | [
"Enter",
"the",
"tracert",
"command",
"start",
"test",
"and",
"catch",
"the",
"exceptions",
".",
"This",
"function",
"simulates",
"tracert",
"an",
"executable",
"command",
"on",
"the",
"Windows",
"operating",
"system",
".",
"It",
"will",
"catch",
"a",
"wrong",... | def start_trace(*fuzzy_search_list):
startflag = True
while startflag:
command = input(os.getcwd() + ">" + os.path.basename(sys.argv[0]) + ">").split()
cmdLen = len(command)
if cmdLen == 0:
continue
elif cmdLen == 1:
if command[0] == "exit":
... | [
"def",
"start_trace",
"(",
"*",
"fuzzy_search_list",
")",
":",
"startflag",
"=",
"True",
"while",
"startflag",
":",
"command",
"=",
"input",
"(",
"os",
".",
"getcwd",
"(",
")",
"+",
"\">\"",
"+",
"os",
".",
"path",
".",
"basename",
"(",
"sys",
".",
"... | Enter the tracert command, start test and catch the exceptions. | [
"Enter",
"the",
"tracert",
"command",
"start",
"test",
"and",
"catch",
"the",
"exceptions",
"."
] | [
"\"\"\"Enter the tracert command, start test and catch the exceptions.\n\n This function simulates tracert, an executable command on the\n Windows operating system. It will catch a wrong command before a test\n and print a warning.\n\n Args:\n :param fuzzy_search_list: Ignore case to find the cor... | [] | {
"returns": [],
"raises": [
{
"docstring": "The destination host name could not be resolved.",
"docstring_tokens": [
"The",
"destination",
"host",
"name",
"could",
"not",
"be",
"resolved",
"."
],
"type": "socket.gai... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | checksum | <not_specific> | def checksum(string):
"""Fetch string and calculate the checksum.
This function is copied from sample code file.
Args:
:param string: A string of the time in seconds since the epoch.
Returns:
:return: The value of checksum (integer type).
"""
csum = 0
count_to = (len(strin... | Fetch string and calculate the checksum.
This function is copied from sample code file.
Args:
:param string: A string of the time in seconds since the epoch.
Returns:
:return: The value of checksum (integer type).
| Fetch string and calculate the checksum.
This function is copied from sample code file. | [
"Fetch",
"string",
"and",
"calculate",
"the",
"checksum",
".",
"This",
"function",
"is",
"copied",
"from",
"sample",
"code",
"file",
"."
] | def checksum(string):
csum = 0
count_to = (len(string) // 2) * 2
count = 0
while count < count_to:
this_val = string[count + 1] * 256 + string[count]
csum = csum + this_val
csum = csum & 0xffffffff
count = count + 2
if count_to < len(string):
csum = csum + str... | [
"def",
"checksum",
"(",
"string",
")",
":",
"csum",
"=",
"0",
"count_to",
"=",
"(",
"len",
"(",
"string",
")",
"//",
"2",
")",
"*",
"2",
"count",
"=",
"0",
"while",
"count",
"<",
"count_to",
":",
"this_val",
"=",
"string",
"[",
"count",
"+",
"1",... | Fetch string and calculate the checksum. | [
"Fetch",
"string",
"and",
"calculate",
"the",
"checksum",
"."
] | [
"\"\"\"Fetch string and calculate the checksum.\n\n This function is copied from sample code file.\n\n Args:\n :param string: A string of the time in seconds since the epoch.\n\n Returns:\n :return: The value of checksum (integer type).\n \"\"\""
] | [
{
"param": "string",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: The value of checksum (integer type).",
"docstring_tokens": [
":",
"return",
":",
"The",
"value",
"of",
"checksum",
"(",
"integer",
"type",
")",
"."
],
"t... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | ping_statistics | <not_specific> | def ping_statistics(list):
"""Find the minimum, maximum and average latency.
Args:
:param list: the list of delay time where packet is received successfully.
Returns:
:return: minimum, maximum and average latency (integer type).
"""
max_delay = list[0]
mini_delay = list[0]
... | Find the minimum, maximum and average latency.
Args:
:param list: the list of delay time where packet is received successfully.
Returns:
:return: minimum, maximum and average latency (integer type).
| Find the minimum, maximum and average latency. | [
"Find",
"the",
"minimum",
"maximum",
"and",
"average",
"latency",
"."
] | def ping_statistics(list):
max_delay = list[0]
mini_delay = list[0]
sum = 0
for item in list:
if item >= max_delay:
max_delay = item
elif item <= mini_delay:
mini_delay = item
sum += item
avg_delay = int(sum / (len(list)))
return mini_delay, max_de... | [
"def",
"ping_statistics",
"(",
"list",
")",
":",
"max_delay",
"=",
"list",
"[",
"0",
"]",
"mini_delay",
"=",
"list",
"[",
"0",
"]",
"sum",
"=",
"0",
"for",
"item",
"in",
"list",
":",
"if",
"item",
">=",
"max_delay",
":",
"max_delay",
"=",
"item",
"... | Find the minimum, maximum and average latency. | [
"Find",
"the",
"minimum",
"maximum",
"and",
"average",
"latency",
"."
] | [
"\"\"\"Find the minimum, maximum and average latency.\n\n Args:\n :param list: the list of delay time where packet is received successfully.\n\n Returns:\n :return: minimum, maximum and average latency (integer type).\n \"\"\""
] | [
{
"param": "list",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: minimum, maximum and average latency (integer type).",
"docstring_tokens": [
":",
"return",
":",
"minimum",
"maximum",
"and",
"average",
"latency",
"(",
"integer",
"type",
... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | receive_one_ping | <not_specific> | def receive_one_ping(icmp_socket, port_id, timeout, send_time):
"""The socket waits for a reply and calculate latency.
This function will measure and report different packet loss.
Args:
:param icmp_socket: the socket which is created from doOnePing function.
:param port_id: current process... | The socket waits for a reply and calculate latency.
This function will measure and report different packet loss.
Args:
:param icmp_socket: the socket which is created from doOnePing function.
:param port_id: current process id.
:param timeout: configurable timeout, set using an optiona... | The socket waits for a reply and calculate latency.
This function will measure and report different packet loss. | [
"The",
"socket",
"waits",
"for",
"a",
"reply",
"and",
"calculate",
"latency",
".",
"This",
"function",
"will",
"measure",
"and",
"report",
"different",
"packet",
"loss",
"."
] | def receive_one_ping(icmp_socket, port_id, timeout, send_time):
while True:
wait_for_data = select.select([icmp_socket], [], [], timeout)
data_received = time.time()
rec_packet, addr = icmp_socket.recvfrom(1024)
ip_header = rec_packet[8: 12]
icmp_header = rec_packet[20: 28]
... | [
"def",
"receive_one_ping",
"(",
"icmp_socket",
",",
"port_id",
",",
"timeout",
",",
"send_time",
")",
":",
"while",
"True",
":",
"wait_for_data",
"=",
"select",
".",
"select",
"(",
"[",
"icmp_socket",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"timeout",
... | The socket waits for a reply and calculate latency. | [
"The",
"socket",
"waits",
"for",
"a",
"reply",
"and",
"calculate",
"latency",
"."
] | [
"\"\"\"The socket waits for a reply and calculate latency.\n\n This function will measure and report different packet loss.\n\n Args:\n :param icmp_socket: the socket which is created from doOnePing function.\n :param port_id: current process id.\n :param timeout: configurable timeout, se... | [
{
"param": "icmp_socket",
"type": null
},
{
"param": "port_id",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param": "send_time",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: 1 (if Host unreachable error).\n0 (if Network unreachable error).\nbyte size, latency and ttl (for successful reply).",
"docstring_tokens": [
":",
"return",
":",
"1",
"(",
"if",
"Host",
"unreachable... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | send_one_ping | <not_specific> | def send_one_ping(icmp_socket, dest_addr, port_id, sequence):
"""Build, pack and send the ICMP packet using socket.
Args:
:param icmp_socket: the socket which is created from doOnePing function.
:param dest_addr: the IP address of the destination host.
:param port_id: current process id... | Build, pack and send the ICMP packet using socket.
Args:
:param icmp_socket: the socket which is created from doOnePing function.
:param dest_addr: the IP address of the destination host.
:param port_id: current process id.
:param sequence: the nth times of the latency test.
Re... | Build, pack and send the ICMP packet using socket. | [
"Build",
"pack",
"and",
"send",
"the",
"ICMP",
"packet",
"using",
"socket",
"."
] | def send_one_ping(icmp_socket, dest_addr, port_id, sequence):
icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, 0, port_id, sequence)
payload_data = struct.pack("!f", time.time())
packet_checksum = checksum(icmp_header + payload_data)
icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, pac... | [
"def",
"send_one_ping",
"(",
"icmp_socket",
",",
"dest_addr",
",",
"port_id",
",",
"sequence",
")",
":",
"icmp_header",
"=",
"struct",
".",
"pack",
"(",
"\"!bbHHh\"",
",",
"ICMP_ECHO_REQUEST",
",",
"0",
",",
"0",
",",
"port_id",
",",
"sequence",
")",
"payl... | Build, pack and send the ICMP packet using socket. | [
"Build",
"pack",
"and",
"send",
"the",
"ICMP",
"packet",
"using",
"socket",
"."
] | [
"\"\"\"Build, pack and send the ICMP packet using socket.\n\n Args:\n :param icmp_socket: the socket which is created from doOnePing function.\n :param dest_addr: the IP address of the destination host.\n :param port_id: current process id.\n :param sequence: the nth times of the late... | [
{
"param": "icmp_socket",
"type": null
},
{
"param": "dest_addr",
"type": null
},
{
"param": "port_id",
"type": null
},
{
"param": "sequence",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: the time when packet is sent.",
"docstring_tokens": [
":",
"return",
":",
"the",
"time",
"when",
"packet",
"is",
"sent",
"."
],
"type": null
}
],
"raises": [],
... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | do_one_ping | <not_specific> | def do_one_ping(dest_addr, timeout, sequence):
"""Create ICMP socket and then send, receive packets of the same size.
After getting the delay time from receiveOnePing function, we need to close
the socket in order to cut the connection.
Args:
:param dest_addr: the IP address of the destination... | Create ICMP socket and then send, receive packets of the same size.
After getting the delay time from receiveOnePing function, we need to close
the socket in order to cut the connection.
Args:
:param dest_addr: the IP address of the destination host.
:param timeout: configurable timeout, s... | Create ICMP socket and then send, receive packets of the same size.
After getting the delay time from receiveOnePing function, we need to close
the socket in order to cut the connection. | [
"Create",
"ICMP",
"socket",
"and",
"then",
"send",
"receive",
"packets",
"of",
"the",
"same",
"size",
".",
"After",
"getting",
"the",
"delay",
"time",
"from",
"receiveOnePing",
"function",
"we",
"need",
"to",
"close",
"the",
"socket",
"in",
"order",
"to",
... | def do_one_ping(dest_addr, timeout, sequence):
port_id = os.getpid()
icmp_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, 1)
icmp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, timeout)
send_time = send_one_ping(icmp_socket, dest_addr, port_id, sequence)
receive_data = receive_on... | [
"def",
"do_one_ping",
"(",
"dest_addr",
",",
"timeout",
",",
"sequence",
")",
":",
"port_id",
"=",
"os",
".",
"getpid",
"(",
")",
"icmp_socket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_RAW",
",",
"1",
")",... | Create ICMP socket and then send, receive packets of the same size. | [
"Create",
"ICMP",
"socket",
"and",
"then",
"send",
"receive",
"packets",
"of",
"the",
"same",
"size",
"."
] | [
"\"\"\"Create ICMP socket and then send, receive packets of the same size.\n\n After getting the delay time from receiveOnePing function, we need to close\n the socket in order to cut the connection.\n\n Args:\n :param dest_addr: the IP address of the destination host.\n :param timeout: confi... | [
{
"param": "dest_addr",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param": "sequence",
"type": null
}
] | {
"returns": [
{
"docstring": ":return: the delay time between the socket send and receive a packet.",
"docstring_tokens": [
":",
"return",
":",
"the",
"delay",
"time",
"between",
"the",
"socket",
"send",
"and",
... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | ping | null | def ping(host, count_num="4", time_out="1"):
"""Print the result to the console.
This function will print the IP address of the host, byte size, latency
and TTL of a packet or handle an exception after each ping.
Args:
:param host: The website or IP address that we want to test latency.
... | Print the result to the console.
This function will print the IP address of the host, byte size, latency
and TTL of a packet or handle an exception after each ping.
Args:
:param host: The website or IP address that we want to test latency.
:param count_num: the total number of the network ... | Print the result to the console.
This function will print the IP address of the host, byte size, latency
and TTL of a packet or handle an exception after each ping. | [
"Print",
"the",
"result",
"to",
"the",
"console",
".",
"This",
"function",
"will",
"print",
"the",
"IP",
"address",
"of",
"the",
"host",
"byte",
"size",
"latency",
"and",
"TTL",
"of",
"a",
"packet",
"or",
"handle",
"an",
"exception",
"after",
"each",
"pi... | def ping(host, count_num="4", time_out="1"):
ip_addr = socket.gethostbyname(host)
successful_list = list()
lost = 0
error = 0
bytes = 32
count = int(count_num)
timeout = int(time_out)
timeout_start = 0
head = False
timedout_mark = False
for i in range(count):
if hea... | [
"def",
"ping",
"(",
"host",
",",
"count_num",
"=",
"\"4\"",
",",
"time_out",
"=",
"\"1\"",
")",
":",
"ip_addr",
"=",
"socket",
".",
"gethostbyname",
"(",
"host",
")",
"successful_list",
"=",
"list",
"(",
")",
"lost",
"=",
"0",
"error",
"=",
"0",
"byt... | Print the result to the console. | [
"Print",
"the",
"result",
"to",
"the",
"console",
"."
] | [
"\"\"\"Print the result to the console.\n\n This function will print the IP address of the host, byte size, latency\n and TTL of a packet or handle an exception after each ping.\n\n Args:\n :param host: The website or IP address that we want to test latency.\n :param count_num: the total numb... | [
{
"param": "host",
"type": null
},
{
"param": "count_num",
"type": null
},
{
"param": "time_out",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "host",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count_num",
"type": null,
"docstring": null,
"docstring_token... |
996118eed46e7c4adc3edbf0a327090cf9456fab | Hephaest/ComputerNetworkApplications | ICMP Ping/ICMPPing.py | [
"MIT"
] | Python | start_ping | null | def start_ping(*fuzzy_search_list):
""" Enter the ping command, start test and catch the exceptions.
This function simulates ping, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning.
Args:
:param fuzzy_search_list: Ignore c... | Enter the ping command, start test and catch the exceptions.
This function simulates ping, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning.
Args:
:param fuzzy_search_list: Ignore case to find the correct command.
Raise... | Enter the ping command, start test and catch the exceptions.
This function simulates ping, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning. | [
"Enter",
"the",
"ping",
"command",
"start",
"test",
"and",
"catch",
"the",
"exceptions",
".",
"This",
"function",
"simulates",
"ping",
"an",
"executable",
"command",
"on",
"the",
"Windows",
"operating",
"system",
".",
"It",
"will",
"catch",
"a",
"wrong",
"co... | def start_ping(*fuzzy_search_list):
start_flag = True
while start_flag:
command = input(os.getcwd() + ">" +
os.path.basename(sys.argv[0]) + ">").split()
cmd_len = len(command)
if cmd_len == 0:
continue
elif cmd_len == 1:
if command[... | [
"def",
"start_ping",
"(",
"*",
"fuzzy_search_list",
")",
":",
"start_flag",
"=",
"True",
"while",
"start_flag",
":",
"command",
"=",
"input",
"(",
"os",
".",
"getcwd",
"(",
")",
"+",
"\">\"",
"+",
"os",
".",
"path",
".",
"basename",
"(",
"sys",
".",
... | Enter the ping command, start test and catch the exceptions. | [
"Enter",
"the",
"ping",
"command",
"start",
"test",
"and",
"catch",
"the",
"exceptions",
"."
] | [
"\"\"\" Enter the ping command, start test and catch the exceptions.\n\n This function simulates ping, an executable command on the\n Windows operating system. It will catch a wrong command before a test\n and print a warning.\n Args:\n :param fuzzy_search_list: Ignore case to find the correct co... | [] | {
"returns": [],
"raises": [
{
"docstring": "Hostname might be wrong.",
"docstring_tokens": [
"Hostname",
"might",
"be",
"wrong",
"."
],
"type": "socket.gaierror"
},
{
"docstring": "Optional argument is empty.",
"docstring_token... |
63ef5654d7094c040363f9598408ef0383559202 | Hephaest/ComputerNetworkApplications | Web Proxy/WebProxy.py | [
"MIT"
] | Python | start_listen | null | def start_listen(tcp_socket, client_ip, client_port):
""" Receive HTTP request message and retrieve the object from cache or server.
This function could handle different HTTP request message. Especially for
"Get" method type, proxy will firstly try to find the requested object from
cache, if not found,... | Receive HTTP request message and retrieve the object from cache or server.
This function could handle different HTTP request message. Especially for
"Get" method type, proxy will firstly try to find the requested object from
cache, if not found, proxy than forward the HTTP request message to server
an... | Receive HTTP request message and retrieve the object from cache or server.
This function could handle different HTTP request message. Especially for
"Get" method type, proxy will firstly try to find the requested object from
cache, if not found, proxy than forward the HTTP request message to server
and then forward the... | [
"Receive",
"HTTP",
"request",
"message",
"and",
"retrieve",
"the",
"object",
"from",
"cache",
"or",
"server",
".",
"This",
"function",
"could",
"handle",
"different",
"HTTP",
"request",
"message",
".",
"Especially",
"for",
"\"",
"Get",
"\"",
"method",
"type",
... | def start_listen(tcp_socket, client_ip, client_port):
message = tcp_socket.recv(1024).decode()
handle_str = StrProcess(message)
print("client is coming: {addr}:{port}".format(addr = client_ip, port = client_port))
file_error = False
global host
try:
command = handle_str.get_cmd_type()
... | [
"def",
"start_listen",
"(",
"tcp_socket",
",",
"client_ip",
",",
"client_port",
")",
":",
"message",
"=",
"tcp_socket",
".",
"recv",
"(",
"1024",
")",
".",
"decode",
"(",
")",
"handle_str",
"=",
"StrProcess",
"(",
"message",
")",
"print",
"(",
"\"client is... | Receive HTTP request message and retrieve the object from cache or server. | [
"Receive",
"HTTP",
"request",
"message",
"and",
"retrieve",
"the",
"object",
"from",
"cache",
"or",
"server",
"."
] | [
"\"\"\" Receive HTTP request message and retrieve the object from cache or server.\n\n This function could handle different HTTP request message. Especially for\n \"Get\" method type, proxy will firstly try to find the requested object from\n cache, if not found, proxy than forward the HTTP request message... | [
{
"param": "tcp_socket",
"type": null
},
{
"param": "client_ip",
"type": null
},
{
"param": "client_port",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "file does not exist.",
"docstring_tokens": [
"file",
"does",
"not",
"exist",
"."
],
"type": "IOError, FileNotFoundError"
},
{
"docstring": "client refresh the browser while server still sen... |
63ef5654d7094c040363f9598408ef0383559202 | Hephaest/ComputerNetworkApplications | Web Proxy/WebProxy.py | [
"MIT"
] | Python | start_server | null | def start_server(port):
"""Create a socket and wait for TCP connection at port [Port].
:param port: Configurable port, defined as an optional argument.
"""
# 1. Create server socket
server_socket = socket(AF_INET, SOCK_STREAM) # In IPv4
# 2. Bind the server socket to server address and server ... | Create a socket and wait for TCP connection at port [Port].
:param port: Configurable port, defined as an optional argument.
| Create a socket and wait for TCP connection at port [Port]. | [
"Create",
"a",
"socket",
"and",
"wait",
"for",
"TCP",
"connection",
"at",
"port",
"[",
"Port",
"]",
"."
] | def start_server(port):
server_socket = socket(AF_INET, SOCK_STREAM)
server_socket.bind(("", port))
server_socket.listen(5)
while True:
connection_socket, (client_ip, client_port) = server_socket.accept()
print('wait for request:')
start_listen(connection_socket, client_ip, cli... | [
"def",
"start_server",
"(",
"port",
")",
":",
"server_socket",
"=",
"socket",
"(",
"AF_INET",
",",
"SOCK_STREAM",
")",
"server_socket",
".",
"bind",
"(",
"(",
"\"\"",
",",
"port",
")",
")",
"server_socket",
".",
"listen",
"(",
"5",
")",
"while",
"True",
... | Create a socket and wait for TCP connection at port [Port]. | [
"Create",
"a",
"socket",
"and",
"wait",
"for",
"TCP",
"connection",
"at",
"port",
"[",
"Port",
"]",
"."
] | [
"\"\"\"Create a socket and wait for TCP connection at port [Port].\n\n :param port: Configurable port, defined as an optional argument.\n \"\"\"",
"# 1. Create server socket",
"# In IPv4",
"# 2. Bind the server socket to server address and server port",
"# 3. Continuously listen for connections to ser... | [
{
"param": "port",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "port",
"type": null,
"docstring": "Configurable port, defined as an optional argument.",
"docstring_tokens": [
"Configurable",
"port",
"defined",
"as",
"an",
"optional",
... |
7d7161739739057598e31d84ad178b9dd722f7d5 | dunnkevin/sdk-codegen | examples/python/create_dashboard_filter.py | [
"MIT"
] | Python | main | null | def main():
"""This file creates a new dashboard filter, and applies that filtering to all tiles on the dashboard.
Dashboard elements listen on the same field that the dashboard filter is created from.
This example can be modified to create a filter on many dashboards at once if you've added a new field to ... | This file creates a new dashboard filter, and applies that filtering to all tiles on the dashboard.
Dashboard elements listen on the same field that the dashboard filter is created from.
This example can be modified to create a filter on many dashboards at once if you've added a new field to your LookML,
... | This file creates a new dashboard filter, and applies that filtering to all tiles on the dashboard.
Dashboard elements listen on the same field that the dashboard filter is created from.
This example can be modified to create a filter on many dashboards at once if you've added a new field to your LookML,
dynamically ge... | [
"This",
"file",
"creates",
"a",
"new",
"dashboard",
"filter",
"and",
"applies",
"that",
"filtering",
"to",
"all",
"tiles",
"on",
"the",
"dashboard",
".",
"Dashboard",
"elements",
"listen",
"on",
"the",
"same",
"field",
"that",
"the",
"dashboard",
"filter",
"... | def main():
dash_id = '<dashboard_id>'
filter_name = '<name_of_filter>'
filter_model = '<model_name>'
filter_explore = '<explore_name>'
filter_dimension = '<view_name.field_name>'
filter = create_filter(dash_id, filter_name, filter_model, filter_explore, filter_dimension)
elements = sdk.das... | [
"def",
"main",
"(",
")",
":",
"dash_id",
"=",
"'<dashboard_id>'",
"filter_name",
"=",
"'<name_of_filter>'",
"filter_model",
"=",
"'<model_name>'",
"filter_explore",
"=",
"'<explore_name>'",
"filter_dimension",
"=",
"'<view_name.field_name>'",
"filter",
"=",
"create_filter... | This file creates a new dashboard filter, and applies that filtering to all tiles on the dashboard. | [
"This",
"file",
"creates",
"a",
"new",
"dashboard",
"filter",
"and",
"applies",
"that",
"filtering",
"to",
"all",
"tiles",
"on",
"the",
"dashboard",
"."
] | [
"\"\"\"This file creates a new dashboard filter, and applies that filtering to all tiles on the dashboard.\n Dashboard elements listen on the same field that the dashboard filter is created from.\n This example can be modified to create a filter on many dashboards at once if you've added a new field to your L... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7d7161739739057598e31d84ad178b9dd722f7d5 | dunnkevin/sdk-codegen | examples/python/create_dashboard_filter.py | [
"MIT"
] | Python | create_filter | DashboardFilter | def create_filter(dash_id: str, filter_name: str, filter_model: str, filter_explore: str , filter_dimension: str ) -> DashboardFilter:
"""Creates a dashboard filter object on the specified dashboard. Filters must be tied to a specific LookML Dimension.
Args:
dash_id (str): ID of the dashboard to create... | Creates a dashboard filter object on the specified dashboard. Filters must be tied to a specific LookML Dimension.
Args:
dash_id (str): ID of the dashboard to create the filter on
name (str): Name/Title of the filter
model (str): Model of the dimension
explore (str): Explore of the ... | Creates a dashboard filter object on the specified dashboard. Filters must be tied to a specific LookML Dimension. | [
"Creates",
"a",
"dashboard",
"filter",
"object",
"on",
"the",
"specified",
"dashboard",
".",
"Filters",
"must",
"be",
"tied",
"to",
"a",
"specific",
"LookML",
"Dimension",
"."
] | def create_filter(dash_id: str, filter_name: str, filter_model: str, filter_explore: str , filter_dimension: str ) -> DashboardFilter:
return sdk.create_dashboard_filter(
body=models.WriteCreateDashboardFilter(
dashboard_id=dash_id,
name=filter_name,
title=filter_name,
... | [
"def",
"create_filter",
"(",
"dash_id",
":",
"str",
",",
"filter_name",
":",
"str",
",",
"filter_model",
":",
"str",
",",
"filter_explore",
":",
"str",
",",
"filter_dimension",
":",
"str",
")",
"->",
"DashboardFilter",
":",
"return",
"sdk",
".",
"create_dash... | Creates a dashboard filter object on the specified dashboard. | [
"Creates",
"a",
"dashboard",
"filter",
"object",
"on",
"the",
"specified",
"dashboard",
"."
] | [
"\"\"\"Creates a dashboard filter object on the specified dashboard. Filters must be tied to a specific LookML Dimension.\n\n Args:\n dash_id (str): ID of the dashboard to create the filter on\n name (str): Name/Title of the filter\n model (str): Model of the dimension\n explore (str)... | [
{
"param": "dash_id",
"type": "str"
},
{
"param": "filter_name",
"type": "str"
},
{
"param": "filter_model",
"type": "str"
},
{
"param": "filter_explore",
"type": "str"
},
{
"param": "filter_dimension",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dash_id",
"type": "str",
"docstring": "ID of the dashboard to create the filter on",
"docstring_tokens": [
"ID",
"of",
"the",
"dashboard",
"to",
"create",
"the",
... |
7d7161739739057598e31d84ad178b9dd722f7d5 | dunnkevin/sdk-codegen | examples/python/create_dashboard_filter.py | [
"MIT"
] | Python | update_elements_filters | None | def update_elements_filters(element: DashboardElement, filter: DashboardFilter) -> None:
"""Updates a dashboard element's result maker to include a listener on the new dashboard filter.
Args:
element (DashboardElement): Dashboard element to update with the new filter
filter (DashboardFilter): ... | Updates a dashboard element's result maker to include a listener on the new dashboard filter.
Args:
element (DashboardElement): Dashboard element to update with the new filter
filter (DashboardFilter): Dashboard filter the element will listen to
| Updates a dashboard element's result maker to include a listener on the new dashboard filter. | [
"Updates",
"a",
"dashboard",
"element",
"'",
"s",
"result",
"maker",
"to",
"include",
"a",
"listener",
"on",
"the",
"new",
"dashboard",
"filter",
"."
] | def update_elements_filters(element: DashboardElement, filter: DashboardFilter) -> None:
current_filterables = element.result_maker.filterables
element.result_maker.filterables = []
for filterable in current_filterables:
new_listens = filterable.listen
if filter.model == filterable.model and... | [
"def",
"update_elements_filters",
"(",
"element",
":",
"DashboardElement",
",",
"filter",
":",
"DashboardFilter",
")",
"->",
"None",
":",
"current_filterables",
"=",
"element",
".",
"result_maker",
".",
"filterables",
"element",
".",
"result_maker",
".",
"filterable... | Updates a dashboard element's result maker to include a listener on the new dashboard filter. | [
"Updates",
"a",
"dashboard",
"element",
"'",
"s",
"result",
"maker",
"to",
"include",
"a",
"listener",
"on",
"the",
"new",
"dashboard",
"filter",
"."
] | [
"\"\"\"Updates a dashboard element's result maker to include a listener on the new dashboard filter.\n\n\n Args:\n element (DashboardElement): Dashboard element to update with the new filter\n filter (DashboardFilter): Dashboard filter the element will listen to\n \"\"\"",
"# Keep track of the... | [
{
"param": "element",
"type": "DashboardElement"
},
{
"param": "filter",
"type": "DashboardFilter"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "element",
"type": "DashboardElement",
"docstring": "Dashboard element to update with the new filter",
"docstring_tokens": [
"Dashboard",
"element",
"to",
"update",
"with",
"the",... |
bc498b48ab223457bde050e0d7c63a4fa8661694 | dsuch/dpath-python | dpath/util.py | [
"MIT"
] | Python | new | <not_specific> | def new(obj, path, value, separator="/"):
"""
Set the element at the terminus of path to value, and create
it if it does not exist (as opposed to 'set' that can only
change existing keys).
path will NOT be treated like a glob. If it has globbing
characters in it, they will become part of the re... |
Set the element at the terminus of path to value, and create
it if it does not exist (as opposed to 'set' that can only
change existing keys).
path will NOT be treated like a glob. If it has globbing
characters in it, they will become part of the resulting
keys
| Set the element at the terminus of path to value, and create
it if it does not exist (as opposed to 'set' that can only
change existing keys).
path will NOT be treated like a glob. If it has globbing
characters in it, they will become part of the resulting
keys | [
"Set",
"the",
"element",
"at",
"the",
"terminus",
"of",
"path",
"to",
"value",
"and",
"create",
"it",
"if",
"it",
"does",
"not",
"exist",
"(",
"as",
"opposed",
"to",
"'",
"set",
"'",
"that",
"can",
"only",
"change",
"existing",
"keys",
")",
".",
"pat... | def new(obj, path, value, separator="/"):
pathobj = dpath.path.path_types(obj, path.lstrip(separator).split(separator))
return dpath.path.set(obj, pathobj, value, create_missing=True) | [
"def",
"new",
"(",
"obj",
",",
"path",
",",
"value",
",",
"separator",
"=",
"\"/\"",
")",
":",
"pathobj",
"=",
"dpath",
".",
"path",
".",
"path_types",
"(",
"obj",
",",
"path",
".",
"lstrip",
"(",
"separator",
")",
".",
"split",
"(",
"separator",
"... | Set the element at the terminus of path to value, and create
it if it does not exist (as opposed to 'set' that can only
change existing keys). | [
"Set",
"the",
"element",
"at",
"the",
"terminus",
"of",
"path",
"to",
"value",
"and",
"create",
"it",
"if",
"it",
"does",
"not",
"exist",
"(",
"as",
"opposed",
"to",
"'",
"set",
"'",
"that",
"can",
"only",
"change",
"existing",
"keys",
")",
"."
] | [
"\"\"\"\n Set the element at the terminus of path to value, and create\n it if it does not exist (as opposed to 'set' that can only\n change existing keys).\n\n path will NOT be treated like a glob. If it has globbing\n characters in it, they will become part of the resulting\n keys\n \"\"\""
] | [
{
"param": "obj",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "separator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": []... |
bc498b48ab223457bde050e0d7c63a4fa8661694 | dsuch/dpath-python | dpath/util.py | [
"MIT"
] | Python | delete | <not_specific> | def delete(obj, glob, separator="/", afilter=None):
"""
Given a path glob, delete all elements that match the glob.
Returns the number of deleted objects. Raises PathNotFound if no paths are
found to delete.
"""
deleted = 0
paths = []
for path in _inner_search(obj, glob.lstrip(separator... |
Given a path glob, delete all elements that match the glob.
Returns the number of deleted objects. Raises PathNotFound if no paths are
found to delete.
| Given a path glob, delete all elements that match the glob.
Returns the number of deleted objects. Raises PathNotFound if no paths are
found to delete. | [
"Given",
"a",
"path",
"glob",
"delete",
"all",
"elements",
"that",
"match",
"the",
"glob",
".",
"Returns",
"the",
"number",
"of",
"deleted",
"objects",
".",
"Raises",
"PathNotFound",
"if",
"no",
"paths",
"are",
"found",
"to",
"delete",
"."
] | def delete(obj, glob, separator="/", afilter=None):
deleted = 0
paths = []
for path in _inner_search(obj, glob.lstrip(separator).split(separator), separator):
paths.append(path)
for path in paths:
cur = obj
prev = None
for item in path:
prev = cur
... | [
"def",
"delete",
"(",
"obj",
",",
"glob",
",",
"separator",
"=",
"\"/\"",
",",
"afilter",
"=",
"None",
")",
":",
"deleted",
"=",
"0",
"paths",
"=",
"[",
"]",
"for",
"path",
"in",
"_inner_search",
"(",
"obj",
",",
"glob",
".",
"lstrip",
"(",
"separa... | Given a path glob, delete all elements that match the glob. | [
"Given",
"a",
"path",
"glob",
"delete",
"all",
"elements",
"that",
"match",
"the",
"glob",
"."
] | [
"\"\"\"\n Given a path glob, delete all elements that match the glob.\n\n Returns the number of deleted objects. Raises PathNotFound if no paths are\n found to delete.\n \"\"\"",
"# These are yielded back, don't mess up the dict.",
"# This only happens when we delete X/Y and the next",
"# item in ... | [
{
"param": "obj",
"type": null
},
{
"param": "glob",
"type": null
},
{
"param": "separator",
"type": null
},
{
"param": "afilter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "glob",
"type": null,
"docstring": null,
"docstring_tokens": []... |
bc498b48ab223457bde050e0d7c63a4fa8661694 | dsuch/dpath-python | dpath/util.py | [
"MIT"
] | Python | values | <not_specific> | def values(obj, glob, separator="/", afilter=None, dirs=True):
"""
Given an object and a path glob, return an array of all values which match
the glob. The arguments to this function are identical to those of search(),
and it is primarily a shorthand for a list comprehension over a yielded
search ca... |
Given an object and a path glob, return an array of all values which match
the glob. The arguments to this function are identical to those of search(),
and it is primarily a shorthand for a list comprehension over a yielded
search call.
| Given an object and a path glob, return an array of all values which match
the glob. The arguments to this function are identical to those of search(),
and it is primarily a shorthand for a list comprehension over a yielded
search call. | [
"Given",
"an",
"object",
"and",
"a",
"path",
"glob",
"return",
"an",
"array",
"of",
"all",
"values",
"which",
"match",
"the",
"glob",
".",
"The",
"arguments",
"to",
"this",
"function",
"are",
"identical",
"to",
"those",
"of",
"search",
"()",
"and",
"it",... | def values(obj, glob, separator="/", afilter=None, dirs=True):
return [x[1] for x in dpath.util.search(obj, glob, yielded=True, separator=separator, afilter=afilter, dirs=dirs)] | [
"def",
"values",
"(",
"obj",
",",
"glob",
",",
"separator",
"=",
"\"/\"",
",",
"afilter",
"=",
"None",
",",
"dirs",
"=",
"True",
")",
":",
"return",
"[",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"dpath",
".",
"util",
".",
"search",
"(",
"obj",
","... | Given an object and a path glob, return an array of all values which match
the glob. | [
"Given",
"an",
"object",
"and",
"a",
"path",
"glob",
"return",
"an",
"array",
"of",
"all",
"values",
"which",
"match",
"the",
"glob",
"."
] | [
"\"\"\"\n Given an object and a path glob, return an array of all values which match\n the glob. The arguments to this function are identical to those of search(),\n and it is primarily a shorthand for a list comprehension over a yielded\n search call.\n \"\"\""
] | [
{
"param": "obj",
"type": null
},
{
"param": "glob",
"type": null
},
{
"param": "separator",
"type": null
},
{
"param": "afilter",
"type": null
},
{
"param": "dirs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "glob",
"type": null,
"docstring": null,
"docstring_tokens": []... |
bc498b48ab223457bde050e0d7c63a4fa8661694 | dsuch/dpath-python | dpath/util.py | [
"MIT"
] | Python | search | <not_specific> | def search(obj, glob, yielded=False, separator="/", afilter=None, dirs = True):
"""
Given a path glob, return a dictionary containing all keys
that matched the given glob.
If 'yielded' is true, then a dictionary will not be returned.
Instead tuples will be yielded in the form of (path, value) for
... |
Given a path glob, return a dictionary containing all keys
that matched the given glob.
If 'yielded' is true, then a dictionary will not be returned.
Instead tuples will be yielded in the form of (path, value) for
every element in the document that matched the glob.
| Given a path glob, return a dictionary containing all keys
that matched the given glob.
If 'yielded' is true, then a dictionary will not be returned.
Instead tuples will be yielded in the form of (path, value) for
every element in the document that matched the glob. | [
"Given",
"a",
"path",
"glob",
"return",
"a",
"dictionary",
"containing",
"all",
"keys",
"that",
"matched",
"the",
"given",
"glob",
".",
"If",
"'",
"yielded",
"'",
"is",
"true",
"then",
"a",
"dictionary",
"will",
"not",
"be",
"returned",
".",
"Instead",
"... | def search(obj, glob, yielded=False, separator="/", afilter=None, dirs = True):
def _search_view(obj, glob, separator, afilter, dirs):
view = {}
for path in _inner_search(obj, glob.lstrip(separator).split(separator), separator, dirs=dirs):
try:
val = dpath.path.get(obj, p... | [
"def",
"search",
"(",
"obj",
",",
"glob",
",",
"yielded",
"=",
"False",
",",
"separator",
"=",
"\"/\"",
",",
"afilter",
"=",
"None",
",",
"dirs",
"=",
"True",
")",
":",
"def",
"_search_view",
"(",
"obj",
",",
"glob",
",",
"separator",
",",
"afilter",... | Given a path glob, return a dictionary containing all keys
that matched the given glob. | [
"Given",
"a",
"path",
"glob",
"return",
"a",
"dictionary",
"containing",
"all",
"keys",
"that",
"matched",
"the",
"given",
"glob",
"."
] | [
"\"\"\"\n Given a path glob, return a dictionary containing all keys\n that matched the given glob.\n\n If 'yielded' is true, then a dictionary will not be returned.\n Instead tuples will be yielded in the form of (path, value) for\n every element in the document that matched the glob.\n \"\"\""
] | [
{
"param": "obj",
"type": null
},
{
"param": "glob",
"type": null
},
{
"param": "yielded",
"type": null
},
{
"param": "separator",
"type": null
},
{
"param": "afilter",
"type": null
},
{
"param": "dirs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "glob",
"type": null,
"docstring": null,
"docstring_tokens": []... |
bc498b48ab223457bde050e0d7c63a4fa8661694 | dsuch/dpath-python | dpath/util.py | [
"MIT"
] | Python | _inner_search | null | def _inner_search(obj, glob, separator, dirs=True, leaves=False):
"""Search the object paths that match the glob."""
for path in dpath.path.paths(obj, dirs, leaves, skip=True, separator = separator):
if dpath.path.match(path, glob):
yield path | Search the object paths that match the glob. | Search the object paths that match the glob. | [
"Search",
"the",
"object",
"paths",
"that",
"match",
"the",
"glob",
"."
] | def _inner_search(obj, glob, separator, dirs=True, leaves=False):
for path in dpath.path.paths(obj, dirs, leaves, skip=True, separator = separator):
if dpath.path.match(path, glob):
yield path | [
"def",
"_inner_search",
"(",
"obj",
",",
"glob",
",",
"separator",
",",
"dirs",
"=",
"True",
",",
"leaves",
"=",
"False",
")",
":",
"for",
"path",
"in",
"dpath",
".",
"path",
".",
"paths",
"(",
"obj",
",",
"dirs",
",",
"leaves",
",",
"skip",
"=",
... | Search the object paths that match the glob. | [
"Search",
"the",
"object",
"paths",
"that",
"match",
"the",
"glob",
"."
] | [
"\"\"\"Search the object paths that match the glob.\"\"\""
] | [
{
"param": "obj",
"type": null
},
{
"param": "glob",
"type": null
},
{
"param": "separator",
"type": null
},
{
"param": "dirs",
"type": null
},
{
"param": "leaves",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "glob",
"type": null,
"docstring": null,
"docstring_tokens": []... |
bc498b48ab223457bde050e0d7c63a4fa8661694 | dsuch/dpath-python | dpath/util.py | [
"MIT"
] | Python | merge | <not_specific> | def merge(dst, src, separator="/", afilter=None, flags=MERGE_ADDITIVE, _path=""):
"""Merge source into destination. Like dict.update() but performs
deep merging.
flags is an OR'ed combination of MERGE_ADDITIVE, MERGE_REPLACE, or
MERGE_TYPESAFE.
* MERGE_ADDITIVE : List objects are combined onto ... | Merge source into destination. Like dict.update() but performs
deep merging.
flags is an OR'ed combination of MERGE_ADDITIVE, MERGE_REPLACE, or
MERGE_TYPESAFE.
* MERGE_ADDITIVE : List objects are combined onto one long
list (NOT a set). This is the default flag.
* MERGE_REPLACE : ... | Merge source into destination. Like dict.update() but performs
deep merging.
flags is an OR'ed combination of MERGE_ADDITIVE, MERGE_REPLACE, or
MERGE_TYPESAFE.
MERGE_ADDITIVE : List objects are combined onto one long
list (NOT a set). This is the default flag.
MERGE_REPLACE : Instead of combining list objects, when
2 ... | [
"Merge",
"source",
"into",
"destination",
".",
"Like",
"dict",
".",
"update",
"()",
"but",
"performs",
"deep",
"merging",
".",
"flags",
"is",
"an",
"OR",
"'",
"ed",
"combination",
"of",
"MERGE_ADDITIVE",
"MERGE_REPLACE",
"or",
"MERGE_TYPESAFE",
".",
"MERGE_ADD... | def merge(dst, src, separator="/", afilter=None, flags=MERGE_ADDITIVE, _path=""):
if afilter:
src = search(src, '**', afilter=afilter)
return merge(dst, src)
def _check_typesafe(obj1, obj2, key, path):
if not key in obj1:
return
elif ( (flags & MERGE_TYPESAFE == MERGE... | [
"def",
"merge",
"(",
"dst",
",",
"src",
",",
"separator",
"=",
"\"/\"",
",",
"afilter",
"=",
"None",
",",
"flags",
"=",
"MERGE_ADDITIVE",
",",
"_path",
"=",
"\"\"",
")",
":",
"if",
"afilter",
":",
"src",
"=",
"search",
"(",
"src",
",",
"'**'",
",",... | Merge source into destination. | [
"Merge",
"source",
"into",
"destination",
"."
] | [
"\"\"\"Merge source into destination. Like dict.update() but performs\n deep merging.\n\n flags is an OR'ed combination of MERGE_ADDITIVE, MERGE_REPLACE, or\n MERGE_TYPESAFE.\n * MERGE_ADDITIVE : List objects are combined onto one long\n list (NOT a set). This is the default flag.\n ... | [
{
"param": "dst",
"type": null
},
{
"param": "src",
"type": null
},
{
"param": "separator",
"type": null
},
{
"param": "afilter",
"type": null
},
{
"param": "flags",
"type": null
},
{
"param": "_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dst",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
802c10818c866b29854020f2569eac35870df7d8 | dsuch/dpath-python | dpath/path.py | [
"MIT"
] | Python | path_types | <not_specific> | def path_types(obj, path):
"""
Given a list of path name elements, return anew list of [name, type] path components, given the reference object.
"""
result = []
#for elem in path[:-1]:
cur = obj
for elem in path[:-1]:
if ((issubclass(cur.__class__, dict) and elem in cur)):
... |
Given a list of path name elements, return anew list of [name, type] path components, given the reference object.
| Given a list of path name elements, return anew list of [name, type] path components, given the reference object. | [
"Given",
"a",
"list",
"of",
"path",
"name",
"elements",
"return",
"anew",
"list",
"of",
"[",
"name",
"type",
"]",
"path",
"components",
"given",
"the",
"reference",
"object",
"."
] | def path_types(obj, path):
result = []
cur = obj
for elem in path[:-1]:
if ((issubclass(cur.__class__, dict) and elem in cur)):
result.append([elem, cur[elem].__class__])
cur = cur[elem]
elif (issubclass(cur.__class__, (list, tuple)) and int(elem) < len(cur)):
... | [
"def",
"path_types",
"(",
"obj",
",",
"path",
")",
":",
"result",
"=",
"[",
"]",
"cur",
"=",
"obj",
"for",
"elem",
"in",
"path",
"[",
":",
"-",
"1",
"]",
":",
"if",
"(",
"(",
"issubclass",
"(",
"cur",
".",
"__class__",
",",
"dict",
")",
"and",
... | Given a list of path name elements, return anew list of [name, type] path components, given the reference object. | [
"Given",
"a",
"list",
"of",
"path",
"name",
"elements",
"return",
"anew",
"list",
"of",
"[",
"name",
"type",
"]",
"path",
"components",
"given",
"the",
"reference",
"object",
"."
] | [
"\"\"\"\n Given a list of path name elements, return anew list of [name, type] path components, given the reference object.\n \"\"\"",
"#for elem in path[:-1]:"
] | [
{
"param": "obj",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": []... |
802c10818c866b29854020f2569eac35870df7d8 | dsuch/dpath-python | dpath/path.py | [
"MIT"
] | Python | paths_only | <not_specific> | def paths_only(path):
"""
Return a list containing only the pathnames of the given path list, not the types.
"""
l = []
for p in path:
l.append(p[0])
return l |
Return a list containing only the pathnames of the given path list, not the types.
| Return a list containing only the pathnames of the given path list, not the types. | [
"Return",
"a",
"list",
"containing",
"only",
"the",
"pathnames",
"of",
"the",
"given",
"path",
"list",
"not",
"the",
"types",
"."
] | def paths_only(path):
l = []
for p in path:
l.append(p[0])
return l | [
"def",
"paths_only",
"(",
"path",
")",
":",
"l",
"=",
"[",
"]",
"for",
"p",
"in",
"path",
":",
"l",
".",
"append",
"(",
"p",
"[",
"0",
"]",
")",
"return",
"l"
] | Return a list containing only the pathnames of the given path list, not the types. | [
"Return",
"a",
"list",
"containing",
"only",
"the",
"pathnames",
"of",
"the",
"given",
"path",
"list",
"not",
"the",
"types",
"."
] | [
"\"\"\"\n Return a list containing only the pathnames of the given path list, not the types.\n \"\"\""
] | [
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
802c10818c866b29854020f2569eac35870df7d8 | dsuch/dpath-python | dpath/path.py | [
"MIT"
] | Python | validate | null | def validate(path, separator="/", regex=None):
"""
Validate that all the keys in the given list of path components are valid, given that they do not contain the separator, and match any optional regex given.
"""
validated = []
for elem in path:
key = elem[0]
strkey = str(key)
... |
Validate that all the keys in the given list of path components are valid, given that they do not contain the separator, and match any optional regex given.
| Validate that all the keys in the given list of path components are valid, given that they do not contain the separator, and match any optional regex given. | [
"Validate",
"that",
"all",
"the",
"keys",
"in",
"the",
"given",
"list",
"of",
"path",
"components",
"are",
"valid",
"given",
"that",
"they",
"do",
"not",
"contain",
"the",
"separator",
"and",
"match",
"any",
"optional",
"regex",
"given",
"."
] | def validate(path, separator="/", regex=None):
validated = []
for elem in path:
key = elem[0]
strkey = str(key)
if (separator and (separator in strkey)):
raise dpath.exceptions.InvalidKeyName("{} at {} contains the separator {}"
... | [
"def",
"validate",
"(",
"path",
",",
"separator",
"=",
"\"/\"",
",",
"regex",
"=",
"None",
")",
":",
"validated",
"=",
"[",
"]",
"for",
"elem",
"in",
"path",
":",
"key",
"=",
"elem",
"[",
"0",
"]",
"strkey",
"=",
"str",
"(",
"key",
")",
"if",
"... | Validate that all the keys in the given list of path components are valid, given that they do not contain the separator, and match any optional regex given. | [
"Validate",
"that",
"all",
"the",
"keys",
"in",
"the",
"given",
"list",
"of",
"path",
"components",
"are",
"valid",
"given",
"that",
"they",
"do",
"not",
"contain",
"the",
"separator",
"and",
"match",
"any",
"optional",
"regex",
"given",
"."
] | [
"\"\"\"\n Validate that all the keys in the given list of path components are valid, given that they do not contain the separator, and match any optional regex given.\n \"\"\""
] | [
{
"param": "path",
"type": null
},
{
"param": "separator",
"type": null
},
{
"param": "regex",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "separator",
"type": null,
"docstring": null,
"docstring_token... |
802c10818c866b29854020f2569eac35870df7d8 | dsuch/dpath-python | dpath/path.py | [
"MIT"
] | Python | match | <not_specific> | def match(path, glob):
"""Match the path with the glob.
Arguments:
path -- A list of keys representing the path.
glob -- A list of globs to match against the path.
"""
path_len = len(path)
glob_len = len(glob)
ss = -1
ss_glob = glob
if '**' in glob:
ss = glob.index('*... | Match the path with the glob.
Arguments:
path -- A list of keys representing the path.
glob -- A list of globs to match against the path.
| Match the path with the glob.
Arguments.
- A list of keys representing the path.
glob -- A list of globs to match against the path. | [
"Match",
"the",
"path",
"with",
"the",
"glob",
".",
"Arguments",
".",
"-",
"A",
"list",
"of",
"keys",
"representing",
"the",
"path",
".",
"glob",
"--",
"A",
"list",
"of",
"globs",
"to",
"match",
"against",
"the",
"path",
"."
] | def match(path, glob):
path_len = len(path)
glob_len = len(glob)
ss = -1
ss_glob = glob
if '**' in glob:
ss = glob.index('**')
if '**' in glob[ss + 1:]:
raise dpath.exceptions.InvalidGlob("Invalid glob. Only one '**' is permitted per glob.")
if path_len >= glob_le... | [
"def",
"match",
"(",
"path",
",",
"glob",
")",
":",
"path_len",
"=",
"len",
"(",
"path",
")",
"glob_len",
"=",
"len",
"(",
"glob",
")",
"ss",
"=",
"-",
"1",
"ss_glob",
"=",
"glob",
"if",
"'**'",
"in",
"glob",
":",
"ss",
"=",
"glob",
".",
"index... | Match the path with the glob. | [
"Match",
"the",
"path",
"with",
"the",
"glob",
"."
] | [
"\"\"\"Match the path with the glob.\n\n Arguments:\n\n path -- A list of keys representing the path.\n glob -- A list of globs to match against the path.\n\n \"\"\"",
"# Just right or more stars.",
"# Need one less star.",
"# Python 3 support",
"# Default to Python 2"
] | [
{
"param": "path",
"type": null
},
{
"param": "glob",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "glob",
"type": null,
"docstring": null,
"docstring_tokens": [... |
ee9f470ec32ac521c4caeb3b0ef2fd16a4e5bfde | Jesse989/home-price-predictions | notebooks/model.py | [
"MIT"
] | Python | adj_r2 | <not_specific> | def adj_r2(r2_score, num_observations, num_parameters):
"""Calculate the Adjusted R-Squared value
Args:
r2_score (int): R-Squared value to adjust
num_observations (int): Number of observations used in model
num_parameters (int): Number of parameters used in model
Returns:
... | Calculate the Adjusted R-Squared value
Args:
r2_score (int): R-Squared value to adjust
num_observations (int): Number of observations used in model
num_parameters (int): Number of parameters used in model
Returns:
adj_r2 (float): Adjusted R-Squared value
| Calculate the Adjusted R-Squared value | [
"Calculate",
"the",
"Adjusted",
"R",
"-",
"Squared",
"value"
] | def adj_r2(r2_score, num_observations, num_parameters):
return r2_score-(num_parameters-1)/(num_observations-num_parameters)*(1-r2_score) | [
"def",
"adj_r2",
"(",
"r2_score",
",",
"num_observations",
",",
"num_parameters",
")",
":",
"return",
"r2_score",
"-",
"(",
"num_parameters",
"-",
"1",
")",
"/",
"(",
"num_observations",
"-",
"num_parameters",
")",
"*",
"(",
"1",
"-",
"r2_score",
")"
] | Calculate the Adjusted R-Squared value | [
"Calculate",
"the",
"Adjusted",
"R",
"-",
"Squared",
"value"
] | [
"\"\"\"Calculate the Adjusted R-Squared value\n\n Args: \n r2_score (int): R-Squared value to adjust\n num_observations (int): Number of observations used in model\n num_parameters (int): Number of parameters used in model\n\n Returns:\n adj_r2 (float): Adjusted R-Squared value\n ... | [
{
"param": "r2_score",
"type": null
},
{
"param": "num_observations",
"type": null
},
{
"param": "num_parameters",
"type": null
}
] | {
"returns": [
{
"docstring": "adj_r2 (float): Adjusted R-Squared value",
"docstring_tokens": [
"adj_r2",
"(",
"float",
")",
":",
"Adjusted",
"R",
"-",
"Squared",
"value"
],
"type": null
}
],
"raises": ... |
5e3cba3ed6e39eba96454e70ea9eddd50ed9c475 | jamiehathaway/gap | scripts/scene_checker.py | [
"Apache-2.0"
] | Python | parseArgs | <not_specific> | def parseArgs(argv):
'''
Parses command-line options.
'''
# Parameters
data_dir = ''
img_dir = ''
first = 0
scenes = 1
img_ext = '.png'
usage = 'usage: ' + argv[0] + ' [options]\n' + USAGE
try:
opts, args = getopt.getopt(argv[1:],
"hi:d:s:n:e:",["img_... |
Parses command-line options.
| Parses command-line options. | [
"Parses",
"command",
"-",
"line",
"options",
"."
] | def parseArgs(argv):
data_dir = ''
img_dir = ''
first = 0
scenes = 1
img_ext = '.png'
usage = 'usage: ' + argv[0] + ' [options]\n' + USAGE
try:
opts, args = getopt.getopt(argv[1:],
"hi:d:s:n:e:",["img_dir=","data_dir=","scenes=","first=","img_ext"])
except getopt.Ge... | [
"def",
"parseArgs",
"(",
"argv",
")",
":",
"data_dir",
"=",
"''",
"img_dir",
"=",
"''",
"first",
"=",
"0",
"scenes",
"=",
"1",
"img_ext",
"=",
"'.png'",
"usage",
"=",
"'usage: '",
"+",
"argv",
"[",
"0",
"]",
"+",
"' [options]\\n'",
"+",
"USAGE",
"t... | Parses command-line options. | [
"Parses",
"command",
"-",
"line",
"options",
"."
] | [
"'''\n Parses command-line options.\n '''",
"# Parameters"
] | [
{
"param": "argv",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argv",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e3cba3ed6e39eba96454e70ea9eddd50ed9c475 | jamiehathaway/gap | scripts/scene_checker.py | [
"Apache-2.0"
] | Python | onUpdate | null | def onUpdate(self):
'''
Shows image and object bounding box overlays.
'''
# Filenames
img_file = self.img_dir + '/' + str(int(self.cur / 100)) + \
'00/' + str(self.cur) + self.img_ext
data_file = self.data_dir + '/' + str(self.cur) + EXT_DATA
# print(... |
Shows image and object bounding box overlays.
| Shows image and object bounding box overlays. | [
"Shows",
"image",
"and",
"object",
"bounding",
"box",
"overlays",
"."
] | def onUpdate(self):
img_file = self.img_dir + '/' + str(int(self.cur / 100)) + \
'00/' + str(self.cur) + self.img_ext
data_file = self.data_dir + '/' + str(self.cur) + EXT_DATA
self.canvas.delete("all")
try:
image = Image.open(img_file)
photo = ImageT... | [
"def",
"onUpdate",
"(",
"self",
")",
":",
"img_file",
"=",
"self",
".",
"img_dir",
"+",
"'/'",
"+",
"str",
"(",
"int",
"(",
"self",
".",
"cur",
"/",
"100",
")",
")",
"+",
"'00/'",
"+",
"str",
"(",
"self",
".",
"cur",
")",
"+",
"self",
".",
"i... | Shows image and object bounding box overlays. | [
"Shows",
"image",
"and",
"object",
"bounding",
"box",
"overlays",
"."
] | [
"'''\n Shows image and object bounding box overlays.\n '''",
"# Filenames",
"# print(img_file, data_file)",
"# Clean canvas",
"# Update scene image",
"# Open XML dataset file",
"# Commands",
"# Draw label with cur / total scene indicator",
"# Draw help label",
"# Draw bounding boxes"... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e3cba3ed6e39eba96454e70ea9eddd50ed9c475 | jamiehathaway/gap | scripts/scene_checker.py | [
"Apache-2.0"
] | Python | onLeft | <not_specific> | def onLeft(self, event):
'''
Updates counter and calls update function.
'''
if (self.cur == 0): return
self.cur = self.cur - 1
if (self.cur >= self.first + self.scenes): sys.exit(0)
self.onUpdate() |
Updates counter and calls update function.
| Updates counter and calls update function. | [
"Updates",
"counter",
"and",
"calls",
"update",
"function",
"."
] | def onLeft(self, event):
if (self.cur == 0): return
self.cur = self.cur - 1
if (self.cur >= self.first + self.scenes): sys.exit(0)
self.onUpdate() | [
"def",
"onLeft",
"(",
"self",
",",
"event",
")",
":",
"if",
"(",
"self",
".",
"cur",
"==",
"0",
")",
":",
"return",
"self",
".",
"cur",
"=",
"self",
".",
"cur",
"-",
"1",
"if",
"(",
"self",
".",
"cur",
">=",
"self",
".",
"first",
"+",
"self",... | Updates counter and calls update function. | [
"Updates",
"counter",
"and",
"calls",
"update",
"function",
"."
] | [
"'''\n Updates counter and calls update function.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "event",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "event",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5e3cba3ed6e39eba96454e70ea9eddd50ed9c475 | jamiehathaway/gap | scripts/scene_checker.py | [
"Apache-2.0"
] | Python | onRight | <not_specific> | def onRight(self, event):
'''
Updates counter and calls update function.
'''
if (self.cur == self.first + self.scenes - 1): return
self.cur = self.cur + 1
if (self.cur >= self.first + self.scenes): sys.exit(0)
self.onUpdate() |
Updates counter and calls update function.
| Updates counter and calls update function. | [
"Updates",
"counter",
"and",
"calls",
"update",
"function",
"."
] | def onRight(self, event):
if (self.cur == self.first + self.scenes - 1): return
self.cur = self.cur + 1
if (self.cur >= self.first + self.scenes): sys.exit(0)
self.onUpdate() | [
"def",
"onRight",
"(",
"self",
",",
"event",
")",
":",
"if",
"(",
"self",
".",
"cur",
"==",
"self",
".",
"first",
"+",
"self",
".",
"scenes",
"-",
"1",
")",
":",
"return",
"self",
".",
"cur",
"=",
"self",
".",
"cur",
"+",
"1",
"if",
"(",
"sel... | Updates counter and calls update function. | [
"Updates",
"counter",
"and",
"calls",
"update",
"function",
"."
] | [
"'''\n Updates counter and calls update function.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "event",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "event",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5e3cba3ed6e39eba96454e70ea9eddd50ed9c475 | jamiehathaway/gap | scripts/scene_checker.py | [
"Apache-2.0"
] | Python | main | null | def main(argv):
'''
Simple tool to open image and overlay bounding box data to check
whether or not a scene dataset is correct.
'''
# Obtain command-line arguments
[data_dir, img_dir, scenes, first, img_ext] = parseArgs(argv)
# Open root window
root = tk.Tk()
# Create app objec... |
Simple tool to open image and overlay bounding box data to check
whether or not a scene dataset is correct.
| Simple tool to open image and overlay bounding box data to check
whether or not a scene dataset is correct. | [
"Simple",
"tool",
"to",
"open",
"image",
"and",
"overlay",
"bounding",
"box",
"data",
"to",
"check",
"whether",
"or",
"not",
"a",
"scene",
"dataset",
"is",
"correct",
"."
] | def main(argv):
[data_dir, img_dir, scenes, first, img_ext] = parseArgs(argv)
root = tk.Tk()
app = ImageViewer(root, data_dir, img_dir, scenes, first, img_ext)
root.mainloop() | [
"def",
"main",
"(",
"argv",
")",
":",
"[",
"data_dir",
",",
"img_dir",
",",
"scenes",
",",
"first",
",",
"img_ext",
"]",
"=",
"parseArgs",
"(",
"argv",
")",
"root",
"=",
"tk",
".",
"Tk",
"(",
")",
"app",
"=",
"ImageViewer",
"(",
"root",
",",
"dat... | Simple tool to open image and overlay bounding box data to check
whether or not a scene dataset is correct. | [
"Simple",
"tool",
"to",
"open",
"image",
"and",
"overlay",
"bounding",
"box",
"data",
"to",
"check",
"whether",
"or",
"not",
"a",
"scene",
"dataset",
"is",
"correct",
"."
] | [
"'''\n Simple tool to open image and overlay bounding box data to check\n whether or not a scene dataset is correct.\n '''",
"# Obtain command-line arguments",
"# Open root window",
"# Create app object",
"# Main loop"
] | [
{
"param": "argv",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argv",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ddba753cee098b325cb03d0235c9e86fbdaedf9 | pllim/ci_watson | ci_watson/artifactory_helpers.py | [
"BSD-3-Clause"
] | Python | check_url | <not_specific> | def check_url(url):
"""Determine if URL can be resolved without error."""
if RE_URL.match(url) is None:
return False
# Optional import: requests is not needed for local big data setup.
import requests
# requests.head does not work with Artifactory landing page.
r = requests.get(url, al... | Determine if URL can be resolved without error. | Determine if URL can be resolved without error. | [
"Determine",
"if",
"URL",
"can",
"be",
"resolved",
"without",
"error",
"."
] | def check_url(url):
if RE_URL.match(url) is None:
return False
import requests
r = requests.get(url, allow_redirects=True)
if r.status_code >= 400:
return False
return True | [
"def",
"check_url",
"(",
"url",
")",
":",
"if",
"RE_URL",
".",
"match",
"(",
"url",
")",
"is",
"None",
":",
"return",
"False",
"import",
"requests",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"allow_redirects",
"=",
"True",
")",
"if",
"r",
... | Determine if URL can be resolved without error. | [
"Determine",
"if",
"URL",
"can",
"be",
"resolved",
"without",
"error",
"."
] | [
"\"\"\"Determine if URL can be resolved without error.\"\"\"",
"# Optional import: requests is not needed for local big data setup.",
"# requests.head does not work with Artifactory landing page.",
"# TODO: Can we simply return r.ok here?"
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ddba753cee098b325cb03d0235c9e86fbdaedf9 | pllim/ci_watson | ci_watson/artifactory_helpers.py | [
"BSD-3-Clause"
] | Python | _download | <not_specific> | def _download(url, dest, timeout=30):
"""Simple HTTP/HTTPS downloader."""
# Optional import: requests is not needed for local big data setup.
import requests
dest = os.path.abspath(dest)
with requests.get(url, stream=True, timeout=timeout) as r:
with open(dest, 'w+b') as data:
... | Simple HTTP/HTTPS downloader. | Simple HTTP/HTTPS downloader. | [
"Simple",
"HTTP",
"/",
"HTTPS",
"downloader",
"."
] | def _download(url, dest, timeout=30):
import requests
dest = os.path.abspath(dest)
with requests.get(url, stream=True, timeout=timeout) as r:
with open(dest, 'w+b') as data:
for chunk in r.iter_content(chunk_size=0x4000):
data.write(chunk)
return dest | [
"def",
"_download",
"(",
"url",
",",
"dest",
",",
"timeout",
"=",
"30",
")",
":",
"import",
"requests",
"dest",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"dest",
")",
"with",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
",",
... | Simple HTTP/HTTPS downloader. | [
"Simple",
"HTTP",
"/",
"HTTPS",
"downloader",
"."
] | [
"\"\"\"Simple HTTP/HTTPS downloader.\"\"\"",
"# Optional import: requests is not needed for local big data setup."
] | [
{
"param": "url",
"type": null
},
{
"param": "dest",
"type": null
},
{
"param": "timeout",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": null,
"docstring": null,
"docstring_tokens": []... |
1ddba753cee098b325cb03d0235c9e86fbdaedf9 | pllim/ci_watson | ci_watson/artifactory_helpers.py | [
"BSD-3-Clause"
] | Python | generate_upload_schema | null | def generate_upload_schema(pattern, target, testname, recursive=False):
"""
Write out JSON file to upload Jenkins results from test to
Artifactory storage area.
This function relies on the JFROG JSON schema for uploading data into
artifactory using the Jenkins plugin. Docs can be found at
http... |
Write out JSON file to upload Jenkins results from test to
Artifactory storage area.
This function relies on the JFROG JSON schema for uploading data into
artifactory using the Jenkins plugin. Docs can be found at
https://www.jfrog.com/confluence/display/RTF/Using+File+Specs
Parameters
-... | Write out JSON file to upload Jenkins results from test to
Artifactory storage area.
This function relies on the JFROG JSON schema for uploading data into
artifactory using the Jenkins plugin.
Parameters
pattern : str or list of strings
Specifies the local file system path to test results which should be
uploaded to... | [
"Write",
"out",
"JSON",
"file",
"to",
"upload",
"Jenkins",
"results",
"from",
"test",
"to",
"Artifactory",
"storage",
"area",
".",
"This",
"function",
"relies",
"on",
"the",
"JFROG",
"JSON",
"schema",
"for",
"uploading",
"data",
"into",
"artifactory",
"using",... | def generate_upload_schema(pattern, target, testname, recursive=False):
jsonfile = "{}_results.json".format(testname)
recursive = repr(recursive).lower()
if not isinstance(pattern, str):
upload_schema = {"files": []}
for p in pattern:
temp_schema = copy.deepcopy(UPLOAD_SCHEMA["fi... | [
"def",
"generate_upload_schema",
"(",
"pattern",
",",
"target",
",",
"testname",
",",
"recursive",
"=",
"False",
")",
":",
"jsonfile",
"=",
"\"{}_results.json\"",
".",
"format",
"(",
"testname",
")",
"recursive",
"=",
"repr",
"(",
"recursive",
")",
".",
"low... | Write out JSON file to upload Jenkins results from test to
Artifactory storage area. | [
"Write",
"out",
"JSON",
"file",
"to",
"upload",
"Jenkins",
"results",
"from",
"test",
"to",
"Artifactory",
"storage",
"area",
"."
] | [
"\"\"\"\n Write out JSON file to upload Jenkins results from test to\n Artifactory storage area.\n\n This function relies on the JFROG JSON schema for uploading data into\n artifactory using the Jenkins plugin. Docs can be found at\n https://www.jfrog.com/confluence/display/RTF/Using+File+Specs\n\n ... | [
{
"param": "pattern",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "testname",
"type": null
},
{
"param": "recursive",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pattern",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_token... |
69ffb65f1d3c109e6fec539cfc6d711338589471 | cbedetti/LexicalRichness | lexicalrichness/lexicalrichness.py | [
"MIT"
] | Python | blobber | <not_specific> | def blobber(text):
""" Tokenize text into a list of tokens using TextBlob.
Parameter
---------
text: string
Return
------
TextBlob list of words
"""
blob = TextBlob(text)
return blob.words | Tokenize text into a list of tokens using TextBlob.
Parameter
---------
text: string
Return
------
TextBlob list of words
| Tokenize text into a list of tokens using TextBlob.
Parameter
string
Return
TextBlob list of words | [
"Tokenize",
"text",
"into",
"a",
"list",
"of",
"tokens",
"using",
"TextBlob",
".",
"Parameter",
"string",
"Return",
"TextBlob",
"list",
"of",
"words"
] | def blobber(text):
blob = TextBlob(text)
return blob.words | [
"def",
"blobber",
"(",
"text",
")",
":",
"blob",
"=",
"TextBlob",
"(",
"text",
")",
"return",
"blob",
".",
"words"
] | Tokenize text into a list of tokens using TextBlob. | [
"Tokenize",
"text",
"into",
"a",
"list",
"of",
"tokens",
"using",
"TextBlob",
"."
] | [
"\"\"\" Tokenize text into a list of tokens using TextBlob.\n\n Parameter\n ---------\n text: string\n\n Return\n ------\n TextBlob list of words\n \"\"\""
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eebf72cbc847bcca5f487733cdbe510f03347391 | Krekep/cuBool | python/pycubool/gviz.py | [
"MIT"
] | Python | matrices_to_gviz | str | def matrices_to_gviz(matrices: dict, **kwargs) -> str:
"""
Export the labeled square matrices dictionary to the graph viz graph description script.
All matrices must have the save shape.
>>> name = "Test" # Displayed graph name
>>> shape = (4, 4) #... |
Export the labeled square matrices dictionary to the graph viz graph description script.
All matrices must have the save shape.
>>> name = "Test" # Displayed graph name
>>> shape = (4, 4) # Adjacency matrices shape
>>> colors = {"a": "red", "b": "... | Export the labeled square matrices dictionary to the graph viz graph description script.
All matrices must have the save shape.
| [
"Export",
"the",
"labeled",
"square",
"matrices",
"dictionary",
"to",
"the",
"graph",
"viz",
"graph",
"description",
"script",
".",
"All",
"matrices",
"must",
"have",
"the",
"save",
"shape",
"."
] | def matrices_to_gviz(matrices: dict, **kwargs) -> str:
assert len(matrices) > 0
base = next(iter(matrices.values()))
shape = base.shape
for m in matrices.values():
assert m.shape == shape
matrices_data = dict()
for key, value in matrices.items():
assert isinstance(value, Matrix)
... | [
"def",
"matrices_to_gviz",
"(",
"matrices",
":",
"dict",
",",
"**",
"kwargs",
")",
"->",
"str",
":",
"assert",
"len",
"(",
"matrices",
")",
">",
"0",
"base",
"=",
"next",
"(",
"iter",
"(",
"matrices",
".",
"values",
"(",
")",
")",
")",
"shape",
"="... | Export the labeled square matrices dictionary to the graph viz graph description script. | [
"Export",
"the",
"labeled",
"square",
"matrices",
"dictionary",
"to",
"the",
"graph",
"viz",
"graph",
"description",
"script",
"."
] | [
"\"\"\"\n Export the labeled square matrices dictionary to the graph viz graph description script.\n All matrices must have the save shape.\n\n >>> name = \"Test\" # Displayed graph name\n >>> shape = (4, 4) # Adjacency matrices shape\n >>> colors = ... | [
{
"param": "matrices",
"type": "dict"
}
] | {
"returns": [
{
"docstring": "Text script gviz graph representation",
"docstring_tokens": [
"Text",
"script",
"gviz",
"graph",
"representation"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "matrices",
"typ... |
78d30e251787bcdc90fb0c4e01691e99ca466542 | andyil/jupylet | jupylet/model.py | [
"BSD-2-Clause"
] | Python | q2aa | <not_specific> | def q2aa(rotation, deg=False):
"""Transform quaternion to angle+axis."""
if not rotation or rotation == (1., 0., 0., 0.):
return 0, glm.vec3(0, 0, 1)
c, xs, ys, zs = rotation #glm.conjugate(rotation)
angle = math.acos(c) * 2
s = math.sin(angle / 2)
if deg:
angle = rou... | Transform quaternion to angle+axis. | Transform quaternion to angle+axis. | [
"Transform",
"quaternion",
"to",
"angle",
"+",
"axis",
"."
] | def q2aa(rotation, deg=False):
if not rotation or rotation == (1., 0., 0., 0.):
return 0, glm.vec3(0, 0, 1)
c, xs, ys, zs = rotation
angle = math.acos(c) * 2
s = math.sin(angle / 2)
if deg:
angle = round(180 * angle / math.pi, 3)
return angle, glm.vec3(xs / s, ys / s, zs / s) | [
"def",
"q2aa",
"(",
"rotation",
",",
"deg",
"=",
"False",
")",
":",
"if",
"not",
"rotation",
"or",
"rotation",
"==",
"(",
"1.",
",",
"0.",
",",
"0.",
",",
"0.",
")",
":",
"return",
"0",
",",
"glm",
".",
"vec3",
"(",
"0",
",",
"0",
",",
"1",
... | Transform quaternion to angle+axis. | [
"Transform",
"quaternion",
"to",
"angle",
"+",
"axis",
"."
] | [
"\"\"\"Transform quaternion to angle+axis.\"\"\"",
"#glm.conjugate(rotation)"
] | [
{
"param": "rotation",
"type": null
},
{
"param": "deg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rotation",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "deg",
"type": null,
"docstring": null,
"docstring_tokens"... |
32a1dee7e2f47878bf5c5aa9496909464bbf93ab | andyil/jupylet | jupylet/resource.py | [
"BSD-2-Clause"
] | Python | image | <not_specific> | def image(name, flip_x=False, flip_y=False, rotate=0, atlas=True, autocrop=False):
"""Load an image with optional transformation.
This is similar to `texture`, except the resulting image will be
packed into a :py:class:`~pyglet.image.atlas.TextureBin` if it is an appropriate size for packing.
This is m... | Load an image with optional transformation.
This is similar to `texture`, except the resulting image will be
packed into a :py:class:`~pyglet.image.atlas.TextureBin` if it is an appropriate size for packing.
This is more efficient than loading images into separate textures.
:Parameters:
`name`... | Load an image with optional transformation.
This is similar to `texture`, except the resulting image will be
packed into a :py:class:`~pyglet.image.atlas.TextureBin` if it is an appropriate size for packing.
This is more efficient than loading images into separate textures. | [
"Load",
"an",
"image",
"with",
"optional",
"transformation",
".",
"This",
"is",
"similar",
"to",
"`",
"texture",
"`",
"except",
"the",
"resulting",
"image",
"will",
"be",
"packed",
"into",
"a",
":",
"py",
":",
"class",
":",
"`",
"~pyglet",
".",
"image",
... | def image(name, flip_x=False, flip_y=False, rotate=0, atlas=True, autocrop=False):
_loader._require_index()
name0 = name + '-autocrop' if autocrop else name
if name0 in _loader._cached_images:
identity = _loader._cached_images[name0]
else:
identity = _loader._cached_images[name0] = _allo... | [
"def",
"image",
"(",
"name",
",",
"flip_x",
"=",
"False",
",",
"flip_y",
"=",
"False",
",",
"rotate",
"=",
"0",
",",
"atlas",
"=",
"True",
",",
"autocrop",
"=",
"False",
")",
":",
"_loader",
".",
"_require_index",
"(",
")",
"name0",
"=",
"name",
"+... | Load an image with optional transformation. | [
"Load",
"an",
"image",
"with",
"optional",
"transformation",
"."
] | [
"\"\"\"Load an image with optional transformation.\n\n This is similar to `texture`, except the resulting image will be\n packed into a :py:class:`~pyglet.image.atlas.TextureBin` if it is an appropriate size for packing.\n This is more efficient than loading images into separate textures.\n\n :Parameter... | [
{
"param": "name",
"type": null
},
{
"param": "flip_x",
"type": null
},
{
"param": "flip_y",
"type": null
},
{
"param": "rotate",
"type": null
},
{
"param": "atlas",
"type": null
},
{
"param": "autocrop",
"type": null
}
] | {
"returns": [
{
"docstring": "A complete texture if the image is large or not in an atlas,\notherwise a :py:class:`~pyglet.image.TextureRegion` of a texture atlas.",
"docstring_tokens": [
"A",
"complete",
"texture",
"if",
"the",
"image",
"is",
... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | idle | <not_specific> | def idle(self):
"""Called during each iteration of the event loop.
The method is called immediately after any window events (i.e., after
any user input). The method can return a duration after which
the idle method will be called again. The method may be called
earlier if the ... | Called during each iteration of the event loop.
The method is called immediately after any window events (i.e., after
any user input). The method can return a duration after which
the idle method will be called again. The method may be called
earlier if the user creates more input eve... | Called during each iteration of the event loop.
The method is called immediately after any window events . The method can return a duration after which
the idle method will be called again. The method may be called
earlier if the user creates more input events. The method
can return `None` to only wait for user even... | [
"Called",
"during",
"each",
"iteration",
"of",
"the",
"event",
"loop",
".",
"The",
"method",
"is",
"called",
"immediately",
"after",
"any",
"window",
"events",
".",
"The",
"method",
"can",
"return",
"a",
"duration",
"after",
"which",
"the",
"idle",
"method",... | def idle(self):
dt = self.clock.update_time()
self.clock.call_scheduled_functions(dt)
return self.clock.get_sleep_time(True) | [
"def",
"idle",
"(",
"self",
")",
":",
"dt",
"=",
"self",
".",
"clock",
".",
"update_time",
"(",
")",
"self",
".",
"clock",
".",
"call_scheduled_functions",
"(",
"dt",
")",
"return",
"self",
".",
"clock",
".",
"get_sleep_time",
"(",
"True",
")"
] | Called during each iteration of the event loop. | [
"Called",
"during",
"each",
"iteration",
"of",
"the",
"event",
"loop",
"."
] | [
"\"\"\"Called during each iteration of the event loop.\n\n The method is called immediately after any window events (i.e., after\n any user input). The method can return a duration after which\n the idle method will be called again. The method may be called\n earlier if the user create... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "The number of seconds before the idle method should\nbe called again, or `None` to block for user input.",
"docstring_tokens": [
"The",
"number",
"of",
"seconds",
"before",
"the",
"idle",
"method",
"... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | schedule_interval | <not_specific> | def schedule_interval(self, interval, *args, **kwargs):
"""Schedule decorated function on the default clock every interval seconds.
The arguments passed to ``func`` are ``dt`` (time since last function
call), followed by any ``*args`` and ``**kwargs`` given here.
:Param... | Schedule decorated function on the default clock every interval seconds.
The arguments passed to ``func`` are ``dt`` (time since last function
call), followed by any ``*args`` and ``**kwargs`` given here.
:Parameters:
`interval` : float
The number of... | Schedule decorated function on the default clock every interval seconds. | [
"Schedule",
"decorated",
"function",
"on",
"the",
"default",
"clock",
"every",
"interval",
"seconds",
"."
] | def schedule_interval(self, interval, *args, **kwargs):
def schedule0(foo):
if inspect.iscoroutinefunction(foo):
raise TypeError('Coroutine functions can only be scheduled with schedule_once() and its aliases.')
if inspect.isgeneratorfunction(foo):
raise T... | [
"def",
"schedule_interval",
"(",
"self",
",",
"interval",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"def",
"schedule0",
"(",
"foo",
")",
":",
"if",
"inspect",
".",
"iscoroutinefunction",
"(",
"foo",
")",
":",
"raise",
"TypeError",
"(",
"'Coroutine... | Schedule decorated function on the default clock every interval seconds. | [
"Schedule",
"decorated",
"function",
"on",
"the",
"default",
"clock",
"every",
"interval",
"seconds",
"."
] | [
"\"\"\"Schedule decorated function on the default clock every interval seconds.\n \n The arguments passed to ``func`` are ``dt`` (time since last function\n call), followed by any ``*args`` and ``**kwargs`` given here.\n \n :Parameters:\n `interval` : float\n ... | [
{
"param": "self",
"type": null
},
{
"param": "interval",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "interval",
"type": null,
"docstring": null,
"docstring_tokens... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | schedule_interval_soft | <not_specific> | def schedule_interval_soft(self, interval, *args, **kwargs):
"""Schedule a function to be called every ``interval`` seconds.
This method is similar to `schedule_interval`, except that the
clock will move the interval out of phase with other scheduled
functions so as to distribut... | Schedule a function to be called every ``interval`` seconds.
This method is similar to `schedule_interval`, except that the
clock will move the interval out of phase with other scheduled
functions so as to distribute CPU more load evenly over time.
| Schedule a function to be called every ``interval`` seconds.
This method is similar to `schedule_interval`, except that the
clock will move the interval out of phase with other scheduled
functions so as to distribute CPU more load evenly over time. | [
"Schedule",
"a",
"function",
"to",
"be",
"called",
"every",
"`",
"`",
"interval",
"`",
"`",
"seconds",
".",
"This",
"method",
"is",
"similar",
"to",
"`",
"schedule_interval",
"`",
"except",
"that",
"the",
"clock",
"will",
"move",
"the",
"interval",
"out",
... | def schedule_interval_soft(self, interval, *args, **kwargs):
def schedule0(foo):
if inspect.iscoroutinefunction(foo):
raise TypeError('Coroutine functions can only be scheduled with schedule_once() and its aliases.')
if inspect.isgeneratorfunction(foo):
ra... | [
"def",
"schedule_interval_soft",
"(",
"self",
",",
"interval",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"def",
"schedule0",
"(",
"foo",
")",
":",
"if",
"inspect",
".",
"iscoroutinefunction",
"(",
"foo",
")",
":",
"raise",
"TypeError",
"(",
"'Coro... | Schedule a function to be called every ``interval`` seconds. | [
"Schedule",
"a",
"function",
"to",
"be",
"called",
"every",
"`",
"`",
"interval",
"`",
"`",
"seconds",
"."
] | [
"\"\"\"Schedule a function to be called every ``interval`` seconds.\n \n This method is similar to `schedule_interval`, except that the\n clock will move the interval out of phase with other scheduled\n functions so as to distribute CPU more load evenly over time.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "interval",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "interval",
"type": null,
"docstring": null,
"docstring_tokens... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | unschedule | null | def unschedule(self, foo=None, **kwargs):
"""Remove function from the default clock's schedule.
No error is raised if the ``func`` was never scheduled.
:Parameters:
`foo` : callable
The function to remove from the schedule. If no function is given
... | Remove function from the default clock's schedule.
No error is raised if the ``func`` was never scheduled.
:Parameters:
`foo` : callable
The function to remove from the schedule. If no function is given
unschedule the caller.
| Remove function from the default clock's schedule.
No error is raised if the ``func`` was never scheduled. | [
"Remove",
"function",
"from",
"the",
"default",
"clock",
"'",
"s",
"schedule",
".",
"No",
"error",
"is",
"raised",
"if",
"the",
"`",
"`",
"func",
"`",
"`",
"was",
"never",
"scheduled",
"."
] | def unschedule(self, foo=None, **kwargs):
if foo is None:
fname = inspect.stack()[kwargs.get('levels_up', 1)][3]
else:
fname = foo.__name__
d = self.schedules.pop(fname, {})
if 'func' in d:
self.clock.unschedule(d.get('func'))
if 'task' in d:
... | [
"def",
"unschedule",
"(",
"self",
",",
"foo",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"foo",
"is",
"None",
":",
"fname",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",
"kwargs",
".",
"get",
"(",
"'levels_up'",
",",
"1",
")",
"]",
"[",
"... | Remove function from the default clock's schedule. | [
"Remove",
"function",
"from",
"the",
"default",
"clock",
"'",
"s",
"schedule",
"."
] | [
"\"\"\"Remove function from the default clock's schedule.\n \n No error is raised if the ``func`` was never scheduled.\n \n :Parameters:\n `foo` : callable\n The function to remove from the schedule. If no function is given\n unschedule the caller... | [
{
"param": "self",
"type": null
},
{
"param": "foo",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "foo",
"type": null,
"docstring": null,
"docstring_tokens": []... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | event | <not_specific> | def event(self, *args):
"""Function decorator for an event handler.
Usage::
@app.event
def on_resize(self, width, height):
# ...
or::
@app.event('on_resize')
def foo(self, width, height):
# ...
"""
if... | Function decorator for an event handler.
Usage::
@app.event
def on_resize(self, width, height):
# ...
or::
@app.event('on_resize')
def foo(self, width, height):
# ...
| Function decorator for an event handler. | [
"Function",
"decorator",
"for",
"an",
"event",
"handler",
"."
] | def event(self, *args):
if len(args) == 0:
def decorator(func):
name = func.__name__
self._dispatcher.set_handler(name, func)
return func
return decorator
elif inspect.isroutine(args[0]):
fu... | [
"def",
"event",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
"__name__",
"self",
".",
"_dispatcher",
".",
"set_handler",
"(",
"name",
... | Function decorator for an event handler. | [
"Function",
"decorator",
"for",
"an",
"event",
"handler",
"."
] | [
"\"\"\"Function decorator for an event handler.\n Usage::\n @app.event\n def on_resize(self, width, height):\n # ...\n or::\n @app.event('on_resize')\n def foo(self, width, height):\n # ...\n \"\"\"",
"# @window.event()... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | scale_window_to | null | def scale_window_to(self, px):
"""Scale window size so that its bigges dimension (either width or height)
is px pixels.
This is useful for RL applications since smaller windows render faster.
"""
assert self.mode not in ['jupyter', 'both'], 'Cannot rescale window in Jupyter mode... | Scale window size so that its bigges dimension (either width or height)
is px pixels.
This is useful for RL applications since smaller windows render faster.
| Scale window size so that its bigges dimension (either width or height)
is px pixels.
This is useful for RL applications since smaller windows render faster. | [
"Scale",
"window",
"size",
"so",
"that",
"its",
"bigges",
"dimension",
"(",
"either",
"width",
"or",
"height",
")",
"is",
"px",
"pixels",
".",
"This",
"is",
"useful",
"for",
"RL",
"applications",
"since",
"smaller",
"windows",
"render",
"faster",
"."
] | def scale_window_to(self, px):
assert self.mode not in ['jupyter', 'both'], 'Cannot rescale window in Jupyter mode.'
assert self.event_loop.is_running, 'Window can only be scaled once app has been started.'
width0 = self.window.width
height0 = self.window.height
scale = px / max(... | [
"def",
"scale_window_to",
"(",
"self",
",",
"px",
")",
":",
"assert",
"self",
".",
"mode",
"not",
"in",
"[",
"'jupyter'",
",",
"'both'",
"]",
",",
"'Cannot rescale window in Jupyter mode.'",
"assert",
"self",
".",
"event_loop",
".",
"is_running",
",",
"'Window... | Scale window size so that its bigges dimension (either width or height)
is px pixels. | [
"Scale",
"window",
"size",
"so",
"that",
"its",
"bigges",
"dimension",
"(",
"either",
"width",
"or",
"height",
")",
"is",
"px",
"pixels",
"."
] | [
"\"\"\"Scale window size so that its bigges dimension (either width or height)\n is px pixels.\n\n This is useful for RL applications since smaller windows render faster.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "px",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "px",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | _a2b | <not_specific> | def _a2b(a, format='JPEG', **kwargs):
"""Encode a numpy array of an image using given format."""
b0 = io.BytesIO()
i0 = PIL.Image.fromarray(a)
i0.save(b0, format, **kwargs)
return b0.getvalue() | Encode a numpy array of an image using given format. | Encode a numpy array of an image using given format. | [
"Encode",
"a",
"numpy",
"array",
"of",
"an",
"image",
"using",
"given",
"format",
"."
] | def _a2b(a, format='JPEG', **kwargs):
b0 = io.BytesIO()
i0 = PIL.Image.fromarray(a)
i0.save(b0, format, **kwargs)
return b0.getvalue() | [
"def",
"_a2b",
"(",
"a",
",",
"format",
"=",
"'JPEG'",
",",
"**",
"kwargs",
")",
":",
"b0",
"=",
"io",
".",
"BytesIO",
"(",
")",
"i0",
"=",
"PIL",
".",
"Image",
".",
"fromarray",
"(",
"a",
")",
"i0",
".",
"save",
"(",
"b0",
",",
"format",
","... | Encode a numpy array of an image using given format. | [
"Encode",
"a",
"numpy",
"array",
"of",
"an",
"image",
"using",
"given",
"format",
"."
] | [
"\"\"\"Encode a numpy array of an image using given format.\"\"\""
] | [
{
"param": "a",
"type": null
},
{
"param": "format",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "format",
"type": null,
"docstring": null,
"docstring_tokens": []... |
c3ab3cc676dafe712cfc86068e828621582e63ab | andyil/jupylet | jupylet/app.py | [
"BSD-2-Clause"
] | Python | _a2w | <not_specific> | def _a2w(a, format='JPEG', **kwargs):
"""Convert a numpy array of an image to an ipywidget image."""
b0 = _a2b(a, format=format, **kwargs)
return ipywidgets.Image(value=b0, format=format) | Convert a numpy array of an image to an ipywidget image. | Convert a numpy array of an image to an ipywidget image. | [
"Convert",
"a",
"numpy",
"array",
"of",
"an",
"image",
"to",
"an",
"ipywidget",
"image",
"."
] | def _a2w(a, format='JPEG', **kwargs):
b0 = _a2b(a, format=format, **kwargs)
return ipywidgets.Image(value=b0, format=format) | [
"def",
"_a2w",
"(",
"a",
",",
"format",
"=",
"'JPEG'",
",",
"**",
"kwargs",
")",
":",
"b0",
"=",
"_a2b",
"(",
"a",
",",
"format",
"=",
"format",
",",
"**",
"kwargs",
")",
"return",
"ipywidgets",
".",
"Image",
"(",
"value",
"=",
"b0",
",",
"format... | Convert a numpy array of an image to an ipywidget image. | [
"Convert",
"a",
"numpy",
"array",
"of",
"an",
"image",
"to",
"an",
"ipywidget",
"image",
"."
] | [
"\"\"\"Convert a numpy array of an image to an ipywidget image.\"\"\""
] | [
{
"param": "a",
"type": null
},
{
"param": "format",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "format",
"type": null,
"docstring": null,
"docstring_tokens": []... |
f806fdd6625e6b539b53f498cc7c33f19d9ee766 | HusainZafar/tic_tac_toe | tic_tac_toe/tic_tac_toe.py | [
"MIT"
] | Python | minimax | <not_specific> | def minimax(self, board, move, computerChar, playerChar, depth=0):
"""
Implements the minimax algorithm. Returns 1 : computer has won.
Returns -1 when player wins.
When it's the computer's turn and it has to return a value to its parent,
the maximum value from the array is chosen else, the minimum value.
""... |
Implements the minimax algorithm. Returns 1 : computer has won.
Returns -1 when player wins.
When it's the computer's turn and it has to return a value to its parent,
the maximum value from the array is chosen else, the minimum value.
| Implements the minimax algorithm. Returns 1 : computer has won.
Returns -1 when player wins.
When it's the computer's turn and it has to return a value to its parent,
the maximum value from the array is chosen else, the minimum value. | [
"Implements",
"the",
"minimax",
"algorithm",
".",
"Returns",
"1",
":",
"computer",
"has",
"won",
".",
"Returns",
"-",
"1",
"when",
"player",
"wins",
".",
"When",
"it",
"'",
"s",
"the",
"computer",
"'",
"s",
"turn",
"and",
"it",
"has",
"to",
"return",
... | def minimax(self, board, move, computerChar, playerChar, depth=0):
[is_win, who_won] = utils.check_win(board, computerChar, playerChar)
if is_win == 2:
return 0
if is_win == 1:
if who_won == computerChar:
return 1
if who_won == playerChar:
return -1
ret_list = []
for i in range(9):
i... | [
"def",
"minimax",
"(",
"self",
",",
"board",
",",
"move",
",",
"computerChar",
",",
"playerChar",
",",
"depth",
"=",
"0",
")",
":",
"[",
"is_win",
",",
"who_won",
"]",
"=",
"utils",
".",
"check_win",
"(",
"board",
",",
"computerChar",
",",
"playerChar"... | Implements the minimax algorithm. | [
"Implements",
"the",
"minimax",
"algorithm",
"."
] | [
"\"\"\"\n\t\tImplements the minimax algorithm. Returns 1 : computer has won.\n\t\tReturns -1 when player wins.\n\t\tWhen it's the computer's turn and it has to return a value to its parent,\n\t\tthe maximum value from the array is chosen else, the minimum value.\n\t\t\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "board",
"type": null
},
{
"param": "move",
"type": null
},
{
"param": "computerChar",
"type": null
},
{
"param": "playerChar",
"type": null
},
{
"param": "depth",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": ... |
29bf21fdf5f624521c763ae7815b4930bf644c7a | HusainZafar/tic_tac_toe | tic_tac_toe/utils.py | [
"MIT"
] | Python | clearScreen | null | def clearScreen():
"""
Clears terminal based on user's OS
"""
os.system('cls' if os.name=='nt' else 'clear') |
Clears terminal based on user's OS
| Clears terminal based on user's OS | [
"Clears",
"terminal",
"based",
"on",
"user",
"'",
"s",
"OS"
] | def clearScreen():
os.system('cls' if os.name=='nt' else 'clear') | [
"def",
"clearScreen",
"(",
")",
":",
"os",
".",
"system",
"(",
"'cls'",
"if",
"os",
".",
"name",
"==",
"'nt'",
"else",
"'clear'",
")"
] | Clears terminal based on user's OS | [
"Clears",
"terminal",
"based",
"on",
"user",
"'",
"s",
"OS"
] | [
"\"\"\"\n\tClears terminal based on user's OS\n\t\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
29bf21fdf5f624521c763ae7815b4930bf644c7a | HusainZafar/tic_tac_toe | tic_tac_toe/utils.py | [
"MIT"
] | Python | display_tutorial_board | null | def display_tutorial_board(board, tut):
"""
prints the current board plus the feasibility of each move
"""
prob = board[::]
i = j = 0
scoreToResult = {1:'W', 0:'D', -1:'L'}
while j < len(board) :
if board[j] == '-':
prob[j] = scoreToResult[tut[i]]
i += 1
else:
prob[j] = '-'
j += 1
print ("TIC TA... |
prints the current board plus the feasibility of each move
| prints the current board plus the feasibility of each move | [
"prints",
"the",
"current",
"board",
"plus",
"the",
"feasibility",
"of",
"each",
"move"
] | def display_tutorial_board(board, tut):
prob = board[::]
i = j = 0
scoreToResult = {1:'W', 0:'D', -1:'L'}
while j < len(board) :
if board[j] == '-':
prob[j] = scoreToResult[tut[i]]
i += 1
else:
prob[j] = '-'
j += 1
print ("TIC TAC TOE Move Index Winning chance\n")
print (" " + bo... | [
"def",
"display_tutorial_board",
"(",
"board",
",",
"tut",
")",
":",
"prob",
"=",
"board",
"[",
":",
":",
"]",
"i",
"=",
"j",
"=",
"0",
"scoreToResult",
"=",
"{",
"1",
":",
"'W'",
",",
"0",
":",
"'D'",
",",
"-",
"1",
":",
"'L'",
"}",
"while",
... | prints the current board plus the feasibility of each move | [
"prints",
"the",
"current",
"board",
"plus",
"the",
"feasibility",
"of",
"each",
"move"
] | [
"\"\"\"\n\tprints the current board plus the feasibility of each move\n\t\"\"\""
] | [
{
"param": "board",
"type": null
},
{
"param": "tut",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tut",
"type": null,
"docstring": null,
"docstring_tokens": [... |
29bf21fdf5f624521c763ae7815b4930bf644c7a | HusainZafar/tic_tac_toe | tic_tac_toe/utils.py | [
"MIT"
] | Python | move_random | <not_specific> | def move_random(moves_list):
"""
returns random index of one of the many possible moves
"""
return random.choice(moves_list) |
returns random index of one of the many possible moves
| returns random index of one of the many possible moves | [
"returns",
"random",
"index",
"of",
"one",
"of",
"the",
"many",
"possible",
"moves"
] | def move_random(moves_list):
return random.choice(moves_list) | [
"def",
"move_random",
"(",
"moves_list",
")",
":",
"return",
"random",
".",
"choice",
"(",
"moves_list",
")"
] | returns random index of one of the many possible moves | [
"returns",
"random",
"index",
"of",
"one",
"of",
"the",
"many",
"possible",
"moves"
] | [
"\"\"\"\n\treturns random index of one of the many possible moves\n\t\"\"\""
] | [
{
"param": "moves_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "moves_list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f924384039dd193ff52e062c03fa4ab56299ddef | shashfrankenstien/Flask_Production | tests/test_plugins.py | [
"MIT"
] | Python | wash_car | null | def wash_car():
"""
This is a dummy job that is scheduled to wash my car
Note: objects in the mirror are closer than they appear
"""
global toggle
toggle = not toggle
if toggle:
count = 50
while count > 0:
time.sleep(0.1)
print("washing..\n")
count -= 1
print("The car was washed")
else:
time.sl... |
This is a dummy job that is scheduled to wash my car
Note: objects in the mirror are closer than they appear
| This is a dummy job that is scheduled to wash my car
Note: objects in the mirror are closer than they appear | [
"This",
"is",
"a",
"dummy",
"job",
"that",
"is",
"scheduled",
"to",
"wash",
"my",
"car",
"Note",
":",
"objects",
"in",
"the",
"mirror",
"are",
"closer",
"than",
"they",
"appear"
] | def wash_car():
global toggle
toggle = not toggle
if toggle:
count = 50
while count > 0:
time.sleep(0.1)
print("washing..\n")
count -= 1
print("The car was washed")
else:
time.sleep(1)
raise Exception("car wash failed!") | [
"def",
"wash_car",
"(",
")",
":",
"global",
"toggle",
"toggle",
"=",
"not",
"toggle",
"if",
"toggle",
":",
"count",
"=",
"50",
"while",
"count",
">",
"0",
":",
"time",
".",
"sleep",
"(",
"0.1",
")",
"print",
"(",
"\"washing..\\n\"",
")",
"count",
"-=... | This is a dummy job that is scheduled to wash my car
Note: objects in the mirror are closer than they appear | [
"This",
"is",
"a",
"dummy",
"job",
"that",
"is",
"scheduled",
"to",
"wash",
"my",
"car",
"Note",
":",
"objects",
"in",
"the",
"mirror",
"are",
"closer",
"than",
"they",
"appear"
] | [
"\"\"\"\n\tThis is a dummy job that is scheduled to wash my car\n\tNote: objects in the mirror are closer than they appear\n\t\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | player | <not_specific> | def player(board):
"""
Returns player who has the next turn on a board.
"""
Xcount = 0
Ocount = 0
for row in board:
Xcount += row.count(X)
Ocount += row.count(O)
if Xcount <= Ocount:
return X
else:
return O |
Returns player who has the next turn on a board.
| Returns player who has the next turn on a board. | [
"Returns",
"player",
"who",
"has",
"the",
"next",
"turn",
"on",
"a",
"board",
"."
] | def player(board):
Xcount = 0
Ocount = 0
for row in board:
Xcount += row.count(X)
Ocount += row.count(O)
if Xcount <= Ocount:
return X
else:
return O | [
"def",
"player",
"(",
"board",
")",
":",
"Xcount",
"=",
"0",
"Ocount",
"=",
"0",
"for",
"row",
"in",
"board",
":",
"Xcount",
"+=",
"row",
".",
"count",
"(",
"X",
")",
"Ocount",
"+=",
"row",
".",
"count",
"(",
"O",
")",
"if",
"Xcount",
"<=",
"Oc... | Returns player who has the next turn on a board. | [
"Returns",
"player",
"who",
"has",
"the",
"next",
"turn",
"on",
"a",
"board",
"."
] | [
"\"\"\"\n Returns player who has the next turn on a board.\n \"\"\""
] | [
{
"param": "board",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | actions | <not_specific> | def actions(board):
"""
Returns set of all possible actions (i, j) available on the board.
"""
possible_moves = set()
for row_index, row in enumerate(board):
for column_index, item in enumerate(row):
if item == None:
possible_moves.add((row_index, column_index))... |
Returns set of all possible actions (i, j) available on the board.
| Returns set of all possible actions (i, j) available on the board. | [
"Returns",
"set",
"of",
"all",
"possible",
"actions",
"(",
"i",
"j",
")",
"available",
"on",
"the",
"board",
"."
] | def actions(board):
possible_moves = set()
for row_index, row in enumerate(board):
for column_index, item in enumerate(row):
if item == None:
possible_moves.add((row_index, column_index))
return possible_moves | [
"def",
"actions",
"(",
"board",
")",
":",
"possible_moves",
"=",
"set",
"(",
")",
"for",
"row_index",
",",
"row",
"in",
"enumerate",
"(",
"board",
")",
":",
"for",
"column_index",
",",
"item",
"in",
"enumerate",
"(",
"row",
")",
":",
"if",
"item",
"=... | Returns set of all possible actions (i, j) available on the board. | [
"Returns",
"set",
"of",
"all",
"possible",
"actions",
"(",
"i",
"j",
")",
"available",
"on",
"the",
"board",
"."
] | [
"\"\"\"\n Returns set of all possible actions (i, j) available on the board.\n \"\"\""
] | [
{
"param": "board",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | result | <not_specific> | def result(board, action):
"""
Returns the board that results from making move (i, j) on the board.
"""
player_move = player(board)
new_board = deepcopy(board)
i, j = action
if board[i][j] != None:
raise Exception
else:
new_board[i][j] = player_move
return new_boar... |
Returns the board that results from making move (i, j) on the board.
| Returns the board that results from making move (i, j) on the board. | [
"Returns",
"the",
"board",
"that",
"results",
"from",
"making",
"move",
"(",
"i",
"j",
")",
"on",
"the",
"board",
"."
] | def result(board, action):
player_move = player(board)
new_board = deepcopy(board)
i, j = action
if board[i][j] != None:
raise Exception
else:
new_board[i][j] = player_move
return new_board | [
"def",
"result",
"(",
"board",
",",
"action",
")",
":",
"player_move",
"=",
"player",
"(",
"board",
")",
"new_board",
"=",
"deepcopy",
"(",
"board",
")",
"i",
",",
"j",
"=",
"action",
"if",
"board",
"[",
"i",
"]",
"[",
"j",
"]",
"!=",
"None",
":"... | Returns the board that results from making move (i, j) on the board. | [
"Returns",
"the",
"board",
"that",
"results",
"from",
"making",
"move",
"(",
"i",
"j",
")",
"on",
"the",
"board",
"."
] | [
"\"\"\"\n Returns the board that results from making move (i, j) on the board.\n \"\"\""
] | [
{
"param": "board",
"type": null
},
{
"param": "action",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "action",
"type": null,
"docstring": null,
"docstring_tokens"... |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | winner | <not_specific> | def winner(board):
"""
Returns the winner of the game, if there is one.
"""
for player in (X, O):
# check vertical
for row in board:
if row == [player] * 3:
return player
# check horizontal
for i in range(3):
column = [board[x][i] ... |
Returns the winner of the game, if there is one.
| Returns the winner of the game, if there is one. | [
"Returns",
"the",
"winner",
"of",
"the",
"game",
"if",
"there",
"is",
"one",
"."
] | def winner(board):
for player in (X, O):
for row in board:
if row == [player] * 3:
return player
for i in range(3):
column = [board[x][i] for x in range(3)]
if column == [player] * 3:
return player
if [board[i][i] for i in range(0, 3)] ... | [
"def",
"winner",
"(",
"board",
")",
":",
"for",
"player",
"in",
"(",
"X",
",",
"O",
")",
":",
"for",
"row",
"in",
"board",
":",
"if",
"row",
"==",
"[",
"player",
"]",
"*",
"3",
":",
"return",
"player",
"for",
"i",
"in",
"range",
"(",
"3",
")"... | Returns the winner of the game, if there is one. | [
"Returns",
"the",
"winner",
"of",
"the",
"game",
"if",
"there",
"is",
"one",
"."
] | [
"\"\"\"\n Returns the winner of the game, if there is one.\n \"\"\"",
"# check vertical",
"# check horizontal",
"# check diagonal"
] | [
{
"param": "board",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | terminal | <not_specific> | def terminal(board):
"""
Returns True if game is over, False otherwise.
"""
# game is won by one of the players
if winner(board) != None:
return True
# moves still possible
for row in board:
if EMPTY in row:
return False
# no possible moves
return True |
Returns True if game is over, False otherwise.
| Returns True if game is over, False otherwise. | [
"Returns",
"True",
"if",
"game",
"is",
"over",
"False",
"otherwise",
"."
] | def terminal(board):
if winner(board) != None:
return True
for row in board:
if EMPTY in row:
return False
return True | [
"def",
"terminal",
"(",
"board",
")",
":",
"if",
"winner",
"(",
"board",
")",
"!=",
"None",
":",
"return",
"True",
"for",
"row",
"in",
"board",
":",
"if",
"EMPTY",
"in",
"row",
":",
"return",
"False",
"return",
"True"
] | Returns True if game is over, False otherwise. | [
"Returns",
"True",
"if",
"game",
"is",
"over",
"False",
"otherwise",
"."
] | [
"\"\"\"\n Returns True if game is over, False otherwise.\n \"\"\"",
"# game is won by one of the players",
"# moves still possible",
"# no possible moves"
] | [
{
"param": "board",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | utility | <not_specific> | def utility(board):
"""
Returns 1 if X has won the game, -1 if O has won, 0 otherwise.
"""
win_player = winner(board)
if win_player == X:
return 1
elif win_player == O:
return -1
else:
return 0 |
Returns 1 if X has won the game, -1 if O has won, 0 otherwise.
| Returns 1 if X has won the game, -1 if O has won, 0 otherwise. | [
"Returns",
"1",
"if",
"X",
"has",
"won",
"the",
"game",
"-",
"1",
"if",
"O",
"has",
"won",
"0",
"otherwise",
"."
] | def utility(board):
win_player = winner(board)
if win_player == X:
return 1
elif win_player == O:
return -1
else:
return 0 | [
"def",
"utility",
"(",
"board",
")",
":",
"win_player",
"=",
"winner",
"(",
"board",
")",
"if",
"win_player",
"==",
"X",
":",
"return",
"1",
"elif",
"win_player",
"==",
"O",
":",
"return",
"-",
"1",
"else",
":",
"return",
"0"
] | Returns 1 if X has won the game, -1 if O has won, 0 otherwise. | [
"Returns",
"1",
"if",
"X",
"has",
"won",
"the",
"game",
"-",
"1",
"if",
"O",
"has",
"won",
"0",
"otherwise",
"."
] | [
"\"\"\"\n Returns 1 if X has won the game, -1 if O has won, 0 otherwise.\n \"\"\""
] | [
{
"param": "board",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7fdb5346a81c8485961bd16fd6001eeac1a510c8 | bharatchanddandamudi/cs50ai | week0/tictactoe/tictactoe.py | [
"MIT"
] | Python | minimax | <not_specific> | def minimax(board):
"""
Returns the optimal action for the current player on the board.
"""
def max_value(board):
optimal_move = ()
if terminal(board):
return utility(board), optimal_move
else:
v = -5
for action in actions(board):
... |
Returns the optimal action for the current player on the board.
| Returns the optimal action for the current player on the board. | [
"Returns",
"the",
"optimal",
"action",
"for",
"the",
"current",
"player",
"on",
"the",
"board",
"."
] | def minimax(board):
def max_value(board):
optimal_move = ()
if terminal(board):
return utility(board), optimal_move
else:
v = -5
for action in actions(board):
minval = min_value(result(board, action))[0]
if minval > v:
... | [
"def",
"minimax",
"(",
"board",
")",
":",
"def",
"max_value",
"(",
"board",
")",
":",
"optimal_move",
"=",
"(",
")",
"if",
"terminal",
"(",
"board",
")",
":",
"return",
"utility",
"(",
"board",
")",
",",
"optimal_move",
"else",
":",
"v",
"=",
"-",
... | Returns the optimal action for the current player on the board. | [
"Returns",
"the",
"optimal",
"action",
"for",
"the",
"current",
"player",
"on",
"the",
"board",
"."
] | [
"\"\"\"\n Returns the optimal action for the current player on the board.\n \"\"\""
] | [
{
"param": "board",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "board",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | enforce_node_consistency | null | def enforce_node_consistency(self):
"""
Update `self.domains` such that each variable is node-consistent.
(Remove any values that are inconsistent with a variable's unary
constraints; in this case, the length of the word.)
"""
for variable, words in self.domains.items():... |
Update `self.domains` such that each variable is node-consistent.
(Remove any values that are inconsistent with a variable's unary
constraints; in this case, the length of the word.)
| Update `self.domains` such that each variable is node-consistent.
(Remove any values that are inconsistent with a variable's unary
constraints; in this case, the length of the word.) | [
"Update",
"`",
"self",
".",
"domains",
"`",
"such",
"that",
"each",
"variable",
"is",
"node",
"-",
"consistent",
".",
"(",
"Remove",
"any",
"values",
"that",
"are",
"inconsistent",
"with",
"a",
"variable",
"'",
"s",
"unary",
"constraints",
";",
"in",
"th... | def enforce_node_consistency(self):
for variable, words in self.domains.items():
words_to_remove = set()
for word in words:
if len(word) != variable.length:
words_to_remove.add(word)
self.domains[variable] = words.difference(words_to_... | [
"def",
"enforce_node_consistency",
"(",
"self",
")",
":",
"for",
"variable",
",",
"words",
"in",
"self",
".",
"domains",
".",
"items",
"(",
")",
":",
"words_to_remove",
"=",
"set",
"(",
")",
"for",
"word",
"in",
"words",
":",
"if",
"len",
"(",
"word",
... | Update `self.domains` such that each variable is node-consistent. | [
"Update",
"`",
"self",
".",
"domains",
"`",
"such",
"that",
"each",
"variable",
"is",
"node",
"-",
"consistent",
"."
] | [
"\"\"\"\n Update `self.domains` such that each variable is node-consistent.\n (Remove any values that are inconsistent with a variable's unary\n constraints; in this case, the length of the word.)\n \"\"\"",
"# Iterate over all variables and their potential words",
"# Set to store w... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | revise | <not_specific> | def revise(self, x, y):
"""
USE PSEUDOCODE FROM THE LECTURE NODES
Make variable `x` arc consistent with variable `y`.
To do so, remove values from `self.domains[x]` for which there is no
possible corresponding value for `y` in `self.domains[y]`.
Return True if a revisio... |
USE PSEUDOCODE FROM THE LECTURE NODES
Make variable `x` arc consistent with variable `y`.
To do so, remove values from `self.domains[x]` for which there is no
possible corresponding value for `y` in `self.domains[y]`.
Return True if a revision was made to the domain of `x`; re... |
Return True if a revision was made to the domain of `x`; return
False if no revision was made. | [
"Return",
"True",
"if",
"a",
"revision",
"was",
"made",
"to",
"the",
"domain",
"of",
"`",
"x",
"`",
";",
"return",
"False",
"if",
"no",
"revision",
"was",
"made",
"."
] | def revise(self, x, y):
revised = False
overlap = self.crossword.overlaps[x, y]
if overlap:
v1, v2 = overlap
xs_to_remove = set()
for x_i in self.domains[x]:
overlaps = False
for y_j in self.domains[y]:
... | [
"def",
"revise",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"revised",
"=",
"False",
"overlap",
"=",
"self",
".",
"crossword",
".",
"overlaps",
"[",
"x",
",",
"y",
"]",
"if",
"overlap",
":",
"v1",
",",
"v2",
"=",
"overlap",
"xs_to_remove",
"=",
"... | USE PSEUDOCODE FROM THE LECTURE NODES
Make variable `x` arc consistent with variable `y`. | [
"USE",
"PSEUDOCODE",
"FROM",
"THE",
"LECTURE",
"NODES",
"Make",
"variable",
"`",
"x",
"`",
"arc",
"consistent",
"with",
"variable",
"`",
"y",
"`",
"."
] | [
"\"\"\"\n USE PSEUDOCODE FROM THE LECTURE NODES\n\n Make variable `x` arc consistent with variable `y`.\n To do so, remove values from `self.domains[x]` for which there is no\n possible corresponding value for `y` in `self.domains[y]`.\n\n Return True if a revision was made to the... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "y",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | ac3 | <not_specific> | def ac3(self, arcs=None):
"""
USE PSEUDOCODE FROM THE LECTURE NOTES
Update `self.domains` such that each variable is arc consistent.
If `arcs` is None, begin with initial list of all arcs in the problem.
Otherwise, use `arcs` as the initial list of arcs to make consistent.
... |
USE PSEUDOCODE FROM THE LECTURE NOTES
Update `self.domains` such that each variable is arc consistent.
If `arcs` is None, begin with initial list of all arcs in the problem.
Otherwise, use `arcs` as the initial list of arcs to make consistent.
Return True if arc consistency is... |
Return True if arc consistency is enforced and no domains are empty;
return False if one or more domains end up empty. | [
"Return",
"True",
"if",
"arc",
"consistency",
"is",
"enforced",
"and",
"no",
"domains",
"are",
"empty",
";",
"return",
"False",
"if",
"one",
"or",
"more",
"domains",
"end",
"up",
"empty",
"."
] | def ac3(self, arcs=None):
if arcs is None:
arcs = deque()
for v1 in self.crossword.variables:
for v2 in self.crossword.neighbors(v1):
arcs.appendleft((v1, v2))
else:
arcs = deque(arcs)
while arcs:
x, y = arcs... | [
"def",
"ac3",
"(",
"self",
",",
"arcs",
"=",
"None",
")",
":",
"if",
"arcs",
"is",
"None",
":",
"arcs",
"=",
"deque",
"(",
")",
"for",
"v1",
"in",
"self",
".",
"crossword",
".",
"variables",
":",
"for",
"v2",
"in",
"self",
".",
"crossword",
".",
... | USE PSEUDOCODE FROM THE LECTURE NOTES
Update `self.domains` such that each variable is arc consistent. | [
"USE",
"PSEUDOCODE",
"FROM",
"THE",
"LECTURE",
"NOTES",
"Update",
"`",
"self",
".",
"domains",
"`",
"such",
"that",
"each",
"variable",
"is",
"arc",
"consistent",
"."
] | [
"\"\"\"\n USE PSEUDOCODE FROM THE LECTURE NOTES\n\n Update `self.domains` such that each variable is arc consistent.\n If `arcs` is None, begin with initial list of all arcs in the problem.\n Otherwise, use `arcs` as the initial list of arcs to make consistent.\n\n Return True if ... | [
{
"param": "self",
"type": null
},
{
"param": "arcs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arcs",
"type": null,
"docstring": null,
"docstring_tokens": [... |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | assignment_complete | <not_specific> | def assignment_complete(self, assignment):
"""
Return True if `assignment` is complete (i.e., assigns a value to each
crossword variable); return False otherwise.
"""
# traverse over all variables in the crossword
for variable in self.crossword.variables:
# if... |
Return True if `assignment` is complete (i.e., assigns a value to each
crossword variable); return False otherwise.
| Return True if `assignment` is complete ; return False otherwise. | [
"Return",
"True",
"if",
"`",
"assignment",
"`",
"is",
"complete",
";",
"return",
"False",
"otherwise",
"."
] | def assignment_complete(self, assignment):
for variable in self.crossword.variables:
if variable not in assignment.keys():
return False
if assignment[variable] not in self.crossword.words:
return False
return True | [
"def",
"assignment_complete",
"(",
"self",
",",
"assignment",
")",
":",
"for",
"variable",
"in",
"self",
".",
"crossword",
".",
"variables",
":",
"if",
"variable",
"not",
"in",
"assignment",
".",
"keys",
"(",
")",
":",
"return",
"False",
"if",
"assignment"... | Return True if `assignment` is complete (i.e., assigns a value to each
crossword variable); return False otherwise. | [
"Return",
"True",
"if",
"`",
"assignment",
"`",
"is",
"complete",
"(",
"i",
".",
"e",
".",
"assigns",
"a",
"value",
"to",
"each",
"crossword",
"variable",
")",
";",
"return",
"False",
"otherwise",
"."
] | [
"\"\"\"\n Return True if `assignment` is complete (i.e., assigns a value to each\n crossword variable); return False otherwise.\n \"\"\"",
"# traverse over all variables in the crossword",
"# if variable is not in the assignment, meaning it doesn't have a",
"# word assigned to it, return ... | [
{
"param": "self",
"type": null
},
{
"param": "assignment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "assignment",
"type": null,
"docstring": null,
"docstring_toke... |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | consistent | <not_specific> | def consistent(self, assignment):
"""
Return True if `assignment` is consistent (i.e., words fit in crossword
puzzle without conflicting characters); return False otherwise.
"""
for variable_x, word_x in assignment.items():
if variable_x.length != len(word_x): # chec... |
Return True if `assignment` is consistent (i.e., words fit in crossword
puzzle without conflicting characters); return False otherwise.
| Return True if `assignment` is consistent ; return False otherwise. | [
"Return",
"True",
"if",
"`",
"assignment",
"`",
"is",
"consistent",
";",
"return",
"False",
"otherwise",
"."
] | def consistent(self, assignment):
for variable_x, word_x in assignment.items():
if variable_x.length != len(word_x):
return False
for variable_y, word_y in assignment.items():
if variable_x != variable_y:
if word_x == word_y:
... | [
"def",
"consistent",
"(",
"self",
",",
"assignment",
")",
":",
"for",
"variable_x",
",",
"word_x",
"in",
"assignment",
".",
"items",
"(",
")",
":",
"if",
"variable_x",
".",
"length",
"!=",
"len",
"(",
"word_x",
")",
":",
"return",
"False",
"for",
"vari... | Return True if `assignment` is consistent (i.e., words fit in crossword
puzzle without conflicting characters); return False otherwise. | [
"Return",
"True",
"if",
"`",
"assignment",
"`",
"is",
"consistent",
"(",
"i",
".",
"e",
".",
"words",
"fit",
"in",
"crossword",
"puzzle",
"without",
"conflicting",
"characters",
")",
";",
"return",
"False",
"otherwise",
"."
] | [
"\"\"\"\n Return True if `assignment` is consistent (i.e., words fit in crossword\n puzzle without conflicting characters); return False otherwise.\n \"\"\"",
"# check if assigned word is of the proper length for the variable",
"# check if the word assigned to variable x is unique (not used... | [
{
"param": "self",
"type": null
},
{
"param": "assignment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "assignment",
"type": null,
"docstring": null,
"docstring_toke... |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | order_domain_values | <not_specific> | def order_domain_values(self, var, assignment):
"""
Return a list of values in the domain of `var`, in order by
the number of values they rule out for neighboring variables.
The first value in the list, for example, should be the one
that rules out the fewest values among the nei... |
Return a list of values in the domain of `var`, in order by
the number of values they rule out for neighboring variables.
The first value in the list, for example, should be the one
that rules out the fewest values among the neighbors of `var`.
| Return a list of values in the domain of `var`, in order by
the number of values they rule out for neighboring variables.
The first value in the list, for example, should be the one
that rules out the fewest values among the neighbors of `var`. | [
"Return",
"a",
"list",
"of",
"values",
"in",
"the",
"domain",
"of",
"`",
"var",
"`",
"in",
"order",
"by",
"the",
"number",
"of",
"values",
"they",
"rule",
"out",
"for",
"neighboring",
"variables",
".",
"The",
"first",
"value",
"in",
"the",
"list",
"for... | def order_domain_values(self, var, assignment):
neighbors = self.crossword.neighbors(var)
for variable in assignment:
if variable in neighbors:
neighbors.remove(variable)
result = []
for variable in self.domains[var]:
ruled_out = 0
fo... | [
"def",
"order_domain_values",
"(",
"self",
",",
"var",
",",
"assignment",
")",
":",
"neighbors",
"=",
"self",
".",
"crossword",
".",
"neighbors",
"(",
"var",
")",
"for",
"variable",
"in",
"assignment",
":",
"if",
"variable",
"in",
"neighbors",
":",
"neighb... | Return a list of values in the domain of `var`, in order by
the number of values they rule out for neighboring variables. | [
"Return",
"a",
"list",
"of",
"values",
"in",
"the",
"domain",
"of",
"`",
"var",
"`",
"in",
"order",
"by",
"the",
"number",
"of",
"values",
"they",
"rule",
"out",
"for",
"neighboring",
"variables",
"."
] | [
"\"\"\"\n Return a list of values in the domain of `var`, in order by\n the number of values they rule out for neighboring variables.\n The first value in the list, for example, should be the one\n that rules out the fewest values among the neighbors of `var`.\n \"\"\"",
"# find... | [
{
"param": "self",
"type": null
},
{
"param": "var",
"type": null
},
{
"param": "assignment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "var",
"type": null,
"docstring": null,
"docstring_tokens": []... |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | select_unassigned_variable | <not_specific> | def select_unassigned_variable(self, assignment):
"""
Return an unassigned variable not already part of `assignment`.
Choose the variable with the minimum number of remaining values
in its domain. If there is a tie, choose the variable with the highest
degree. If there is a tie, ... |
Return an unassigned variable not already part of `assignment`.
Choose the variable with the minimum number of remaining values
in its domain. If there is a tie, choose the variable with the highest
degree. If there is a tie, any of the tied variables are acceptable
return value... | Return an unassigned variable not already part of `assignment`.
Choose the variable with the minimum number of remaining values
in its domain. If there is a tie, choose the variable with the highest
degree. If there is a tie, any of the tied variables are acceptable
return values. | [
"Return",
"an",
"unassigned",
"variable",
"not",
"already",
"part",
"of",
"`",
"assignment",
"`",
".",
"Choose",
"the",
"variable",
"with",
"the",
"minimum",
"number",
"of",
"remaining",
"values",
"in",
"its",
"domain",
".",
"If",
"there",
"is",
"a",
"tie"... | def select_unassigned_variable(self, assignment):
potential_variables = []
for variable in self.crossword.variables:
if variable not in assignment:
potential_variables.append([variable, len(self.domains[variable]), len(self.crossword.neighbors(variable))])
if pote... | [
"def",
"select_unassigned_variable",
"(",
"self",
",",
"assignment",
")",
":",
"potential_variables",
"=",
"[",
"]",
"for",
"variable",
"in",
"self",
".",
"crossword",
".",
"variables",
":",
"if",
"variable",
"not",
"in",
"assignment",
":",
"potential_variables"... | Return an unassigned variable not already part of `assignment`. | [
"Return",
"an",
"unassigned",
"variable",
"not",
"already",
"part",
"of",
"`",
"assignment",
"`",
"."
] | [
"\"\"\"\n Return an unassigned variable not already part of `assignment`.\n Choose the variable with the minimum number of remaining values\n in its domain. If there is a tie, choose the variable with the highest\n degree. If there is a tie, any of the tied variables are acceptable\n ... | [
{
"param": "self",
"type": null
},
{
"param": "assignment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "assignment",
"type": null,
"docstring": null,
"docstring_toke... |
b1f4bfb04e3a9c5639743e78fd2aa8a06d8b51c6 | bharatchanddandamudi/cs50ai | week3/crossword/generate.py | [
"MIT"
] | Python | backtrack | <not_specific> | def backtrack(self, assignment):
"""
USE PSEUDOCODE FROM THE LECTURE NOTES
Using Backtracking Search, take as input a partial assignment for the
crossword and return a complete assignment if possible to do so.
`assignment` is a mapping from variables (keys) to words (values).
... |
USE PSEUDOCODE FROM THE LECTURE NOTES
Using Backtracking Search, take as input a partial assignment for the
crossword and return a complete assignment if possible to do so.
`assignment` is a mapping from variables (keys) to words (values).
If no assignment is possible, return... | USE PSEUDOCODE FROM THE LECTURE NOTES
Using Backtracking Search, take as input a partial assignment for the
crossword and return a complete assignment if possible to do so.
`assignment` is a mapping from variables (keys) to words (values).
If no assignment is possible, return None. | [
"USE",
"PSEUDOCODE",
"FROM",
"THE",
"LECTURE",
"NOTES",
"Using",
"Backtracking",
"Search",
"take",
"as",
"input",
"a",
"partial",
"assignment",
"for",
"the",
"crossword",
"and",
"return",
"a",
"complete",
"assignment",
"if",
"possible",
"to",
"do",
"so",
".",
... | def backtrack(self, assignment):
if self.assignment_complete(assignment): return assignment
variable = self.select_unassigned_variable(assignment)
for value in self.order_domain_values(variable, assignment):
assignment[variable] = value
if self.consistent(assignment):
... | [
"def",
"backtrack",
"(",
"self",
",",
"assignment",
")",
":",
"if",
"self",
".",
"assignment_complete",
"(",
"assignment",
")",
":",
"return",
"assignment",
"variable",
"=",
"self",
".",
"select_unassigned_variable",
"(",
"assignment",
")",
"for",
"value",
"in... | USE PSEUDOCODE FROM THE LECTURE NOTES
Using Backtracking Search, take as input a partial assignment for the
crossword and return a complete assignment if possible to do so. | [
"USE",
"PSEUDOCODE",
"FROM",
"THE",
"LECTURE",
"NOTES",
"Using",
"Backtracking",
"Search",
"take",
"as",
"input",
"a",
"partial",
"assignment",
"for",
"the",
"crossword",
"and",
"return",
"a",
"complete",
"assignment",
"if",
"possible",
"to",
"do",
"so",
"."
] | [
"\"\"\"\n USE PSEUDOCODE FROM THE LECTURE NOTES\n\n Using Backtracking Search, take as input a partial assignment for the\n crossword and return a complete assignment if possible to do so.\n\n `assignment` is a mapping from variables (keys) to words (values).\n\n If no assignment ... | [
{
"param": "self",
"type": null
},
{
"param": "assignment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "assignment",
"type": null,
"docstring": null,
"docstring_toke... |
71df9caa0cefee2d65dcf7938e93deaf937af612 | bharatchanddandamudi/cs50ai | week4/shopping/shopping.py | [
"MIT"
] | Python | load_data | <not_specific> | def load_data(filename):
"""
Load shopping data from a CSV file `filename` and convert into a list of
evidence lists and a list of labels. Return a tuple (evidence, labels).
evidence should be a list of lists, where each list contains the
following values, in order:
- Administrative, an int... |
Load shopping data from a CSV file `filename` and convert into a list of
evidence lists and a list of labels. Return a tuple (evidence, labels).
evidence should be a list of lists, where each list contains the
following values, in order:
- Administrative, an integer
- Administrative_Du... | Load shopping data from a CSV file `filename` and convert into a list of
evidence lists and a list of labels. Return a tuple (evidence, labels).
evidence should be a list of lists, where each list contains the
following values, in order:
Administrative, an integer
Administrative_Duration, a floating point number
Infor... | [
"Load",
"shopping",
"data",
"from",
"a",
"CSV",
"file",
"`",
"filename",
"`",
"and",
"convert",
"into",
"a",
"list",
"of",
"evidence",
"lists",
"and",
"a",
"list",
"of",
"labels",
".",
"Return",
"a",
"tuple",
"(",
"evidence",
"labels",
")",
".",
"evide... | def load_data(filename):
evidence = []
labels = []
months = {'Jan': 0,
'Feb': 1,
'Mar': 2,
'Apr': 3,
'May': 4,
'June': 5,
'Jul': 6,
'Aug': 7,
'Sep': 8,
'Oct': 9,
'Nov':... | [
"def",
"load_data",
"(",
"filename",
")",
":",
"evidence",
"=",
"[",
"]",
"labels",
"=",
"[",
"]",
"months",
"=",
"{",
"'Jan'",
":",
"0",
",",
"'Feb'",
":",
"1",
",",
"'Mar'",
":",
"2",
",",
"'Apr'",
":",
"3",
",",
"'May'",
":",
"4",
",",
"'J... | Load shopping data from a CSV file `filename` and convert into a list of
evidence lists and a list of labels. | [
"Load",
"shopping",
"data",
"from",
"a",
"CSV",
"file",
"`",
"filename",
"`",
"and",
"convert",
"into",
"a",
"list",
"of",
"evidence",
"lists",
"and",
"a",
"list",
"of",
"labels",
"."
] | [
"\"\"\"\n Load shopping data from a CSV file `filename` and convert into a list of\n evidence lists and a list of labels. Return a tuple (evidence, labels).\n\n evidence should be a list of lists, where each list contains the\n following values, in order:\n - Administrative, an integer\n -... | [
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
71df9caa0cefee2d65dcf7938e93deaf937af612 | bharatchanddandamudi/cs50ai | week4/shopping/shopping.py | [
"MIT"
] | Python | train_model | <not_specific> | def train_model(evidence, labels):
"""
Given a list of evidence lists and a list of labels, return a
fitted k-nearest neighbor model (k=1) trained on the data.
"""
neigh = KNeighborsClassifier(n_neighbors=1)
neigh.fit(evidence, labels)
return neigh |
Given a list of evidence lists and a list of labels, return a
fitted k-nearest neighbor model (k=1) trained on the data.
| Given a list of evidence lists and a list of labels, return a
fitted k-nearest neighbor model (k=1) trained on the data. | [
"Given",
"a",
"list",
"of",
"evidence",
"lists",
"and",
"a",
"list",
"of",
"labels",
"return",
"a",
"fitted",
"k",
"-",
"nearest",
"neighbor",
"model",
"(",
"k",
"=",
"1",
")",
"trained",
"on",
"the",
"data",
"."
] | def train_model(evidence, labels):
neigh = KNeighborsClassifier(n_neighbors=1)
neigh.fit(evidence, labels)
return neigh | [
"def",
"train_model",
"(",
"evidence",
",",
"labels",
")",
":",
"neigh",
"=",
"KNeighborsClassifier",
"(",
"n_neighbors",
"=",
"1",
")",
"neigh",
".",
"fit",
"(",
"evidence",
",",
"labels",
")",
"return",
"neigh"
] | Given a list of evidence lists and a list of labels, return a
fitted k-nearest neighbor model (k=1) trained on the data. | [
"Given",
"a",
"list",
"of",
"evidence",
"lists",
"and",
"a",
"list",
"of",
"labels",
"return",
"a",
"fitted",
"k",
"-",
"nearest",
"neighbor",
"model",
"(",
"k",
"=",
"1",
")",
"trained",
"on",
"the",
"data",
"."
] | [
"\"\"\"\n Given a list of evidence lists and a list of labels, return a\n fitted k-nearest neighbor model (k=1) trained on the data.\n \"\"\""
] | [
{
"param": "evidence",
"type": null
},
{
"param": "labels",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "evidence",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "labels",
"type": null,
"docstring": null,
"docstring_toke... |
71df9caa0cefee2d65dcf7938e93deaf937af612 | bharatchanddandamudi/cs50ai | week4/shopping/shopping.py | [
"MIT"
] | Python | evaluate | <not_specific> | def evaluate(labels, predictions):
"""
Given a list of actual labels and a list of predicted labels,
return a tuple (sensitivity, specificty).
Assume each label is either a 1 (positive) or 0 (negative).
`sensitivity` should be a floating-point value from 0 to 1
representing the "true positive ... |
Given a list of actual labels and a list of predicted labels,
return a tuple (sensitivity, specificty).
Assume each label is either a 1 (positive) or 0 (negative).
`sensitivity` should be a floating-point value from 0 to 1
representing the "true positive rate": the proportion of
actual positi... | Given a list of actual labels and a list of predicted labels,
return a tuple (sensitivity, specificty).
Assume each label is either a 1 (positive) or 0 (negative).
`sensitivity` should be a floating-point value from 0 to 1
representing the "true positive rate": the proportion of
actual positive labels that were accur... | [
"Given",
"a",
"list",
"of",
"actual",
"labels",
"and",
"a",
"list",
"of",
"predicted",
"labels",
"return",
"a",
"tuple",
"(",
"sensitivity",
"specificty",
")",
".",
"Assume",
"each",
"label",
"is",
"either",
"a",
"1",
"(",
"positive",
")",
"or",
"0",
"... | def evaluate(labels, predictions):
tn, fp, fn, tp = confusion_matrix(labels, predictions).ravel()
sensitivity = tp / (tp + fn)
specificity = tn / (tn + fp)
return sensitivity, specificity | [
"def",
"evaluate",
"(",
"labels",
",",
"predictions",
")",
":",
"tn",
",",
"fp",
",",
"fn",
",",
"tp",
"=",
"confusion_matrix",
"(",
"labels",
",",
"predictions",
")",
".",
"ravel",
"(",
")",
"sensitivity",
"=",
"tp",
"/",
"(",
"tp",
"+",
"fn",
")"... | Given a list of actual labels and a list of predicted labels,
return a tuple (sensitivity, specificty). | [
"Given",
"a",
"list",
"of",
"actual",
"labels",
"and",
"a",
"list",
"of",
"predicted",
"labels",
"return",
"a",
"tuple",
"(",
"sensitivity",
"specificty",
")",
"."
] | [
"\"\"\"\n Given a list of actual labels and a list of predicted labels,\n return a tuple (sensitivity, specificty).\n\n Assume each label is either a 1 (positive) or 0 (negative).\n\n `sensitivity` should be a floating-point value from 0 to 1\n representing the \"true positive rate\": the proportion ... | [
{
"param": "labels",
"type": null
},
{
"param": "predictions",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "labels",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "predictions",
"type": null,
"docstring": null,
"docstring_t... |
3adf12642451ff79d4a25e9b7f946d5f5f45d266 | bharatchanddandamudi/cs50ai | week2/pagerank/pagerank.py | [
"MIT"
] | Python | transition_model | <not_specific> | def transition_model(corpus, page, damping_factor):
"""
Return a probability distribution over which page to visit next,
given a current page.
With probability `damping_factor`, choose a link at random
linked to by `page`. With probability `1 - damping_factor`, choose
a link at random chosen fr... |
Return a probability distribution over which page to visit next,
given a current page.
With probability `damping_factor`, choose a link at random
linked to by `page`. With probability `1 - damping_factor`, choose
a link at random chosen from all pages in the corpus.
| Return a probability distribution over which page to visit next,
given a current page.
With probability `damping_factor`, choose a link at random
linked to by `page`. With probability `1 - damping_factor`, choose
a link at random chosen from all pages in the corpus. | [
"Return",
"a",
"probability",
"distribution",
"over",
"which",
"page",
"to",
"visit",
"next",
"given",
"a",
"current",
"page",
".",
"With",
"probability",
"`",
"damping_factor",
"`",
"choose",
"a",
"link",
"at",
"random",
"linked",
"to",
"by",
"`",
"page",
... | def transition_model(corpus, page, damping_factor):
distribution = {}
links = len(corpus[page])
if links:
for link in corpus:
distribution[link] = (1 - damping_factor) / len(corpus)
for link in corpus[page]:
distribution[link] += damping_factor / links
... | [
"def",
"transition_model",
"(",
"corpus",
",",
"page",
",",
"damping_factor",
")",
":",
"distribution",
"=",
"{",
"}",
"links",
"=",
"len",
"(",
"corpus",
"[",
"page",
"]",
")",
"if",
"links",
":",
"for",
"link",
"in",
"corpus",
":",
"distribution",
"[... | Return a probability distribution over which page to visit next,
given a current page. | [
"Return",
"a",
"probability",
"distribution",
"over",
"which",
"page",
"to",
"visit",
"next",
"given",
"a",
"current",
"page",
"."
] | [
"\"\"\"\n Return a probability distribution over which page to visit next,\n given a current page.\n\n With probability `damping_factor`, choose a link at random\n linked to by `page`. With probability `1 - damping_factor`, choose\n a link at random chosen from all pages in the corpus.\n \"\"\""
] | [
{
"param": "corpus",
"type": null
},
{
"param": "page",
"type": null
},
{
"param": "damping_factor",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "corpus",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "page",
"type": null,
"docstring": null,
"docstring_tokens":... |
3adf12642451ff79d4a25e9b7f946d5f5f45d266 | bharatchanddandamudi/cs50ai | week2/pagerank/pagerank.py | [
"MIT"
] | Python | sample_pagerank | <not_specific> | def sample_pagerank(corpus, damping_factor, n):
"""
Return PageRank values for each page by sampling `n` pages
according to transition model, starting with a page at random.
Return a dictionary where keys are page names, and values are
their estimated PageRank value (a value between 0 and 1). All
... |
Return PageRank values for each page by sampling `n` pages
according to transition model, starting with a page at random.
Return a dictionary where keys are page names, and values are
their estimated PageRank value (a value between 0 and 1). All
PageRank values should sum to 1.
| Return PageRank values for each page by sampling `n` pages
according to transition model, starting with a page at random.
Return a dictionary where keys are page names, and values are
their estimated PageRank value (a value between 0 and 1). All
PageRank values should sum to 1. | [
"Return",
"PageRank",
"values",
"for",
"each",
"page",
"by",
"sampling",
"`",
"n",
"`",
"pages",
"according",
"to",
"transition",
"model",
"starting",
"with",
"a",
"page",
"at",
"random",
".",
"Return",
"a",
"dictionary",
"where",
"keys",
"are",
"page",
"n... | def sample_pagerank(corpus, damping_factor, n):
distribution = {}
for page in corpus:
distribution[page] = 0
page = random.choice(list(corpus.keys()))
for i in range(1, n):
current_distribution = transition_model(corpus, page, damping_factor)
for page in distribution:
... | [
"def",
"sample_pagerank",
"(",
"corpus",
",",
"damping_factor",
",",
"n",
")",
":",
"distribution",
"=",
"{",
"}",
"for",
"page",
"in",
"corpus",
":",
"distribution",
"[",
"page",
"]",
"=",
"0",
"page",
"=",
"random",
".",
"choice",
"(",
"list",
"(",
... | Return PageRank values for each page by sampling `n` pages
according to transition model, starting with a page at random. | [
"Return",
"PageRank",
"values",
"for",
"each",
"page",
"by",
"sampling",
"`",
"n",
"`",
"pages",
"according",
"to",
"transition",
"model",
"starting",
"with",
"a",
"page",
"at",
"random",
"."
] | [
"\"\"\"\n Return PageRank values for each page by sampling `n` pages\n according to transition model, starting with a page at random.\n\n Return a dictionary where keys are page names, and values are\n their estimated PageRank value (a value between 0 and 1). All\n PageRank values should sum to 1.\n ... | [
{
"param": "corpus",
"type": null
},
{
"param": "damping_factor",
"type": null
},
{
"param": "n",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "corpus",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "damping_factor",
"type": null,
"docstring": null,
"docstrin... |
3adf12642451ff79d4a25e9b7f946d5f5f45d266 | bharatchanddandamudi/cs50ai | week2/pagerank/pagerank.py | [
"MIT"
] | Python | iterate_pagerank | <not_specific> | def iterate_pagerank(corpus, damping_factor):
"""
Return PageRank values for each page by iteratively updating
PageRank values until convergence.
Return a dictionary where keys are page names, and values are
their estimated PageRank value (a value between 0 and 1). All
PageRank values should su... |
Return PageRank values for each page by iteratively updating
PageRank values until convergence.
Return a dictionary where keys are page names, and values are
their estimated PageRank value (a value between 0 and 1). All
PageRank values should sum to 1.
| Return PageRank values for each page by iteratively updating
PageRank values until convergence.
Return a dictionary where keys are page names, and values are
their estimated PageRank value (a value between 0 and 1). All
PageRank values should sum to 1. | [
"Return",
"PageRank",
"values",
"for",
"each",
"page",
"by",
"iteratively",
"updating",
"PageRank",
"values",
"until",
"convergence",
".",
"Return",
"a",
"dictionary",
"where",
"keys",
"are",
"page",
"names",
"and",
"values",
"are",
"their",
"estimated",
"PageRa... | def iterate_pagerank(corpus, damping_factor):
ranks = {}
threshold = 0.0005
N = len(corpus)
for key in corpus:
ranks[key] = 1 / N
while True:
count = 0
for key in corpus:
new = (1 - damping_factor) / N
sigma = 0
for page in corpus:
... | [
"def",
"iterate_pagerank",
"(",
"corpus",
",",
"damping_factor",
")",
":",
"ranks",
"=",
"{",
"}",
"threshold",
"=",
"0.0005",
"N",
"=",
"len",
"(",
"corpus",
")",
"for",
"key",
"in",
"corpus",
":",
"ranks",
"[",
"key",
"]",
"=",
"1",
"/",
"N",
"wh... | Return PageRank values for each page by iteratively updating
PageRank values until convergence. | [
"Return",
"PageRank",
"values",
"for",
"each",
"page",
"by",
"iteratively",
"updating",
"PageRank",
"values",
"until",
"convergence",
"."
] | [
"\"\"\"\n Return PageRank values for each page by iteratively updating\n PageRank values until convergence.\n\n Return a dictionary where keys are page names, and values are\n their estimated PageRank value (a value between 0 and 1). All\n PageRank values should sum to 1.\n \"\"\""
] | [
{
"param": "corpus",
"type": null
},
{
"param": "damping_factor",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "corpus",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "damping_factor",
"type": null,
"docstring": null,
"docstrin... |
129c17f72fe2311c62fe783089abd692407ffd4a | bharatchanddandamudi/cs50ai | week6/questions/questions.py | [
"MIT"
] | Python | load_files | <not_specific> | def load_files(directory):
"""
Given a directory name, return a dictionary mapping the filename of each
`.txt` file inside that directory to the file's contents as a string.
"""
file_content = dict()
for filename in os.listdir(directory):
file = open(os.path.join(directory, filename), "r... |
Given a directory name, return a dictionary mapping the filename of each
`.txt` file inside that directory to the file's contents as a string.
| Given a directory name, return a dictionary mapping the filename of each
`.txt` file inside that directory to the file's contents as a string. | [
"Given",
"a",
"directory",
"name",
"return",
"a",
"dictionary",
"mapping",
"the",
"filename",
"of",
"each",
"`",
".",
"txt",
"`",
"file",
"inside",
"that",
"directory",
"to",
"the",
"file",
"'",
"s",
"contents",
"as",
"a",
"string",
"."
] | def load_files(directory):
file_content = dict()
for filename in os.listdir(directory):
file = open(os.path.join(directory, filename), "r")
file_content[filename] = file.read()
return file_content | [
"def",
"load_files",
"(",
"directory",
")",
":",
"file_content",
"=",
"dict",
"(",
")",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"file",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"filen... | Given a directory name, return a dictionary mapping the filename of each
`.txt` file inside that directory to the file's contents as a string. | [
"Given",
"a",
"directory",
"name",
"return",
"a",
"dictionary",
"mapping",
"the",
"filename",
"of",
"each",
"`",
".",
"txt",
"`",
"file",
"inside",
"that",
"directory",
"to",
"the",
"file",
"'",
"s",
"contents",
"as",
"a",
"string",
"."
] | [
"\"\"\"\n Given a directory name, return a dictionary mapping the filename of each\n `.txt` file inside that directory to the file's contents as a string.\n \"\"\""
] | [
{
"param": "directory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
129c17f72fe2311c62fe783089abd692407ffd4a | bharatchanddandamudi/cs50ai | week6/questions/questions.py | [
"MIT"
] | Python | tokenize | <not_specific> | def tokenize(document):
"""
Given a document (represented as a string), return a list of all of the
words in that document, in order.
Process document by converting all words to lowercase, and removing any
punctuation or English stopwords.
"""
words = nltk.word_tokenize(document.lower()) ... |
Given a document (represented as a string), return a list of all of the
words in that document, in order.
Process document by converting all words to lowercase, and removing any
punctuation or English stopwords.
| Given a document (represented as a string), return a list of all of the
words in that document, in order.
Process document by converting all words to lowercase, and removing any
punctuation or English stopwords. | [
"Given",
"a",
"document",
"(",
"represented",
"as",
"a",
"string",
")",
"return",
"a",
"list",
"of",
"all",
"of",
"the",
"words",
"in",
"that",
"document",
"in",
"order",
".",
"Process",
"document",
"by",
"converting",
"all",
"words",
"to",
"lowercase",
... | def tokenize(document):
words = nltk.word_tokenize(document.lower())
stopwords = set(nltk.corpus.stopwords.words('english'))
punctuation = set(string.punctuation)
to_be_removed = set()
n = len(words)
for i in rang... | [
"def",
"tokenize",
"(",
"document",
")",
":",
"words",
"=",
"nltk",
".",
"word_tokenize",
"(",
"document",
".",
"lower",
"(",
")",
")",
"stopwords",
"=",
"set",
"(",
"nltk",
".",
"corpus",
".",
"stopwords",
".",
"words",
"(",
"'english'",
")",
")",
"... | Given a document (represented as a string), return a list of all of the
words in that document, in order. | [
"Given",
"a",
"document",
"(",
"represented",
"as",
"a",
"string",
")",
"return",
"a",
"list",
"of",
"all",
"of",
"the",
"words",
"in",
"that",
"document",
"in",
"order",
"."
] | [
"\"\"\"\n Given a document (represented as a string), return a list of all of the\n words in that document, in order.\n\n Process document by converting all words to lowercase, and removing any\n punctuation or English stopwords.\n \"\"\"",
"# Tokenize all words in the document and lowercase",
"#... | [
{
"param": "document",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "document",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
129c17f72fe2311c62fe783089abd692407ffd4a | bharatchanddandamudi/cs50ai | week6/questions/questions.py | [
"MIT"
] | Python | compute_idfs | <not_specific> | def compute_idfs(documents):
"""
Given a dictionary of `documents` that maps names of documents to a list
of words, return a dictionary that maps words to their IDF values.
Any word that appears in at least one of the documents should be in the
resulting dictionary.
"""
idfs = dict() # Ini... |
Given a dictionary of `documents` that maps names of documents to a list
of words, return a dictionary that maps words to their IDF values.
Any word that appears in at least one of the documents should be in the
resulting dictionary.
| Given a dictionary of `documents` that maps names of documents to a list
of words, return a dictionary that maps words to their IDF values.
Any word that appears in at least one of the documents should be in the
resulting dictionary. | [
"Given",
"a",
"dictionary",
"of",
"`",
"documents",
"`",
"that",
"maps",
"names",
"of",
"documents",
"to",
"a",
"list",
"of",
"words",
"return",
"a",
"dictionary",
"that",
"maps",
"words",
"to",
"their",
"IDF",
"values",
".",
"Any",
"word",
"that",
"appe... | def compute_idfs(documents):
idfs = dict()
for document in documents.keys():
for word in documents[document]:
if word in idfs.keys():
idfs[word] += 1
else:
idfs[word] = 1
num_documents = len(documents.keys())
for word in idfs.keys():
... | [
"def",
"compute_idfs",
"(",
"documents",
")",
":",
"idfs",
"=",
"dict",
"(",
")",
"for",
"document",
"in",
"documents",
".",
"keys",
"(",
")",
":",
"for",
"word",
"in",
"documents",
"[",
"document",
"]",
":",
"if",
"word",
"in",
"idfs",
".",
"keys",
... | Given a dictionary of `documents` that maps names of documents to a list
of words, return a dictionary that maps words to their IDF values. | [
"Given",
"a",
"dictionary",
"of",
"`",
"documents",
"`",
"that",
"maps",
"names",
"of",
"documents",
"to",
"a",
"list",
"of",
"words",
"return",
"a",
"dictionary",
"that",
"maps",
"words",
"to",
"their",
"IDF",
"values",
"."
] | [
"\"\"\"\n Given a dictionary of `documents` that maps names of documents to a list\n of words, return a dictionary that maps words to their IDF values.\n\n Any word that appears in at least one of the documents should be in the\n resulting dictionary.\n \"\"\"",
"# Initialize a dictionary to keep c... | [
{
"param": "documents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "documents",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
293ad53f4ced774af5d3cdf366d004a1487b3762 | vesche/we-get | we_get/core/module.py | [
"MIT"
] | Python | http_custom_get_request | <not_specific> | def http_custom_get_request(self, url, headers):
""" http_custom_get_request: HTTP GET request with custom headers.
@return: data.
"""
opener = urllib.request.build_opener()
opener.addheaders = headers
return opener.open(url).read() | http_custom_get_request: HTTP GET request with custom headers.
@return: data.
| HTTP GET request with custom headers. | [
"HTTP",
"GET",
"request",
"with",
"custom",
"headers",
"."
] | def http_custom_get_request(self, url, headers):
opener = urllib.request.build_opener()
opener.addheaders = headers
return opener.open(url).read() | [
"def",
"http_custom_get_request",
"(",
"self",
",",
"url",
",",
"headers",
")",
":",
"opener",
"=",
"urllib",
".",
"request",
".",
"build_opener",
"(",
")",
"opener",
".",
"addheaders",
"=",
"headers",
"return",
"opener",
".",
"open",
"(",
"url",
")",
".... | http_custom_get_request: HTTP GET request with custom headers. | [
"http_custom_get_request",
":",
"HTTP",
"GET",
"request",
"with",
"custom",
"headers",
"."
] | [
"\"\"\" http_custom_get_request: HTTP GET request with custom headers.\n @return: data.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "headers",
"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
... |
4b7b96a173d0931a7750f4e811a13f3324cc0e68 | vesche/we-get | we_get/core/we_get.py | [
"MIT"
] | Python | add_items_label | <not_specific> | def add_items_label(self, target, items):
""" add_items_label - add label of the target to the torrent name.
@target
@items
"""
nitems = dict()
for item in items:
items[item].update({"target": target})
nitems.update({item: items[item]})
... | add_items_label - add label of the target to the torrent name.
@target
@items
| add label of the target to the torrent name.
@target
@items | [
"add",
"label",
"of",
"the",
"target",
"to",
"the",
"torrent",
"name",
".",
"@target",
"@items"
] | def add_items_label(self, target, items):
nitems = dict()
for item in items:
items[item].update({"target": target})
nitems.update({item: items[item]})
return nitems | [
"def",
"add_items_label",
"(",
"self",
",",
"target",
",",
"items",
")",
":",
"nitems",
"=",
"dict",
"(",
")",
"for",
"item",
"in",
"items",
":",
"items",
"[",
"item",
"]",
".",
"update",
"(",
"{",
"\"target\"",
":",
"target",
"}",
")",
"nitems",
"... | add_items_label - add label of the target to the torrent name. | [
"add_items_label",
"-",
"add",
"label",
"of",
"the",
"target",
"to",
"the",
"torrent",
"name",
"."
] | [
"\"\"\" add_items_label - add label of the target to the torrent name.\n @target\n @items\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "items",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
4b7b96a173d0931a7750f4e811a13f3324cc0e68 | vesche/we-get | we_get/core/we_get.py | [
"MIT"
] | Python | sort_items_by_seeds | <not_specific> | def sort_items_by_seeds(self, items):
"""sort_items_by_seeds - sort items by number of seeds.
"""
nitems = OrderedDict()
# Sort by number of seeds
i = sorted(items, key=lambda x: int(items[x]['seeds']), reverse=True)
for item in i:
nitems.update({item: items[... | sort_items_by_seeds - sort items by number of seeds.
| sort items by number of seeds. | [
"sort",
"items",
"by",
"number",
"of",
"seeds",
"."
] | def sort_items_by_seeds(self, items):
nitems = OrderedDict()
i = sorted(items, key=lambda x: int(items[x]['seeds']), reverse=True)
for item in i:
nitems.update({item: items[item]})
return nitems | [
"def",
"sort_items_by_seeds",
"(",
"self",
",",
"items",
")",
":",
"nitems",
"=",
"OrderedDict",
"(",
")",
"i",
"=",
"sorted",
"(",
"items",
",",
"key",
"=",
"lambda",
"x",
":",
"int",
"(",
"items",
"[",
"x",
"]",
"[",
"'seeds'",
"]",
")",
",",
"... | sort_items_by_seeds - sort items by number of seeds. | [
"sort_items_by_seeds",
"-",
"sort",
"items",
"by",
"number",
"of",
"seeds",
"."
] | [
"\"\"\"sort_items_by_seeds - sort items by number of seeds.\n \"\"\"",
"# Sort by number of seeds"
] | [
{
"param": "self",
"type": null
},
{
"param": "items",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "items",
"type": null,
"docstring": null,
"docstring_tokens": ... |
00e9f725ee77a76e90fde3319058e945c21b3525 | Py-Ping/py-ping-fed-sdk | src/docker_generate.py | [
"Apache-2.0"
] | Python | wait | null | def wait(self):
"""
Block execution until the container is paused, exited or running.
"""
while self.container.status not in ["running", "exited", "paused"]:
self.container = self.client.containers.get(self.container.id)
sleep(5) |
Block execution until the container is paused, exited or running.
| Block execution until the container is paused, exited or running. | [
"Block",
"execution",
"until",
"the",
"container",
"is",
"paused",
"exited",
"or",
"running",
"."
] | def wait(self):
while self.container.status not in ["running", "exited", "paused"]:
self.container = self.client.containers.get(self.container.id)
sleep(5) | [
"def",
"wait",
"(",
"self",
")",
":",
"while",
"self",
".",
"container",
".",
"status",
"not",
"in",
"[",
"\"running\"",
",",
"\"exited\"",
",",
"\"paused\"",
"]",
":",
"self",
".",
"container",
"=",
"self",
".",
"client",
".",
"containers",
".",
"get"... | Block execution until the container is paused, exited or running. | [
"Block",
"execution",
"until",
"the",
"container",
"is",
"paused",
"exited",
"or",
"running",
"."
] | [
"\"\"\"\n Block execution until the container is paused, exited or running.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
00e9f725ee77a76e90fde3319058e945c21b3525 | Py-Ping/py-ping-fed-sdk | src/docker_generate.py | [
"Apache-2.0"
] | Python | running | <not_specific> | def running(self, image_name):
"""
Given an image name, return if currently running
"""
for container in self.client.containers.list():
if container.image.tags[0] == image_name:
return True
return False |
Given an image name, return if currently running
| Given an image name, return if currently running | [
"Given",
"an",
"image",
"name",
"return",
"if",
"currently",
"running"
] | def running(self, image_name):
for container in self.client.containers.list():
if container.image.tags[0] == image_name:
return True
return False | [
"def",
"running",
"(",
"self",
",",
"image_name",
")",
":",
"for",
"container",
"in",
"self",
".",
"client",
".",
"containers",
".",
"list",
"(",
")",
":",
"if",
"container",
".",
"image",
".",
"tags",
"[",
"0",
"]",
"==",
"image_name",
":",
"return"... | Given an image name, return if currently running | [
"Given",
"an",
"image",
"name",
"return",
"if",
"currently",
"running"
] | [
"\"\"\"\n Given an image name, return if currently running\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "image_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "image_name",
"type": null,
"docstring": null,
"docstring_toke... |
bbe2833f65606230d2b707b277e2a5364e324fb1 | Py-Ping/py-ping-fed-sdk | src/fetch.py | [
"Apache-2.0"
] | Python | write_json | null | def write_json(self, data, name, directory=None):
"""
given string data write it to file name in folder directory
"""
if not directory:
directory = "./templates/resources/"
targetdirectory = os.path.join(self.project_path, directory)
if not os.path.exists(tar... |
given string data write it to file name in folder directory
| given string data write it to file name in folder directory | [
"given",
"string",
"data",
"write",
"it",
"to",
"file",
"name",
"in",
"folder",
"directory"
] | def write_json(self, data, name, directory=None):
if not directory:
directory = "./templates/resources/"
targetdirectory = os.path.join(self.project_path, directory)
if not os.path.exists(targetdirectory):
os.makedirs(targetdirectory)
path = f"{targetdirectory}/{n... | [
"def",
"write_json",
"(",
"self",
",",
"data",
",",
"name",
",",
"directory",
"=",
"None",
")",
":",
"if",
"not",
"directory",
":",
"directory",
"=",
"\"./templates/resources/\"",
"targetdirectory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
... | given string data write it to file name in folder directory | [
"given",
"string",
"data",
"write",
"it",
"to",
"file",
"name",
"in",
"folder",
"directory"
] | [
"\"\"\"\n given string data write it to file name in folder directory\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "directory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
bbe2833f65606230d2b707b277e2a5364e324fb1 | Py-Ping/py-ping-fed-sdk | src/fetch.py | [
"Apache-2.0"
] | Python | read_json | <not_specific> | def read_json(self, file):
"""
extract a JSON document from the project path
and load into a dict type
"""
try:
with open(os.path.join(self.project_path, file), "r") as file:
return json.loads(file.read())
except IOError:
return Fal... |
extract a JSON document from the project path
and load into a dict type
| extract a JSON document from the project path
and load into a dict type | [
"extract",
"a",
"JSON",
"document",
"from",
"the",
"project",
"path",
"and",
"load",
"into",
"a",
"dict",
"type"
] | def read_json(self, file):
try:
with open(os.path.join(self.project_path, file), "r") as file:
return json.loads(file.read())
except IOError:
return False | [
"def",
"read_json",
"(",
"self",
",",
"file",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"project_path",
",",
"file",
")",
",",
"\"r\"",
")",
"as",
"file",
":",
"return",
"json",
".",
"loads",
"("... | extract a JSON document from the project path
and load into a dict type | [
"extract",
"a",
"JSON",
"document",
"from",
"the",
"project",
"path",
"and",
"load",
"into",
"a",
"dict",
"type"
] | [
"\"\"\"\n extract a JSON document from the project path\n and load into a dict type\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [... |
e168093a59d5a915c5c6717f0d3c774812d4c31d | Py-Ping/py-ping-fed-sdk | src/property.py | [
"Apache-2.0"
] | Python | _process | null | def _process(self):
"""
This method loads all values from the dictionary into the class so type information can
be queried when we generate the package. This includes:
- determing what models to import
- determining the enum classes to import
- generating the type... |
This method loads all values from the dictionary into the class so type information can
be queried when we generate the package. This includes:
- determing what models to import
- determining the enum classes to import
- generating the type marshalling string for the `fr... | This method loads all values from the dictionary into the class so type information can
be queried when we generate the package. This includes:
determing what models to import
determining the enum classes to import
generating the type marshalling string for the `from_dict` method
providing more type hint details | [
"This",
"method",
"loads",
"all",
"values",
"from",
"the",
"dictionary",
"into",
"the",
"class",
"so",
"type",
"information",
"can",
"be",
"queried",
"when",
"we",
"generate",
"the",
"package",
".",
"This",
"includes",
":",
"determing",
"what",
"models",
"to... | def _process(self):
type_class = self.raw_property_dict.get("$ref")
self.description = self.raw_property_dict.get(
"description", ""
).replace("\n", "").replace("<br>", "\n ").replace(" \n", "\n").strip()
if type_class and "enum" in self.raw_property_dict:
... | [
"def",
"_process",
"(",
"self",
")",
":",
"type_class",
"=",
"self",
".",
"raw_property_dict",
".",
"get",
"(",
"\"$ref\"",
")",
"self",
".",
"description",
"=",
"self",
".",
"raw_property_dict",
".",
"get",
"(",
"\"description\"",
",",
"\"\"",
")",
".",
... | This method loads all values from the dictionary into the class so type information can
be queried when we generate the package. | [
"This",
"method",
"loads",
"all",
"values",
"from",
"the",
"dictionary",
"into",
"the",
"class",
"so",
"type",
"information",
"can",
"be",
"queried",
"when",
"we",
"generate",
"the",
"package",
"."
] | [
"\"\"\"\n This method loads all values from the dictionary into the class so type information can\n be queried when we generate the package. This includes:\n - determing what models to import\n - determining the enum classes to import\n - generating the type marshalling st... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9953a67ac653d4523d3e553e8c6e6a8fd5d0374a | cardforcoin/shale-python | shale/__init__.py | [
"MIT"
] | Python | _process_json_data | <not_specific> | def _process_json_data(self, resp):
"""
Process JSON data from a response.
"""
try:
resp_data = json.loads(resp.content.decode('UTF-8'))
except ValueError as e:
raise ShaleException(
"The shale server did not return JSON.", e, resp.content... |
Process JSON data from a response.
| Process JSON data from a response. | [
"Process",
"JSON",
"data",
"from",
"a",
"response",
"."
] | def _process_json_data(self, resp):
try:
resp_data = json.loads(resp.content.decode('UTF-8'))
except ValueError as e:
raise ShaleException(
"The shale server did not return JSON.", e, resp.content)
if 'error' in resp_data:
raise ShaleException(... | [
"def",
"_process_json_data",
"(",
"self",
",",
"resp",
")",
":",
"try",
":",
"resp_data",
"=",
"json",
".",
"loads",
"(",
"resp",
".",
"content",
".",
"decode",
"(",
"'UTF-8'",
")",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"ShaleException",
... | Process JSON data from a response. | [
"Process",
"JSON",
"data",
"from",
"a",
"response",
"."
] | [
"\"\"\"\n Process JSON data from a response.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "resp",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resp",
"type": null,
"docstring": null,
"docstring_tokens": [... |
f4ff88e078b4a56b11fe47d5897b70d6974ad33c | mvcisback/pyLazyTree | lazytree/lazytree.py | [
"MIT"
] | Python | iddfs | null | def iddfs(self, max_depth=float('inf'), flatten=True, randomize=False):
"""Iterative deepening depth-first search."""
depth = 0
while depth <= max_depth:
nodes = self.leaves(max_depth=depth, randomize=randomize)
if flatten:
yield from nodes
els... | Iterative deepening depth-first search. | Iterative deepening depth-first search. | [
"Iterative",
"deepening",
"depth",
"-",
"first",
"search",
"."
] | def iddfs(self, max_depth=float('inf'), flatten=True, randomize=False):
depth = 0
while depth <= max_depth:
nodes = self.leaves(max_depth=depth, randomize=randomize)
if flatten:
yield from nodes
else:
yield tuple(nodes)
dept... | [
"def",
"iddfs",
"(",
"self",
",",
"max_depth",
"=",
"float",
"(",
"'inf'",
")",
",",
"flatten",
"=",
"True",
",",
"randomize",
"=",
"False",
")",
":",
"depth",
"=",
"0",
"while",
"depth",
"<=",
"max_depth",
":",
"nodes",
"=",
"self",
".",
"leaves",
... | Iterative deepening depth-first search. | [
"Iterative",
"deepening",
"depth",
"-",
"first",
"search",
"."
] | [
"\"\"\"Iterative deepening depth-first search.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "max_depth",
"type": null
},
{
"param": "flatten",
"type": null
},
{
"param": "randomize",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_depth",
"type": null,
"docstring": null,
"docstring_token... |
89cd77360d629ccfe4e1a357db512101d9e2c45e | ndubaak/eurocom-django-model-utils2 | edmu/admin.py | [
"BSD-3-Clause"
] | Python | save_model | null | def save_model(self, request, obj, form, change):
"""
We need to pass the user to the save method as it is what the underlying model expects.
"""
if not obj.pk:
obj.created_by = request.user
obj.updated_by = request.user
obj.save() |
We need to pass the user to the save method as it is what the underlying model expects.
| We need to pass the user to the save method as it is what the underlying model expects. | [
"We",
"need",
"to",
"pass",
"the",
"user",
"to",
"the",
"save",
"method",
"as",
"it",
"is",
"what",
"the",
"underlying",
"model",
"expects",
"."
] | def save_model(self, request, obj, form, change):
if not obj.pk:
obj.created_by = request.user
obj.updated_by = request.user
obj.save() | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"if",
"not",
"obj",
".",
"pk",
":",
"obj",
".",
"created_by",
"=",
"request",
".",
"user",
"obj",
".",
"updated_by",
"=",
"request",
".",
"user",
"o... | We need to pass the user to the save method as it is what the underlying model expects. | [
"We",
"need",
"to",
"pass",
"the",
"user",
"to",
"the",
"save",
"method",
"as",
"it",
"is",
"what",
"the",
"underlying",
"model",
"expects",
"."
] | [
"\"\"\"\n We need to pass the user to the save method as it is what the underlying model expects.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "obj",
"type": null
},
{
"param": "form",
"type": null
},
{
"param": "change",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
d74adb30ec271df448019bae29a8c150b3d12504 | DzimbaS/NBSDynamics | src/core/common/environment.py | [
"MIT"
] | Python | validate_dataframe_or_path | pd.DataFrame | def validate_dataframe_or_path(cls, value: EnvInputAttr) -> pd.DataFrame:
"""
Transforms an input into the expected type for the parameter. In case a file it's provided
it's content is converted into a pandas DataFrame.
Args:
value (EnvInputAttr): Value to be validated (Unio... |
Transforms an input into the expected type for the parameter. In case a file it's provided
it's content is converted into a pandas DataFrame.
Args:
value (EnvInputAttr): Value to be validated (Union[pd.DataFrame, Path, str]).
Raises:
FileNotFoundError: When the... | Transforms an input into the expected type for the parameter. In case a file it's provided
it's content is converted into a pandas DataFrame. | [
"Transforms",
"an",
"input",
"into",
"the",
"expected",
"type",
"for",
"the",
"parameter",
".",
"In",
"case",
"a",
"file",
"it",
"'",
"s",
"provided",
"it",
"'",
"s",
"content",
"is",
"converted",
"into",
"a",
"pandas",
"DataFrame",
"."
] | def validate_dataframe_or_path(cls, value: EnvInputAttr) -> pd.DataFrame:
def read_index(value_file: Path) -> pd.DataFrame:
time_series = pd.read_csv(value_file, sep="\t")
if time_series.isnull().values.any():
msg = f"NaNs detected in time series {value_file}"
... | [
"def",
"validate_dataframe_or_path",
"(",
"cls",
",",
"value",
":",
"EnvInputAttr",
")",
"->",
"pd",
".",
"DataFrame",
":",
"def",
"read_index",
"(",
"value_file",
":",
"Path",
")",
"->",
"pd",
".",
"DataFrame",
":",
"\"\"\"Function applicable to time-series in Pa... | Transforms an input into the expected type for the parameter. | [
"Transforms",
"an",
"input",
"into",
"the",
"expected",
"type",
"for",
"the",
"parameter",
"."
] | [
"\"\"\"\n Transforms an input into the expected type for the parameter. In case a file it's provided\n it's content is converted into a pandas DataFrame.\n\n Args:\n value (EnvInputAttr): Value to be validated (Union[pd.DataFrame, Path, str]).\n\n Raises:\n FileNotF... | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": "EnvInputAttr"
}
] | {
"returns": [
{
"docstring": "Validated attribute value.",
"docstring_tokens": [
"Validated",
"attribute",
"value",
"."
],
"type": "pd.DataFrame"
}
],
"raises": [
{
"docstring": "When the provided value is a non-existent Path.",
"doc... |
d74adb30ec271df448019bae29a8c150b3d12504 | DzimbaS/NBSDynamics | src/core/common/environment.py | [
"MIT"
] | Python | read_index | pd.DataFrame | def read_index(value_file: Path) -> pd.DataFrame:
"""Function applicable to time-series in Pandas."""
time_series = pd.read_csv(value_file, sep="\t")
if time_series.isnull().values.any():
msg = f"NaNs detected in time series {value_file}"
raise ValueEr... | Function applicable to time-series in Pandas. | Function applicable to time-series in Pandas. | [
"Function",
"applicable",
"to",
"time",
"-",
"series",
"in",
"Pandas",
"."
] | def read_index(value_file: Path) -> pd.DataFrame:
time_series = pd.read_csv(value_file, sep="\t")
if time_series.isnull().values.any():
msg = f"NaNs detected in time series {value_file}"
raise ValueError(msg)
time_series["date"] = pd.to_datetime(time_s... | [
"def",
"read_index",
"(",
"value_file",
":",
"Path",
")",
"->",
"pd",
".",
"DataFrame",
":",
"time_series",
"=",
"pd",
".",
"read_csv",
"(",
"value_file",
",",
"sep",
"=",
"\"\\t\"",
")",
"if",
"time_series",
".",
"isnull",
"(",
")",
".",
"values",
"."... | Function applicable to time-series in Pandas. | [
"Function",
"applicable",
"to",
"time",
"-",
"series",
"in",
"Pandas",
"."
] | [
"\"\"\"Function applicable to time-series in Pandas.\"\"\""
] | [
{
"param": "value_file",
"type": "Path"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value_file",
"type": "Path",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d74adb30ec271df448019bae29a8c150b3d12504 | DzimbaS/NBSDynamics | src/core/common/environment.py | [
"MIT"
] | Python | validate_storm_category | pd.DataFrame | def validate_storm_category(cls, value: EnvInputAttr) -> pd.DataFrame:
"""
Transforms the input value given for the 'storm_category' parameter
into a valid 'Environment' attribute.
Args:
value (EnvInputAttr): Value assigned to the attribute (Union[pd.DataFrame, Path, str]).
... |
Transforms the input value given for the 'storm_category' parameter
into a valid 'Environment' attribute.
Args:
value (EnvInputAttr): Value assigned to the attribute (Union[pd.DataFrame, Path, str]).
Raises:
FileNotFoundError: When the provided value is a non-e... | Transforms the input value given for the 'storm_category' parameter
into a valid 'Environment' attribute. | [
"Transforms",
"the",
"input",
"value",
"given",
"for",
"the",
"'",
"storm_category",
"'",
"parameter",
"into",
"a",
"valid",
"'",
"Environment",
"'",
"attribute",
"."
] | def validate_storm_category(cls, value: EnvInputAttr) -> pd.DataFrame:
if isinstance(value, pd.DataFrame):
return value
if isinstance(value, str):
value = Path(value)
if isinstance(value, Path):
if not value.is_file():
raise FileNotFoundError(v... | [
"def",
"validate_storm_category",
"(",
"cls",
",",
"value",
":",
"EnvInputAttr",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"isinstance",
"(",
"value",
",",
"pd",
".",
"DataFrame",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"s... | Transforms the input value given for the 'storm_category' parameter
into a valid 'Environment' attribute. | [
"Transforms",
"the",
"input",
"value",
"given",
"for",
"the",
"'",
"storm_category",
"'",
"parameter",
"into",
"a",
"valid",
"'",
"Environment",
"'",
"attribute",
"."
] | [
"\"\"\"\n Transforms the input value given for the 'storm_category' parameter\n into a valid 'Environment' attribute.\n\n Args:\n value (EnvInputAttr): Value assigned to the attribute (Union[pd.DataFrame, Path, str]).\n\n Raises:\n FileNotFoundError: When the provid... | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": "EnvInputAttr"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "pd.DataFrame"
}
],
"raises": [
{
"docstring": "When the provided value is a non-existent Path.",
"docstring_tokens": [
"When",
"the",
"provided",
"va... |
d74adb30ec271df448019bae29a8c150b3d12504 | DzimbaS/NBSDynamics | src/core/common/environment.py | [
"MIT"
] | Python | prevalidate_dates | pd.DataFrame | def prevalidate_dates(
cls, value: Union[pd.DataFrame, Iterable[Union[str, datetime]]]
) -> pd.DataFrame:
"""
Prevalidates the the input value given for the 'dates' parameter transforming it
into a valid 'Environment' attribute.
Args:
value (Union[pd.DataFrame, I... |
Prevalidates the the input value given for the 'dates' parameter transforming it
into a valid 'Environment' attribute.
Args:
value (Union[pd.DataFrame, Iterable[Union[str, datetime]]]): Value assigned to the attribute.
Raises:
NotImplementedError: When the prov... | Prevalidates the the input value given for the 'dates' parameter transforming it
into a valid 'Environment' attribute. | [
"Prevalidates",
"the",
"the",
"input",
"value",
"given",
"for",
"the",
"'",
"dates",
"'",
"parameter",
"transforming",
"it",
"into",
"a",
"valid",
"'",
"Environment",
"'",
"attribute",
"."
] | def prevalidate_dates(
cls, value: Union[pd.DataFrame, Iterable[Union[str, datetime]]]
) -> pd.DataFrame:
if isinstance(value, pd.DataFrame):
return value
if isinstance(value, Iterable):
return cls.get_dates_dataframe(value[0], value[-1])
raise NotImplementedE... | [
"def",
"prevalidate_dates",
"(",
"cls",
",",
"value",
":",
"Union",
"[",
"pd",
".",
"DataFrame",
",",
"Iterable",
"[",
"Union",
"[",
"str",
",",
"datetime",
"]",
"]",
"]",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"isinstance",
"(",
"value",
",",... | Prevalidates the the input value given for the 'dates' parameter transforming it
into a valid 'Environment' attribute. | [
"Prevalidates",
"the",
"the",
"input",
"value",
"given",
"for",
"the",
"'",
"dates",
"'",
"parameter",
"transforming",
"it",
"into",
"a",
"valid",
"'",
"Environment",
"'",
"attribute",
"."
] | [
"\"\"\"\n Prevalidates the the input value given for the 'dates' parameter transforming it\n into a valid 'Environment' attribute.\n\n Args:\n value (Union[pd.DataFrame, Iterable[Union[str, datetime]]]): Value assigned to the attribute.\n\n Raises:\n NotImplementedE... | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": "Union[pd.DataFrame, Iterable[Union[str, datetime]]]"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "pd.DataFrame"
}
],
"raises": [
{
"docstring": "When the provided value is not supported.",
"docstring_tokens": [
"When",
"the",
"provided",
"value",
... |
d74adb30ec271df448019bae29a8c150b3d12504 | DzimbaS/NBSDynamics | src/core/common/environment.py | [
"MIT"
] | Python | temp_kelvin | pd.DataFrame | def temp_kelvin(self) -> pd.DataFrame:
"""
Gets the temperature property in Kelvin.
Returns:
pd.DataFrame: value representation.
"""
if all(self.temperature.values < 100) and self.temperature is not None:
return self.temperature + 273.15
return se... |
Gets the temperature property in Kelvin.
Returns:
pd.DataFrame: value representation.
| Gets the temperature property in Kelvin. | [
"Gets",
"the",
"temperature",
"property",
"in",
"Kelvin",
"."
] | def temp_kelvin(self) -> pd.DataFrame:
if all(self.temperature.values < 100) and self.temperature is not None:
return self.temperature + 273.15
return self.temperature | [
"def",
"temp_kelvin",
"(",
"self",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"all",
"(",
"self",
".",
"temperature",
".",
"values",
"<",
"100",
")",
"and",
"self",
".",
"temperature",
"is",
"not",
"None",
":",
"return",
"self",
".",
"temperature",
... | Gets the temperature property in Kelvin. | [
"Gets",
"the",
"temperature",
"property",
"in",
"Kelvin",
"."
] | [
"\"\"\"\n Gets the temperature property in Kelvin.\n\n Returns:\n pd.DataFrame: value representation.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "pd.DataFrame"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional... |
d74adb30ec271df448019bae29a8c150b3d12504 | DzimbaS/NBSDynamics | src/core/common/environment.py | [
"MIT"
] | Python | temp_celsius | pd.DataFrame | def temp_celsius(self) -> pd.DataFrame:
"""
Gets the temperature property in Celsius.
Returns:
pd.DataFrame: value representation.
"""
if all(self.temperature.values > 100) and self.temperature is not None:
return self.temperature - 273.15
return ... |
Gets the temperature property in Celsius.
Returns:
pd.DataFrame: value representation.
| Gets the temperature property in Celsius. | [
"Gets",
"the",
"temperature",
"property",
"in",
"Celsius",
"."
] | def temp_celsius(self) -> pd.DataFrame:
if all(self.temperature.values > 100) and self.temperature is not None:
return self.temperature - 273.15
return self.temperature | [
"def",
"temp_celsius",
"(",
"self",
")",
"->",
"pd",
".",
"DataFrame",
":",
"if",
"all",
"(",
"self",
".",
"temperature",
".",
"values",
">",
"100",
")",
"and",
"self",
".",
"temperature",
"is",
"not",
"None",
":",
"return",
"self",
".",
"temperature",... | Gets the temperature property in Celsius. | [
"Gets",
"the",
"temperature",
"property",
"in",
"Celsius",
"."
] | [
"\"\"\"\n Gets the temperature property in Celsius.\n\n Returns:\n pd.DataFrame: value representation.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "pd.DataFrame"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional... |
38766a6357c2f0f8712f8cebd3a51376d838cce5 | DzimbaS/NBSDynamics | src/core/simulation/coral_transect_simulation.py | [
"MIT"
] | Python | configure_hydrodynamics | null | def configure_hydrodynamics(self):
"""
Initializes the `HydrodynamicsProtocol` model.
"""
self.hydrodynamics.initiate() |
Initializes the `HydrodynamicsProtocol` model.
| Initializes the `HydrodynamicsProtocol` model. | [
"Initializes",
"the",
"`",
"HydrodynamicsProtocol",
"`",
"model",
"."
] | def configure_hydrodynamics(self):
self.hydrodynamics.initiate() | [
"def",
"configure_hydrodynamics",
"(",
"self",
")",
":",
"self",
".",
"hydrodynamics",
".",
"initiate",
"(",
")"
] | Initializes the `HydrodynamicsProtocol` model. | [
"Initializes",
"the",
"`",
"HydrodynamicsProtocol",
"`",
"model",
"."
] | [
"\"\"\"\n Initializes the `HydrodynamicsProtocol` model.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b390bc2d89abfe0af6a925632c01d4ad2548f4cc | DzimbaS/NBSDynamics | test/core/hydrodynamics/test_reef_1d.py | [
"MIT"
] | Python | reef_1d | Reef1D | def reef_1d(self) -> Reef1D:
"""
Initializes a valid Reef1D to be used in the tests.
Returns:
Reef1D: Valid Reef1D for testing.
"""
return Reef1D() |
Initializes a valid Reef1D to be used in the tests.
Returns:
Reef1D: Valid Reef1D for testing.
| Initializes a valid Reef1D to be used in the tests. | [
"Initializes",
"a",
"valid",
"Reef1D",
"to",
"be",
"used",
"in",
"the",
"tests",
"."
] | def reef_1d(self) -> Reef1D:
return Reef1D() | [
"def",
"reef_1d",
"(",
"self",
")",
"->",
"Reef1D",
":",
"return",
"Reef1D",
"(",
")"
] | Initializes a valid Reef1D to be used in the tests. | [
"Initializes",
"a",
"valid",
"Reef1D",
"to",
"be",
"used",
"in",
"the",
"tests",
"."
] | [
"\"\"\"\n Initializes a valid Reef1D to be used in the tests.\n\n Returns:\n Reef1D: Valid Reef1D for testing.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "Valid Reef1D for testing.",
"docstring_tokens": [
"Valid",
"Reef1D",
"for",
"testing",
"."
],
"type": "Reef1D"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstr... |
2f2885041a850e932a78ebdc5bbc7513f3b6ae18 | DzimbaS/NBSDynamics | src/core/hydrodynamics/transect.py | [
"MIT"
] | Python | input_check | null | def input_check(self):
"""Check if all requested content is provided"""
self.input_check_definition("xy_coordinates")
self.input_check_definition("water_depth")
files = ("mdu", "config")
[self.input_check_definition(file) for file in files] | Check if all requested content is provided | Check if all requested content is provided | [
"Check",
"if",
"all",
"requested",
"content",
"is",
"provided"
] | def input_check(self):
self.input_check_definition("xy_coordinates")
self.input_check_definition("water_depth")
files = ("mdu", "config")
[self.input_check_definition(file) for file in files] | [
"def",
"input_check",
"(",
"self",
")",
":",
"self",
".",
"input_check_definition",
"(",
"\"xy_coordinates\"",
")",
"self",
".",
"input_check_definition",
"(",
"\"water_depth\"",
")",
"files",
"=",
"(",
"\"mdu\"",
",",
"\"config\"",
")",
"[",
"self",
".",
"inp... | Check if all requested content is provided | [
"Check",
"if",
"all",
"requested",
"content",
"is",
"provided"
] | [
"\"\"\"Check if all requested content is provided\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2f2885041a850e932a78ebdc5bbc7513f3b6ae18 | DzimbaS/NBSDynamics | src/core/hydrodynamics/transect.py | [
"MIT"
] | Python | input_check_definition | null | def input_check_definition(self, obj):
"""Check definition of critical object."""
if getattr(self, obj) is None:
msg = f"{obj} undefined (required for Transect)"
raise ValueError(msg) | Check definition of critical object. | Check definition of critical object. | [
"Check",
"definition",
"of",
"critical",
"object",
"."
] | def input_check_definition(self, obj):
if getattr(self, obj) is None:
msg = f"{obj} undefined (required for Transect)"
raise ValueError(msg) | [
"def",
"input_check_definition",
"(",
"self",
",",
"obj",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"obj",
")",
"is",
"None",
":",
"msg",
"=",
"f\"{obj} undefined (required for Transect)\"",
"raise",
"ValueError",
"(",
"msg",
")"
] | Check definition of critical object. | [
"Check",
"definition",
"of",
"critical",
"object",
"."
] | [
"\"\"\"Check definition of critical object.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "obj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": []... |
2f2885041a850e932a78ebdc5bbc7513f3b6ae18 | DzimbaS/NBSDynamics | src/core/hydrodynamics/transect.py | [
"MIT"
] | Python | xy_coordinates | np.ndarray | def xy_coordinates(self) -> np.ndarray:
"""
The (x,y)-coordinates of the model domain,
retrieved from hydrodynamic model; otherwise based on provided definition.
Returns:
np.ndarray: The (x,y) coordinates.
"""
if self.x_coordinates is None or self.y_coordinat... |
The (x,y)-coordinates of the model domain,
retrieved from hydrodynamic model; otherwise based on provided definition.
Returns:
np.ndarray: The (x,y) coordinates.
| The (x,y)-coordinates of the model domain,
retrieved from hydrodynamic model; otherwise based on provided definition. | [
"The",
"(",
"x",
"y",
")",
"-",
"coordinates",
"of",
"the",
"model",
"domain",
"retrieved",
"from",
"hydrodynamic",
"model",
";",
"otherwise",
"based",
"on",
"provided",
"definition",
"."
] | def xy_coordinates(self) -> np.ndarray:
if self.x_coordinates is None or self.y_coordinates is None:
return None
return np.array(
[
[self.x_coordinates[i], self.y_coordinates[i]]
for i in range(len(self.x_coordinates))
]
) | [
"def",
"xy_coordinates",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"self",
".",
"x_coordinates",
"is",
"None",
"or",
"self",
".",
"y_coordinates",
"is",
"None",
":",
"return",
"None",
"return",
"np",
".",
"array",
"(",
"[",
"[",
"self",
... | The (x,y)-coordinates of the model domain,
retrieved from hydrodynamic model; otherwise based on provided definition. | [
"The",
"(",
"x",
"y",
")",
"-",
"coordinates",
"of",
"the",
"model",
"domain",
"retrieved",
"from",
"hydrodynamic",
"model",
";",
"otherwise",
"based",
"on",
"provided",
"definition",
"."
] | [
"\"\"\"\n The (x,y)-coordinates of the model domain,\n retrieved from hydrodynamic model; otherwise based on provided definition.\n\n Returns:\n np.ndarray: The (x,y) coordinates.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "The (x,y) coordinates.",
"docstring_tokens": [
"The",
"(",
"x",
"y",
")",
"coordinates",
"."
],
"type": "np.ndarray"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.