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
4ec7f711c396b80277ae0fb055509ec6da7c8133
holitics/minermedic
minermedic/pools/base_pool.py
[ "Apache-2.0" ]
Python
parse_json
null
def parse_json(self, json, results, miner, worker, pool, algo, algo_idx, coin_idx, coin_cost): """ Parses the JSON data retrieved from the Mining Pool's API. This method must be implemented per POOL and is a POOL dependent implementation of how to parse the data. The follow...
Parses the JSON data retrieved from the Mining Pool's API. This method must be implemented per POOL and is a POOL dependent implementation of how to parse the data. The following stats are to be collected from the pool: - "profitability" - This is a measure of COIN / s...
Parses the JSON data retrieved from the Mining Pool's API. This method must be implemented per POOL and is a POOL dependent implementation of how to parse the data. The following stats are to be collected from the pool. "profitability" - This is a measure of COIN / speed suffix / per DAY This is a calculated stat, us...
[ "Parses", "the", "JSON", "data", "retrieved", "from", "the", "Mining", "Pool", "'", "s", "API", ".", "This", "method", "must", "be", "implemented", "per", "POOL", "and", "is", "a", "POOL", "dependent", "implementation", "of", "how", "to", "parse", "the", ...
def parse_json(self, json, results, miner, worker, pool, algo, algo_idx, coin_idx, coin_cost): pass
[ "def", "parse_json", "(", "self", ",", "json", ",", "results", ",", "miner", ",", "worker", ",", "pool", ",", "algo", ",", "algo_idx", ",", "coin_idx", ",", "coin_cost", ")", ":", "pass" ]
Parses the JSON data retrieved from the Mining Pool's API.
[ "Parses", "the", "JSON", "data", "retrieved", "from", "the", "Mining", "Pool", "'", "s", "API", "." ]
[ "\"\"\"\n Parses the JSON data retrieved from the Mining Pool's API.\n This method must be implemented per POOL and is a POOL\n dependent implementation of how to parse the data.\n\n The following stats are to be collected from the pool:\n\n - \"profitability\" - This is a...
[ { "param": "self", "type": null }, { "param": "json", "type": null }, { "param": "results", "type": null }, { "param": "miner", "type": null }, { "param": "worker", "type": null }, { "param": "pool", "type": null }, { "param": "algo", "...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json", "type": null, "docstring": null, "docstring_tokens": [...
f2f91ee70612a1dba5e03ab44d3855152872cea9
holitics/minermedic
minermedic/miners/helper.py
[ "Apache-2.0" ]
Python
parse_worker_string
<not_specific>
def parse_worker_string(miner, worker): """ Parses a worker string and returns the coin address and worker ID Returns: String, String """ worker_part_count = worker.count(".") + 1 if worker_part_count > 1: if worker_part_count == 2: coin_address, worker = worker.s...
Parses a worker string and returns the coin address and worker ID Returns: String, String
Parses a worker string and returns the coin address and worker ID
[ "Parses", "a", "worker", "string", "and", "returns", "the", "coin", "address", "and", "worker", "ID" ]
def parse_worker_string(miner, worker): worker_part_count = worker.count(".") + 1 if worker_part_count > 1: if worker_part_count == 2: coin_address, worker = worker.split('.') else: worker_parts = worker.split('.') coin_address = worker_parts[0] wo...
[ "def", "parse_worker_string", "(", "miner", ",", "worker", ")", ":", "worker_part_count", "=", "worker", ".", "count", "(", "\".\"", ")", "+", "1", "if", "worker_part_count", ">", "1", ":", "if", "worker_part_count", "==", "2", ":", "coin_address", ",", "w...
Parses a worker string and returns the coin address and worker ID
[ "Parses", "a", "worker", "string", "and", "returns", "the", "coin", "address", "and", "worker", "ID" ]
[ "\"\"\"\n Parses a worker string and returns the coin address and worker ID\n\n Returns:\n String, String\n \"\"\"" ]
[ { "param": "miner", "type": null }, { "param": "worker", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "miner", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
f2f91ee70612a1dba5e03ab44d3855152872cea9
holitics/minermedic
minermedic/miners/helper.py
[ "Apache-2.0" ]
Python
calculate_hashrates
<not_specific>
def calculate_hashrates(results, miner, hashrate_ghs5s, algo): """ Calculates Hashrates for a miner based on the Algo and a passed Hashrate in GH/s. Stores values in the Miner Results Object. Returns: None """ # first get the hashrate info for this ALGO on this MODEL miner hashra...
Calculates Hashrates for a miner based on the Algo and a passed Hashrate in GH/s. Stores values in the Miner Results Object. Returns: None
Calculates Hashrates for a miner based on the Algo and a passed Hashrate in GH/s. Stores values in the Miner Results Object.
[ "Calculates", "Hashrates", "for", "a", "miner", "based", "on", "the", "Algo", "and", "a", "passed", "Hashrate", "in", "GH", "/", "s", ".", "Stores", "values", "in", "the", "Miner", "Results", "Object", "." ]
def calculate_hashrates(results, miner, hashrate_ghs5s, algo): hashrate_info = get_hashrate_info(results, miner, algo) if hashrate_info is None: return current_hashrate, hashrate_units = \ get_normalized_hashrate_from_gigahash_per_sec(hashrate_ghs5s, hashrate_info['units']) expected_hash...
[ "def", "calculate_hashrates", "(", "results", ",", "miner", ",", "hashrate_ghs5s", ",", "algo", ")", ":", "hashrate_info", "=", "get_hashrate_info", "(", "results", ",", "miner", ",", "algo", ")", "if", "hashrate_info", "is", "None", ":", "return", "current_ha...
Calculates Hashrates for a miner based on the Algo and a passed Hashrate in GH/s.
[ "Calculates", "Hashrates", "for", "a", "miner", "based", "on", "the", "Algo", "and", "a", "passed", "Hashrate", "in", "GH", "/", "s", "." ]
[ "\"\"\"\n Calculates Hashrates for a miner based on the Algo and a passed Hashrate in GH/s.\n Stores values in the Miner Results Object.\n\n Returns:\n None\n\n \"\"\"", "# first get the hashrate info for this ALGO on this MODEL miner", "# get the current hashrate and units, normalized to wha...
[ { "param": "results", "type": null }, { "param": "miner", "type": null }, { "param": "hashrate_ghs5s", "type": null }, { "param": "algo", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "results", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null...
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
object_dialog
<not_specific>
def object_dialog(id, header_only, show_details): """ Generates an Object Dialog Template, usually shown as a PopUp :param id: Object ID :param header_only: Show the Top part of the Dialog Only (handled by template) :param show_details: Show the object details (handled by template) :return: HTM...
Generates an Object Dialog Template, usually shown as a PopUp :param id: Object ID :param header_only: Show the Top part of the Dialog Only (handled by template) :param show_details: Show the object details (handled by template) :return: HTML Template with the Object Dialog and contents
Generates an Object Dialog Template, usually shown as a PopUp
[ "Generates", "an", "Object", "Dialog", "Template", "usually", "shown", "as", "a", "PopUp" ]
def object_dialog(id, header_only, show_details): return ui.object_dialog(None, id, header_only, show_details)
[ "def", "object_dialog", "(", "id", ",", "header_only", ",", "show_details", ")", ":", "return", "ui", ".", "object_dialog", "(", "None", ",", "id", ",", "header_only", ",", "show_details", ")" ]
Generates an Object Dialog Template, usually shown as a PopUp
[ "Generates", "an", "Object", "Dialog", "Template", "usually", "shown", "as", "a", "PopUp" ]
[ "\"\"\"\n Generates an Object Dialog Template, usually shown as a PopUp\n :param id: Object ID\n :param header_only: Show the Top part of the Dialog Only (handled by template)\n :param show_details: Show the object details (handled by template)\n :return: HTML Template with the Object Dialog and cont...
[ { "param": "id", "type": null }, { "param": "header_only", "type": null }, { "param": "show_details", "type": null } ]
{ "returns": [ { "docstring": "HTML Template with the Object Dialog and contents", "docstring_tokens": [ "HTML", "Template", "with", "the", "Object", "Dialog", "and", "contents" ], "type": null } ], "raises": [], "pa...
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
miner_status
<not_specific>
def miner_status(): """ Generates a UI Status screen for MinerMedic App :return: HTML Template with Status information """ return ui.status()
Generates a UI Status screen for MinerMedic App :return: HTML Template with Status information
Generates a UI Status screen for MinerMedic App
[ "Generates", "a", "UI", "Status", "screen", "for", "MinerMedic", "App" ]
def miner_status(): return ui.status()
[ "def", "miner_status", "(", ")", ":", "return", "ui", ".", "status", "(", ")" ]
Generates a UI Status screen for MinerMedic App
[ "Generates", "a", "UI", "Status", "screen", "for", "MinerMedic", "App" ]
[ "\"\"\"\n Generates a UI Status screen for MinerMedic App\n :return: HTML Template with Status information\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "HTML Template with Status information", "docstring_tokens": [ "HTML", "Template", "with", "Status", "information" ], "type": null } ], "raises": [], "params": [], "outlier_params": [], "others": [] }
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
miner_messages
<not_specific>
def miner_messages(): """ Generates a set of "messages" for the MinerMedic App :return: HTML Template for Messages """ return ui.messages()
Generates a set of "messages" for the MinerMedic App :return: HTML Template for Messages
Generates a set of "messages" for the MinerMedic App
[ "Generates", "a", "set", "of", "\"", "messages", "\"", "for", "the", "MinerMedic", "App" ]
def miner_messages(): return ui.messages()
[ "def", "miner_messages", "(", ")", ":", "return", "ui", ".", "messages", "(", ")" ]
Generates a set of "messages" for the MinerMedic App
[ "Generates", "a", "set", "of", "\"", "messages", "\"", "for", "the", "MinerMedic", "App" ]
[ "\"\"\"\n Generates a set of \"messages\" for the MinerMedic App\n :return: HTML Template for Messages\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "HTML Template for Messages", "docstring_tokens": [ "HTML", "Template", "for", "Messages" ], "type": null } ], "raises": [], "params": [], "outlier_params": [], "others": [] }
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
miner_predictions
<not_specific>
def miner_predictions(): """ Returns a Model Template Prediction Status screen :return: HTML Template for Model Prediction Status """ logger.debug("/predictions - remote addr:" + request.remote_addr) # render the template return render_template('predictions.html', version='0.0')
Returns a Model Template Prediction Status screen :return: HTML Template for Model Prediction Status
Returns a Model Template Prediction Status screen
[ "Returns", "a", "Model", "Template", "Prediction", "Status", "screen" ]
def miner_predictions(): logger.debug("/predictions - remote addr:" + request.remote_addr) return render_template('predictions.html', version='0.0')
[ "def", "miner_predictions", "(", ")", ":", "logger", ".", "debug", "(", "\"/predictions - remote addr:\"", "+", "request", ".", "remote_addr", ")", "return", "render_template", "(", "'predictions.html'", ",", "version", "=", "'0.0'", ")" ]
Returns a Model Template Prediction Status screen
[ "Returns", "a", "Model", "Template", "Prediction", "Status", "screen" ]
[ "\"\"\"\n Returns a Model Template Prediction Status screen\n :return: HTML Template for Model Prediction Status\n \"\"\"", "# render the template" ]
[]
{ "returns": [ { "docstring": "HTML Template for Model Prediction Status", "docstring_tokens": [ "HTML", "Template", "for", "Model", "Prediction", "Status" ], "type": null } ], "raises": [], "params": [], "outlier_params": [], "...
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
hashrate_by_model
<not_specific>
def hashrate_by_model(): """ Creates a JSON dict of HashRates By Model. Can be called directly. Used by an AJAX js method called by "/hashrate" screen. :return: JSON with Hashrate Info """ from phenome_core.core.globals import results_collector model_hashrates = dict() try: m...
Creates a JSON dict of HashRates By Model. Can be called directly. Used by an AJAX js method called by "/hashrate" screen. :return: JSON with Hashrate Info
Creates a JSON dict of HashRates By Model. Can be called directly. Used by an AJAX js method called by "/hashrate" screen.
[ "Creates", "a", "JSON", "dict", "of", "HashRates", "By", "Model", ".", "Can", "be", "called", "directly", ".", "Used", "by", "an", "AJAX", "js", "method", "called", "by", "\"", "/", "hashrate", "\"", "screen", "." ]
def hashrate_by_model(): from phenome_core.core.globals import results_collector model_hashrates = dict() try: model_hashrates = results_collector['CRYPTO_MINER'].hash_rate_per_model except: pass model_list = [] x = 0 for model,value in model_hashrates.items(): text =...
[ "def", "hashrate_by_model", "(", ")", ":", "from", "phenome_core", ".", "core", ".", "globals", "import", "results_collector", "model_hashrates", "=", "dict", "(", ")", "try", ":", "model_hashrates", "=", "results_collector", "[", "'CRYPTO_MINER'", "]", ".", "ha...
Creates a JSON dict of HashRates By Model.
[ "Creates", "a", "JSON", "dict", "of", "HashRates", "By", "Model", "." ]
[ "\"\"\"\n Creates a JSON dict of HashRates By Model. Can be called directly.\n Used by an AJAX js method called by \"/hashrate\" screen.\n\n :return: JSON with Hashrate Info\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "JSON with Hashrate Info", "docstring_tokens": [ "JSON", "with", "Hashrate", "Info" ], "type": null } ], "raises": [], "params": [], "outlier_params": [], "others": [] }
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
__add_miner
<not_specific>
def __add_miner(ip_address, model_id): """ Internal method to add a miner. :param ip_address: IP Address of the Miner :param model_id: Model ID of the Miner :return: Boolean """ from phenome_core.core.helpers.model_helpers import add_object obj = add_object('CRYPTO_MINER', model_id, ip...
Internal method to add a miner. :param ip_address: IP Address of the Miner :param model_id: Model ID of the Miner :return: Boolean
Internal method to add a miner.
[ "Internal", "method", "to", "add", "a", "miner", "." ]
def __add_miner(ip_address, model_id): from phenome_core.core.helpers.model_helpers import add_object obj = add_object('CRYPTO_MINER', model_id, ip_address, None, None) return obj is not None
[ "def", "__add_miner", "(", "ip_address", ",", "model_id", ")", ":", "from", "phenome_core", ".", "core", ".", "helpers", ".", "model_helpers", "import", "add_object", "obj", "=", "add_object", "(", "'CRYPTO_MINER'", ",", "model_id", ",", "ip_address", ",", "No...
Internal method to add a miner.
[ "Internal", "method", "to", "add", "a", "miner", "." ]
[ "\"\"\"\n Internal method to add a miner.\n :param ip_address: IP Address of the Miner\n :param model_id: Model ID of the Miner\n :return: Boolean\n \"\"\"" ]
[ { "param": "ip_address", "type": null }, { "param": "model_id", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "ip_address", "type": null, "docstring": "IP Address of the Miner", "docstring_tokens": [ "IP", "Add...
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
api_add_miner
<not_specific>
def api_add_miner(ip_address, model_id): """ Adds a Miner Object via the REST API e.g.: http://localhost:5000/minermedic/api/v1/add_miner/192.168.1.223/17 Please Note - when adding a Miner from the UI, this endpoint is NOT CALLED. Instead, the __add_object_internal API call is called in the core ...
Adds a Miner Object via the REST API e.g.: http://localhost:5000/minermedic/api/v1/add_miner/192.168.1.223/17 Please Note - when adding a Miner from the UI, this endpoint is NOT CALLED. Instead, the __add_object_internal API call is called in the core REST API. This endpoint is a convenience meth...
Please Note - when adding a Miner from the UI, this endpoint is NOT CALLED. Instead, the __add_object_internal API call is called in the core REST API. This endpoint is a convenience method for other 3rd party implementations.
[ "Please", "Note", "-", "when", "adding", "a", "Miner", "from", "the", "UI", "this", "endpoint", "is", "NOT", "CALLED", ".", "Instead", "the", "__add_object_internal", "API", "call", "is", "called", "in", "the", "core", "REST", "API", ".", "This", "endpoint...
def api_add_miner(ip_address, model_id): from flask.json import jsonify success = __add_miner(ip_address, model_id) if success: status = _API_ERROR_CODES_['OK'].value error = _API_ERROR_MESSAGES_['OK'].value miner_id = get_object_by_ip(ip_address).id else: status = _API_E...
[ "def", "api_add_miner", "(", "ip_address", ",", "model_id", ")", ":", "from", "flask", ".", "json", "import", "jsonify", "success", "=", "__add_miner", "(", "ip_address", ",", "model_id", ")", "if", "success", ":", "status", "=", "_API_ERROR_CODES_", "[", "'...
Adds a Miner Object via the REST API e.g.
[ "Adds", "a", "Miner", "Object", "via", "the", "REST", "API", "e", ".", "g", "." ]
[ "\"\"\"\n Adds a Miner Object via the REST API\n e.g.: http://localhost:5000/minermedic/api/v1/add_miner/192.168.1.223/17\n\n Please Note - when adding a Miner from the UI, this endpoint is NOT CALLED.\n Instead, the __add_object_internal API call is called in the core REST API.\n This endpoint is a...
[ { "param": "ip_address", "type": null }, { "param": "model_id", "type": null } ]
{ "returns": [ { "docstring": "JSON response including new Miner ID if successful", "docstring_tokens": [ "JSON", "response", "including", "new", "Miner", "ID", "if", "successful" ], "type": null } ], "raises": [], "...
4c6672e6b23a4292e4ca32bbfce7821116ee1e15
holitics/minermedic
minermedic/minermedic.py
[ "Apache-2.0" ]
Python
delete_miner
<not_specific>
def delete_miner(id): """ Deletes a Miner using a Rest API call :param id: Miner ID for Miner to delete :return: JSON with status """ # delete the miner object from the system success = delete_object(id, False, True) response = {"status": success, "id": id} return...
Deletes a Miner using a Rest API call :param id: Miner ID for Miner to delete :return: JSON with status
Deletes a Miner using a Rest API call
[ "Deletes", "a", "Miner", "using", "a", "Rest", "API", "call" ]
def delete_miner(id): success = delete_object(id, False, True) response = {"status": success, "id": id} return response
[ "def", "delete_miner", "(", "id", ")", ":", "success", "=", "delete_object", "(", "id", ",", "False", ",", "True", ")", "response", "=", "{", "\"status\"", ":", "success", ",", "\"id\"", ":", "id", "}", "return", "response" ]
Deletes a Miner using a Rest API call
[ "Deletes", "a", "Miner", "using", "a", "Rest", "API", "call" ]
[ "\"\"\"\n Deletes a Miner using a Rest API call\n :param id: Miner ID for Miner to delete\n :return: JSON with status\n \"\"\"", "# delete the miner object from the system" ]
[ { "param": "id", "type": null } ]
{ "returns": [ { "docstring": "JSON with status", "docstring_tokens": [ "JSON", "with", "status" ], "type": null } ], "raises": [], "params": [ { "identifier": "id", "type": null, "docstring": "Miner ID for Miner to delete", "do...
fa6f035afe69ae8aa2c55051f1de881c28e62a10
holitics/minermedic
minermedic/api/cgminer.py
[ "Apache-2.0" ]
Python
reboot_claymore_miner
<not_specific>
def reboot_claymore_miner(ip): """ Sends a command to reboot a Claymore Miner Returns: dict - containing success or failure """ port = flask_app.config.get("MINER_API_PORTS_CLAYMORE_PORT"); cgminer = CgminerAPI(host=ip,port=port,payload_command="method") output = cgminer.miner_reb...
Sends a command to reboot a Claymore Miner Returns: dict - containing success or failure
Sends a command to reboot a Claymore Miner
[ "Sends", "a", "command", "to", "reboot", "a", "Claymore", "Miner" ]
def reboot_claymore_miner(ip): port = flask_app.config.get("MINER_API_PORTS_CLAYMORE_PORT"); cgminer = CgminerAPI(host=ip,port=port,payload_command="method") output = cgminer.miner_reboot() output.update({"IP": ip}) return dict(output)
[ "def", "reboot_claymore_miner", "(", "ip", ")", ":", "port", "=", "flask_app", ".", "config", ".", "get", "(", "\"MINER_API_PORTS_CLAYMORE_PORT\"", ")", ";", "cgminer", "=", "CgminerAPI", "(", "host", "=", "ip", ",", "port", "=", "port", ",", "payload_comman...
Sends a command to reboot a Claymore Miner
[ "Sends", "a", "command", "to", "reboot", "a", "Claymore", "Miner" ]
[ "\"\"\"\n Sends a command to reboot a Claymore Miner\n\n Returns:\n dict - containing success or failure\n \"\"\"" ]
[ { "param": "ip", "type": null } ]
{ "returns": [ { "docstring": "containing success or failure", "docstring_tokens": [ "containing", "success", "or", "failure" ], "type": null } ], "raises": [], "params": [ { "identifier": "ip", "type": null, "docstring": null...
fa6f035afe69ae8aa2c55051f1de881c28e62a10
holitics/minermedic
minermedic/api/cgminer.py
[ "Apache-2.0" ]
Python
restart_claymore_miner
<not_specific>
def restart_claymore_miner(ip): """ Sends a command to restart a Claymore Miner Returns: dict - containing success or failure """ port = flask_app.config.get("MINER_API_PORTS_CLAYMORE_PORT"); cgminer = CgminerAPI(host=ip,port=port, payload_command="method") output = cgminer.miner_...
Sends a command to restart a Claymore Miner Returns: dict - containing success or failure
Sends a command to restart a Claymore Miner
[ "Sends", "a", "command", "to", "restart", "a", "Claymore", "Miner" ]
def restart_claymore_miner(ip): port = flask_app.config.get("MINER_API_PORTS_CLAYMORE_PORT"); cgminer = CgminerAPI(host=ip,port=port, payload_command="method") output = cgminer.miner_restart() output.update({"IP": ip}) return dict(output)
[ "def", "restart_claymore_miner", "(", "ip", ")", ":", "port", "=", "flask_app", ".", "config", ".", "get", "(", "\"MINER_API_PORTS_CLAYMORE_PORT\"", ")", ";", "cgminer", "=", "CgminerAPI", "(", "host", "=", "ip", ",", "port", "=", "port", ",", "payload_comma...
Sends a command to restart a Claymore Miner
[ "Sends", "a", "command", "to", "restart", "a", "Claymore", "Miner" ]
[ "\"\"\"\n Sends a command to restart a Claymore Miner\n\n Returns:\n dict - containing success or failure\n \"\"\"" ]
[ { "param": "ip", "type": null } ]
{ "returns": [ { "docstring": "containing success or failure", "docstring_tokens": [ "containing", "success", "or", "failure" ], "type": null } ], "raises": [], "params": [ { "identifier": "ip", "type": null, "docstring": null...
4e6d34c78a84d9823cb66857a16d58e54a61d004
holitics/minermedic
minermedic/pools/helper.py
[ "Apache-2.0" ]
Python
process_pool_apis
null
def process_pool_apis(results, miner, worker, algo, pool): """ Processes all pool APIs for the specific pool Returns: None """ success = False pool_attrs = None pool_class = None pool_not_supported = False if pool not in pool_lookups: # get the pool classnames e...
Processes all pool APIs for the specific pool Returns: None
Processes all pool APIs for the specific pool
[ "Processes", "all", "pool", "APIs", "for", "the", "specific", "pool" ]
def process_pool_apis(results, miner, worker, algo, pool): success = False pool_attrs = None pool_class = None pool_not_supported = False if pool not in pool_lookups: enum_pools = global_enums.get_enum_details('_POOL_STATS_CLASSNAMES_') for enum_pool in enum_pools: pool_a...
[ "def", "process_pool_apis", "(", "results", ",", "miner", ",", "worker", ",", "algo", ",", "pool", ")", ":", "success", "=", "False", "pool_attrs", "=", "None", "pool_class", "=", "None", "pool_not_supported", "=", "False", "if", "pool", "not", "in", "pool...
Processes all pool APIs for the specific pool
[ "Processes", "all", "pool", "APIs", "for", "the", "specific", "pool" ]
[ "\"\"\"\n Processes all pool APIs for the specific pool\n\n Returns:\n None\n\n \"\"\"", "# get the pool classnames enum", "# add the name to the attributes", "# add the attributes to the list.", "# get the model class to operate with", "# create the mining pool", "# add the relations (w...
[ { "param": "results", "type": null }, { "param": "miner", "type": null }, { "param": "worker", "type": null }, { "param": "algo", "type": null }, { "param": "pool", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "results", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null...
54a8b79359f56aa9198dd0decde2ee483677e8e7
holitics/minermedic
minermedic/miner_results.py
[ "Apache-2.0" ]
Python
populate_chip_results
null
def populate_chip_results(self, miner, chips): """ Build chip status and chip summary strings and populate the results :param miner: Miner Object :param chips: MinerChipStats Object :return: None """ # build a status dict chip_status = {'active': chips....
Build chip status and chip summary strings and populate the results :param miner: Miner Object :param chips: MinerChipStats Object :return: None
Build chip status and chip summary strings and populate the results
[ "Build", "chip", "status", "and", "chip", "summary", "strings", "and", "populate", "the", "results" ]
def populate_chip_results(self, miner, chips): chip_status = {'active': chips.chips_working, 'failed': chips.chips_defective, 'missing': chips.chips_missing} chips_bad = chips.chips_defective+chips.chips_missing chips_total = chips.chips_working +...
[ "def", "populate_chip_results", "(", "self", ",", "miner", ",", "chips", ")", ":", "chip_status", "=", "{", "'active'", ":", "chips", ".", "chips_working", ",", "'failed'", ":", "chips", ".", "chips_defective", ",", "'missing'", ":", "chips", ".", "chips_mis...
Build chip status and chip summary strings and populate the results
[ "Build", "chip", "status", "and", "chip", "summary", "strings", "and", "populate", "the", "results" ]
[ "\"\"\"\n Build chip status and chip summary strings and populate the results\n :param miner: Miner Object\n :param chips: MinerChipStats Object\n :return: None\n \"\"\"", "# build a status dict", "# get some working totals", "# set a result of chip status as a percent", "...
[ { "param": "self", "type": null }, { "param": "miner", "type": null }, { "param": "chips", "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 ...
54a8b79359f56aa9198dd0decde2ee483677e8e7
holitics/minermedic
minermedic/miner_results.py
[ "Apache-2.0" ]
Python
populate_fan_results
null
def populate_fan_results(self, miner, fan_speeds): """ Populates the Fan Results for a Miner :param miner: Miner Object :param fan_speeds: (List) of Fan Speeds for that Miner :return: None """ fan_avg = 0 fan_status_pct = 100 try: #...
Populates the Fan Results for a Miner :param miner: Miner Object :param fan_speeds: (List) of Fan Speeds for that Miner :return: None
Populates the Fan Results for a Miner
[ "Populates", "the", "Fan", "Results", "for", "a", "Miner" ]
def populate_fan_results(self, miner, fan_speeds): fan_avg = 0 fan_status_pct = 100 try: fan_avg = math_functions.get_average_of_list(fan_speeds, 0) if fan_avg < 101: if fan_avg == 0: fan_avg = "" else: ...
[ "def", "populate_fan_results", "(", "self", ",", "miner", ",", "fan_speeds", ")", ":", "fan_avg", "=", "0", "fan_status_pct", "=", "100", "try", ":", "fan_avg", "=", "math_functions", ".", "get_average_of_list", "(", "fan_speeds", ",", "0", ")", "if", "fan_a...
Populates the Fan Results for a Miner
[ "Populates", "the", "Fan", "Results", "for", "a", "Miner" ]
[ "\"\"\"\n Populates the Fan Results for a Miner\n :param miner: Miner Object\n :param fan_speeds: (List) of Fan Speeds for that Miner\n :return: None\n \"\"\"", "# get the avg fan" ]
[ { "param": "self", "type": null }, { "param": "miner", "type": null }, { "param": "fan_speeds", "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 ...
54a8b79359f56aa9198dd0decde2ee483677e8e7
holitics/minermedic
minermedic/miner_results.py
[ "Apache-2.0" ]
Python
populate_miner_results
null
def populate_miner_results(self, miner, elapsed_secs, worker, algo, pool, chips, temps, fan_speeds, hashrate_ghs5s, hw_error_rate): """ Populates all Miner Results for a particular poll cycle :param miner: Miner Object :param elapsed_secs: Number of Second...
Populates all Miner Results for a particular poll cycle :param miner: Miner Object :param elapsed_secs: Number of Seconds that miner has been running :param worker: (String) worker ID :param algo: (String) Algorithm running on Miner at that time :param pool: The Pool ID ...
Populates all Miner Results for a particular poll cycle
[ "Populates", "all", "Miner", "Results", "for", "a", "particular", "poll", "cycle" ]
def populate_miner_results(self, miner, elapsed_secs, worker, algo, pool, chips, temps, fan_speeds, hashrate_ghs5s, hw_error_rate): self.set_result(miner, 'uptimes', timedelta(seconds=elapsed_secs)) self.set_result(miner, 'temperatures', temps) self.set_result(min...
[ "def", "populate_miner_results", "(", "self", ",", "miner", ",", "elapsed_secs", ",", "worker", ",", "algo", ",", "pool", ",", "chips", ",", "temps", ",", "fan_speeds", ",", "hashrate_ghs5s", ",", "hw_error_rate", ")", ":", "self", ".", "set_result", "(", ...
Populates all Miner Results for a particular poll cycle
[ "Populates", "all", "Miner", "Results", "for", "a", "particular", "poll", "cycle" ]
[ "\"\"\"\n Populates all Miner Results for a particular poll cycle\n :param miner: Miner Object\n :param elapsed_secs: Number of Seconds that miner has been running\n :param worker: (String) worker ID\n :param algo: (String) Algorithm running on Miner at that time\n :param p...
[ { "param": "self", "type": null }, { "param": "miner", "type": null }, { "param": "elapsed_secs", "type": null }, { "param": "worker", "type": null }, { "param": "algo", "type": null }, { "param": "pool", "type": null }, { "param": "chips",...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
54a8b79359f56aa9198dd0decde2ee483677e8e7
holitics/minermedic
minermedic/miner_results.py
[ "Apache-2.0" ]
Python
populate_pool_results
null
def populate_pool_results(self, miner, worker, pool, algo, algo_idx, coin_idx, coin_cost, profitability, speed_accepted, speed_reported, speed_suffix): """ Populates all the pool results for a particular Miner. :param miner: Miner Object :param worker: (Str...
Populates all the pool results for a particular Miner. :param miner: Miner Object :param worker: (String) worker ID :param pool: (Integer) Pool ID :param algo: (String) Algo currently running on the miner :param algo_idx: (Integer) Algo index (internal) :param co...
Populates all the pool results for a particular Miner.
[ "Populates", "all", "the", "pool", "results", "for", "a", "particular", "Miner", "." ]
def populate_pool_results(self, miner, worker, pool, algo, algo_idx, coin_idx, coin_cost, profitability, speed_accepted, speed_reported, speed_suffix): coin_generated_per_minute = (profitability * speed_accepted) / (60 * 24) power_used, power_used_cost = get_power_usage_inf...
[ "def", "populate_pool_results", "(", "self", ",", "miner", ",", "worker", ",", "pool", ",", "algo", ",", "algo_idx", ",", "coin_idx", ",", "coin_cost", ",", "profitability", ",", "speed_accepted", ",", "speed_reported", ",", "speed_suffix", ")", ":", "coin_gen...
Populates all the pool results for a particular Miner.
[ "Populates", "all", "the", "pool", "results", "for", "a", "particular", "Miner", "." ]
[ "\"\"\"\n Populates all the pool results for a particular Miner.\n :param miner: Miner Object\n :param worker: (String) worker ID\n :param pool: (Integer) Pool ID\n :param algo: (String) Algo currently running on the miner\n :param algo_idx: (Integer) Algo index (internal)\...
[ { "param": "self", "type": null }, { "param": "miner", "type": null }, { "param": "worker", "type": null }, { "param": "pool", "type": null }, { "param": "algo", "type": null }, { "param": "algo_idx", "type": null }, { "param": "coin_idx", ...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6a77eee324fedcb2bf9b8cd9929eae1db55e236d
holitics/minermedic
minermedic/miners/base_miner.py
[ "Apache-2.0" ]
Python
poll
null
def poll(self, results): """ Poll method communicates to the Miner and stores statistics in the MinerResults object. ABSTRACT. Actual miner specific code must be implemented in each Miner Subclass. """ pass
Poll method communicates to the Miner and stores statistics in the MinerResults object. ABSTRACT. Actual miner specific code must be implemented in each Miner Subclass.
Poll method communicates to the Miner and stores statistics in the MinerResults object. ABSTRACT. Actual miner specific code must be implemented in each Miner Subclass.
[ "Poll", "method", "communicates", "to", "the", "Miner", "and", "stores", "statistics", "in", "the", "MinerResults", "object", ".", "ABSTRACT", ".", "Actual", "miner", "specific", "code", "must", "be", "implemented", "in", "each", "Miner", "Subclass", "." ]
def poll(self, results): pass
[ "def", "poll", "(", "self", ",", "results", ")", ":", "pass" ]
Poll method communicates to the Miner and stores statistics in the MinerResults object.
[ "Poll", "method", "communicates", "to", "the", "Miner", "and", "stores", "statistics", "in", "the", "MinerResults", "object", "." ]
[ "\"\"\"\n Poll method communicates to the Miner and stores statistics in the MinerResults object.\n ABSTRACT. Actual miner specific code must be implemented in each Miner Subclass.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "results", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "results", "type": null, "docstring": null, "docstring_tokens"...
6a77eee324fedcb2bf9b8cd9929eae1db55e236d
holitics/minermedic
minermedic/miners/base_miner.py
[ "Apache-2.0" ]
Python
poll_pool_stats
null
def poll_pool_stats(miner): """ Pool Stats are retrieved from the Miner. Generic, shared call. """ last_share_time = 0 miner.algo = None # WORKER, POOL, ALGO, LAST SHARE TIME miner_pools = cgminer.get_pools(miner.ip) for miner_pool in miner_pools['POOL...
Pool Stats are retrieved from the Miner. Generic, shared call.
Pool Stats are retrieved from the Miner. Generic, shared call.
[ "Pool", "Stats", "are", "retrieved", "from", "the", "Miner", ".", "Generic", "shared", "call", "." ]
def poll_pool_stats(miner): last_share_time = 0 miner.algo = None miner_pools = cgminer.get_pools(miner.ip) for miner_pool in miner_pools['POOLS']: miner_pool_status = miner_pool.get('Status') miner_pool_stratum_active = miner_pool.get('Stratum_Active') ...
[ "def", "poll_pool_stats", "(", "miner", ")", ":", "last_share_time", "=", "0", "miner", ".", "algo", "=", "None", "miner_pools", "=", "cgminer", ".", "get_pools", "(", "miner", ".", "ip", ")", "for", "miner_pool", "in", "miner_pools", "[", "'POOLS'", "]", ...
Pool Stats are retrieved from the Miner.
[ "Pool", "Stats", "are", "retrieved", "from", "the", "Miner", "." ]
[ "\"\"\"\n Pool Stats are retrieved from the Miner. Generic, shared call.\n \"\"\"", "# WORKER, POOL, ALGO, LAST SHARE TIME", "# pull pertinent information", "# get the PORT as well, different pools/algos at different ports", "# IDLE STATE", "# convert last share time to minutes (i.e. share c...
[ { "param": "miner", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "miner", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6a77eee324fedcb2bf9b8cd9929eae1db55e236d
holitics/minermedic
minermedic/miners/base_miner.py
[ "Apache-2.0" ]
Python
restart_miner
<not_specific>
def restart_miner(self): """ Attempts to restart the miner. This is a wrapper for "miner.restart()". The actual "restart" method must be implemented individually for each subclass of Miner. Returns: boolean """ success = False # can we still ping ...
Attempts to restart the miner. This is a wrapper for "miner.restart()". The actual "restart" method must be implemented individually for each subclass of Miner. Returns: boolean
Attempts to restart the miner. This is a wrapper for "miner.restart()". The actual "restart" method must be implemented individually for each subclass of Miner.
[ "Attempts", "to", "restart", "the", "miner", ".", "This", "is", "a", "wrapper", "for", "\"", "miner", ".", "restart", "()", "\"", ".", "The", "actual", "\"", "restart", "\"", "method", "must", "be", "implemented", "individually", "for", "each", "subclass",...
def restart_miner(self): success = False if self.object_states.ping_error == 0: logger.debug("Attempt to restart object {}".format(self.id)) success = False self.__init_restart_delay(self.object) restart = time_functions.get_timeout_expired(self.last_resta...
[ "def", "restart_miner", "(", "self", ")", ":", "success", "=", "False", "if", "self", ".", "object_states", ".", "ping_error", "==", "0", ":", "logger", ".", "debug", "(", "\"Attempt to restart object {}\"", ".", "format", "(", "self", ".", "id", ")", ")",...
Attempts to restart the miner.
[ "Attempts", "to", "restart", "the", "miner", "." ]
[ "\"\"\"\n Attempts to restart the miner. This is a wrapper for \"miner.restart()\".\n The actual \"restart\" method must be implemented individually for each subclass of Miner.\n\n Returns:\n boolean\n\n \"\"\"", "# can we still ping this miner?", "# we can still ping it, ...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
3b7725d3f2d5bfc0fb0162bf0b824f217dd528a5
holitics/minermedic
minermedic/miner_processor.py
[ "Apache-2.0" ]
Python
process_object_states
<not_specific>
def process_object_states(self, object, results): """ Simple state machine that handles default Miner Actions when specific Actions are not defined in the ActionModel. Returns: Boolean """ if object is None: # should not happen logg...
Simple state machine that handles default Miner Actions when specific Actions are not defined in the ActionModel. Returns: Boolean
Simple state machine that handles default Miner Actions when specific Actions are not defined in the ActionModel.
[ "Simple", "state", "machine", "that", "handles", "default", "Miner", "Actions", "when", "specific", "Actions", "are", "not", "defined", "in", "the", "ActionModel", "." ]
def process_object_states(self, object, results): if object is None: logger.error("OBJECT is None") return False if object.admin_disabled: return False if not self.has_object_init_time_passed(object, results): return False logger.debug("pro...
[ "def", "process_object_states", "(", "self", ",", "object", ",", "results", ")", ":", "if", "object", "is", "None", ":", "logger", ".", "error", "(", "\"OBJECT is None\"", ")", "return", "False", "if", "object", ".", "admin_disabled", ":", "return", "False",...
Simple state machine that handles default Miner Actions when specific Actions are not defined in the ActionModel.
[ "Simple", "state", "machine", "that", "handles", "default", "Miner", "Actions", "when", "specific", "Actions", "are", "not", "defined", "in", "the", "ActionModel", "." ]
[ "\"\"\"\n Simple state machine that handles default Miner Actions\n when specific Actions are not defined in the ActionModel.\n\n Returns:\n Boolean\n\n \"\"\"", "# should not happen", "# do not execute the state machine for items that are still initializing...", "# STEP...
[ { "param": "self", "type": null }, { "param": "object", "type": null }, { "param": "results", "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 ...
19fe381ec0c5deb6993cc80314f4096ae58ce341
eigenfoo-forks/pymc4
tests/test_distributions.py
[ "Apache-2.0" ]
Python
random_variable_args
<not_specific>
def random_variable_args(): """Provide arguments for each random variable.""" # Commented out tests are currently failing and will be fixed _random_variable_args = ( ("Bernoulli", {"probs": 0.5, "sample": 1.0}), ("Beta", {"concentration0": 1, "concentration1": 1}), ("Binomial", {"to...
Provide arguments for each random variable.
Provide arguments for each random variable.
[ "Provide", "arguments", "for", "each", "random", "variable", "." ]
def random_variable_args(): _random_variable_args = ( ("Bernoulli", {"probs": 0.5, "sample": 1.0}), ("Beta", {"concentration0": 1, "concentration1": 1}), ("Binomial", {"total_count": 5.0, "probs": 0.5, "sample": 1.0}), ("Categorical", {"probs": [0.1, 0.5, 0.4], "sample": 2.0}), ...
[ "def", "random_variable_args", "(", ")", ":", "_random_variable_args", "=", "(", "(", "\"Bernoulli\"", ",", "{", "\"probs\"", ":", "0.5", ",", "\"sample\"", ":", "1.0", "}", ")", ",", "(", "\"Beta\"", ",", "{", "\"concentration0\"", ":", "1", ",", "\"conce...
Provide arguments for each random variable.
[ "Provide", "arguments", "for", "each", "random", "variable", "." ]
[ "\"\"\"Provide arguments for each random variable.\"\"\"", "# Commented out tests are currently failing and will be fixed", "# (\"HalfStudentT\", {\"scale\": 1, \"nu\": 10}),", "# (\"Weibull\", {\"beta\": 0.1, \"alpha\": 1.0}),", "# (\"ZeroInflatedBinomial\", {\"psi\": 0.2, \"total_count\": 10, \"p\": 0.5, ...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
5eb179110ae3189705e507499cdfa74daa880888
eigenfoo-forks/pymc4
pymc4/utils.py
[ "Apache-2.0" ]
Python
biwrap
Callable
def biwrap(wrapper) -> Callable: """Allow for optional keyword arguments in lower level decoratrors. Notes ----- Currently this is only used to wrap pm.Model to capture model runtime flags such as keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters """ @functo...
Allow for optional keyword arguments in lower level decoratrors. Notes ----- Currently this is only used to wrap pm.Model to capture model runtime flags such as keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters
Allow for optional keyword arguments in lower level decoratrors. Notes Currently this is only used to wrap pm.Model to capture model runtime flags such as keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters
[ "Allow", "for", "optional", "keyword", "arguments", "in", "lower", "level", "decoratrors", ".", "Notes", "Currently", "this", "is", "only", "used", "to", "wrap", "pm", ".", "Model", "to", "capture", "model", "runtime", "flags", "such", "as", "keep_auxiliary", ...
def biwrap(wrapper) -> Callable: @functools.wraps(wrapper) def enhanced(*args, **kwargs) -> Callable: is_bound_method = hasattr(args[0], wrapper.__name__) if args else False if is_bound_method: count = 1 else: count = 0 if len(args) > count: ne...
[ "def", "biwrap", "(", "wrapper", ")", "->", "Callable", ":", "@", "functools", ".", "wraps", "(", "wrapper", ")", "def", "enhanced", "(", "*", "args", ",", "**", "kwargs", ")", "->", "Callable", ":", "is_bound_method", "=", "hasattr", "(", "args", "[",...
Allow for optional keyword arguments in lower level decoratrors.
[ "Allow", "for", "optional", "keyword", "arguments", "in", "lower", "level", "decoratrors", "." ]
[ "\"\"\"Allow for optional keyword arguments in lower level decoratrors.\n\n Notes\n -----\n Currently this is only used to wrap pm.Model to capture model runtime flags such as\n keep_auxiliary and keep_return. See pm.Model for all possible keyword parameters\n\n \"\"\"", "# Check if decorated metho...
[ { "param": "wrapper", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wrapper", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
76a8045b53f990e3e0106540d246ef073ca375e8
eigenfoo-forks/pymc4
pymc4/ast_compiler.py
[ "Apache-2.0" ]
Python
recompile
<not_specific>
def recompile(source, filename, mode, flags=0, firstlineno=1, privateprefix=None): """Recompile output of uncompile back to a code object. source may also be preparsed AST.""" if isinstance(source, ast.AST): a = source else: a = parse_snippet(source, filename, mode, flags, firstlineno) n...
Recompile output of uncompile back to a code object. source may also be preparsed AST.
Recompile output of uncompile back to a code object. source may also be preparsed AST.
[ "Recompile", "output", "of", "uncompile", "back", "to", "a", "code", "object", ".", "source", "may", "also", "be", "preparsed", "AST", "." ]
def recompile(source, filename, mode, flags=0, firstlineno=1, privateprefix=None): if isinstance(source, ast.AST): a = source else: a = parse_snippet(source, filename, mode, flags, firstlineno) node = a.body[0] if not isinstance(node, ast.FunctionDef): raise ValueError("Expecting...
[ "def", "recompile", "(", "source", ",", "filename", ",", "mode", ",", "flags", "=", "0", ",", "firstlineno", "=", "1", ",", "privateprefix", "=", "None", ")", ":", "if", "isinstance", "(", "source", ",", "ast", ".", "AST", ")", ":", "a", "=", "sour...
Recompile output of uncompile back to a code object.
[ "Recompile", "output", "of", "uncompile", "back", "to", "a", "code", "object", "." ]
[ "\"\"\"Recompile output of uncompile back to a code object. source may also be preparsed AST.\"\"\"", "# This code object defines the function. Find the function's actual body code:", "# Re-mangle private names:", "# pylint: disable=undefined-loop-variable", "# pylint: disable=undefined-loop-variable", "#...
[ { "param": "source", "type": null }, { "param": "filename", "type": null }, { "param": "mode", "type": null }, { "param": "flags", "type": null }, { "param": "firstlineno", "type": null }, { "param": "privateprefix", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_toke...
76a8045b53f990e3e0106540d246ef073ca375e8
eigenfoo-forks/pymc4
pymc4/ast_compiler.py
[ "Apache-2.0" ]
Python
parse_snippet
<not_specific>
def parse_snippet(source, filename, mode, flags, firstlineno, privateprefix_ignored=None): """Like ast.parse, but accepts indented code snippet with a line number offset.""" args = filename, mode, flags | ast.PyCF_ONLY_AST, True prefix = "\n" try: a = compile(prefix + source, *args) except I...
Like ast.parse, but accepts indented code snippet with a line number offset.
Like ast.parse, but accepts indented code snippet with a line number offset.
[ "Like", "ast", ".", "parse", "but", "accepts", "indented", "code", "snippet", "with", "a", "line", "number", "offset", "." ]
def parse_snippet(source, filename, mode, flags, firstlineno, privateprefix_ignored=None): args = filename, mode, flags | ast.PyCF_ONLY_AST, True prefix = "\n" try: a = compile(prefix + source, *args) except IndentationError: prefix = "with 0:\n" a = compile(prefix + source, *arg...
[ "def", "parse_snippet", "(", "source", ",", "filename", ",", "mode", ",", "flags", ",", "firstlineno", ",", "privateprefix_ignored", "=", "None", ")", ":", "args", "=", "filename", ",", "mode", ",", "flags", "|", "ast", ".", "PyCF_ONLY_AST", ",", "True", ...
Like ast.parse, but accepts indented code snippet with a line number offset.
[ "Like", "ast", ".", "parse", "but", "accepts", "indented", "code", "snippet", "with", "a", "line", "number", "offset", "." ]
[ "\"\"\"Like ast.parse, but accepts indented code snippet with a line number offset.\"\"\"", "# Already indented? Wrap with dummy compound statement", "# peel wrapper" ]
[ { "param": "source", "type": null }, { "param": "filename", "type": null }, { "param": "mode", "type": null }, { "param": "flags", "type": null }, { "param": "firstlineno", "type": null }, { "param": "privateprefix_ignored", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_toke...
34676903f65d22fd2f2277879daecde3db9b16d0
eigenfoo-forks/pymc4
pymc4/flow/transformed_executor.py
[ "Apache-2.0" ]
Python
modify_distribution
<not_specific>
def modify_distribution(self, dist, model_info, state): """Apply transformations to a distribution.""" dist = super().modify_distribution(dist, model_info, state) if not isinstance(dist, distribution.Distribution): return dist scoped_name = scopes.variable_name(dist.name) ...
Apply transformations to a distribution.
Apply transformations to a distribution.
[ "Apply", "transformations", "to", "a", "distribution", "." ]
def modify_distribution(self, dist, model_info, state): dist = super().modify_distribution(dist, model_info, state) if not isinstance(dist, distribution.Distribution): return dist scoped_name = scopes.variable_name(dist.name) if dist.transform is None or dist.model_info.get( ...
[ "def", "modify_distribution", "(", "self", ",", "dist", ",", "model_info", ",", "state", ")", ":", "dist", "=", "super", "(", ")", ".", "modify_distribution", "(", "dist", ",", "model_info", ",", "state", ")", "if", "not", "isinstance", "(", "dist", ",",...
Apply transformations to a distribution.
[ "Apply", "transformations", "to", "a", "distribution", "." ]
[ "\"\"\"Apply transformations to a distribution.\"\"\"", "# do nothing else if no transform is set", "# already autotransformed, do nothing else", "# double underscore stands for transform", "# do not modify a distribution if it is observed", "# same for programmatically observed", "# but not for program...
[ { "param": "self", "type": null }, { "param": "dist", "type": null }, { "param": "model_info", "type": null }, { "param": "state", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dist", "type": null, "docstring": null, "docstring_tokens": [...
e74063a6d040f59ddd947531c788791599f05c5c
eigenfoo-forks/pymc4
pymc4/distributions/distribution.py
[ "Apache-2.0" ]
Python
unpack_conditions
dict
def unpack_conditions(**kwargs) -> dict: """ Parse arguments. This is used to form :attr:`conditions` for a distributions, as one may desire to have different parametrizations, this all should be done there """ return kwargs
Parse arguments. This is used to form :attr:`conditions` for a distributions, as one may desire to have different parametrizations, this all should be done there
Parse arguments. This is used to form :attr:`conditions` for a distributions, as one may desire to have different parametrizations, this all should be done there
[ "Parse", "arguments", ".", "This", "is", "used", "to", "form", ":", "attr", ":", "`", "conditions", "`", "for", "a", "distributions", "as", "one", "may", "desire", "to", "have", "different", "parametrizations", "this", "all", "should", "be", "done", "there...
def unpack_conditions(**kwargs) -> dict: return kwargs
[ "def", "unpack_conditions", "(", "**", "kwargs", ")", "->", "dict", ":", "return", "kwargs" ]
Parse arguments.
[ "Parse", "arguments", "." ]
[ "\"\"\"\n Parse arguments.\n\n This is used to form :attr:`conditions` for a distributions, as\n one may desire to have different parametrizations, this all should be done there\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
e74063a6d040f59ddd947531c788791599f05c5c
eigenfoo-forks/pymc4
pymc4/distributions/distribution.py
[ "Apache-2.0" ]
Python
sample_numpy
<not_specific>
def sample_numpy(self, shape=(), seed=None): """ Forward sampling implementation returning raw numpy arrays. Parameters ---------- shape : tuple sample shape seed : int|None random seed Returns ---------- array of given sha...
Forward sampling implementation returning raw numpy arrays. Parameters ---------- shape : tuple sample shape seed : int|None random seed Returns ---------- array of given shape
Forward sampling implementation returning raw numpy arrays. Parameters shape : tuple sample shape seed : int|None random seed Returns array of given shape
[ "Forward", "sampling", "implementation", "returning", "raw", "numpy", "arrays", ".", "Parameters", "shape", ":", "tuple", "sample", "shape", "seed", ":", "int|None", "random", "seed", "Returns", "array", "of", "given", "shape" ]
def sample_numpy(self, shape=(), seed=None): return self.sample(shape, seed).numpy()
[ "def", "sample_numpy", "(", "self", ",", "shape", "=", "(", ")", ",", "seed", "=", "None", ")", ":", "return", "self", ".", "sample", "(", "shape", ",", "seed", ")", ".", "numpy", "(", ")" ]
Forward sampling implementation returning raw numpy arrays.
[ "Forward", "sampling", "implementation", "returning", "raw", "numpy", "arrays", "." ]
[ "\"\"\"\n Forward sampling implementation returning raw numpy arrays.\n\n Parameters\n ----------\n shape : tuple\n sample shape\n seed : int|None\n random seed\n Returns\n ----------\n array of given shape\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "shape", "type": null }, { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shape", "type": null, "docstring": null, "docstring_tokens": ...
a135ca332c1ac34f37138c1af648f6548343f205
eigenfoo-forks/pymc4
pymc4/flow/executor.py
[ "Apache-2.0" ]
Python
as_sampling_state
"SamplingState"
def as_sampling_state(self) -> "SamplingState": """Create a sampling state that should be used within MCMC sampling. There are some principles that hold for the state. 1. Check there is at least one distribution 2. Check all transformed distributions are autotransformed ...
Create a sampling state that should be used within MCMC sampling. There are some principles that hold for the state. 1. Check there is at least one distribution 2. Check all transformed distributions are autotransformed 3. Remove untransformed values if transformed are pres...
Create a sampling state that should be used within MCMC sampling. There are some principles that hold for the state. 1. Check there is at least one distribution 2. Check all transformed distributions are autotransformed 3. Remove untransformed values if transformed are present 4. Remove all other irrelevant values
[ "Create", "a", "sampling", "state", "that", "should", "be", "used", "within", "MCMC", "sampling", ".", "There", "are", "some", "principles", "that", "hold", "for", "the", "state", ".", "1", ".", "Check", "there", "is", "at", "least", "one", "distribution",...
def as_sampling_state(self) -> "SamplingState": if not self.distributions: raise TypeError( "No distributions found in the state. " "the model you evaluated is empty and does not yield any PyMC4 distribution" ) untransformed_values = dict() ...
[ "def", "as_sampling_state", "(", "self", ")", "->", "\"SamplingState\"", ":", "if", "not", "self", ".", "distributions", ":", "raise", "TypeError", "(", "\"No distributions found in the state. \"", "\"the model you evaluated is empty and does not yield any PyMC4 distribution\"", ...
Create a sampling state that should be used within MCMC sampling.
[ "Create", "a", "sampling", "state", "that", "should", "be", "used", "within", "MCMC", "sampling", "." ]
[ "\"\"\"Create a sampling state that should be used within MCMC sampling.\n\n There are some principles that hold for the state.\n\n 1. Check there is at least one distribution\n 2. Check all transformed distributions are autotransformed\n 3. Remove untransformed values if tra...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bc60e115332a132570dbf472dbc9f9cc6cb9b4c
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/proto/engine_pb2_grpc.py
[ "Apache-2.0" ]
Python
Log
null
def Log(self, request, context): """Log logs a global message in the engine, including errors and warnings. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
Log logs a global message in the engine, including errors and warnings.
Log logs a global message in the engine, including errors and warnings.
[ "Log", "logs", "a", "global", "message", "in", "the", "engine", "including", "errors", "and", "warnings", "." ]
def Log(self, request, context): context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "Log", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplementedError", "(...
Log logs a global message in the engine, including errors and warnings.
[ "Log", "logs", "a", "global", "message", "in", "the", "engine", "including", "errors", "and", "warnings", "." ]
[ "\"\"\"Log logs a global message in the engine, including errors and warnings.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "context", "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"...
3bc60e115332a132570dbf472dbc9f9cc6cb9b4c
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/proto/engine_pb2_grpc.py
[ "Apache-2.0" ]
Python
GetRootResource
null
def GetRootResource(self, request, context): """GetRootResource gets the URN of the root resource, the resource that should be the root of all otherwise-unparented resources. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedEr...
GetRootResource gets the URN of the root resource, the resource that should be the root of all otherwise-unparented resources.
GetRootResource gets the URN of the root resource, the resource that should be the root of all otherwise-unparented resources.
[ "GetRootResource", "gets", "the", "URN", "of", "the", "root", "resource", "the", "resource", "that", "should", "be", "the", "root", "of", "all", "otherwise", "-", "unparented", "resources", "." ]
def GetRootResource(self, request, context): context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "GetRootResource", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplemented...
GetRootResource gets the URN of the root resource, the resource that should be the root of all otherwise-unparented resources.
[ "GetRootResource", "gets", "the", "URN", "of", "the", "root", "resource", "the", "resource", "that", "should", "be", "the", "root", "of", "all", "otherwise", "-", "unparented", "resources", "." ]
[ "\"\"\"GetRootResource gets the URN of the root resource, the resource that should be the root of all\n otherwise-unparented resources.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "context", "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"...
3bc60e115332a132570dbf472dbc9f9cc6cb9b4c
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/proto/engine_pb2_grpc.py
[ "Apache-2.0" ]
Python
SetRootResource
null
def SetRootResource(self, request, context): """SetRootResource sets the URN of the root resource. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
SetRootResource sets the URN of the root resource.
SetRootResource sets the URN of the root resource.
[ "SetRootResource", "sets", "the", "URN", "of", "the", "root", "resource", "." ]
def SetRootResource(self, request, context): context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "SetRootResource", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplemented...
SetRootResource sets the URN of the root resource.
[ "SetRootResource", "sets", "the", "URN", "of", "the", "root", "resource", "." ]
[ "\"\"\"SetRootResource sets the URN of the root resource.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "context", "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"...
44a2646f6400634d413f9422c81c777627aa8579
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/rpc_manager.py
[ "Apache-2.0" ]
Python
do_rpc
Callable[..., Awaitable[Tuple[Any, Exception]]]
def do_rpc(self, name: str, rpc_function: Callable[..., Awaitable[Tuple[Any, Exception]]]) -> Callable[..., Awaitable[Tuple[Any, Exception]]]: """ Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio event loop. The wrapped function catches all unhandle...
Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio event loop. The wrapped function catches all unhandled exceptions and reports them to the exception future, which consumers can await upon to listen for unhandled exceptions. The wrapped fun...
Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio event loop. The wrapped function catches all unhandled exceptions and reports them to the exception future, which consumers can await upon to listen for unhandled exceptions. The wrapped function also keeps track of the num...
[ "Wraps", "a", "given", "RPC", "function", "by", "producing", "an", "awaitable", "function", "suitable", "to", "be", "run", "in", "the", "asyncio", "event", "loop", ".", "The", "wrapped", "function", "catches", "all", "unhandled", "exceptions", "and", "reports"...
def do_rpc(self, name: str, rpc_function: Callable[..., Awaitable[Tuple[Any, Exception]]]) -> Callable[..., Awaitable[Tuple[Any, Exception]]]: async def rpc_wrapper(*args, **kwargs): log.debug(f"beginning rpc {name}") self.count += 1 log.debug(f"recorded new RPC, {self.count}...
[ "def", "do_rpc", "(", "self", ",", "name", ":", "str", ",", "rpc_function", ":", "Callable", "[", "...", ",", "Awaitable", "[", "Tuple", "[", "Any", ",", "Exception", "]", "]", "]", ")", "->", "Callable", "[", "...", ",", "Awaitable", "[", "Tuple", ...
Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio event loop.
[ "Wraps", "a", "given", "RPC", "function", "by", "producing", "an", "awaitable", "function", "suitable", "to", "be", "run", "in", "the", "asyncio", "event", "loop", "." ]
[ "\"\"\"\n Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio\n event loop. The wrapped function catches all unhandled exceptions and reports them to the exception\n future, which consumers can await upon to listen for unhandled exceptions.\n\n ...
[ { "param": "self", "type": null }, { "param": "name", "type": "str" }, { "param": "rpc_function", "type": "Callable[..., Awaitable[Tuple[Any, Exception]]]" } ]
{ "returns": [ { "docstring": "An awaitable function implementing the RPC", "docstring_tokens": [ "An", "awaitable", "function", "implementing", "the", "RPC" ], "type": null } ], "raises": [], "params": [ { "identifier": "...
0964ea11f70418d58d8bc88b08ddc9fdc2d65d01
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/proto/language_pb2_grpc.py
[ "Apache-2.0" ]
Python
GetRequiredPlugins
null
def GetRequiredPlugins(self, request, context): """GetRequiredPlugins computes the complete set of anticipated plugins required by a program. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
GetRequiredPlugins computes the complete set of anticipated plugins required by a program.
GetRequiredPlugins computes the complete set of anticipated plugins required by a program.
[ "GetRequiredPlugins", "computes", "the", "complete", "set", "of", "anticipated", "plugins", "required", "by", "a", "program", "." ]
def GetRequiredPlugins(self, request, context): context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "GetRequiredPlugins", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplemen...
GetRequiredPlugins computes the complete set of anticipated plugins required by a program.
[ "GetRequiredPlugins", "computes", "the", "complete", "set", "of", "anticipated", "plugins", "required", "by", "a", "program", "." ]
[ "\"\"\"GetRequiredPlugins computes the complete set of anticipated plugins required by a program.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "context", "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"...
0964ea11f70418d58d8bc88b08ddc9fdc2d65d01
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/proto/language_pb2_grpc.py
[ "Apache-2.0" ]
Python
GetPluginInfo
null
def GetPluginInfo(self, request, context): """GetPluginInfo returns generic information about this plugin, like its version. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
GetPluginInfo returns generic information about this plugin, like its version.
GetPluginInfo returns generic information about this plugin, like its version.
[ "GetPluginInfo", "returns", "generic", "information", "about", "this", "plugin", "like", "its", "version", "." ]
def GetPluginInfo(self, request, context): context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "GetPluginInfo", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplementedEr...
GetPluginInfo returns generic information about this plugin, like its version.
[ "GetPluginInfo", "returns", "generic", "information", "about", "this", "plugin", "like", "its", "version", "." ]
[ "\"\"\"GetPluginInfo returns generic information about this plugin, like its version.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "context", "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"...
d700a29b730e14a991a1571ec714c2174fe4dad2
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/invoke.py
[ "Apache-2.0" ]
Python
_sync_await
Any
def _sync_await(awaitable: Awaitable[Any]) -> Any: """ _sync_await waits for the given future to complete by effectively yielding the current task and pumping the event loop. """ # Fetch the current event loop and ensure a future. loop = asyncio.get_event_loop() fut = asyncio.ensure_future(...
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event loop.
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event loop.
[ "_sync_await", "waits", "for", "the", "given", "future", "to", "complete", "by", "effectively", "yielding", "the", "current", "task", "and", "pumping", "the", "event", "loop", "." ]
def _sync_await(awaitable: Awaitable[Any]) -> Any: loop = asyncio.get_event_loop() fut = asyncio.ensure_future(awaitable) if not loop.is_running(): return loop.run_until_complete(fut) task = asyncio.Task.current_task(loop) if task is not None: _leave_task(loop, task) In order to...
[ "def", "_sync_await", "(", "awaitable", ":", "Awaitable", "[", "Any", "]", ")", "->", "Any", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "fut", "=", "asyncio", ".", "ensure_future", "(", "awaitable", ")", "if", "not", "loop", ".", "is...
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event loop.
[ "_sync_await", "waits", "for", "the", "given", "future", "to", "complete", "by", "effectively", "yielding", "the", "current", "task", "and", "pumping", "the", "event", "loop", "." ]
[ "\"\"\"\n _sync_await waits for the given future to complete by effectively yielding the current task and pumping the event\n loop.\n \"\"\"", "# Fetch the current event loop and ensure a future.", "# If the loop is not running, we can just use run_until_complete. Without this, we would need to duplica...
[ { "param": "awaitable", "type": "Awaitable[Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "awaitable", "type": "Awaitable[Any]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d700a29b730e14a991a1571ec714c2174fe4dad2
prasannapad/pulumi
sdk/python/lib/pulumi/runtime/invoke.py
[ "Apache-2.0" ]
Python
invoke
InvokeResult
def invoke(tok: str, props: Inputs, opts: InvokeOptions = None) -> InvokeResult: """ invoke dynamically invokes the function, tok, which is offered by a provider plugin. The inputs can be a bag of computed values (Ts or Awaitable[T]s), and the result is a Awaitable[Any] that resolves when the invoke fi...
invoke dynamically invokes the function, tok, which is offered by a provider plugin. The inputs can be a bag of computed values (Ts or Awaitable[T]s), and the result is a Awaitable[Any] that resolves when the invoke finishes.
invoke dynamically invokes the function, tok, which is offered by a provider plugin. The inputs can be a bag of computed values (Ts or Awaitable[T]s), and the result is a Awaitable[Any] that resolves when the invoke finishes.
[ "invoke", "dynamically", "invokes", "the", "function", "tok", "which", "is", "offered", "by", "a", "provider", "plugin", ".", "The", "inputs", "can", "be", "a", "bag", "of", "computed", "values", "(", "Ts", "or", "Awaitable", "[", "T", "]", "s", ")", "...
def invoke(tok: str, props: Inputs, opts: InvokeOptions = None) -> InvokeResult: log.debug(f"Invoking function: tok={tok}") if opts is None: opts = InvokeOptions() async def do_invoke(): if opts.parent is not None and opts.provider is None: opts.provider = opts.parent.get_provide...
[ "def", "invoke", "(", "tok", ":", "str", ",", "props", ":", "Inputs", ",", "opts", ":", "InvokeOptions", "=", "None", ")", "->", "InvokeResult", ":", "log", ".", "debug", "(", "f\"Invoking function: tok={tok}\"", ")", "if", "opts", "is", "None", ":", "op...
invoke dynamically invokes the function, tok, which is offered by a provider plugin.
[ "invoke", "dynamically", "invokes", "the", "function", "tok", "which", "is", "offered", "by", "a", "provider", "plugin", "." ]
[ "\"\"\"\n invoke dynamically invokes the function, tok, which is offered by a provider plugin. The inputs\n can be a bag of computed values (Ts or Awaitable[T]s), and the result is a Awaitable[Any] that\n resolves when the invoke finishes.\n \"\"\"", "# If a parent was provided, but no provider was p...
[ { "param": "tok", "type": "str" }, { "param": "props", "type": "Inputs" }, { "param": "opts", "type": "InvokeOptions" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tok", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "props", "type": "Inputs", "docstring": null, "docstring_token...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
__create_graph
<not_specific>
def __create_graph(self, data_path: str): ''' Function to create the graph using NetworkX. Args: data_path: The path to the json file with the graph data Returns: A NetworkX graph object ''' with open(data_path) as data_file: data = jso...
Function to create the graph using NetworkX. Args: data_path: The path to the json file with the graph data Returns: A NetworkX graph object
Function to create the graph using NetworkX.
[ "Function", "to", "create", "the", "graph", "using", "NetworkX", "." ]
def __create_graph(self, data_path: str): with open(data_path) as data_file: data = json.load(data_file) graph = nx.Graph() for entry in tqdm.tqdm(data, desc="Creating graph..."): conference = { "id_str":entry["id_conference"], "id_int":ent...
[ "def", "__create_graph", "(", "self", ",", "data_path", ":", "str", ")", ":", "with", "open", "(", "data_path", ")", "as", "data_file", ":", "data", "=", "json", ".", "load", "(", "data_file", ")", "graph", "=", "nx", ".", "Graph", "(", ")", "for", ...
Function to create the graph using NetworkX.
[ "Function", "to", "create", "the", "graph", "using", "NetworkX", "." ]
[ "'''\n Function to create the graph using NetworkX.\n Args:\n data_path: The path to the json file with the graph data\n Returns:\n A NetworkX graph object\n '''" ]
[ { "param": "self", "type": null }, { "param": "data_path", "type": "str" } ]
{ "returns": [ { "docstring": "A NetworkX graph object", "docstring_tokens": [ "A", "NetworkX", "graph", "object" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "d...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
__add_weights
<not_specific>
def __add_weights(self, graph): ''' Function to add weights to the graph object. The weights are added as 1 - jaccard similarity between two connected nodes ''' edges_ids = graph.edges() for node_id1, node_id2 in tqdm.tqdm(edges_ids, desc="Adding weights..."): ...
Function to add weights to the graph object. The weights are added as 1 - jaccard similarity between two connected nodes
Function to add weights to the graph object. The weights are added as 1 - jaccard similarity between two connected nodes
[ "Function", "to", "add", "weights", "to", "the", "graph", "object", ".", "The", "weights", "are", "added", "as", "1", "-", "jaccard", "similarity", "between", "two", "connected", "nodes" ]
def __add_weights(self, graph): edges_ids = graph.edges() for node_id1, node_id2 in tqdm.tqdm(edges_ids, desc="Adding weights..."): node1 = graph.node[node_id1]["data"] node2 = graph.node[node_id2]["data"] weight = self.__weight(node1, node2) graph[node_id...
[ "def", "__add_weights", "(", "self", ",", "graph", ")", ":", "edges_ids", "=", "graph", ".", "edges", "(", ")", "for", "node_id1", ",", "node_id2", "in", "tqdm", ".", "tqdm", "(", "edges_ids", ",", "desc", "=", "\"Adding weights...\"", ")", ":", "node1",...
Function to add weights to the graph object.
[ "Function", "to", "add", "weights", "to", "the", "graph", "object", "." ]
[ "'''\n Function to add weights to the graph object.\n The weights are added as 1 - jaccard similarity between two connected nodes\n '''" ]
[ { "param": "self", "type": null }, { "param": "graph", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "graph", "type": null, "docstring": null, "docstring_tokens": ...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
__weight
<not_specific>
def __weight(self, node1, node2): ''' Calculates 1 - jaccard similarity between two nodes. The jaccard similarity is calculated as the number of publications in common divided by the number of total publications between two authors. Args node1: A node from a NetworkX ...
Calculates 1 - jaccard similarity between two nodes. The jaccard similarity is calculated as the number of publications in common divided by the number of total publications between two authors. Args node1: A node from a NetworkX graph node2: A node from a Networ...
Calculates 1 - jaccard similarity between two nodes. The jaccard similarity is calculated as the number of publications in common divided by the number of total publications between two authors. Args node1: A node from a NetworkX graph node2: A node from a NetworkX graph
[ "Calculates", "1", "-", "jaccard", "similarity", "between", "two", "nodes", ".", "The", "jaccard", "similarity", "is", "calculated", "as", "the", "number", "of", "publications", "in", "common", "divided", "by", "the", "number", "of", "total", "publications", "...
def __weight(self, node1, node2): pubs1 = set(node1['publications'].keys()) pubs2 = set(node2['publications'].keys()) weight = 1 - (len(pubs1.intersection(pubs2))/len(pubs1.union(pubs2))) return weight
[ "def", "__weight", "(", "self", ",", "node1", ",", "node2", ")", ":", "pubs1", "=", "set", "(", "node1", "[", "'publications'", "]", ".", "keys", "(", ")", ")", "pubs2", "=", "set", "(", "node2", "[", "'publications'", "]", ".", "keys", "(", ")", ...
Calculates 1 - jaccard similarity between two nodes.
[ "Calculates", "1", "-", "jaccard", "similarity", "between", "two", "nodes", "." ]
[ "'''\n Calculates 1 - jaccard similarity between two nodes.\n The jaccard similarity is calculated as the number of publications in common\n divided by the number of total publications between two authors.\n Args\n node1: A node from a NetworkX graph\n node2: A node...
[ { "param": "self", "type": null }, { "param": "node1", "type": null }, { "param": "node2", "type": null } ]
{ "returns": [ { "docstring": "jaccard similarity between node1 and node2", "docstring_tokens": [ "jaccard", "similarity", "between", "node1", "and", "node2" ], "type": null } ], "raises": [], "params": [ { "identifier": "...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
aris_distance
<not_specific>
def aris_distance(self, author_id: int): ''' Gets the shortest distance between author_id and Aris Args: author_id: The integer id of an author Returns: A path as a tuple where element 0 is the author id, element 1 is the distance between the author a...
Gets the shortest distance between author_id and Aris Args: author_id: The integer id of an author Returns: A path as a tuple where element 0 is the author id, element 1 is the distance between the author and aris and element 2 is the authors nam...
Gets the shortest distance between author_id and Aris
[ "Gets", "the", "shortest", "distance", "between", "author_id", "and", "Aris" ]
def aris_distance(self, author_id: int): aris_node = None for node in self.graph.nodes(): author_name = self.graph.node[node]['data']['author']['name'] if author_name.lower() == 'aris anagnostopoulos': aris_node = node break if aris_node is...
[ "def", "aris_distance", "(", "self", ",", "author_id", ":", "int", ")", ":", "aris_node", "=", "None", "for", "node", "in", "self", ".", "graph", ".", "nodes", "(", ")", ":", "author_name", "=", "self", ".", "graph", ".", "node", "[", "node", "]", ...
Gets the shortest distance between author_id and Aris
[ "Gets", "the", "shortest", "distance", "between", "author_id", "and", "Aris" ]
[ "'''\n Gets the shortest distance between author_id and Aris\n Args:\n author_id: The integer id of an author\n Returns:\n A path as a tuple where element 0 is the author id, \n element 1 is the distance between the author and aris\n and element 2 is ...
[ { "param": "self", "type": null }, { "param": "author_id", "type": "int" } ]
{ "returns": [ { "docstring": "A path as a tuple where element 0 is the author id,\nelement 1 is the distance between the author and aris\nand element 2 is the authors name.\nIf author_id does not exist on graph it returns None", "docstring_tokens": [ "A", "path", "as", ...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
__save_graph
null
def __save_graph(self, reduced: bool = False): ''' Saves the graph object locally for later reuse Args: reduced: If the graph being save is the reduced one or not ''' filename = RED_GRAPH if reduced else GRAPH with open(filename, 'wb') as output: p...
Saves the graph object locally for later reuse Args: reduced: If the graph being save is the reduced one or not
Saves the graph object locally for later reuse
[ "Saves", "the", "graph", "object", "locally", "for", "later", "reuse" ]
def __save_graph(self, reduced: bool = False): filename = RED_GRAPH if reduced else GRAPH with open(filename, 'wb') as output: pickle.dump(self.graph, output, pickle.HIGHEST_PROTOCOL)
[ "def", "__save_graph", "(", "self", ",", "reduced", ":", "bool", "=", "False", ")", ":", "filename", "=", "RED_GRAPH", "if", "reduced", "else", "GRAPH", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "output", ":", "pickle", ".", "dump", "(",...
Saves the graph object locally for later reuse
[ "Saves", "the", "graph", "object", "locally", "for", "later", "reuse" ]
[ "'''\n Saves the graph object locally for later reuse\n Args:\n reduced: If the graph being save is the reduced one or not\n '''" ]
[ { "param": "self", "type": null }, { "param": "reduced", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reduced", "type": "bool", "docstring": "If the graph being save is ...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
__load_graph
<not_specific>
def __load_graph(self, reduced: bool = False): ''' Loads the graph object from local folder Args: reduced: If the graph being loaded is the reduced one or not Return: The graph object ''' filename = RED_GRAPH if reduced else GRAPH with open...
Loads the graph object from local folder Args: reduced: If the graph being loaded is the reduced one or not Return: The graph object
Loads the graph object from local folder
[ "Loads", "the", "graph", "object", "from", "local", "folder" ]
def __load_graph(self, reduced: bool = False): filename = RED_GRAPH if reduced else GRAPH with open(filename, 'rb') as input_graph: return pickle.load(input_graph)
[ "def", "__load_graph", "(", "self", ",", "reduced", ":", "bool", "=", "False", ")", ":", "filename", "=", "RED_GRAPH", "if", "reduced", "else", "GRAPH", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "input_graph", ":", "return", "pickle", ".",...
Loads the graph object from local folder
[ "Loads", "the", "graph", "object", "from", "local", "folder" ]
[ "'''\n Loads the graph object from local folder\n Args:\n reduced: If the graph being loaded is the reduced one or not\n Return:\n The graph object\n '''" ]
[ { "param": "self", "type": null }, { "param": "reduced", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reduced", "type": "bool", "docstring": "If the graph being loaded i...
895d8ed8486724e1e2264d46ee28924a9497778f
pedromb/ADM-HW4
src/graph.py
[ "MIT" ]
Python
__check_node
<not_specific>
def __check_node(self, node: int): ''' Check if node exists on graph. Args: node: id of the node to be checked Return: True if node exists on graph, false otherwise ''' try: self.graph.node[node] return True except K...
Check if node exists on graph. Args: node: id of the node to be checked Return: True if node exists on graph, false otherwise
Check if node exists on graph.
[ "Check", "if", "node", "exists", "on", "graph", "." ]
def __check_node(self, node: int): try: self.graph.node[node] return True except KeyError: print("Author id {} does not exist on graph".format(str(node))) return False
[ "def", "__check_node", "(", "self", ",", "node", ":", "int", ")", ":", "try", ":", "self", ".", "graph", ".", "node", "[", "node", "]", "return", "True", "except", "KeyError", ":", "print", "(", "\"Author id {} does not exist on graph\"", ".", "format", "(...
Check if node exists on graph.
[ "Check", "if", "node", "exists", "on", "graph", "." ]
[ "'''\n Check if node exists on graph.\n Args:\n node: id of the node to be checked\n Return:\n True if node exists on graph, false otherwise\n '''" ]
[ { "param": "self", "type": null }, { "param": "node", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node", "type": "int", "docstring": "id of the node to be checked", ...
502b20ab39933a99fb4dd4231598e57a1d103412
pedromb/ADM-HW4
homework.py
[ "MIT" ]
Python
viz_subgraph_author
null
def viz_subgraph_author(author_id: int, max_hop_dist: int, reduced: bool = False): ''' Visualize the subgraph induced by nodes that have hop distance at most equal to max_hop_dist with author_id Args: author_id: The integer id of an author max_hop_dist: the maximum hop distance to create...
Visualize the subgraph induced by nodes that have hop distance at most equal to max_hop_dist with author_id Args: author_id: The integer id of an author max_hop_dist: the maximum hop distance to create the subgraph reduced: If reduced equals true it will use the reduced data ...
Visualize the subgraph induced by nodes that have hop distance at most equal to max_hop_dist with author_id
[ "Visualize", "the", "subgraph", "induced", "by", "nodes", "that", "have", "hop", "distance", "at", "most", "equal", "to", "max_hop_dist", "with", "author_id" ]
def viz_subgraph_author(author_id: int, max_hop_dist: int, reduced: bool = False): graph = Graph(reduced) subgraph, node_list = graph.get_subgraph_author(author_id, max_hop_dist) author_component = nx.node_connected_component(graph.graph, author_id) per = round((len(subgraph.nodes())/len(author_componen...
[ "def", "viz_subgraph_author", "(", "author_id", ":", "int", ",", "max_hop_dist", ":", "int", ",", "reduced", ":", "bool", "=", "False", ")", ":", "graph", "=", "Graph", "(", "reduced", ")", "subgraph", ",", "node_list", "=", "graph", ".", "get_subgraph_aut...
Visualize the subgraph induced by nodes that have hop distance at most equal to max_hop_dist with author_id
[ "Visualize", "the", "subgraph", "induced", "by", "nodes", "that", "have", "hop", "distance", "at", "most", "equal", "to", "max_hop_dist", "with", "author_id" ]
[ "'''\n Visualize the subgraph induced by nodes that have hop distance at most\n equal to max_hop_dist with author_id\n Args:\n author_id: The integer id of an author\n max_hop_dist: the maximum hop distance to create the subgraph\n reduced: If reduced equals true it will use the reduce...
[ { "param": "author_id", "type": "int" }, { "param": "max_hop_dist", "type": "int" }, { "param": "reduced", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "author_id", "type": "int", "docstring": "The integer id of an author", "docstring_tokens": [ "The", "integer", "id", "of", "an", "author" ], "default": null, "i...
502b20ab39933a99fb4dd4231598e57a1d103412
pedromb/ADM-HW4
homework.py
[ "MIT" ]
Python
aris_distance
null
def aris_distance(author_id: int, reduced: bool = False): ''' Gets the shortest distance between author_id and Aris Args: author_id: The integer id of an author reduced: If reduced equals true it will use the reduced data to create the graph, otherwise it will use the full data ...
Gets the shortest distance between author_id and Aris Args: author_id: The integer id of an author reduced: If reduced equals true it will use the reduced data to create the graph, otherwise it will use the full data
Gets the shortest distance between author_id and Aris
[ "Gets", "the", "shortest", "distance", "between", "author_id", "and", "Aris" ]
def aris_distance(author_id: int, reduced: bool = False): graph = Graph(reduced) author_name = graph.get_author_name(author_id) print("Getting shortest path weight between {} and Aris\n".format(author_name)) path = graph.aris_distance(author_id) edge_labels = [] if path is not None: aris...
[ "def", "aris_distance", "(", "author_id", ":", "int", ",", "reduced", ":", "bool", "=", "False", ")", ":", "graph", "=", "Graph", "(", "reduced", ")", "author_name", "=", "graph", ".", "get_author_name", "(", "author_id", ")", "print", "(", "\"Getting shor...
Gets the shortest distance between author_id and Aris
[ "Gets", "the", "shortest", "distance", "between", "author_id", "and", "Aris" ]
[ "'''\n Gets the shortest distance between author_id and Aris\n Args:\n author_id: The integer id of an author\n reduced: If reduced equals true it will use the reduced data\n to create the graph, otherwise it will use the full data\n '''" ]
[ { "param": "author_id", "type": "int" }, { "param": "reduced", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "author_id", "type": "int", "docstring": "The integer id of an author", "docstring_tokens": [ "The", "integer", "id", "of", "an", "author" ], "default": null, "i...
502b20ab39933a99fb4dd4231598e57a1d103412
pedromb/ADM-HW4
homework.py
[ "MIT" ]
Python
group_numbers
null
def group_numbers(nodes_list: list, reduced: bool = False): ''' Sets the group numbers for the nodes on the graph and saves locally as a json file. The group number is the min shortest path between the node and the nodes on nodes_list. Args: nodes_list: an integer list with nodes id ...
Sets the group numbers for the nodes on the graph and saves locally as a json file. The group number is the min shortest path between the node and the nodes on nodes_list. Args: nodes_list: an integer list with nodes id reduced: If reduced equals true it will use the reduced data ...
Sets the group numbers for the nodes on the graph and saves locally as a json file. The group number is the min shortest path between the node and the nodes on nodes_list.
[ "Sets", "the", "group", "numbers", "for", "the", "nodes", "on", "the", "graph", "and", "saves", "locally", "as", "a", "json", "file", ".", "The", "group", "number", "is", "the", "min", "shortest", "path", "between", "the", "node", "and", "the", "nodes", ...
def group_numbers(nodes_list: list, reduced: bool = False): graph = Graph(reduced) graph.set_group_number(nodes_list) with open("group_numbers.json", 'w') as jfile: json.dump(graph.group_numbers, jfile) print("group_numbers.json available under current directory\n")
[ "def", "group_numbers", "(", "nodes_list", ":", "list", ",", "reduced", ":", "bool", "=", "False", ")", ":", "graph", "=", "Graph", "(", "reduced", ")", "graph", ".", "set_group_number", "(", "nodes_list", ")", "with", "open", "(", "\"group_numbers.json\"", ...
Sets the group numbers for the nodes on the graph and saves locally as a json file.
[ "Sets", "the", "group", "numbers", "for", "the", "nodes", "on", "the", "graph", "and", "saves", "locally", "as", "a", "json", "file", "." ]
[ "'''\n Sets the group numbers for the nodes on the graph and saves locally as\n a json file.\n The group number is the min shortest path between the node and the nodes\n on nodes_list.\n Args:\n nodes_list: an integer list with nodes id\n reduced: If reduced equals true it will use the ...
[ { "param": "nodes_list", "type": "list" }, { "param": "reduced", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nodes_list", "type": "list", "docstring": "an integer list with nodes id", "docstring_tokens": [ "an", "integer", "list", "with", "nodes", "id" ], "default": null, ...
502b20ab39933a99fb4dd4231598e57a1d103412
pedromb/ADM-HW4
homework.py
[ "MIT" ]
Python
main
null
def main(argv): ''' Main entry point to call modules/functions to solve the exercises ''' exercise = '' letter = '' reduced = False try: opts, _ = getopt.getopt(argv, "he:l:r:", ["exercise=", "letter=", "reduced="]) except getopt.GetoptError: ...
Main entry point to call modules/functions to solve the exercises
Main entry point to call modules/functions to solve the exercises
[ "Main", "entry", "point", "to", "call", "modules", "/", "functions", "to", "solve", "the", "exercises" ]
def main(argv): exercise = '' letter = '' reduced = False try: opts, _ = getopt.getopt(argv, "he:l:r:", ["exercise=", "letter=", "reduced="]) except getopt.GetoptError: print('homework.py -e <exercise> -l <letter> -r <reduced>') sys.exit(2) ...
[ "def", "main", "(", "argv", ")", ":", "exercise", "=", "''", "letter", "=", "''", "reduced", "=", "False", "try", ":", "opts", ",", "_", "=", "getopt", ".", "getopt", "(", "argv", ",", "\"he:l:r:\"", ",", "[", "\"exercise=\"", ",", "\"letter=\"", ","...
Main entry point to call modules/functions to solve the exercises
[ "Main", "entry", "point", "to", "call", "modules", "/", "functions", "to", "solve", "the", "exercises" ]
[ "'''\n Main entry point to call modules/functions to solve the exercises\n '''" ]
[ { "param": "argv", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argv", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d32d75532f268428858d15dc64368c41914a284d
vincedgy/fastapi-async-with-postgresql
src/main.py
[ "MIT" ]
Python
create_note
<not_specific>
async def create_note(note: NoteIn): """Create a note into the database and send back the created record's id""" logger.info(f"Creating Note {note}") query = notes.insert(values={"text": note.text, "completed": note.completed}) last_record_id = await database.execute(query=query) return {**note.dict...
Create a note into the database and send back the created record's id
Create a note into the database and send back the created record's id
[ "Create", "a", "note", "into", "the", "database", "and", "send", "back", "the", "created", "record", "'", "s", "id" ]
async def create_note(note: NoteIn): logger.info(f"Creating Note {note}") query = notes.insert(values={"text": note.text, "completed": note.completed}) last_record_id = await database.execute(query=query) return {**note.dict(), "id": last_record_id}
[ "async", "def", "create_note", "(", "note", ":", "NoteIn", ")", ":", "logger", ".", "info", "(", "f\"Creating Note {note}\"", ")", "query", "=", "notes", ".", "insert", "(", "values", "=", "{", "\"text\"", ":", "note", ".", "text", ",", "\"completed\"", ...
Create a note into the database and send back the created record's id
[ "Create", "a", "note", "into", "the", "database", "and", "send", "back", "the", "created", "record", "'", "s", "id" ]
[ "\"\"\"Create a note into the database and send back the created record's id\"\"\"" ]
[ { "param": "note", "type": "NoteIn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "note", "type": "NoteIn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d32d75532f268428858d15dc64368c41914a284d
vincedgy/fastapi-async-with-postgresql
src/main.py
[ "MIT" ]
Python
update_note
<not_specific>
async def update_note(note_id: int, payload: NoteIn): """Update one note given its id""" query = notes.select().where(notes.c.id == note_id) row = await database.fetch_one(query=query) if row is None: logger.info("No record !") raise HTTPException( status_code=404, ...
Update one note given its id
Update one note given its id
[ "Update", "one", "note", "given", "its", "id" ]
async def update_note(note_id: int, payload: NoteIn): query = notes.select().where(notes.c.id == note_id) row = await database.fetch_one(query=query) if row is None: logger.info("No record !") raise HTTPException( status_code=404, detail="Item not found", ...
[ "async", "def", "update_note", "(", "note_id", ":", "int", ",", "payload", ":", "NoteIn", ")", ":", "query", "=", "notes", ".", "select", "(", ")", ".", "where", "(", "notes", ".", "c", ".", "id", "==", "note_id", ")", "row", "=", "await", "databas...
Update one note given its id
[ "Update", "one", "note", "given", "its", "id" ]
[ "\"\"\"Update one note given its id\"\"\"" ]
[ { "param": "note_id", "type": "int" }, { "param": "payload", "type": "NoteIn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "note_id", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "payload", "type": "NoteIn", "docstring": null, "docstring...
d32d75532f268428858d15dc64368c41914a284d
vincedgy/fastapi-async-with-postgresql
src/main.py
[ "MIT" ]
Python
delete_note
<not_specific>
async def delete_note(note_id: int): """Delete one note given its id""" query = notes.delete().where(notes.c.id == note_id) await database.execute(query=query) return {"message": f"Note with id {note_id} has been deleted."}
Delete one note given its id
Delete one note given its id
[ "Delete", "one", "note", "given", "its", "id" ]
async def delete_note(note_id: int): query = notes.delete().where(notes.c.id == note_id) await database.execute(query=query) return {"message": f"Note with id {note_id} has been deleted."}
[ "async", "def", "delete_note", "(", "note_id", ":", "int", ")", ":", "query", "=", "notes", ".", "delete", "(", ")", ".", "where", "(", "notes", ".", "c", ".", "id", "==", "note_id", ")", "await", "database", ".", "execute", "(", "query", "=", "que...
Delete one note given its id
[ "Delete", "one", "note", "given", "its", "id" ]
[ "\"\"\"Delete one note given its id\"\"\"" ]
[ { "param": "note_id", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "note_id", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46866e03f1dbb425885bd72e6747d12882405dea
TargetProcess/duro
tests/conftest.py
[ "MIT" ]
Python
similar_query
bool
def similar_query(first_query: str, second_query: str, *args) -> bool: """ True if all strings are the same after we remove all spaces, tabs, and newlines. """ queries = (first_query, second_query, *args) if all(q is None for q in queries): return True single_lines = [re.sub("[ \t\n...
True if all strings are the same after we remove all spaces, tabs, and newlines.
True if all strings are the same after we remove all spaces, tabs, and newlines.
[ "True", "if", "all", "strings", "are", "the", "same", "after", "we", "remove", "all", "spaces", "tabs", "and", "newlines", "." ]
def similar_query(first_query: str, second_query: str, *args) -> bool: queries = (first_query, second_query, *args) if all(q is None for q in queries): return True single_lines = [re.sub("[ \t\n]", "", query) for query in queries] return all(query == single_lines[0] for query in single_lines[1:]...
[ "def", "similar_query", "(", "first_query", ":", "str", ",", "second_query", ":", "str", ",", "*", "args", ")", "->", "bool", ":", "queries", "=", "(", "first_query", ",", "second_query", ",", "*", "args", ")", "if", "all", "(", "q", "is", "None", "f...
True if all strings are the same after we remove all spaces, tabs, and newlines.
[ "True", "if", "all", "strings", "are", "the", "same", "after", "we", "remove", "all", "spaces", "tabs", "and", "newlines", "." ]
[ "\"\"\"\n True if all strings are the same after we remove all spaces,\n tabs, and newlines.\n \"\"\"" ]
[ { "param": "first_query", "type": "str" }, { "param": "second_query", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "first_query", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "second_query", "type": "str", "docstring": null, "doc...
53cfdf597f143b50eb51e4c36fac908e603eb9f2
UWaterloo-ASL/ML_lite
Environment/LASROMEnv.py
[ "MIT" ]
Python
step
<not_specific>
def step(self, action): """ Take one step of interaction. Parameters ---------- action: x,y,z,radius,threshold,intensity range: x [-7.5 7.5] y [-5, 5] z [0 2] radius = [0 2] threshold = [0,5] intensity = [0,1] R...
Take one step of interaction. Parameters ---------- action: x,y,z,radius,threshold,intensity range: x [-7.5 7.5] y [-5, 5] z [0 2] radius = [0 2] threshold = [0,5] intensity = [0,1] Returns ------- obse...
Take one step of interaction. Parameters Returns ndarray obervation of environment after taking an action reward: float reward after taking an action done: bool whether simulation is done or not. info: some information for debugging
[ "Take", "one", "step", "of", "interaction", ".", "Parameters", "Returns", "ndarray", "obervation", "of", "environment", "after", "taking", "an", "action", "reward", ":", "float", "reward", "after", "taking", "an", "action", "done", ":", "bool", "whether", "sim...
def step(self, action): x = action[0]*7.5 y = action[1]*5.0 z = action[2] + 1.0 radius = action[3] + 1.0 threshold = action[4]*2.5 + 2.5 intensity = action[5]*0.5 + 0.5 self.behaviour.act([x,y,z,radius,threshold,max(intensity,radius)]) self._move_to_excit...
[ "def", "step", "(", "self", ",", "action", ")", ":", "x", "=", "action", "[", "0", "]", "*", "7.5", "y", "=", "action", "[", "1", "]", "*", "5.0", "z", "=", "action", "[", "2", "]", "+", "1.0", "radius", "=", "action", "[", "3", "]", "+", ...
Take one step of interaction.
[ "Take", "one", "step", "of", "interaction", "." ]
[ "\"\"\"\n Take one step of interaction.\n\n Parameters\n ----------\n action: x,y,z,radius,threshold,intensity\n range:\n x [-7.5 7.5]\n y [-5, 5]\n z [0 2]\n radius = [0 2]\n threshold = [0,5]\n intensity = [0,1]\n\n Returns\n ...
[ { "param": "self", "type": null }, { "param": "action", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "action", "type": null, "docstring": null, "docstring_tokens":...
53cfdf597f143b50eb51e4c36fac908e603eb9f2
UWaterloo-ASL/ML_lite
Environment/LASROMEnv.py
[ "MIT" ]
Python
_reward
<not_specific>
def _reward(self, observation): """ Calculate reward based on observation of proximity sensor. All sensors have accumulated time rewards. The longer it has been triggered, the greater the reward will be. The reward function also uses memories of actions. For sensors with zero ac...
Calculate reward based on observation of proximity sensor. All sensors have accumulated time rewards. The longer it has been triggered, the greater the reward will be. The reward function also uses memories of actions. For sensors with zero accumulated rewards, if it detects a new trig...
Calculate reward based on observation of proximity sensor. All sensors have accumulated time rewards. The longer it has been triggered, the greater the reward will be. The reward function also uses memories of actions. For sensors with zero accumulated rewards, if it detects a new trigger but an action belonging to its...
[ "Calculate", "reward", "based", "on", "observation", "of", "proximity", "sensor", ".", "All", "sensors", "have", "accumulated", "time", "rewards", ".", "The", "longer", "it", "has", "been", "triggered", "the", "greater", "the", "reward", "will", "be", ".", "...
def _reward(self, observation): individual_action_summary = np.array([0]*self.lights_num) if len(self.action_history) > 0: for step_action in self.action_history: individual_action_summary = individual_action_summary | step_action group_action_summary = np.array([0]*s...
[ "def", "_reward", "(", "self", ",", "observation", ")", ":", "individual_action_summary", "=", "np", ".", "array", "(", "[", "0", "]", "*", "self", ".", "lights_num", ")", "if", "len", "(", "self", ".", "action_history", ")", ">", "0", ":", "for", "s...
Calculate reward based on observation of proximity sensor.
[ "Calculate", "reward", "based", "on", "observation", "of", "proximity", "sensor", "." ]
[ "\"\"\"\n Calculate reward based on observation of proximity sensor.\n\n All sensors have accumulated time rewards. The longer it has been triggered, the greater\n the reward will be. The reward function also uses memories of actions. For sensors with\n zero accumulated rewards, if it de...
[ { "param": "self", "type": null }, { "param": "observation", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "observation", "type": null, "docstring": null, "docstring_tok...
53cfdf597f143b50eb51e4c36fac908e603eb9f2
UWaterloo-ASL/ML_lite
Environment/LASROMEnv.py
[ "MIT" ]
Python
_reward_ir
<not_specific>
def _reward_ir(self, observation): """ Reward function based on proximity sensor reading """ length = self.prox_sensor_num reward = 0 for i in range(length): reward += observation[i] return reward
Reward function based on proximity sensor reading
Reward function based on proximity sensor reading
[ "Reward", "function", "based", "on", "proximity", "sensor", "reading" ]
def _reward_ir(self, observation): length = self.prox_sensor_num reward = 0 for i in range(length): reward += observation[i] return reward
[ "def", "_reward_ir", "(", "self", ",", "observation", ")", ":", "length", "=", "self", ".", "prox_sensor_num", "reward", "=", "0", "for", "i", "in", "range", "(", "length", ")", ":", "reward", "+=", "observation", "[", "i", "]", "return", "reward" ]
Reward function based on proximity sensor reading
[ "Reward", "function", "based", "on", "proximity", "sensor", "reading" ]
[ "\"\"\"\n Reward function based on proximity sensor reading\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "observation", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "observation", "type": null, "docstring": null, "docstring_tok...
53cfdf597f143b50eb51e4c36fac908e603eb9f2
UWaterloo-ASL/ML_lite
Environment/LASROMEnv.py
[ "MIT" ]
Python
_reward_actuator_intensity
<not_specific>
def _reward_actuator_intensity(self, observation): """ This reward function is used in non-interactive model and only for testing and tuning hyper-parameters of LASAgent. The reward is sum of the intensity of light. Maybe we will add intensity of SMA into calculating the rewards later. ...
This reward function is used in non-interactive model and only for testing and tuning hyper-parameters of LASAgent. The reward is sum of the intensity of light. Maybe we will add intensity of SMA into calculating the rewards later.
This reward function is used in non-interactive model and only for testing and tuning hyper-parameters of LASAgent. The reward is sum of the intensity of light. Maybe we will add intensity of SMA into calculating the rewards later.
[ "This", "reward", "function", "is", "used", "in", "non", "-", "interactive", "model", "and", "only", "for", "testing", "and", "tuning", "hyper", "-", "parameters", "of", "LASAgent", ".", "The", "reward", "is", "sum", "of", "the", "intensity", "of", "light"...
def _reward_actuator_intensity(self, observation): reward = 0.0 light_color_start_index = self.prox_sensor_num red_light_index = [] for i in range(self.lights_num): R = observation[light_color_start_index + i * 3] G = observation[light_color_start_index + i * 3 + ...
[ "def", "_reward_actuator_intensity", "(", "self", ",", "observation", ")", ":", "reward", "=", "0.0", "light_color_start_index", "=", "self", ".", "prox_sensor_num", "red_light_index", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "lights_num", "...
This reward function is used in non-interactive model and only for testing and tuning hyper-parameters of LASAgent.
[ "This", "reward", "function", "is", "used", "in", "non", "-", "interactive", "model", "and", "only", "for", "testing", "and", "tuning", "hyper", "-", "parameters", "of", "LASAgent", "." ]
[ "\"\"\"\n This reward function is used in non-interactive model and only for testing and tuning hyper-parameters of LASAgent.\n The reward is sum of the intensity of light.\n Maybe we will add intensity of SMA into calculating the rewards later.\n\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "observation", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "observation", "type": null, "docstring": null, "docstring_tok...
53cfdf597f143b50eb51e4c36fac908e603eb9f2
UWaterloo-ASL/ML_lite
Environment/LASROMEnv.py
[ "MIT" ]
Python
_move_to_excitor_location
null
def _move_to_excitor_location(self, observation): """ find lights with maximum intensities and move the visitors to that location """ light_color_start_index = self.prox_sensor_num light_intensity = np.zeros(self.lights_num) for i in range(self.lights_num): ...
find lights with maximum intensities and move the visitors to that location
find lights with maximum intensities and move the visitors to that location
[ "find", "lights", "with", "maximum", "intensities", "and", "move", "the", "visitors", "to", "that", "location" ]
def _move_to_excitor_location(self, observation): light_color_start_index = self.prox_sensor_num light_intensity = np.zeros(self.lights_num) for i in range(self.lights_num): light_intensity[i] = observation[light_color_start_index + i * 3] light_inten_order = np.argsort(light...
[ "def", "_move_to_excitor_location", "(", "self", ",", "observation", ")", ":", "light_color_start_index", "=", "self", ".", "prox_sensor_num", "light_intensity", "=", "np", ".", "zeros", "(", "self", ".", "lights_num", ")", "for", "i", "in", "range", "(", "sel...
find lights with maximum intensities and move the visitors to that location
[ "find", "lights", "with", "maximum", "intensities", "and", "move", "the", "visitors", "to", "that", "location" ]
[ "\"\"\"\n find lights with maximum intensities and move the visitors to that location\n\n \"\"\"", "# sort intensity by ascending order", "# Put the rest of the visitors at origin" ]
[ { "param": "self", "type": null }, { "param": "observation", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "observation", "type": null, "docstring": null, "docstring_tok...
53cfdf597f143b50eb51e4c36fac908e603eb9f2
UWaterloo-ASL/ML_lite
Environment/LASROMEnv.py
[ "MIT" ]
Python
_move_single_to_excitor_location
null
def _move_single_to_excitor_location(self, observation, isBody=True): """ find the light with maximum intensity and move Visitor#1 to that location Testing target movement """ light_color_start_index = self.prox_sensor_num target_light_index = -1 max_intensity =...
find the light with maximum intensity and move Visitor#1 to that location Testing target movement
find the light with maximum intensity and move Visitor#1 to that location Testing target movement
[ "find", "the", "light", "with", "maximum", "intensity", "and", "move", "Visitor#1", "to", "that", "location", "Testing", "target", "movement" ]
def _move_single_to_excitor_location(self, observation, isBody=True): light_color_start_index = self.prox_sensor_num target_light_index = -1 max_intensity = 0 for i in range(self.lights_num): light_intensity = observation[light_color_start_index + i * 3] if light_...
[ "def", "_move_single_to_excitor_location", "(", "self", ",", "observation", ",", "isBody", "=", "True", ")", ":", "light_color_start_index", "=", "self", ".", "prox_sensor_num", "target_light_index", "=", "-", "1", "max_intensity", "=", "0", "for", "i", "in", "r...
find the light with maximum intensity and move Visitor#1 to that location Testing target movement
[ "find", "the", "light", "with", "maximum", "intensity", "and", "move", "Visitor#1", "to", "that", "location", "Testing", "target", "movement" ]
[ "\"\"\"\n find the light with maximum intensity and move Visitor#1 to that location\n Testing target movement\n\n \"\"\"", "# fixed height of human model", "# if no light is turned on, then visitor is placed at origin.", "# visitor body", "# visitor target" ]
[ { "param": "self", "type": null }, { "param": "observation", "type": null }, { "param": "isBody", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "observation", "type": null, "docstring": null, "docstring_tok...
cc5b11d41a8aadc9a161395c2d2aca2246b53766
UWaterloo-ASL/ML_lite
Environment/LASEnv.py
[ "MIT" ]
Python
step
<not_specific>
def step(self, action): """ Take one step of interaction. Parameters ---------- action: ndarray action[0: smas_num] are action corresponding to sma action[smas_num: end] are action corresponding to light color Returns ----...
Take one step of interaction. Parameters ---------- action: ndarray action[0: smas_num] are action corresponding to sma action[smas_num: end] are action corresponding to light color Returns ------- observation: ndarray ...
Take one step of interaction. Parameters ndarray action[0: smas_num] are action corresponding to sma action[smas_num: end] are action corresponding to light color Returns ndarray obervation of environment after taking an action reward: float reward after taking an action done: bool whether simulation is done or not....
[ "Take", "one", "step", "of", "interaction", ".", "Parameters", "ndarray", "action", "[", "0", ":", "smas_num", "]", "are", "action", "corresponding", "to", "sma", "action", "[", "smas_num", ":", "end", "]", "are", "action", "corresponding", "to", "light", ...
def step(self, action): if np.sum(np.isnan(action)) != 0: Tracer()() raise ValueError("Find nan value in action!") action = np.clip(action, self.act_min, self.act_max) action = (action + 1) / 2.0 action_smas = action[:self.smas_num] action_lights_color = a...
[ "def", "step", "(", "self", ",", "action", ")", ":", "if", "np", ".", "sum", "(", "np", ".", "isnan", "(", "action", ")", ")", "!=", "0", ":", "Tracer", "(", ")", "(", ")", "raise", "ValueError", "(", "\"Find nan value in action!\"", ")", "action", ...
Take one step of interaction.
[ "Take", "one", "step", "of", "interaction", "." ]
[ "\"\"\"\n Take one step of interaction.\n \n Parameters\n ----------\n action: ndarray\n action[0: smas_num] are action corresponding to sma\n action[smas_num: end] are action corresponding to light color\n \n Returns\n -------\n o...
[ { "param": "self", "type": null }, { "param": "action", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "action", "type": null, "docstring": null, "docstring_tokens":...
c02f6f9a09541170fdd271df91d3311c6a4b787c
marianoeramirez/django-plans
plans/listeners.py
[ "MIT" ]
Python
create_proforma_invoice
null
def create_proforma_invoice(sender, instance, created, **kwargs): """ For every Order if there are defined billing_data creates invoice proforma, which is an order confirmation document """ if created: Invoice.create(instance, Invoice.INVOICE_TYPES['PROFORMA'])
For every Order if there are defined billing_data creates invoice proforma, which is an order confirmation document
For every Order if there are defined billing_data creates invoice proforma, which is an order confirmation document
[ "For", "every", "Order", "if", "there", "are", "defined", "billing_data", "creates", "invoice", "proforma", "which", "is", "an", "order", "confirmation", "document" ]
def create_proforma_invoice(sender, instance, created, **kwargs): if created: Invoice.create(instance, Invoice.INVOICE_TYPES['PROFORMA'])
[ "def", "create_proforma_invoice", "(", "sender", ",", "instance", ",", "created", ",", "**", "kwargs", ")", ":", "if", "created", ":", "Invoice", ".", "create", "(", "instance", ",", "Invoice", ".", "INVOICE_TYPES", "[", "'PROFORMA'", "]", ")" ]
For every Order if there are defined billing_data creates invoice proforma, which is an order confirmation document
[ "For", "every", "Order", "if", "there", "are", "defined", "billing_data", "creates", "invoice", "proforma", "which", "is", "an", "order", "confirmation", "document" ]
[ "\"\"\"\n For every Order if there are defined billing_data creates invoice proforma,\n which is an order confirmation document\n \"\"\"" ]
[ { "param": "sender", "type": null }, { "param": "instance", "type": null }, { "param": "created", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sender", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "instance", "type": null, "docstring": null, "docstring_toke...
ef822e6fa56e931987d01a770b142aa4200680ca
EVAyo/TG_Avatar
telegram_avatar/data_classes.py
[ "Beerware" ]
Python
is_up_to_date
bool
def is_up_to_date(self) -> bool: """ Checking if weather data is up-to-date. Returns: True if weather data is up-to-date else False. """ return all(self.__dict__.values())
Checking if weather data is up-to-date. Returns: True if weather data is up-to-date else False.
Checking if weather data is up-to-date.
[ "Checking", "if", "weather", "data", "is", "up", "-", "to", "-", "date", "." ]
def is_up_to_date(self) -> bool: return all(self.__dict__.values())
[ "def", "is_up_to_date", "(", "self", ")", "->", "bool", ":", "return", "all", "(", "self", ".", "__dict__", ".", "values", "(", ")", ")" ]
Checking if weather data is up-to-date.
[ "Checking", "if", "weather", "data", "is", "up", "-", "to", "-", "date", "." ]
[ "\"\"\"\n Checking if weather data is up-to-date.\n Returns:\n True if weather data is up-to-date else False.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "True if weather data is up-to-date else False.", "docstring_tokens": [ "True", "if", "weather", "data", "is", "up", "-", "to", "-", "date", "else", "False", "." ...
ce2f8cf85d5dbb03e6e514178d07fb748332828a
EVAyo/TG_Avatar
telegram_avatar/__main__.py
[ "Beerware" ]
Python
change_avatar
None
async def change_avatar( tg_client: TelegramClient, avatar_generator: AvatarGenerator, ) -> None: """ Function which updates Telegram avatar with generated new one. Args: tg_client: authorised telethon.TelegramClient object. avatar_generator: AvatarGenerator object which gene...
Function which updates Telegram avatar with generated new one. Args: tg_client: authorised telethon.TelegramClient object. avatar_generator: AvatarGenerator object which generates new avatar image.
Function which updates Telegram avatar with generated new one.
[ "Function", "which", "updates", "Telegram", "avatar", "with", "generated", "new", "one", "." ]
async def change_avatar( tg_client: TelegramClient, avatar_generator: AvatarGenerator, ) -> None: await tg_client( DeletePhotosRequest(await tg_client.get_profile_photos('me')) ) file = await tg_client.upload_file( avatar_generator.generate() ) await tg_client( ...
[ "async", "def", "change_avatar", "(", "tg_client", ":", "TelegramClient", ",", "avatar_generator", ":", "AvatarGenerator", ",", ")", "->", "None", ":", "await", "tg_client", "(", "DeletePhotosRequest", "(", "await", "tg_client", ".", "get_profile_photos", "(", "'m...
Function which updates Telegram avatar with generated new one.
[ "Function", "which", "updates", "Telegram", "avatar", "with", "generated", "new", "one", "." ]
[ "\"\"\"\n Function which updates Telegram avatar with generated new one.\n Args:\n tg_client: authorised telethon.TelegramClient object.\n avatar_generator: AvatarGenerator object which generates\n new avatar image.\n \"\"\"", "# Deleting Telegram avatar", "# Generating and loa...
[ { "param": "tg_client", "type": "TelegramClient" }, { "param": "avatar_generator", "type": "AvatarGenerator" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tg_client", "type": "TelegramClient", "docstring": "authorised telethon.TelegramClient object.", "docstring_tokens": [ "authorised", "telethon", ".", "TelegramClient", "object", ...
4ae3a609dd8e97760e3820663fa70b41dfbdcbe4
EVAyo/TG_Avatar
telegram_avatar/open_weather_map_api.py
[ "Beerware" ]
Python
_weather_image_exists
bool
def _weather_image_exists(self, image_name: str) -> bool: """ Check if weather image icon is exists in folder. Args: image_name: name of image (w/o extension). Returns: True if image is exist, else False. """ img_path = os.path.join( os...
Check if weather image icon is exists in folder. Args: image_name: name of image (w/o extension). Returns: True if image is exist, else False.
Check if weather image icon is exists in folder.
[ "Check", "if", "weather", "image", "icon", "is", "exists", "in", "folder", "." ]
def _weather_image_exists(self, image_name: str) -> bool: img_path = os.path.join( os.getcwd(), WEATHER_ICONS_FOLDER_NAME, image_name + ".png", ) exists = os.path.exists(img_path) self._logger.info(f"Image with name {image_name} existing: {exists}") ...
[ "def", "_weather_image_exists", "(", "self", ",", "image_name", ":", "str", ")", "->", "bool", ":", "img_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "WEATHER_ICONS_FOLDER_NAME", ",", "image_name", "+", "\".png\"", ...
Check if weather image icon is exists in folder.
[ "Check", "if", "weather", "image", "icon", "is", "exists", "in", "folder", "." ]
[ "\"\"\"\n Check if weather image icon is exists in folder.\n Args:\n image_name: name of image (w/o extension).\n Returns:\n True if image is exist, else False.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "image_name", "type": "str" } ]
{ "returns": [ { "docstring": "True if image is exist, else False.", "docstring_tokens": [ "True", "if", "image", "is", "exist", "else", "False", "." ], "type": null } ], "raises": [], "params": [ { "identi...
4ae3a609dd8e97760e3820663fa70b41dfbdcbe4
EVAyo/TG_Avatar
telegram_avatar/open_weather_map_api.py
[ "Beerware" ]
Python
_get_weather_image
None
async def _get_weather_image(self, image_name: str) -> None: """ Method which downloads a weather icon from OpenWeatherMap API. Args: image_name: name of weather icon (w/o extension). Raises: ImageDownloadError: if OpenWeatherMap API returns response ...
Method which downloads a weather icon from OpenWeatherMap API. Args: image_name: name of weather icon (w/o extension). Raises: ImageDownloadError: if OpenWeatherMap API returns response with status code different from 200 or request raises ...
Method which downloads a weather icon from OpenWeatherMap API.
[ "Method", "which", "downloads", "a", "weather", "icon", "from", "OpenWeatherMap", "API", "." ]
async def _get_weather_image(self, image_name: str) -> None: url = self._api_image_url.format(image_name) self._logger.info(f"Loading image with name: {image_name}...") try: resp = await self._client_session.get(url=url) except ClientError as request_error: self._...
[ "async", "def", "_get_weather_image", "(", "self", ",", "image_name", ":", "str", ")", "->", "None", ":", "url", "=", "self", ".", "_api_image_url", ".", "format", "(", "image_name", ")", "self", ".", "_logger", ".", "info", "(", "f\"Loading image with name:...
Method which downloads a weather icon from OpenWeatherMap API.
[ "Method", "which", "downloads", "a", "weather", "icon", "from", "OpenWeatherMap", "API", "." ]
[ "\"\"\"\n Method which downloads a weather icon from OpenWeatherMap API.\n Args:\n image_name: name of weather icon (w/o extension).\n Raises:\n ImageDownloadError: if OpenWeatherMap API returns response\n with status code different from 200 or request raise...
[ { "param": "self", "type": null }, { "param": "image_name", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [ { "docstring": "if OpenWeatherMap API returns response\nwith status code different from 200 or request raises\naiohttp.ClientError.", "docstring_tokens": [ ...
4ae3a609dd8e97760e3820663fa70b41dfbdcbe4
EVAyo/TG_Avatar
telegram_avatar/open_weather_map_api.py
[ "Beerware" ]
Python
_get_weather_data
Tuple[float, str]
async def _get_weather_data(self, city_id: int) -> Tuple[float, str]: """ Method which makes a GET request to OpenWeatherMap API in order to get current temperature and weather icon name to your city. Returns the tuple of updated weather data (temperature and weather icon name). ...
Method which makes a GET request to OpenWeatherMap API in order to get current temperature and weather icon name to your city. Returns the tuple of updated weather data (temperature and weather icon name). Args: city_id: the code of the city for which you want to rec...
Method which makes a GET request to OpenWeatherMap API in order to get current temperature and weather icon name to your city. Returns the tuple of updated weather data (temperature and weather icon name).
[ "Method", "which", "makes", "a", "GET", "request", "to", "OpenWeatherMap", "API", "in", "order", "to", "get", "current", "temperature", "and", "weather", "icon", "name", "to", "your", "city", ".", "Returns", "the", "tuple", "of", "updated", "weather", "data"...
async def _get_weather_data(self, city_id: int) -> Tuple[float, str]: payload = { "id": city_id, "appid": self._api_token, } self._logger.info( f"Updating weather information with payload: {payload}" ) try: response = await self._cl...
[ "async", "def", "_get_weather_data", "(", "self", ",", "city_id", ":", "int", ")", "->", "Tuple", "[", "float", ",", "str", "]", ":", "payload", "=", "{", "\"id\"", ":", "city_id", ",", "\"appid\"", ":", "self", ".", "_api_token", ",", "}", "self", "...
Method which makes a GET request to OpenWeatherMap API in order to get current temperature and weather icon name to your city.
[ "Method", "which", "makes", "a", "GET", "request", "to", "OpenWeatherMap", "API", "in", "order", "to", "get", "current", "temperature", "and", "weather", "icon", "name", "to", "your", "city", "." ]
[ "\"\"\"\n Method which makes a GET request to OpenWeatherMap API in order to\n get current temperature and weather icon name to your city.\n Returns the tuple of updated weather data (temperature\n and weather icon name).\n Args:\n city_id: the code of the city for whic...
[ { "param": "self", "type": null }, { "param": "city_id", "type": "int" } ]
{ "returns": [ { "docstring": "tuple with current temperature and weather icon name.", "docstring_tokens": [ "tuple", "with", "current", "temperature", "and", "weather", "icon", "name", "." ], "type": null } ], ...
4ae3a609dd8e97760e3820663fa70b41dfbdcbe4
EVAyo/TG_Avatar
telegram_avatar/open_weather_map_api.py
[ "Beerware" ]
Python
update_weather_data
None
async def update_weather_data(self, city_id: int) -> None: """ Main method which updates weather data and publish it into a queue. Args: city_id: the code of the city for which you want to receive the weather data. Code for the Moscow city by default. Returns:...
Main method which updates weather data and publish it into a queue. Args: city_id: the code of the city for which you want to receive the weather data. Code for the Moscow city by default. Returns: None.
Main method which updates weather data and publish it into a queue.
[ "Main", "method", "which", "updates", "weather", "data", "and", "publish", "it", "into", "a", "queue", "." ]
async def update_weather_data(self, city_id: int) -> None: try: new_temp, new_icon = await self._get_weather_data(city_id=city_id) self._weather_data.current_temperature = new_temp self._weather_data.current_weather_image = new_icon except (WeatherDataDownloadError, I...
[ "async", "def", "update_weather_data", "(", "self", ",", "city_id", ":", "int", ")", "->", "None", ":", "try", ":", "new_temp", ",", "new_icon", "=", "await", "self", ".", "_get_weather_data", "(", "city_id", "=", "city_id", ")", "self", ".", "_weather_dat...
Main method which updates weather data and publish it into a queue.
[ "Main", "method", "which", "updates", "weather", "data", "and", "publish", "it", "into", "a", "queue", "." ]
[ "\"\"\"\n Main method which updates weather data and publish it into a queue.\n Args:\n city_id: the code of the city for which you want to receive\n the weather data. Code for the Moscow city by default.\n Returns:\n None.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "city_id", "type": "int" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
bd47f91a84d8436aa71124cd5683026a3d8975a1
EVAyo/TG_Avatar
telegram_avatar/avatar_generator.py
[ "Beerware" ]
Python
_get_celsius_from_kelvin
str
def _get_celsius_from_kelvin(t_kelvin: Union[int, float, str]) -> str: """ Method which converts temperature from Kelvin scale to Celsius and formats it to the "<sign><temperature> C" like view. Args: t_kelvin: string or number with Kelvin scale temperature. Returns: ...
Method which converts temperature from Kelvin scale to Celsius and formats it to the "<sign><temperature> C" like view. Args: t_kelvin: string or number with Kelvin scale temperature. Returns: string with formatted temperature in Celsius scale.
Method which converts temperature from Kelvin scale to Celsius and formats it to the " C" like view.
[ "Method", "which", "converts", "temperature", "from", "Kelvin", "scale", "to", "Celsius", "and", "formats", "it", "to", "the", "\"", "C", "\"", "like", "view", "." ]
def _get_celsius_from_kelvin(t_kelvin: Union[int, float, str]) -> str: t_kelvin = int(t_kelvin) t_celsius = t_kelvin-273 result = u"{} C".format(str(t_celsius)) if t_celsius >= 0: result = "+" + result return result
[ "def", "_get_celsius_from_kelvin", "(", "t_kelvin", ":", "Union", "[", "int", ",", "float", ",", "str", "]", ")", "->", "str", ":", "t_kelvin", "=", "int", "(", "t_kelvin", ")", "t_celsius", "=", "t_kelvin", "-", "273", "result", "=", "u\"{} C\"", ".", ...
Method which converts temperature from Kelvin scale to Celsius and formats it to the "<sign><temperature> C" like view.
[ "Method", "which", "converts", "temperature", "from", "Kelvin", "scale", "to", "Celsius", "and", "formats", "it", "to", "the", "\"", "<sign", ">", "<temperature", ">", "C", "\"", "like", "view", "." ]
[ "\"\"\"\n Method which converts temperature from Kelvin scale to Celsius\n and formats it to the \"<sign><temperature> C\" like view.\n Args:\n t_kelvin: string or number with Kelvin scale temperature.\n Returns:\n string with formatted temperature in Celsius scale....
[ { "param": "t_kelvin", "type": "Union[int, float, str]" } ]
{ "returns": [ { "docstring": "string with formatted temperature in Celsius scale.", "docstring_tokens": [ "string", "with", "formatted", "temperature", "in", "Celsius", "scale", "." ], "type": null } ], "raises": [], ...
bd47f91a84d8436aa71124cd5683026a3d8975a1
EVAyo/TG_Avatar
telegram_avatar/avatar_generator.py
[ "Beerware" ]
Python
generate
os.path
def generate(self, avatar_name: str = "Avatar.png") -> os.path: """ Method which generates avatar image with time and current weather data or only with current time if weather data is not available. Args: avatar_name: the name of the file with which the generated ...
Method which generates avatar image with time and current weather data or only with current time if weather data is not available. Args: avatar_name: the name of the file with which the generated avatar will be saved. Returns: os.path object - abs...
Method which generates avatar image with time and current weather data or only with current time if weather data is not available.
[ "Method", "which", "generates", "avatar", "image", "with", "time", "and", "current", "weather", "data", "or", "only", "with", "current", "time", "if", "weather", "data", "is", "not", "available", "." ]
def generate(self, avatar_name: str = "Avatar.png") -> os.path: bg = Image.new( mode="RGBA", size=(200, 200), color=self._bg_color + (255,), ) canvas = ImageDraw.Draw(bg) current_time = datetime.now() time = "{:0>2d}:{:0>2d}".format(current_tim...
[ "def", "generate", "(", "self", ",", "avatar_name", ":", "str", "=", "\"Avatar.png\"", ")", "->", "os", ".", "path", ":", "bg", "=", "Image", ".", "new", "(", "mode", "=", "\"RGBA\"", ",", "size", "=", "(", "200", ",", "200", ")", ",", "color", "...
Method which generates avatar image with time and current weather data or only with current time if weather data is not available.
[ "Method", "which", "generates", "avatar", "image", "with", "time", "and", "current", "weather", "data", "or", "only", "with", "current", "time", "if", "weather", "data", "is", "not", "available", "." ]
[ "\"\"\"\n Method which generates avatar image with time and current weather data\n or only with current time if weather data is not available.\n Args:\n avatar_name: the name of the file with which the generated\n avatar will be saved.\n Returns:\n os...
[ { "param": "self", "type": null }, { "param": "avatar_name", "type": "str" } ]
{ "returns": [ { "docstring": "os.path object - absolute path to the generated avatar image.", "docstring_tokens": [ "os", ".", "path", "object", "-", "absolute", "path", "to", "the", "generated", "avatar", ...
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
has_video_content
<not_specific>
def has_video_content(submission): """ Return boolean based on whether submission is viable to have a youtube playlist made """ all_comments = submission.comments # imported from praw.helpers flat_comments = flatten_tree(all_comments) video_count = 0 for comment in flat_comments: if t...
Return boolean based on whether submission is viable to have a youtube playlist made
Return boolean based on whether submission is viable to have a youtube playlist made
[ "Return", "boolean", "based", "on", "whether", "submission", "is", "viable", "to", "have", "a", "youtube", "playlist", "made" ]
def has_video_content(submission): all_comments = submission.comments flat_comments = flatten_tree(all_comments) video_count = 0 for comment in flat_comments: if type(comment) != MoreComments and comment.score >= MINIMUM_COMMENT_UPVOTES: links_in_comment = YOUTUBE_REGEX.findall(comme...
[ "def", "has_video_content", "(", "submission", ")", ":", "all_comments", "=", "submission", ".", "comments", "flat_comments", "=", "flatten_tree", "(", "all_comments", ")", "video_count", "=", "0", "for", "comment", "in", "flat_comments", ":", "if", "type", "(",...
Return boolean based on whether submission is viable to have a youtube playlist made
[ "Return", "boolean", "based", "on", "whether", "submission", "is", "viable", "to", "have", "a", "youtube", "playlist", "made" ]
[ "\"\"\" Return boolean based on whether submission is viable to have a youtube playlist made \"\"\"", "# imported from praw.helpers" ]
[ { "param": "submission", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "submission", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
add_video
null
def add_video(self, video_id): """ For a video id, add it to the list of videos in the playlist """ try: playlistitems_insert_response = youtube.youtube.playlistItems().insert( part="snippet,status", body=dict( snippet=dict( play...
For a video id, add it to the list of videos in the playlist
For a video id, add it to the list of videos in the playlist
[ "For", "a", "video", "id", "add", "it", "to", "the", "list", "of", "videos", "in", "the", "playlist" ]
def add_video(self, video_id): try: playlistitems_insert_response = youtube.youtube.playlistItems().insert( part="snippet,status", body=dict( snippet=dict( playlistId="%s" % self.id, resourceId=dict( ...
[ "def", "add_video", "(", "self", ",", "video_id", ")", ":", "try", ":", "playlistitems_insert_response", "=", "youtube", ".", "youtube", ".", "playlistItems", "(", ")", ".", "insert", "(", "part", "=", "\"snippet,status\"", ",", "body", "=", "dict", "(", "...
For a video id, add it to the list of videos in the playlist
[ "For", "a", "video", "id", "add", "it", "to", "the", "list", "of", "videos", "in", "the", "playlist" ]
[ "\"\"\" For a video id, add it to the list of videos in the playlist \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "video_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "video_id", "type": null, "docstring": null, "docstring_tokens...
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
run
null
def run(self): """ Automatically execute a list of tasks at regular intervals """ schedule.every(3).minutes.do(self.add_new_submissions) schedule.every(3).minutes.do(self.remove_old_submissions) schedule.every(6).minutes.do(self.refresh_submissions) schedule.every(6).minutes.do(...
Automatically execute a list of tasks at regular intervals
Automatically execute a list of tasks at regular intervals
[ "Automatically", "execute", "a", "list", "of", "tasks", "at", "regular", "intervals" ]
def run(self): schedule.every(3).minutes.do(self.add_new_submissions) schedule.every(3).minutes.do(self.remove_old_submissions) schedule.every(6).minutes.do(self.refresh_submissions) schedule.every(6).minutes.do(self.create_playlists) schedule.every(18).minutes.do(self.update_pla...
[ "def", "run", "(", "self", ")", ":", "schedule", ".", "every", "(", "3", ")", ".", "minutes", ".", "do", "(", "self", ".", "add_new_submissions", ")", "schedule", ".", "every", "(", "3", ")", ".", "minutes", ".", "do", "(", "self", ".", "remove_old...
Automatically execute a list of tasks at regular intervals
[ "Automatically", "execute", "a", "list", "of", "tasks", "at", "regular", "intervals" ]
[ "\"\"\" Automatically execute a list of tasks at regular intervals \"\"\"", "# maintain counters for (addition/removal), (initial playlist creation), (submission/playlist update)" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
add_new_submissions
null
def add_new_submissions(self): """ Add newly created reddit submissions to list of watched submissions """ # submissions created before this shouldn't be watched # time now - 12h for timeout timeout = time.time() - 43200 for submission in reddit.get_hot_submissions("AskReddit")...
Add newly created reddit submissions to list of watched submissions
Add newly created reddit submissions to list of watched submissions
[ "Add", "newly", "created", "reddit", "submissions", "to", "list", "of", "watched", "submissions" ]
def add_new_submissions(self): timeout = time.time() - 43200 for submission in reddit.get_hot_submissions("AskReddit"): if submission not in self.submissions and submission not in self.playlists.keys(): if timeout < submission.created: self.submissions.ap...
[ "def", "add_new_submissions", "(", "self", ")", ":", "timeout", "=", "time", ".", "time", "(", ")", "-", "43200", "for", "submission", "in", "reddit", ".", "get_hot_submissions", "(", "\"AskReddit\"", ")", ":", "if", "submission", "not", "in", "self", ".",...
Add newly created reddit submissions to list of watched submissions
[ "Add", "newly", "created", "reddit", "submissions", "to", "list", "of", "watched", "submissions" ]
[ "\"\"\" Add newly created reddit submissions to list of watched submissions \"\"\"", "# submissions created before this shouldn't be watched", "# time now - 12h for timeout" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
remove_old_submissions
null
def remove_old_submissions(self): """ Remove old reddit submissions from list of watched submissions """ # time now - 12h for timeout timeout = time.time() - 43200 for submission in self.submissions: if timeout > submission.created: self.submissions.remove(s...
Remove old reddit submissions from list of watched submissions
Remove old reddit submissions from list of watched submissions
[ "Remove", "old", "reddit", "submissions", "from", "list", "of", "watched", "submissions" ]
def remove_old_submissions(self): timeout = time.time() - 43200 for submission in self.submissions: if timeout > submission.created: self.submissions.remove(submission) logging.info("Removing Submission - " + submission.title)
[ "def", "remove_old_submissions", "(", "self", ")", ":", "timeout", "=", "time", ".", "time", "(", ")", "-", "43200", "for", "submission", "in", "self", ".", "submissions", ":", "if", "timeout", ">", "submission", ".", "created", ":", "self", ".", "submis...
Remove old reddit submissions from list of watched submissions
[ "Remove", "old", "reddit", "submissions", "from", "list", "of", "watched", "submissions" ]
[ "\"\"\" Remove old reddit submissions from list of watched submissions \"\"\"", "# time now - 12h for timeout" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
refresh_submissions
null
def refresh_submissions(self): """ Update the submission information, which among other things gets the latest comments """ logging.info("Refreshing Submissions") for submission in self.submissions: submission.refresh()
Update the submission information, which among other things gets the latest comments
Update the submission information, which among other things gets the latest comments
[ "Update", "the", "submission", "information", "which", "among", "other", "things", "gets", "the", "latest", "comments" ]
def refresh_submissions(self): logging.info("Refreshing Submissions") for submission in self.submissions: submission.refresh()
[ "def", "refresh_submissions", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Refreshing Submissions\"", ")", "for", "submission", "in", "self", ".", "submissions", ":", "submission", ".", "refresh", "(", ")" ]
Update the submission information, which among other things gets the latest comments
[ "Update", "the", "submission", "information", "which", "among", "other", "things", "gets", "the", "latest", "comments" ]
[ "\"\"\" Update the submission information, which among other things gets the latest comments \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
create_playlists
null
def create_playlists(self): """ Called to check all submissions in watchlist to see if they should have a playlist created """ for submission in [s for s in self.submissions if s.name not in self.playlists.keys() ]: if has_video_content(submission): logging.info("Creating Pl...
Called to check all submissions in watchlist to see if they should have a playlist created
Called to check all submissions in watchlist to see if they should have a playlist created
[ "Called", "to", "check", "all", "submissions", "in", "watchlist", "to", "see", "if", "they", "should", "have", "a", "playlist", "created" ]
def create_playlists(self): for submission in [s for s in self.submissions if s.name not in self.playlists.keys() ]: if has_video_content(submission): logging.info("Creating Playlist for Submission - " + submission.title) new_playlist = self.create_playlist(submission...
[ "def", "create_playlists", "(", "self", ")", ":", "for", "submission", "in", "[", "s", "for", "s", "in", "self", ".", "submissions", "if", "s", ".", "name", "not", "in", "self", ".", "playlists", ".", "keys", "(", ")", "]", ":", "if", "has_video_cont...
Called to check all submissions in watchlist to see if they should have a playlist created
[ "Called", "to", "check", "all", "submissions", "in", "watchlist", "to", "see", "if", "they", "should", "have", "a", "playlist", "created" ]
[ "\"\"\" Called to check all submissions in watchlist to see if they should have a playlist created \"\"\"", "#submission.add_comment(\"comment text\")" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
create_playlist
<not_specific>
def create_playlist(self, submission): """ For a reddit submission, create an associated youtube playlist """ logging.info("--- EXECUTING FUNCTION CREATE_PLAYLIST FOR CLASS PLAYLISTBOT ---") youtube_links = [] # submission.replace_more_comments(limit=None, threshold=0) all_com...
For a reddit submission, create an associated youtube playlist
For a reddit submission, create an associated youtube playlist
[ "For", "a", "reddit", "submission", "create", "an", "associated", "youtube", "playlist" ]
def create_playlist(self, submission): logging.info("--- EXECUTING FUNCTION CREATE_PLAYLIST FOR CLASS PLAYLISTBOT ---") youtube_links = [] all_comments = submission.comments flat_comments = flatten_tree(all_comments) for comment in flat_comments: if type(comment) != M...
[ "def", "create_playlist", "(", "self", ",", "submission", ")", ":", "logging", ".", "info", "(", "\"--- EXECUTING FUNCTION CREATE_PLAYLIST FOR CLASS PLAYLISTBOT ---\"", ")", "youtube_links", "=", "[", "]", "all_comments", "=", "submission", ".", "comments", "flat_commen...
For a reddit submission, create an associated youtube playlist
[ "For", "a", "reddit", "submission", "create", "an", "associated", "youtube", "playlist" ]
[ "\"\"\" For a reddit submission, create an associated youtube playlist \"\"\"", "# submission.replace_more_comments(limit=None, threshold=0)", "# imported from praw.helpers" ]
[ { "param": "self", "type": null }, { "param": "submission", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "submission", "type": null, "docstring": null, "docstring_toke...
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
update_playlists
null
def update_playlists(self, update_all=False): """ Checks all threads with playlists to see if their content should be updated """ logging.info("Updating Playlists") for submission_name, playlist in self.playlists.iteritems(): youtube_links = [] # if the thread is still ...
Checks all threads with playlists to see if their content should be updated
Checks all threads with playlists to see if their content should be updated
[ "Checks", "all", "threads", "with", "playlists", "to", "see", "if", "their", "content", "should", "be", "updated" ]
def update_playlists(self, update_all=False): logging.info("Updating Playlists") for submission_name, playlist in self.playlists.iteritems(): youtube_links = [] submissions_with_name = [s for s in self.submissions if s.name == submission_name] if submissions_with_name...
[ "def", "update_playlists", "(", "self", ",", "update_all", "=", "False", ")", ":", "logging", ".", "info", "(", "\"Updating Playlists\"", ")", "for", "submission_name", ",", "playlist", "in", "self", ".", "playlists", ".", "iteritems", "(", ")", ":", "youtub...
Checks all threads with playlists to see if their content should be updated
[ "Checks", "all", "threads", "with", "playlists", "to", "see", "if", "their", "content", "should", "be", "updated" ]
[ "\"\"\" Checks all threads with playlists to see if their content should be updated \"\"\"", "# if the thread is still being watched", "# keep a record of yt_links in comments", "# add new ones" ]
[ { "param": "self", "type": null }, { "param": "update_all", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "update_all", "type": null, "docstring": null, "docstring_toke...
c5a95aa5aee4b17b38b413176c4301c1a83337bd
beckman94/playlist-bot
playlist_bot.py
[ "MIT" ]
Python
save
null
def save(self): """ Pickles the dictionary of playlist data for if execution of this program is restarted """ logging.info("Saving a Pickle") with open('playlists.p', 'wb') as fp: pickle.dump(self.playlists, fp)
Pickles the dictionary of playlist data for if execution of this program is restarted
Pickles the dictionary of playlist data for if execution of this program is restarted
[ "Pickles", "the", "dictionary", "of", "playlist", "data", "for", "if", "execution", "of", "this", "program", "is", "restarted" ]
def save(self): logging.info("Saving a Pickle") with open('playlists.p', 'wb') as fp: pickle.dump(self.playlists, fp)
[ "def", "save", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Saving a Pickle\"", ")", "with", "open", "(", "'playlists.p'", ",", "'wb'", ")", "as", "fp", ":", "pickle", ".", "dump", "(", "self", ".", "playlists", ",", "fp", ")" ]
Pickles the dictionary of playlist data for if execution of this program is restarted
[ "Pickles", "the", "dictionary", "of", "playlist", "data", "for", "if", "execution", "of", "this", "program", "is", "restarted" ]
[ "\"\"\" Pickles the dictionary of playlist data for if execution of this program is restarted \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ee9304c902dad50ebbc3579cfd939c8d46fc88d0
mshingan/nlp-hw
project/qbmodel.py
[ "MIT" ]
Python
guess_and_buzz
List[Tuple[str, bool]]
def guess_and_buzz(self, question_text: List[str]) -> List[Tuple[str, bool]]: """ This function accepts a list of question strings, and returns a list of tuples containing strings representing the guess and corresponding booleans representing whether or not to buzz. So, guess_...
This function accepts a list of question strings, and returns a list of tuples containing strings representing the guess and corresponding booleans representing whether or not to buzz. So, guess_and_buzz(["This is a question"]) should return [("answer", False)] If you are us...
This function accepts a list of question strings, and returns a list of tuples containing strings representing the guess and corresponding booleans representing whether or not to buzz. So, guess_and_buzz(["This is a question"]) should return [("answer", False)] If you are using a deep learning model, try to use batch...
[ "This", "function", "accepts", "a", "list", "of", "question", "strings", "and", "returns", "a", "list", "of", "tuples", "containing", "strings", "representing", "the", "guess", "and", "corresponding", "booleans", "representing", "whether", "or", "not", "to", "bu...
def guess_and_buzz(self, question_text: List[str]) -> List[Tuple[str, bool]]: pass
[ "def", "guess_and_buzz", "(", "self", ",", "question_text", ":", "List", "[", "str", "]", ")", "->", "List", "[", "Tuple", "[", "str", ",", "bool", "]", "]", ":", "pass" ]
This function accepts a list of question strings, and returns a list of tuples containing strings representing the guess and corresponding booleans representing whether or not to buzz.
[ "This", "function", "accepts", "a", "list", "of", "question", "strings", "and", "returns", "a", "list", "of", "tuples", "containing", "strings", "representing", "the", "guess", "and", "corresponding", "booleans", "representing", "whether", "or", "not", "to", "bu...
[ "\"\"\"\n This function accepts a list of question strings, and returns a list of tuples containing\n strings representing the guess and corresponding booleans representing \n whether or not to buzz. \n\n So, guess_and_buzz([\"This is a question\"]) should return [(\"answer\", False)]\n\...
[ { "param": "self", "type": null }, { "param": "question_text", "type": "List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "question_text", "type": "List[str]", "docstring": null, "docs...
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
dessiner_grille
null
def dessiner_grille(): """ Dessine la grille de jeu sans l'afficher """ fenetre.fill(BLANC) # Dessin des barres verticales for i in range(nb_colonnes + 1): x = (parametres["LARGEUR_CASE"] + EPAISSEUR_LIGNE) * i pygame.draw.line(fenetre, NOIR, (x, 0), (x, hauteur_fenetre - 1), EPAISSEUR_...
Dessine la grille de jeu sans l'afficher
Dessine la grille de jeu sans l'afficher
[ "Dessine", "la", "grille", "de", "jeu", "sans", "l", "'", "afficher" ]
def dessiner_grille(): fenetre.fill(BLANC) for i in range(nb_colonnes + 1): x = (parametres["LARGEUR_CASE"] + EPAISSEUR_LIGNE) * i pygame.draw.line(fenetre, NOIR, (x, 0), (x, hauteur_fenetre - 1), EPAISSEUR_LIGNE) for j in range(nb_lignes + 1): y = (parametres["LARGEUR_CASE"] + EPAIS...
[ "def", "dessiner_grille", "(", ")", ":", "fenetre", ".", "fill", "(", "BLANC", ")", "for", "i", "in", "range", "(", "nb_colonnes", "+", "1", ")", ":", "x", "=", "(", "parametres", "[", "\"LARGEUR_CASE\"", "]", "+", "EPAISSEUR_LIGNE", ")", "*", "i", "...
Dessine la grille de jeu sans l'afficher
[ "Dessine", "la", "grille", "de", "jeu", "sans", "l", "'", "afficher" ]
[ "\"\"\" Dessine la grille de jeu sans l'afficher \"\"\"", "# Dessin des barres verticales", "# Dessin des barres horizontales" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
dessiner_cellule
null
def dessiner_cellule(colonne, ligne): """ Dessine une cellule dans la grille de jeu sans l'afficher """ if plateau[ligne][colonne] == CELLULE_MORTE: couleur = BLANC elif plateau[ligne][colonne] == CELLULE_NAISSANTE: couleur = VERT else: couleur = BLEU x_centre = (colonne * (p...
Dessine une cellule dans la grille de jeu sans l'afficher
Dessine une cellule dans la grille de jeu sans l'afficher
[ "Dessine", "une", "cellule", "dans", "la", "grille", "de", "jeu", "sans", "l", "'", "afficher" ]
def dessiner_cellule(colonne, ligne): if plateau[ligne][colonne] == CELLULE_MORTE: couleur = BLANC elif plateau[ligne][colonne] == CELLULE_NAISSANTE: couleur = VERT else: couleur = BLEU x_centre = (colonne * (parametres["LARGEUR_CASE"] + EPAISSEUR_LIGNE)) + parametres["LARGEUR_CA...
[ "def", "dessiner_cellule", "(", "colonne", ",", "ligne", ")", ":", "if", "plateau", "[", "ligne", "]", "[", "colonne", "]", "==", "CELLULE_MORTE", ":", "couleur", "=", "BLANC", "elif", "plateau", "[", "ligne", "]", "[", "colonne", "]", "==", "CELLULE_NAI...
Dessine une cellule dans la grille de jeu sans l'afficher
[ "Dessine", "une", "cellule", "dans", "la", "grille", "de", "jeu", "sans", "l", "'", "afficher" ]
[ "\"\"\" Dessine une cellule dans la grille de jeu sans l'afficher \"\"\"", "# Cercle plein" ]
[ { "param": "colonne", "type": null }, { "param": "ligne", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "colonne", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ligne", "type": null, "docstring": null, "docstring_tokens...
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
afficher_plateau
null
def afficher_plateau(): """ Affiche la grille de jeu avec ses cellules """ dessiner_grille() for ligne in range(nb_lignes): for colonne in range(nb_colonnes): dessiner_cellule(colonne, ligne) afficher_ecran()
Affiche la grille de jeu avec ses cellules
Affiche la grille de jeu avec ses cellules
[ "Affiche", "la", "grille", "de", "jeu", "avec", "ses", "cellules" ]
def afficher_plateau(): dessiner_grille() for ligne in range(nb_lignes): for colonne in range(nb_colonnes): dessiner_cellule(colonne, ligne) afficher_ecran()
[ "def", "afficher_plateau", "(", ")", ":", "dessiner_grille", "(", ")", "for", "ligne", "in", "range", "(", "nb_lignes", ")", ":", "for", "colonne", "in", "range", "(", "nb_colonnes", ")", ":", "dessiner_cellule", "(", "colonne", ",", "ligne", ")", "affiche...
Affiche la grille de jeu avec ses cellules
[ "Affiche", "la", "grille", "de", "jeu", "avec", "ses", "cellules" ]
[ "\"\"\" Affiche la grille de jeu avec ses cellules \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
deplacer_encadre
<not_specific>
def deplacer_encadre(encadre): """ Retourne un objet rect encadrant la nouvelle structure """ # Effacer l'encadré précédent pygame.draw.rect(fenetre, NOIR, encadre, 1) # Tracer le nouvel encadre encadre = pygame.draw.rect( fenetre, VERT, ( EPAISSEUR_LIGNE - 1 + (...
Retourne un objet rect encadrant la nouvelle structure
Retourne un objet rect encadrant la nouvelle structure
[ "Retourne", "un", "objet", "rect", "encadrant", "la", "nouvelle", "structure" ]
def deplacer_encadre(encadre): pygame.draw.rect(fenetre, NOIR, encadre, 1) encadre = pygame.draw.rect( fenetre, VERT, ( EPAISSEUR_LIGNE - 1 + (position_souris[0] // (parametres["LARGEUR_CASE"] + EPAISSEUR_LIGNE)) * (parametres["LARGEUR_CASE"] + EPAISSEUR_LIGNE), E...
[ "def", "deplacer_encadre", "(", "encadre", ")", ":", "pygame", ".", "draw", ".", "rect", "(", "fenetre", ",", "NOIR", ",", "encadre", ",", "1", ")", "encadre", "=", "pygame", ".", "draw", ".", "rect", "(", "fenetre", ",", "VERT", ",", "(", "EPAISSEUR...
Retourne un objet rect encadrant la nouvelle structure
[ "Retourne", "un", "objet", "rect", "encadrant", "la", "nouvelle", "structure" ]
[ "\"\"\" Retourne un objet rect encadrant la nouvelle structure \"\"\"", "# Effacer l'encadré précédent", "# Tracer le nouvel encadre" ]
[ { "param": "encadre", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "encadre", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
compter_cellules
<not_specific>
def compter_cellules(): """ Retourne le nombre de cellules dans la grille de jeu """ nb_cellules = 0 for ligne in range(nb_lignes): for colonne in range(nb_colonnes): if not plateau[ligne][colonne] == CELLULE_MORTE: nb_cellules += 1 return nb_cellules
Retourne le nombre de cellules dans la grille de jeu
Retourne le nombre de cellules dans la grille de jeu
[ "Retourne", "le", "nombre", "de", "cellules", "dans", "la", "grille", "de", "jeu" ]
def compter_cellules(): nb_cellules = 0 for ligne in range(nb_lignes): for colonne in range(nb_colonnes): if not plateau[ligne][colonne] == CELLULE_MORTE: nb_cellules += 1 return nb_cellules
[ "def", "compter_cellules", "(", ")", ":", "nb_cellules", "=", "0", "for", "ligne", "in", "range", "(", "nb_lignes", ")", ":", "for", "colonne", "in", "range", "(", "nb_colonnes", ")", ":", "if", "not", "plateau", "[", "ligne", "]", "[", "colonne", "]",...
Retourne le nombre de cellules dans la grille de jeu
[ "Retourne", "le", "nombre", "de", "cellules", "dans", "la", "grille", "de", "jeu" ]
[ "\"\"\" Retourne le nombre de cellules dans la grille de jeu \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
detourer_plateau
<not_specific>
def detourer_plateau(x_1, y_1, x_2, y_2): """ Retourne la zone utile de la grille de jeu """ zone_utile = {"X_1": -1, "Y_1": -1, "X_2": nb_colonnes, "Y_2": nb_lignes} for colonne in range(x_1, x_2 + 1): if colonne_vivante(colonne, y_1, y_2): zone_utile["X_1"] = colonne break ...
Retourne la zone utile de la grille de jeu
Retourne la zone utile de la grille de jeu
[ "Retourne", "la", "zone", "utile", "de", "la", "grille", "de", "jeu" ]
def detourer_plateau(x_1, y_1, x_2, y_2): zone_utile = {"X_1": -1, "Y_1": -1, "X_2": nb_colonnes, "Y_2": nb_lignes} for colonne in range(x_1, x_2 + 1): if colonne_vivante(colonne, y_1, y_2): zone_utile["X_1"] = colonne break if zone_utile["X_1"] == -1: return zone_uti...
[ "def", "detourer_plateau", "(", "x_1", ",", "y_1", ",", "x_2", ",", "y_2", ")", ":", "zone_utile", "=", "{", "\"X_1\"", ":", "-", "1", ",", "\"Y_1\"", ":", "-", "1", ",", "\"X_2\"", ":", "nb_colonnes", ",", "\"Y_2\"", ":", "nb_lignes", "}", "for", ...
Retourne la zone utile de la grille de jeu
[ "Retourne", "la", "zone", "utile", "de", "la", "grille", "de", "jeu" ]
[ "\"\"\" Retourne la zone utile de la grille de jeu \"\"\"", "# Rien à sauvegarder !" ]
[ { "param": "x_1", "type": null }, { "param": "y_1", "type": null }, { "param": "x_2", "type": null }, { "param": "y_2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x_1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y_1", "type": null, "docstring": null, "docstring_tokens": [],...
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
sauvegarder_fichier
null
def sauvegarder_fichier(chemin_fichier): """ Sauvegarde la zone utile de la grille de jeu dans un fichier au format Plain Text """ if not os.path.exists(REPERTOIRE_SAUVEGARDE): os.makedirs(REPERTOIRE_SAUVEGARDE) fichier = open(chemin_fichier, "w") fichier.write("!Name: " + nom_fichier + "\n") ...
Sauvegarde la zone utile de la grille de jeu dans un fichier au format Plain Text
Sauvegarde la zone utile de la grille de jeu dans un fichier au format Plain Text
[ "Sauvegarde", "la", "zone", "utile", "de", "la", "grille", "de", "jeu", "dans", "un", "fichier", "au", "format", "Plain", "Text" ]
def sauvegarder_fichier(chemin_fichier): if not os.path.exists(REPERTOIRE_SAUVEGARDE): os.makedirs(REPERTOIRE_SAUVEGARDE) fichier = open(chemin_fichier, "w") fichier.write("!Name: " + nom_fichier + "\n") fichier.write("!Position: " + str(zone_utile["X_1"]) + "," + str(zone_utile["Y_1"]) + "\n") ...
[ "def", "sauvegarder_fichier", "(", "chemin_fichier", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "REPERTOIRE_SAUVEGARDE", ")", ":", "os", ".", "makedirs", "(", "REPERTOIRE_SAUVEGARDE", ")", "fichier", "=", "open", "(", "chemin_fichier", ",", ...
Sauvegarde la zone utile de la grille de jeu dans un fichier au format Plain Text
[ "Sauvegarde", "la", "zone", "utile", "de", "la", "grille", "de", "jeu", "dans", "un", "fichier", "au", "format", "Plain", "Text" ]
[ "\"\"\" Sauvegarde la zone utile de la grille de jeu dans un fichier au format Plain Text \"\"\"" ]
[ { "param": "chemin_fichier", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chemin_fichier", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
charger_fichier_plaintext
<not_specific>
def charger_fichier_plaintext(chemin_fichier): """ Retourne la structure contenue dans un fichier au format Plain Text (.cells) """ structure = [] no_ligne = 0 max_colonnes = 0 fichier = open(chemin_fichier, "r") for ligne_fichier in fichier: no_ligne += 1 ligne_fichier = ligne_f...
Retourne la structure contenue dans un fichier au format Plain Text (.cells)
Retourne la structure contenue dans un fichier au format Plain Text (.cells)
[ "Retourne", "la", "structure", "contenue", "dans", "un", "fichier", "au", "format", "Plain", "Text", "(", ".", "cells", ")" ]
def charger_fichier_plaintext(chemin_fichier): structure = [] no_ligne = 0 max_colonnes = 0 fichier = open(chemin_fichier, "r") for ligne_fichier in fichier: no_ligne += 1 ligne_fichier = ligne_fichier.strip() if not ligne_fichier.startswith("!"): if len(ligne_fic...
[ "def", "charger_fichier_plaintext", "(", "chemin_fichier", ")", ":", "structure", "=", "[", "]", "no_ligne", "=", "0", "max_colonnes", "=", "0", "fichier", "=", "open", "(", "chemin_fichier", ",", "\"r\"", ")", "for", "ligne_fichier", "in", "fichier", ":", "...
Retourne la structure contenue dans un fichier au format Plain Text (.cells)
[ "Retourne", "la", "structure", "contenue", "dans", "un", "fichier", "au", "format", "Plain", "Text", "(", ".", "cells", ")" ]
[ "\"\"\" Retourne la structure contenue dans un fichier au format Plain Text (.cells) \"\"\"", "# Certains fichiers du LifeWiki ne respectent pas la spécification sur", "# https://www.conwaylife.com/wiki/Plaintext et ne mentionnent pas les cellules mortes en fin de", "# ligne, ni les lignes composées uniquemen...
[ { "param": "chemin_fichier", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chemin_fichier", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
charger_fichier_run_length_encoded
<not_specific>
def charger_fichier_run_length_encoded(chemin_fichier): """ Retourne la structure contenue dans un fichier au format Run Length Encoded (.rle) """ structure = [] ligne = [] nb_cellules = 0 nb_lignes = 0 nombre = 0 fin = False no_ligne = 0 fichier = open(chemin_fichier, "r") for l...
Retourne la structure contenue dans un fichier au format Run Length Encoded (.rle)
Retourne la structure contenue dans un fichier au format Run Length Encoded (.rle)
[ "Retourne", "la", "structure", "contenue", "dans", "un", "fichier", "au", "format", "Run", "Length", "Encoded", "(", ".", "rle", ")" ]
def charger_fichier_run_length_encoded(chemin_fichier): structure = [] ligne = [] nb_cellules = 0 nb_lignes = 0 nombre = 0 fin = False no_ligne = 0 fichier = open(chemin_fichier, "r") for ligne_fichier in fichier: no_ligne += 1 ligne_fichier = ligne_fichier.strip() ...
[ "def", "charger_fichier_run_length_encoded", "(", "chemin_fichier", ")", ":", "structure", "=", "[", "]", "ligne", "=", "[", "]", "nb_cellules", "=", "0", "nb_lignes", "=", "0", "nombre", "=", "0", "fin", "=", "False", "no_ligne", "=", "0", "fichier", "=",...
Retourne la structure contenue dans un fichier au format Run Length Encoded (.rle)
[ "Retourne", "la", "structure", "contenue", "dans", "un", "fichier", "au", "format", "Run", "Length", "Encoded", "(", ".", "rle", ")" ]
[ "\"\"\" Retourne la structure contenue dans un fichier au format Run Length Encoded (.rle) \"\"\"" ]
[ { "param": "chemin_fichier", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chemin_fichier", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c3d8f098409d6ec4befe208c0a0bf8b60fc749ae
HubTou/JeuDeLaVie
vie.py
[ "BSD-3-Clause" ]
Python
charger_fichier
<not_specific>
def charger_fichier(chemin_fichier): """ Retourne la structure contenue dans un fichier """ if chemin_fichier.lower().endswith(".cells"): return charger_fichier_plaintext(chemin_fichier) elif chemin_fichier.lower().endswith(".rle"): return charger_fichier_run_length_encoded(chemin_fichier)
Retourne la structure contenue dans un fichier
Retourne la structure contenue dans un fichier
[ "Retourne", "la", "structure", "contenue", "dans", "un", "fichier" ]
def charger_fichier(chemin_fichier): if chemin_fichier.lower().endswith(".cells"): return charger_fichier_plaintext(chemin_fichier) elif chemin_fichier.lower().endswith(".rle"): return charger_fichier_run_length_encoded(chemin_fichier)
[ "def", "charger_fichier", "(", "chemin_fichier", ")", ":", "if", "chemin_fichier", ".", "lower", "(", ")", ".", "endswith", "(", "\".cells\"", ")", ":", "return", "charger_fichier_plaintext", "(", "chemin_fichier", ")", "elif", "chemin_fichier", ".", "lower", "(...
Retourne la structure contenue dans un fichier
[ "Retourne", "la", "structure", "contenue", "dans", "un", "fichier" ]
[ "\"\"\" Retourne la structure contenue dans un fichier \"\"\"" ]
[ { "param": "chemin_fichier", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chemin_fichier", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
29b9fd804fd4122b86e1b581f30d966c4b185d8e
arifmudi/Natural-Language-Processing-and-Computational-Linguistics
code/Chapter_6.py
[ "MIT" ]
Python
main
null
def main(model=None, output_dir=None, n_iter=100): """Load the model, set up the pipeline and train the entity recognizer.""" if model is not None: nlp = spacy.load(model) # load existing spaCy model print("Loaded model '%s'" % model) else: nlp = spacy.blank('en') # create blank La...
Load the model, set up the pipeline and train the entity recognizer.
Load the model, set up the pipeline and train the entity recognizer.
[ "Load", "the", "model", "set", "up", "the", "pipeline", "and", "train", "the", "entity", "recognizer", "." ]
def main(model=None, output_dir=None, n_iter=100): if model is not None: nlp = spacy.load(model) print("Loaded model '%s'" % model) else: nlp = spacy.blank('en') print("Created blank 'en' model") if 'ner' not in nlp.pipe_names: ner = nlp.create_pipe('ner') ...
[ "def", "main", "(", "model", "=", "None", ",", "output_dir", "=", "None", ",", "n_iter", "=", "100", ")", ":", "if", "model", "is", "not", "None", ":", "nlp", "=", "spacy", ".", "load", "(", "model", ")", "print", "(", "\"Loaded model '%s'\"", "%", ...
Load the model, set up the pipeline and train the entity recognizer.
[ "Load", "the", "model", "set", "up", "the", "pipeline", "and", "train", "the", "entity", "recognizer", "." ]
[ "\"\"\"Load the model, set up the pipeline and train the entity recognizer.\"\"\"", "# load existing spaCy model", "# create blank Language class", "# create the built-in pipeline components and add them to the pipeline", "# nlp.create_pipe works for built-ins that are registered with spaCy", "# otherwise...
[ { "param": "model", "type": null }, { "param": "output_dir", "type": null }, { "param": "n_iter", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output_dir", "type": null, "docstring": null, "docstring_tok...
29b9fd804fd4122b86e1b581f30d966c4b185d8e
arifmudi/Natural-Language-Processing-and-Computational-Linguistics
code/Chapter_6.py
[ "MIT" ]
Python
main
null
def main(model=None, new_model_name='animal', output_dir=None, n_iter=20): """Set up the pipeline and entity recognizer, and train the new entity.""" if model is not None: nlp = spacy.load(model) # load existing spaCy model print("Loaded model '%s'" % model) else: nlp = spacy.blank(...
Set up the pipeline and entity recognizer, and train the new entity.
Set up the pipeline and entity recognizer, and train the new entity.
[ "Set", "up", "the", "pipeline", "and", "entity", "recognizer", "and", "train", "the", "new", "entity", "." ]
def main(model=None, new_model_name='animal', output_dir=None, n_iter=20): if model is not None: nlp = spacy.load(model) print("Loaded model '%s'" % model) else: nlp = spacy.blank('en') print("Created blank 'en' model") if 'ner' not in nlp.pipe_names: ner = nlp.cr...
[ "def", "main", "(", "model", "=", "None", ",", "new_model_name", "=", "'animal'", ",", "output_dir", "=", "None", ",", "n_iter", "=", "20", ")", ":", "if", "model", "is", "not", "None", ":", "nlp", "=", "spacy", ".", "load", "(", "model", ")", "pri...
Set up the pipeline and entity recognizer, and train the new entity.
[ "Set", "up", "the", "pipeline", "and", "entity", "recognizer", "and", "train", "the", "new", "entity", "." ]
[ "\"\"\"Set up the pipeline and entity recognizer, and train the new entity.\"\"\"", "# load existing spaCy model", "# create blank Language class", "# Add entity recognizer to model if it's not in the pipeline", "# nlp.create_pipe works for built-ins that are registered with spaCy", "# otherwise, get it, ...
[ { "param": "model", "type": null }, { "param": "new_model_name", "type": null }, { "param": "output_dir", "type": null }, { "param": "n_iter", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "new_model_name", "type": null, "docstring": null, "docstring...
d19f406a2c56885f669849eff5ad33a3512f19bf
arifmudi/Natural-Language-Processing-and-Computational-Linguistics
code/chapter_15.py
[ "MIT" ]
Python
print_top10
null
def print_top10(vectorizer, clf, class_labels): """Prints features with the highest coefficient values, per class""" feature_names = vectorizer.get_feature_names() for i, class_label in enumerate(class_labels): top10 = np.argsort(clf.coef_[i])[-10:] print("%s: %s" % (class_label, ...
Prints features with the highest coefficient values, per class
Prints features with the highest coefficient values, per class
[ "Prints", "features", "with", "the", "highest", "coefficient", "values", "per", "class" ]
def print_top10(vectorizer, clf, class_labels): feature_names = vectorizer.get_feature_names() for i, class_label in enumerate(class_labels): top10 = np.argsort(clf.coef_[i])[-10:] print("%s: %s" % (class_label, " ".join(feature_names[j] for j in top10)))
[ "def", "print_top10", "(", "vectorizer", ",", "clf", ",", "class_labels", ")", ":", "feature_names", "=", "vectorizer", ".", "get_feature_names", "(", ")", "for", "i", ",", "class_label", "in", "enumerate", "(", "class_labels", ")", ":", "top10", "=", "np", ...
Prints features with the highest coefficient values, per class
[ "Prints", "features", "with", "the", "highest", "coefficient", "values", "per", "class" ]
[ "\"\"\"Prints features with the highest coefficient values, per class\"\"\"" ]
[ { "param": "vectorizer", "type": null }, { "param": "clf", "type": null }, { "param": "class_labels", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "vectorizer", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "clf", "type": null, "docstring": null, "docstring_token...
8f595bef4910e8c2fa58d183b84a784950ca8571
arifmudi/Natural-Language-Processing-and-Computational-Linguistics
code/Chapter_7.py
[ "MIT" ]
Python
main
null
def main(model=None, output_dir=None, n_iter=5): """Load the model, set up the pipeline and train the parser.""" if model is not None: nlp = spacy.load(model) # load existing spaCy model print("Loaded model '%s'" % model) else: nlp = spacy.blank('en') # create blank Language class ...
Load the model, set up the pipeline and train the parser.
Load the model, set up the pipeline and train the parser.
[ "Load", "the", "model", "set", "up", "the", "pipeline", "and", "train", "the", "parser", "." ]
def main(model=None, output_dir=None, n_iter=5): if model is not None: nlp = spacy.load(model) print("Loaded model '%s'" % model) else: nlp = spacy.blank('en') print("Created blank 'en' model") if 'parser' in nlp.pipe_names: nlp.remove_pipe('parser') parser = ...
[ "def", "main", "(", "model", "=", "None", ",", "output_dir", "=", "None", ",", "n_iter", "=", "5", ")", ":", "if", "model", "is", "not", "None", ":", "nlp", "=", "spacy", ".", "load", "(", "model", ")", "print", "(", "\"Loaded model '%s'\"", "%", "...
Load the model, set up the pipeline and train the parser.
[ "Load", "the", "model", "set", "up", "the", "pipeline", "and", "train", "the", "parser", "." ]
[ "\"\"\"Load the model, set up the pipeline and train the parser.\"\"\"", "# load existing spaCy model", "# create blank Language class", "# We'll use the built-in dependency parser class, but we want to create a", "# fresh instance – just in case.", "# only train parser", "# test the trained model", "...
[ { "param": "model", "type": null }, { "param": "output_dir", "type": null }, { "param": "n_iter", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output_dir", "type": null, "docstring": null, "docstring_tok...
dc47108959f9385169513c9b5531da0d4707396e
arifmudi/Natural-Language-Processing-and-Computational-Linguistics
code/chapter_14.py
[ "MIT" ]
Python
load_data
<not_specific>
def load_data(limit=0, split=0.8): """Load data from the IMDB dataset.""" # Partition off part of the train data for evaluation train_data, _ = thinc.extra.datasets.imdb() random.shuffle(train_data) train_data = train_data[-limit:] texts, labels = zip(*train_data) cats = [{'POSITIVE': bool(y...
Load data from the IMDB dataset.
Load data from the IMDB dataset.
[ "Load", "data", "from", "the", "IMDB", "dataset", "." ]
def load_data(limit=0, split=0.8): train_data, _ = thinc.extra.datasets.imdb() random.shuffle(train_data) train_data = train_data[-limit:] texts, labels = zip(*train_data) cats = [{'POSITIVE': bool(y)} for y in labels] split = int(len(train_data) * split) return (texts[:split], cats[:split])...
[ "def", "load_data", "(", "limit", "=", "0", ",", "split", "=", "0.8", ")", ":", "train_data", ",", "_", "=", "thinc", ".", "extra", ".", "datasets", ".", "imdb", "(", ")", "random", ".", "shuffle", "(", "train_data", ")", "train_data", "=", "train_da...
Load data from the IMDB dataset.
[ "Load", "data", "from", "the", "IMDB", "dataset", "." ]
[ "\"\"\"Load data from the IMDB dataset.\"\"\"", "# Partition off part of the train data for evaluation" ]
[ { "param": "limit", "type": null }, { "param": "split", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "limit", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "split", "type": null, "docstring": null, "docstring_tokens":...
0057c97eb83422898f180e7b66340e66d23eaf53
LionKimbro/treelinefmt
inject/treeline.py
[ "CC0-1.0" ]
Python
save
null
def save(path=None): """Save a .trln file. When path is not supplied, uses the path that was specified when the file was loaded. """ json.dump(g[CONTENT], open(g[PATH], "w", encoding="utf-8"), indent=g[INDENT])
Save a .trln file. When path is not supplied, uses the path that was specified when the file was loaded.
Save a .trln file. When path is not supplied, uses the path that was specified when the file was loaded.
[ "Save", "a", ".", "trln", "file", ".", "When", "path", "is", "not", "supplied", "uses", "the", "path", "that", "was", "specified", "when", "the", "file", "was", "loaded", "." ]
def save(path=None): json.dump(g[CONTENT], open(g[PATH], "w", encoding="utf-8"), indent=g[INDENT])
[ "def", "save", "(", "path", "=", "None", ")", ":", "json", ".", "dump", "(", "g", "[", "CONTENT", "]", ",", "open", "(", "g", "[", "PATH", "]", ",", "\"w\"", ",", "encoding", "=", "\"utf-8\"", ")", ",", "indent", "=", "g", "[", "INDENT", "]", ...
Save a .trln file.
[ "Save", "a", ".", "trln", "file", "." ]
[ "\"\"\"Save a .trln file.\n\n When path is not supplied, uses the path that was specified when the\n file was loaded.\n \"\"\"" ]
[ { "param": "path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d5cb85d9b4e9f7d04f529634930ef451697fd117
LionKimbro/treelinefmt
inject/injectionspec.py
[ "CC0-1.0" ]
Python
read
null
def read(path): """Read an injection .txt file into .content.""" reset() g[CONTENT] = open(path, encoding="utf-8").read().splitlines() scan()
Read an injection .txt file into .content.
Read an injection .txt file into .content.
[ "Read", "an", "injection", ".", "txt", "file", "into", ".", "content", "." ]
def read(path): reset() g[CONTENT] = open(path, encoding="utf-8").read().splitlines() scan()
[ "def", "read", "(", "path", ")", ":", "reset", "(", ")", "g", "[", "CONTENT", "]", "=", "open", "(", "path", ",", "encoding", "=", "\"utf-8\"", ")", ".", "read", "(", ")", ".", "splitlines", "(", ")", "scan", "(", ")" ]
Read an injection .txt file into .content.
[ "Read", "an", "injection", ".", "txt", "file", "into", ".", "content", "." ]
[ "\"\"\"Read an injection .txt file into .content.\"\"\"" ]
[ { "param": "path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d5cb85d9b4e9f7d04f529634930ef451697fd117
LionKimbro/treelinefmt
inject/injectionspec.py
[ "CC0-1.0" ]
Python
scan
null
def scan(): """Scan .contents into global tables.""" for i, ln in enumerate(g[CONTENT]): if not ln.strip(): # ignore a blank line continue if ln[0] == "#": # ignore a comment line continue line.read(ln) if line.g[INDENT] == 0: finish_format()...
Scan .contents into global tables.
Scan .contents into global tables.
[ "Scan", ".", "contents", "into", "global", "tables", "." ]
def scan(): for i, ln in enumerate(g[CONTENT]): if not ln.strip(): continue if ln[0] == "#": continue line.read(ln) if line.g[INDENT] == 0: finish_format() start_format() elif line.g[INDENT] == 2: if w0() == INJS...
[ "def", "scan", "(", ")", ":", "for", "i", ",", "ln", "in", "enumerate", "(", "g", "[", "CONTENT", "]", ")", ":", "if", "not", "ln", ".", "strip", "(", ")", ":", "continue", "if", "ln", "[", "0", "]", "==", "\"#\"", ":", "continue", "line", "....
Scan .contents into global tables.
[ "Scan", ".", "contents", "into", "global", "tables", "." ]
[ "\"\"\"Scan .contents into global tables.\"\"\"", "# ignore a blank line", "# ignore a comment line", "# work was done in the function" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fce50893366ffe637d7584aa1b5f3bf0dd73e15e
tfing/cros-tools
tot.py
[ "CC0-1.0" ]
Python
main
null
def main(args): """This is the main entrypoint for fromupstream. Args: args: sys.argv[1:] Returns: An int return code. """ parser = argparse.ArgumentParser() parser.add_argument('target', help='tot name or change id. tot names are ' ...
This is the main entrypoint for fromupstream. Args: args: sys.argv[1:] Returns: An int return code.
This is the main entrypoint for fromupstream.
[ "This", "is", "the", "main", "entrypoint", "for", "fromupstream", "." ]
def main(args): parser = argparse.ArgumentParser() parser.add_argument('target', help='tot name or change id. tot names are ' 'atf, blob, coreboot, depthcharge, ec, debug, kernel ' 'and vboot. tot group name is fw.') parser.add_argumen...
[ "def", "main", "(", "args", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'target'", ",", "help", "=", "'tot name or change id. tot names are '", "'atf, blob, coreboot, depthcharge, ec, debug, kernel '", "'and...
This is the main entrypoint for fromupstream.
[ "This", "is", "the", "main", "entrypoint", "for", "fromupstream", "." ]
[ "\"\"\"This is the main entrypoint for fromupstream.\n\n Args:\n args: sys.argv[1:]\n\n Returns:\n An int return code.\n \"\"\"", "# print('target', args.target)", "# print('board', args.board)", "# checkout_target(change_id, branch_postfix, patchset)", "# append branch name to eas...
[ { "param": "args", "type": null } ]
{ "returns": [ { "docstring": "An int return code.", "docstring_tokens": [ "An", "int", "return", "code", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "args", "type": null, "docstring": null, ...
2dd49fdb9ceb04e59434271ded35ecefdc4f074e
devmichaelgirgis/android-perf-testing
run_perf_tests.py
[ "Apache-2.0" ]
Python
perform_systrace
null
def perform_systrace(sdk_path, device_id, dest_dir, package_name): """Execution code for a systrace thread.""" package_parameter = '--app=' + package_name systrace_path = os.path.join(sdk_path, 'platform-tools', 'systrace', 'systrace.py') systrace_command = ['python', s...
Execution code for a systrace thread.
Execution code for a systrace thread.
[ "Execution", "code", "for", "a", "systrace", "thread", "." ]
def perform_systrace(sdk_path, device_id, dest_dir, package_name): package_parameter = '--app=' + package_name systrace_path = os.path.join(sdk_path, 'platform-tools', 'systrace', 'systrace.py') systrace_command = ['python', systrace_path, '--serial='...
[ "def", "perform_systrace", "(", "sdk_path", ",", "device_id", ",", "dest_dir", ",", "package_name", ")", ":", "package_parameter", "=", "'--app='", "+", "package_name", "systrace_path", "=", "os", ".", "path", ".", "join", "(", "sdk_path", ",", "'platform-tools'...
Execution code for a systrace thread.
[ "Execution", "code", "for", "a", "systrace", "thread", "." ]
[ "\"\"\"Execution code for a systrace thread.\"\"\"" ]
[ { "param": "sdk_path", "type": null }, { "param": "device_id", "type": null }, { "param": "dest_dir", "type": null }, { "param": "package_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sdk_path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "device_id", "type": null, "docstring": null, "docstring_t...