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
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
check_exists
<not_specific>
def check_exists(self, row, xpath): """ Checks if an xpath exists `Required` :param row: row to find path on :param str xpath: xpath to check that exists """ try: row.find_element_by_xpath(xpath) return True except NoSuch...
Checks if an xpath exists `Required` :param row: row to find path on :param str xpath: xpath to check that exists
Checks if an xpath exists `Required`
[ "Checks", "if", "an", "xpath", "exists", "`", "Required", "`" ]
def check_exists(self, row, xpath): try: row.find_element_by_xpath(xpath) return True except NoSuchElementException: return False
[ "def", "check_exists", "(", "self", ",", "row", ",", "xpath", ")", ":", "try", ":", "row", ".", "find_element_by_xpath", "(", "xpath", ")", "return", "True", "except", "NoSuchElementException", ":", "return", "False" ]
Checks if an xpath exists `Required`
[ "Checks", "if", "an", "xpath", "exists", "`", "Required", "`" ]
[ "\"\"\"\n Checks if an xpath exists\n\n `Required`\n :param row: row to find path on\n :param str xpath: xpath to check that exists\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "row", "type": null }, { "param": "xpath", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "row", "type": null, "docstring": "row to find path on", "docs...
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
_get_total_pages
null
def _get_total_pages(self): """ Gets the the total page that exists. """ total_pages = self.browser.find_element_by_xpath('//*[@id="__next"]/div/div[1]/div[1]/div/div[2]/div/div/div/div/div[1]/div[2]').text self.total_pages = int(total_pages.split(' ')[1])
Gets the the total page that exists.
Gets the the total page that exists.
[ "Gets", "the", "the", "total", "page", "that", "exists", "." ]
def _get_total_pages(self): total_pages = self.browser.find_element_by_xpath('//*[@id="__next"]/div/div[1]/div[1]/div/div[2]/div/div/div/div/div[1]/div[2]').text self.total_pages = int(total_pages.split(' ')[1])
[ "def", "_get_total_pages", "(", "self", ")", ":", "total_pages", "=", "self", ".", "browser", ".", "find_element_by_xpath", "(", "'//*[@id=\"__next\"]/div/div[1]/div[1]/div/div[2]/div/div/div/div/div[1]/div[2]'", ")", ".", "text", "self", ".", "total_pages", "=", "int", ...
Gets the the total page that exists.
[ "Gets", "the", "the", "total", "page", "that", "exists", "." ]
[ "\"\"\"\n Gets the the total page that exists.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
scrape_rows
null
def scrape_rows(self): """ Scrapes the data on a page """ rows = self.browser.find_elements_by_css_selector('div.master > div.root > div > div:nth-child(3) > div > div > div > div > div.table-responsive > table > tbody > tr.row.styles_item__L_bVx') for row in rows: fr...
Scrapes the data on a page
Scrapes the data on a page
[ "Scrapes", "the", "data", "on", "a", "page" ]
def scrape_rows(self): rows = self.browser.find_elements_by_css_selector('div.master > div.root > div > div:nth-child(3) > div > div > div > div > div.table-responsive > table > tbody > tr.row.styles_item__L_bVx') for row in rows: fromAddress = row.find_element_by_xpath('.//td[5]/span') if s...
[ "def", "scrape_rows", "(", "self", ")", ":", "rows", "=", "self", ".", "browser", ".", "find_elements_by_css_selector", "(", "'div.master > div.root > div > div:nth-child(3) > div > div > div > div > div.table-responsive > table > tbody > tr.row.styles_item__L_bVx'", ")", "for", "r...
Scrapes the data on a page
[ "Scrapes", "the", "data", "on", "a", "page" ]
[ "\"\"\"\n Scrapes the data on a page\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
main
None
async def main(self) -> None: """ Creates the ClientSession and loops through the list of urls to extract data from """ tasks = [] async with aiohttp.ClientSession(headers=self.headers) as session: for url in self.urls: log(f"Making connections to url:...
Creates the ClientSession and loops through the list of urls to extract data from
Creates the ClientSession and loops through the list of urls to extract data from
[ "Creates", "the", "ClientSession", "and", "loops", "through", "the", "list", "of", "urls", "to", "extract", "data", "from" ]
async def main(self) -> None: tasks = [] async with aiohttp.ClientSession(headers=self.headers) as session: for url in self.urls: log(f"Making connections to url: {url}...") tasks.append(self.fetch(session, url)) htmls = await asyncio.gather(*tasks...
[ "async", "def", "main", "(", "self", ")", "->", "None", ":", "tasks", "=", "[", "]", "async", "with", "aiohttp", ".", "ClientSession", "(", "headers", "=", "self", ".", "headers", ")", "as", "session", ":", "for", "url", "in", "self", ".", "urls", ...
Creates the ClientSession and loops through the list of urls to extract data from
[ "Creates", "the", "ClientSession", "and", "loops", "through", "the", "list", "of", "urls", "to", "extract", "data", "from" ]
[ "\"\"\"\n Creates the ClientSession and loops through the list of urls to extract data from\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
log
null
def log(msg: str, level='debug'): """ Log output to the console `Optional` :param str level: Level of verbosity `Required` :param str msg: Data to display on console """ logging.basicConfig(level=logging.DEBUG if globals()['_debug'] else logging.INFO, handlers=[logging.StreamHand...
Log output to the console `Optional` :param str level: Level of verbosity `Required` :param str msg: Data to display on console
Log output to the console `Optional`
[ "Log", "output", "to", "the", "console", "`", "Optional", "`" ]
def log(msg: str, level='debug'): logging.basicConfig(level=logging.DEBUG if globals()['_debug'] else logging.INFO, handlers=[logging.StreamHandler()]) logger = logging.getLogger() getattr(logger, level if hasattr(logger, level) else 'debug')(str(msg))
[ "def", "log", "(", "msg", ":", "str", ",", "level", "=", "'debug'", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", "if", "globals", "(", ")", "[", "'_debug'", "]", "else", "logging", ".", "INFO", ",", "handlers",...
Log output to the console `Optional`
[ "Log", "output", "to", "the", "console", "`", "Optional", "`" ]
[ "\"\"\"\n Log output to the console\n\n `Optional`\n :param str level: Level of verbosity\n\n `Required`\n :param str msg: Data to display on console\n \"\"\"" ]
[ { "param": "msg", "type": "str" }, { "param": "level", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "msg", "type": "str", "docstring": "Data to display on console", "docstring_tokens": [ "Data", "to", "display", "on", "console" ], "default": null, "is_optional": false ...
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
create_urls
<not_specific>
def create_urls(address): """ Creates the list of url for the different pages on the api `Required` :param str address: Address to use for the creation of the url """ urls = [] url = string.Template("https://indexer.algoexplorerapi.io/rl/v1/transactions?page=${page}&&limit=10&&address=$...
Creates the list of url for the different pages on the api `Required` :param str address: Address to use for the creation of the url
Creates the list of url for the different pages on the api `Required`
[ "Creates", "the", "list", "of", "url", "for", "the", "different", "pages", "on", "the", "api", "`", "Required", "`" ]
def create_urls(address): urls = [] url = string.Template("https://indexer.algoexplorerapi.io/rl/v1/transactions?page=${page}&&limit=10&&address=${address}") log(f"Getting number of pages for {address}...", "info") response = requests.get(url.substitute(page=1, address=address)) if response.status_c...
[ "def", "create_urls", "(", "address", ")", ":", "urls", "=", "[", "]", "url", "=", "string", ".", "Template", "(", "\"https://indexer.algoexplorerapi.io/rl/v1/transactions?page=${page}&&limit=10&&address=${address}\"", ")", "log", "(", "f\"Getting number of pages for {address...
Creates the list of url for the different pages on the api `Required`
[ "Creates", "the", "list", "of", "url", "for", "the", "different", "pages", "on", "the", "api", "`", "Required", "`" ]
[ "\"\"\"\n Creates the list of url for the different pages on the api\n\n `Required`\n :param str address: Address to use for the creation of the url\n \"\"\"" ]
[ { "param": "address", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "address", "type": null, "docstring": "Address to use for the creation of the url", "docstring_tokens": [ "Address", "to", "use", "for", "the", "creation", "of", "...
4719cbed1deadfcac7293b691f197ccf777cdc13
BdVade/Voting
Rewards2/Dhanny_reward2/run.py
[ "Apache-2.0" ]
Python
write_csv
null
def write_csv(all_data, wallet, type): """ Writes to a csv file the data received with a filename of the walletaddress and the scantype (algoexplorer or algoscan) `Required` :param list all_data: A list of data containing `from`,`to` and `amount` :param str wallet: The wallet address :pa...
Writes to a csv file the data received with a filename of the walletaddress and the scantype (algoexplorer or algoscan) `Required` :param list all_data: A list of data containing `from`,`to` and `amount` :param str wallet: The wallet address :param str type: Scan type (algoexplorer/a...
Writes to a csv file the data received with a filename of the walletaddress and the scantype (algoexplorer or algoscan) `Required`
[ "Writes", "to", "a", "csv", "file", "the", "data", "received", "with", "a", "filename", "of", "the", "walletaddress", "and", "the", "scantype", "(", "algoexplorer", "or", "algoscan", ")", "`", "Required", "`" ]
def write_csv(all_data, wallet, type): log("Writing to csv file", "info") header = ["from", "to","amount"] filename = f"{wallet}_{type}.csv" with open(filename, "w", encoding="UTF-8") as f: writer = csv.DictWriter(f, fieldnames=header) writer.writeheader() writer.writerows(all_da...
[ "def", "write_csv", "(", "all_data", ",", "wallet", ",", "type", ")", ":", "log", "(", "\"Writing to csv file\"", ",", "\"info\"", ")", "header", "=", "[", "\"from\"", ",", "\"to\"", ",", "\"amount\"", "]", "filename", "=", "f\"{wallet}_{type}.csv\"", "with", ...
Writes to a csv file the data received with a filename of the walletaddress and the scantype (algoexplorer or algoscan) `Required`
[ "Writes", "to", "a", "csv", "file", "the", "data", "received", "with", "a", "filename", "of", "the", "walletaddress", "and", "the", "scantype", "(", "algoexplorer", "or", "algoscan", ")", "`", "Required", "`" ]
[ "\"\"\"\n Writes to a csv file the data received with a filename of the walletaddress and the scantype (algoexplorer or algoscan)\n\n `Required`\n :param list all_data: A list of data containing `from`,`to` and `amount`\n :param str wallet: The wallet address\n :param str type: Scan typ...
[ { "param": "all_data", "type": null }, { "param": "wallet", "type": null }, { "param": "type", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "all_data", "type": null, "docstring": "A list of data containing `from`,`to` and `amount`", "docstring_tokens": [ "A", "list", "of", "data", "containing", "`", "from", ...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
validate_escrow_wallet
bool
def validate_escrow_wallet(address: str, _mnemonic: str, client) -> bool: """Validate an escrow wallet and check it has sufficient funds and is opted in to Choice Coin.""" if not is_valid_address(address): return False # compare the address to the address gotten from the mnemonic if account.add...
Validate an escrow wallet and check it has sufficient funds and is opted in to Choice Coin.
Validate an escrow wallet and check it has sufficient funds and is opted in to Choice Coin.
[ "Validate", "an", "escrow", "wallet", "and", "check", "it", "has", "sufficient", "funds", "and", "is", "opted", "in", "to", "Choice", "Coin", "." ]
def validate_escrow_wallet(address: str, _mnemonic: str, client) -> bool: if not is_valid_address(address): return False if account.address_from_private_key(mnemonic.to_private_key(_mnemonic)) != address: return False if not contains_choice_coin(address, client): return False if ...
[ "def", "validate_escrow_wallet", "(", "address", ":", "str", ",", "_mnemonic", ":", "str", ",", "client", ")", "->", "bool", ":", "if", "not", "is_valid_address", "(", "address", ")", ":", "return", "False", "if", "account", ".", "address_from_private_key", ...
Validate an escrow wallet and check it has sufficient funds and is opted in to Choice Coin.
[ "Validate", "an", "escrow", "wallet", "and", "check", "it", "has", "sufficient", "funds", "and", "is", "opted", "in", "to", "Choice", "Coin", "." ]
[ "\"\"\"Validate an escrow wallet and check it has sufficient funds and is opted in to Choice Coin.\"\"\"", "# compare the address to the address gotten from the mnemonic" ]
[ { "param": "address", "type": "str" }, { "param": "_mnemonic", "type": "str" }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "address", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "_mnemonic", "type": "str", "docstring": null, "docstring_...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
contains_choice_coin
bool
def contains_choice_coin(address: str, client) -> bool: """Checks if the address is opted into Vote Coin.""" account = client.account_info(address) contains_choice = False for asset in account["assets"]: if asset["asset-id"] == ASSET_ID: contains_vote = True break r...
Checks if the address is opted into Vote Coin.
Checks if the address is opted into Vote Coin.
[ "Checks", "if", "the", "address", "is", "opted", "into", "Vote", "Coin", "." ]
def contains_choice_coin(address: str, client) -> bool: account = client.account_info(address) contains_choice = False for asset in account["assets"]: if asset["asset-id"] == ASSET_ID: contains_vote = True break return contains_vote
[ "def", "contains_choice_coin", "(", "address", ":", "str", ",", "client", ")", "->", "bool", ":", "account", "=", "client", ".", "account_info", "(", "address", ")", "contains_choice", "=", "False", "for", "asset", "in", "account", "[", "\"assets\"", "]", ...
Checks if the address is opted into Vote Coin.
[ "Checks", "if", "the", "address", "is", "opted", "into", "Vote", "Coin", "." ]
[ "\"\"\"Checks if the address is opted into Vote Coin.\"\"\"" ]
[ { "param": "address", "type": "str" }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "address", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "client", "type": null, "docstring": null, "docstring_toke...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
create_option_account
str
def create_option_account(escrow_private_key: str, escrow_address: str, client) -> str: """Creates an account for option.""" # This is the amount of Algo to fund the account with. The unit is microAlgos. AMOUNT = 1000000 private_key, address = account.generate_account() is_successful = fund_addres...
Creates an account for option.
Creates an account for option.
[ "Creates", "an", "account", "for", "option", "." ]
def create_option_account(escrow_private_key: str, escrow_address: str, client) -> str: AMOUNT = 1000000 private_key, address = account.generate_account() is_successful = fund_address(AMOUNT, address, escrow_address, escrow_private_key, client) if not is_successful: raise Exception("Funding Fail...
[ "def", "create_option_account", "(", "escrow_private_key", ":", "str", ",", "escrow_address", ":", "str", ",", "client", ")", "->", "str", ":", "AMOUNT", "=", "1000000", "private_key", ",", "address", "=", "account", ".", "generate_account", "(", ")", "is_succ...
Creates an account for option.
[ "Creates", "an", "account", "for", "option", "." ]
[ "\"\"\"Creates an account for option.\"\"\"", "# This is the amount of Algo to fund the account with. The unit is microAlgos." ]
[ { "param": "escrow_private_key", "type": "str" }, { "param": "escrow_address", "type": "str" }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "escrow_private_key", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "escrow_address", "type": "str", "docstring": null, ...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
fund_address
bool
def fund_address( amount: int, recipient_address: str, escrow_address: str, escrow_private_key: str, client ) -> bool: """Fund an account with Algo.""" suggested_params = client.suggested_params() unsigned_transaction = PaymentTxn( escrow_address, suggested_params, recipient_addr...
Fund an account with Algo.
Fund an account with Algo.
[ "Fund", "an", "account", "with", "Algo", "." ]
def fund_address( amount: int, recipient_address: str, escrow_address: str, escrow_private_key: str, client ) -> bool: suggested_params = client.suggested_params() unsigned_transaction = PaymentTxn( escrow_address, suggested_params, recipient_address, amount, note="In...
[ "def", "fund_address", "(", "amount", ":", "int", ",", "recipient_address", ":", "str", ",", "escrow_address", ":", "str", ",", "escrow_private_key", ":", "str", ",", "client", ")", "->", "bool", ":", "suggested_params", "=", "client", ".", "suggested_params",...
Fund an account with Algo.
[ "Fund", "an", "account", "with", "Algo", "." ]
[ "\"\"\"Fund an account with Algo.\"\"\"" ]
[ { "param": "amount", "type": "int" }, { "param": "recipient_address", "type": "str" }, { "param": "escrow_address", "type": "str" }, { "param": "escrow_private_key", "type": "str" }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "amount", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "recipient_address", "type": "str", "docstring": null, "doc...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
opt_in_to_vote
bool
def opt_in_to_vote(private_key: str, address: str, client) -> bool: """Opt in a wallet to vote Coin.""" suggested_params = client.suggested_params() if not contains_choice_coin(address, client): unsigned_transaction = AssetTransferTxn( address, suggested_params, address, 0, ASSET_ID ...
Opt in a wallet to vote Coin.
Opt in a wallet to vote Coin.
[ "Opt", "in", "a", "wallet", "to", "vote", "Coin", "." ]
def opt_in_to_vote(private_key: str, address: str, client) -> bool: suggested_params = client.suggested_params() if not contains_choice_coin(address, client): unsigned_transaction = AssetTransferTxn( address, suggested_params, address, 0, ASSET_ID ) signed_transaction = unsig...
[ "def", "opt_in_to_vote", "(", "private_key", ":", "str", ",", "address", ":", "str", ",", "client", ")", "->", "bool", ":", "suggested_params", "=", "client", ".", "suggested_params", "(", ")", "if", "not", "contains_choice_coin", "(", "address", ",", "clien...
Opt in a wallet to vote Coin.
[ "Opt", "in", "a", "wallet", "to", "vote", "Coin", "." ]
[ "\"\"\"Opt in a wallet to vote Coin.\"\"\"" ]
[ { "param": "private_key", "type": "str" }, { "param": "address", "type": "str" }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "private_key", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": "str", "docstring": null, "docstrin...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
vote
null
def vote(escrow_private_key, escrow_address, option_zero_address, option_one_address, client): """Places a vote based on the input of the user.""" voter = int(input("Vote 0 for zero and vote 1 for one: ")) if voter == 1: make_vote( escrow_address, escrow_private_key, ...
Places a vote based on the input of the user.
Places a vote based on the input of the user.
[ "Places", "a", "vote", "based", "on", "the", "input", "of", "the", "user", "." ]
def vote(escrow_private_key, escrow_address, option_zero_address, option_one_address, client): voter = int(input("Vote 0 for zero and vote 1 for one: ")) if voter == 1: make_vote( escrow_address, escrow_private_key, option_one_address, 100, "Vo...
[ "def", "vote", "(", "escrow_private_key", ",", "escrow_address", ",", "option_zero_address", ",", "option_one_address", ",", "client", ")", ":", "voter", "=", "int", "(", "input", "(", "\"Vote 0 for zero and vote 1 for one: \"", ")", ")", "if", "voter", "==", "1",...
Places a vote based on the input of the user.
[ "Places", "a", "vote", "based", "on", "the", "input", "of", "the", "user", "." ]
[ "\"\"\"Places a vote based on the input of the user.\"\"\"" ]
[ { "param": "escrow_private_key", "type": null }, { "param": "escrow_address", "type": null }, { "param": "option_zero_address", "type": null }, { "param": "option_one_address", "type": null }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "escrow_private_key", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "escrow_address", "type": null, "docstring": null, ...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
calculate_votes
<not_specific>
def calculate_votes(addresses: list, client): """Calculate the result of a voting process.""" results = [] for addr in addresses: account_info = client.account_info(addr) assets = account_info.get("assets") for _asset in assets: if _asset["asset-id"] == ASSET_ID: ...
Calculate the result of a voting process.
Calculate the result of a voting process.
[ "Calculate", "the", "result", "of", "a", "voting", "process", "." ]
def calculate_votes(addresses: list, client): results = [] for addr in addresses: account_info = client.account_info(addr) assets = account_info.get("assets") for _asset in assets: if _asset["asset-id"] == ASSET_ID: amount = _asset.get("amount") ...
[ "def", "calculate_votes", "(", "addresses", ":", "list", ",", "client", ")", ":", "results", "=", "[", "]", "for", "addr", "in", "addresses", ":", "account_info", "=", "client", ".", "account_info", "(", "addr", ")", "assets", "=", "account_info", ".", "...
Calculate the result of a voting process.
[ "Calculate", "the", "result", "of", "a", "voting", "process", "." ]
[ "\"\"\"Calculate the result of a voting process.\"\"\"" ]
[ { "param": "addresses", "type": "list" }, { "param": "client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "addresses", "type": "list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "client", "type": null, "docstring": null, "docstring_t...
becf0ccc61e757a90d3f3350119a8385d52eab65
BdVade/Voting
Bronze_Badges/seun-Choice-Coin-Python/helpers.py
[ "Apache-2.0" ]
Python
wait_for_x_secs
None
def wait_for_x_secs(delay: float) -> None: """Specify the number of seconds the program should delay for.""" # A block takes approximately four(4) seconds to be added to the blockchain on Algorand print(f"Waiting for {delay} second(s) for blockchain to sync...") time.sleep(delay)
Specify the number of seconds the program should delay for.
Specify the number of seconds the program should delay for.
[ "Specify", "the", "number", "of", "seconds", "the", "program", "should", "delay", "for", "." ]
def wait_for_x_secs(delay: float) -> None: print(f"Waiting for {delay} second(s) for blockchain to sync...") time.sleep(delay)
[ "def", "wait_for_x_secs", "(", "delay", ":", "float", ")", "->", "None", ":", "print", "(", "f\"Waiting for {delay} second(s) for blockchain to sync...\"", ")", "time", ".", "sleep", "(", "delay", ")" ]
Specify the number of seconds the program should delay for.
[ "Specify", "the", "number", "of", "seconds", "the", "program", "should", "delay", "for", "." ]
[ "\"\"\"Specify the number of seconds the program should delay for.\"\"\"", "# A block takes approximately four(4) seconds to be added to the blockchain on Algorand" ]
[ { "param": "delay", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "delay", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
94a01d37ccc1992e81f937888ea8226fcc3ef7bd
testsibirtsv/opncrt_my_version
elements/addressbook.py
[ "Apache-2.0" ]
Python
records_count
<not_specific>
def records_count(self): """ Count the number of address records on the Address Book page. """ return len(self.edit_btn_list)
Count the number of address records on the Address Book page.
Count the number of address records on the Address Book page.
[ "Count", "the", "number", "of", "address", "records", "on", "the", "Address", "Book", "page", "." ]
def records_count(self): return len(self.edit_btn_list)
[ "def", "records_count", "(", "self", ")", ":", "return", "len", "(", "self", ".", "edit_btn_list", ")" ]
Count the number of address records on the Address Book page.
[ "Count", "the", "number", "of", "address", "records", "on", "the", "Address", "Book", "page", "." ]
[ "\"\"\"\n Count the number of address records on the Address Book page.\n\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
94a01d37ccc1992e81f937888ea8226fcc3ef7bd
testsibirtsv/opncrt_my_version
elements/addressbook.py
[ "Apache-2.0" ]
Python
open_edit_page_by_position
null
def open_edit_page_by_position(self, position): """ Edit address book entry from the Address Book page by it's positional index. :param position: positional index of address entry in list of addresses on the Address Book page. """ self.edit_btn_list[position].cli...
Edit address book entry from the Address Book page by it's positional index. :param position: positional index of address entry in list of addresses on the Address Book page.
Edit address book entry from the Address Book page by it's positional index.
[ "Edit", "address", "book", "entry", "from", "the", "Address", "Book", "page", "by", "it", "'", "s", "positional", "index", "." ]
def open_edit_page_by_position(self, position): self.edit_btn_list[position].click()
[ "def", "open_edit_page_by_position", "(", "self", ",", "position", ")", ":", "self", ".", "edit_btn_list", "[", "position", "]", ".", "click", "(", ")" ]
Edit address book entry from the Address Book page by it's positional index.
[ "Edit", "address", "book", "entry", "from", "the", "Address", "Book", "page", "by", "it", "'", "s", "positional", "index", "." ]
[ "\"\"\"\n Edit address book entry from the Address Book page\n by it's positional index.\n\n :param position: positional index of address entry\n in list of addresses on the Address Book page.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "position", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "position", "type": null, "docstring": "positional index of address ...
94a01d37ccc1992e81f937888ea8226fcc3ef7bd
testsibirtsv/opncrt_my_version
elements/addressbook.py
[ "Apache-2.0" ]
Python
delete_record_by_index
null
def delete_record_by_index(self, index): """ Delete Address Book entry from Address Book page by it's positional index. :param index: positional index of address entry in list of addresses on Address Book page. """ self.delete_btn_list[index].click()
Delete Address Book entry from Address Book page by it's positional index. :param index: positional index of address entry in list of addresses on Address Book page.
Delete Address Book entry from Address Book page by it's positional index.
[ "Delete", "Address", "Book", "entry", "from", "Address", "Book", "page", "by", "it", "'", "s", "positional", "index", "." ]
def delete_record_by_index(self, index): self.delete_btn_list[index].click()
[ "def", "delete_record_by_index", "(", "self", ",", "index", ")", ":", "self", ".", "delete_btn_list", "[", "index", "]", ".", "click", "(", ")" ]
Delete Address Book entry from Address Book page by it's positional index.
[ "Delete", "Address", "Book", "entry", "from", "Address", "Book", "page", "by", "it", "'", "s", "positional", "index", "." ]
[ "\"\"\"\n Delete Address Book entry from Address Book page\n by it's positional index.\n\n :param index: positional index of address entry\n in list of addresses on Address Book page.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "index", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": null, "docstring": "positional index of address ent...
94a01d37ccc1992e81f937888ea8226fcc3ef7bd
testsibirtsv/opncrt_my_version
elements/addressbook.py
[ "Apache-2.0" ]
Python
open_form_page
null
def open_form_page(self): """ Open Add Address form o n Address Book page. """ self.new_address_btn.click()
Open Add Address form o n Address Book page.
Open Add Address form o n Address Book page.
[ "Open", "Add", "Address", "form", "o", "n", "Address", "Book", "page", "." ]
def open_form_page(self): self.new_address_btn.click()
[ "def", "open_form_page", "(", "self", ")", ":", "self", ".", "new_address_btn", ".", "click", "(", ")" ]
Open Add Address form o n Address Book page.
[ "Open", "Add", "Address", "form", "o", "n", "Address", "Book", "page", "." ]
[ "\"\"\"\n Open Add Address form o\n n Address Book page.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0bfae455cf931809b3c6750a51baf273e3dd315c
testsibirtsv/opncrt_my_version
elements/addaddress.py
[ "Apache-2.0" ]
Python
fill_address_form
null
def fill_address_form(self, address): """ Fill fields with data in Add Address form. :param address: object with parameters for fields. """ self.change_text_field_data(self.firstname_field, address.first_name) self.change_text_field_data(self.lastname_field, address.last...
Fill fields with data in Add Address form. :param address: object with parameters for fields.
Fill fields with data in Add Address form.
[ "Fill", "fields", "with", "data", "in", "Add", "Address", "form", "." ]
def fill_address_form(self, address): self.change_text_field_data(self.firstname_field, address.first_name) self.change_text_field_data(self.lastname_field, address.last_name) self.change_text_field_data(self.company_field, address.company) self.change_text_field_data(self.address1_field...
[ "def", "fill_address_form", "(", "self", ",", "address", ")", ":", "self", ".", "change_text_field_data", "(", "self", ".", "firstname_field", ",", "address", ".", "first_name", ")", "self", ".", "change_text_field_data", "(", "self", ".", "lastname_field", ",",...
Fill fields with data in Add Address form.
[ "Fill", "fields", "with", "data", "in", "Add", "Address", "form", "." ]
[ "\"\"\"\n Fill fields with data in Add Address form.\n\n :param address: object with parameters for fields.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "address", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": null, "docstring": "object with parameters for fi...
0bfae455cf931809b3c6750a51baf273e3dd315c
testsibirtsv/opncrt_my_version
elements/addaddress.py
[ "Apache-2.0" ]
Python
change_drop_list_data
null
def change_drop_list_data(ddlist_option, value): """ Select option in dropdown list in Add Address form. :param ddlist_option: option's id in dropdown list. :param value: option's text in dropdown list. """ if value is not None: data_select = Select(ddlist_op...
Select option in dropdown list in Add Address form. :param ddlist_option: option's id in dropdown list. :param value: option's text in dropdown list.
Select option in dropdown list in Add Address form.
[ "Select", "option", "in", "dropdown", "list", "in", "Add", "Address", "form", "." ]
def change_drop_list_data(ddlist_option, value): if value is not None: data_select = Select(ddlist_option) data_select.select_by_visible_text(value)
[ "def", "change_drop_list_data", "(", "ddlist_option", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "data_select", "=", "Select", "(", "ddlist_option", ")", "data_select", ".", "select_by_visible_text", "(", "value", ")" ]
Select option in dropdown list in Add Address form.
[ "Select", "option", "in", "dropdown", "list", "in", "Add", "Address", "form", "." ]
[ "\"\"\"\n Select option in dropdown list in Add Address form.\n\n :param ddlist_option: option's id in dropdown list.\n :param value: option's text in dropdown list.\n \"\"\"" ]
[ { "param": "ddlist_option", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ddlist_option", "type": null, "docstring": "option's id in dropdown list.", "docstring_tokens": [ "option", "'", "s", "id", "in", "dropdown", "list", "." ],...
0bfae455cf931809b3c6750a51baf273e3dd315c
testsibirtsv/opncrt_my_version
elements/addaddress.py
[ "Apache-2.0" ]
Python
change_text_field_data
null
def change_text_field_data(field_name, value): """ Set text into Add Address form field. :param field_name: field's id in Add Address form. :param value: field's text in Add Address form. """ if value is not None: field_name.click() field_name.cle...
Set text into Add Address form field. :param field_name: field's id in Add Address form. :param value: field's text in Add Address form.
Set text into Add Address form field.
[ "Set", "text", "into", "Add", "Address", "form", "field", "." ]
def change_text_field_data(field_name, value): if value is not None: field_name.click() field_name.clear() field_name.send_keys(value)
[ "def", "change_text_field_data", "(", "field_name", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "field_name", ".", "click", "(", ")", "field_name", ".", "clear", "(", ")", "field_name", ".", "send_keys", "(", "value", ")" ]
Set text into Add Address form field.
[ "Set", "text", "into", "Add", "Address", "form", "field", "." ]
[ "\"\"\"\n Set text into Add Address form field.\n\n :param field_name: field's id in Add Address form.\n :param value: field's text in Add Address form.\n \"\"\"" ]
[ { "param": "field_name", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "field_name", "type": null, "docstring": "field's id in Add Address form.", "docstring_tokens": [ "field", "'", "s", "id", "in", "Add", "Address", "form", ...
c3b4405b276e7fee1cc8ee9ce88df10ddeab5ad0
testsibirtsv/opncrt_my_version
pages/addressbook.py
[ "Apache-2.0" ]
Python
create
null
def create(self, address): """ Open Address Book page, then open and fill Add Address form and submit creation. :param address: object with parameters for fields in Add Address form. """ self.open_address_book_page() self.open_form_page() self.fill_addres...
Open Address Book page, then open and fill Add Address form and submit creation. :param address: object with parameters for fields in Add Address form.
Open Address Book page, then open and fill Add Address form and submit creation.
[ "Open", "Address", "Book", "page", "then", "open", "and", "fill", "Add", "Address", "form", "and", "submit", "creation", "." ]
def create(self, address): self.open_address_book_page() self.open_form_page() self.fill_address_form(address) self.get_continue_button().click()
[ "def", "create", "(", "self", ",", "address", ")", ":", "self", ".", "open_address_book_page", "(", ")", "self", ".", "open_form_page", "(", ")", "self", ".", "fill_address_form", "(", "address", ")", "self", ".", "get_continue_button", "(", ")", ".", "cli...
Open Address Book page, then open and fill Add Address form and submit creation.
[ "Open", "Address", "Book", "page", "then", "open", "and", "fill", "Add", "Address", "form", "and", "submit", "creation", "." ]
[ "\"\"\"\n Open Address Book page, then open and fill Add Address form\n and submit creation.\n\n :param address: object with parameters for fields in Add Address form.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "address", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "address", "type": null, "docstring": "object with parameters for fi...
c3b4405b276e7fee1cc8ee9ce88df10ddeab5ad0
testsibirtsv/opncrt_my_version
pages/addressbook.py
[ "Apache-2.0" ]
Python
edit_record_by_index
null
def edit_record_by_index(self, updated_values, index: int): """ Open Address Book page, then open already existing address entry, fill Add Address form with new data and submit changes. :param updated_values: object with parameters for fields in Add Address form. :param index: p...
Open Address Book page, then open already existing address entry, fill Add Address form with new data and submit changes. :param updated_values: object with parameters for fields in Add Address form. :param index: position of address in list on Address Book page.
Open Address Book page, then open already existing address entry, fill Add Address form with new data and submit changes.
[ "Open", "Address", "Book", "page", "then", "open", "already", "existing", "address", "entry", "fill", "Add", "Address", "form", "with", "new", "data", "and", "submit", "changes", "." ]
def edit_record_by_index(self, updated_values, index: int): self.open_address_book_page() self.open_edit_page_by_position(index) self.fill_address_form(updated_values) self.get_continue_button_from_form().click()
[ "def", "edit_record_by_index", "(", "self", ",", "updated_values", ",", "index", ":", "int", ")", ":", "self", ".", "open_address_book_page", "(", ")", "self", ".", "open_edit_page_by_position", "(", "index", ")", "self", ".", "fill_address_form", "(", "updated_...
Open Address Book page, then open already existing address entry, fill Add Address form with new data and submit changes.
[ "Open", "Address", "Book", "page", "then", "open", "already", "existing", "address", "entry", "fill", "Add", "Address", "form", "with", "new", "data", "and", "submit", "changes", "." ]
[ "\"\"\"\n Open Address Book page, then open already existing address entry,\n fill Add Address form with new data and submit changes.\n\n :param updated_values: object with parameters for fields in Add Address form.\n :param index: position of address in list on Address Book page.\n ...
[ { "param": "self", "type": null }, { "param": "updated_values", "type": null }, { "param": "index", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "updated_values", "type": null, "docstring": "object with parameters...
8045cc2050e8062660de69a260292e9376bfaf4b
testsibirtsv/opncrt_my_version
elements/editaccount.py
[ "Apache-2.0" ]
Python
change_data_in_text_fields
null
def change_data_in_text_fields(form_field, data): """ Enter the data in the textfield. :param form_field: textfield's id. :param data: data entered in the textfield. """ if data is not None: form_field.click() form_field.clear() form_f...
Enter the data in the textfield. :param form_field: textfield's id. :param data: data entered in the textfield.
Enter the data in the textfield.
[ "Enter", "the", "data", "in", "the", "textfield", "." ]
def change_data_in_text_fields(form_field, data): if data is not None: form_field.click() form_field.clear() form_field.send_keys(data)
[ "def", "change_data_in_text_fields", "(", "form_field", ",", "data", ")", ":", "if", "data", "is", "not", "None", ":", "form_field", ".", "click", "(", ")", "form_field", ".", "clear", "(", ")", "form_field", ".", "send_keys", "(", "data", ")" ]
Enter the data in the textfield.
[ "Enter", "the", "data", "in", "the", "textfield", "." ]
[ "\"\"\"\n Enter the data in the textfield.\n\n :param form_field: textfield's id.\n :param data: data entered in the textfield.\n \"\"\"" ]
[ { "param": "form_field", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "form_field", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": "data...
8045cc2050e8062660de69a260292e9376bfaf4b
testsibirtsv/opncrt_my_version
elements/editaccount.py
[ "Apache-2.0" ]
Python
fill_edit_account_form
null
def fill_edit_account_form(self, user_data): """ Change user data in the Edit Account form. :param user_data: data entered in the textfield. """ self.change_data_in_text_fields(self.firstname_field, user_data.first_name) self.change_data_in_text_fields(self.lastname_fiel...
Change user data in the Edit Account form. :param user_data: data entered in the textfield.
Change user data in the Edit Account form.
[ "Change", "user", "data", "in", "the", "Edit", "Account", "form", "." ]
def fill_edit_account_form(self, user_data): self.change_data_in_text_fields(self.firstname_field, user_data.first_name) self.change_data_in_text_fields(self.lastname_field, user_data.last_name) self.change_data_in_text_fields(self.email_field, user_data.email) self.change_data_in_text_f...
[ "def", "fill_edit_account_form", "(", "self", ",", "user_data", ")", ":", "self", ".", "change_data_in_text_fields", "(", "self", ".", "firstname_field", ",", "user_data", ".", "first_name", ")", "self", ".", "change_data_in_text_fields", "(", "self", ".", "lastna...
Change user data in the Edit Account form.
[ "Change", "user", "data", "in", "the", "Edit", "Account", "form", "." ]
[ "\"\"\"\n Change user data in the Edit Account form.\n\n :param user_data: data entered in the textfield.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "user_data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_data", "type": null, "docstring": "data entered in the textfie...
56d16616a07d1329bfa565a3bbed2e15c3297b66
0xbs0d/figures
figures/sites.py
[ "MIT" ]
Python
site_to_id
<not_specific>
def site_to_id(site): """ Helper to cast site or site id to id This is helpful for celery tasks that require primitives for function parameters """ if isinstance(site, Site): return site.id else: return site
Helper to cast site or site id to id This is helpful for celery tasks that require primitives for function parameters
Helper to cast site or site id to id This is helpful for celery tasks that require primitives for function parameters
[ "Helper", "to", "cast", "site", "or", "site", "id", "to", "id", "This", "is", "helpful", "for", "celery", "tasks", "that", "require", "primitives", "for", "function", "parameters" ]
def site_to_id(site): if isinstance(site, Site): return site.id else: return site
[ "def", "site_to_id", "(", "site", ")", ":", "if", "isinstance", "(", "site", ",", "Site", ")", ":", "return", "site", ".", "id", "else", ":", "return", "site" ]
Helper to cast site or site id to id This is helpful for celery tasks that require primitives for function parameters
[ "Helper", "to", "cast", "site", "or", "site", "id", "to", "id", "This", "is", "helpful", "for", "celery", "tasks", "that", "require", "primitives", "for", "function", "parameters" ]
[ "\"\"\"\n Helper to cast site or site id to id\n This is helpful for celery tasks that require primitives for\n function parameters\n \"\"\"" ]
[ { "param": "site", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "site", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
56d16616a07d1329bfa565a3bbed2e15c3297b66
0xbs0d/figures
figures/sites.py
[ "MIT" ]
Python
site_id_iterator
null
def site_id_iterator(sites_or_site_ids): """ Convenience method to iterate over site or site id iterables. This is helpful for iterating over site objects or site ids for Celery tasks """ for obj in sites_or_site_ids: yield site_to_id(obj)
Convenience method to iterate over site or site id iterables. This is helpful for iterating over site objects or site ids for Celery tasks
Convenience method to iterate over site or site id iterables. This is helpful for iterating over site objects or site ids for Celery tasks
[ "Convenience", "method", "to", "iterate", "over", "site", "or", "site", "id", "iterables", ".", "This", "is", "helpful", "for", "iterating", "over", "site", "objects", "or", "site", "ids", "for", "Celery", "tasks" ]
def site_id_iterator(sites_or_site_ids): for obj in sites_or_site_ids: yield site_to_id(obj)
[ "def", "site_id_iterator", "(", "sites_or_site_ids", ")", ":", "for", "obj", "in", "sites_or_site_ids", ":", "yield", "site_to_id", "(", "obj", ")" ]
Convenience method to iterate over site or site id iterables.
[ "Convenience", "method", "to", "iterate", "over", "site", "or", "site", "id", "iterables", "." ]
[ "\"\"\"\n Convenience method to iterate over site or site id iterables.\n\n This is helpful for iterating over site objects or site ids for\n Celery tasks\n \"\"\"" ]
[ { "param": "sites_or_site_ids", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sites_or_site_ids", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
56d16616a07d1329bfa565a3bbed2e15c3297b66
0xbs0d/figures
figures/sites.py
[ "MIT" ]
Python
default_site
<not_specific>
def default_site(): """Returns the default site instance if Django settings defines SITE_ID, else None Tech debt note: Open edX monkeypatches django.contrib.sites to override behavior for getting the current site. """ if getattr(settings, 'SITE_ID', ''): return Site.objects.get(pk=settings....
Returns the default site instance if Django settings defines SITE_ID, else None Tech debt note: Open edX monkeypatches django.contrib.sites to override behavior for getting the current site.
Returns the default site instance if Django settings defines SITE_ID, else None Tech debt note: Open edX monkeypatches django.contrib.sites to override behavior for getting the current site.
[ "Returns", "the", "default", "site", "instance", "if", "Django", "settings", "defines", "SITE_ID", "else", "None", "Tech", "debt", "note", ":", "Open", "edX", "monkeypatches", "django", ".", "contrib", ".", "sites", "to", "override", "behavior", "for", "gettin...
def default_site(): if getattr(settings, 'SITE_ID', ''): return Site.objects.get(pk=settings.SITE_ID) return None
[ "def", "default_site", "(", ")", ":", "if", "getattr", "(", "settings", ",", "'SITE_ID'", ",", "''", ")", ":", "return", "Site", ".", "objects", ".", "get", "(", "pk", "=", "settings", ".", "SITE_ID", ")", "return", "None" ]
Returns the default site instance if Django settings defines SITE_ID, else None Tech debt note: Open edX monkeypatches django.contrib.sites to override behavior for getting the current site.
[ "Returns", "the", "default", "site", "instance", "if", "Django", "settings", "defines", "SITE_ID", "else", "None", "Tech", "debt", "note", ":", "Open", "edX", "monkeypatches", "django", ".", "contrib", ".", "sites", "to", "override", "behavior", "for", "gettin...
[ "\"\"\"Returns the default site instance if Django settings defines SITE_ID, else None\n\n Tech debt note: Open edX monkeypatches django.contrib.sites to override\n behavior for getting the current site.\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
56d16616a07d1329bfa565a3bbed2e15c3297b66
0xbs0d/figures
figures/sites.py
[ "MIT" ]
Python
course_enrollments_for_course
<not_specific>
def course_enrollments_for_course(course_id): """Return a queryset of all `CourseEnrollment` records for a course Relies on the fact that course_ids are globally unique """ return CourseEnrollment.objects.filter(course_id=as_course_key(course_id))
Return a queryset of all `CourseEnrollment` records for a course Relies on the fact that course_ids are globally unique
Return a queryset of all `CourseEnrollment` records for a course Relies on the fact that course_ids are globally unique
[ "Return", "a", "queryset", "of", "all", "`", "CourseEnrollment", "`", "records", "for", "a", "course", "Relies", "on", "the", "fact", "that", "course_ids", "are", "globally", "unique" ]
def course_enrollments_for_course(course_id): return CourseEnrollment.objects.filter(course_id=as_course_key(course_id))
[ "def", "course_enrollments_for_course", "(", "course_id", ")", ":", "return", "CourseEnrollment", ".", "objects", ".", "filter", "(", "course_id", "=", "as_course_key", "(", "course_id", ")", ")" ]
Return a queryset of all `CourseEnrollment` records for a course Relies on the fact that course_ids are globally unique
[ "Return", "a", "queryset", "of", "all", "`", "CourseEnrollment", "`", "records", "for", "a", "course", "Relies", "on", "the", "fact", "that", "course_ids", "are", "globally", "unique" ]
[ "\"\"\"Return a queryset of all `CourseEnrollment` records for a course\n\n Relies on the fact that course_ids are globally unique\n \"\"\"" ]
[ { "param": "course_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "course_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
56d16616a07d1329bfa565a3bbed2e15c3297b66
0xbs0d/figures
figures/sites.py
[ "MIT" ]
Python
student_modules_for_course_enrollment
<not_specific>
def student_modules_for_course_enrollment(ce): """Return a queryset of all `StudentModule` records for a `CourseEnrollment`1 Relies on the fact that course_ids are globally unique """ return StudentModule.objects.filter(student=ce.user, course_id=ce.course_id)
Return a queryset of all `StudentModule` records for a `CourseEnrollment`1 Relies on the fact that course_ids are globally unique
Return a queryset of all `StudentModule` records for a `CourseEnrollment`1 Relies on the fact that course_ids are globally unique
[ "Return", "a", "queryset", "of", "all", "`", "StudentModule", "`", "records", "for", "a", "`", "CourseEnrollment", "`", "1", "Relies", "on", "the", "fact", "that", "course_ids", "are", "globally", "unique" ]
def student_modules_for_course_enrollment(ce): return StudentModule.objects.filter(student=ce.user, course_id=ce.course_id)
[ "def", "student_modules_for_course_enrollment", "(", "ce", ")", ":", "return", "StudentModule", ".", "objects", ".", "filter", "(", "student", "=", "ce", ".", "user", ",", "course_id", "=", "ce", ".", "course_id", ")" ]
Return a queryset of all `StudentModule` records for a `CourseEnrollment`1 Relies on the fact that course_ids are globally unique
[ "Return", "a", "queryset", "of", "all", "`", "StudentModule", "`", "records", "for", "a", "`", "CourseEnrollment", "`", "1", "Relies", "on", "the", "fact", "that", "course_ids", "are", "globally", "unique" ]
[ "\"\"\"Return a queryset of all `StudentModule` records for a `CourseEnrollment`1\n\n Relies on the fact that course_ids are globally unique\n \"\"\"" ]
[ { "param": "ce", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ce", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
populate_single_cdm
null
def populate_single_cdm(course_id, date_for=None, force_update=False): '''Populates a CourseDailyMetrics record for the given date and course ''' if date_for: date_for = as_date(date_for) # Provide info in celery log learner_count = CourseEnrollment.objects.filter( course_id=as_cour...
Populates a CourseDailyMetrics record for the given date and course
Populates a CourseDailyMetrics record for the given date and course
[ "Populates", "a", "CourseDailyMetrics", "record", "for", "the", "given", "date", "and", "course" ]
def populate_single_cdm(course_id, date_for=None, force_update=False): if date_for: date_for = as_date(date_for) learner_count = CourseEnrollment.objects.filter( course_id=as_course_key(course_id)).count() msg = 'populate_single_cdm. course id = "{}", learner count={}'.format( course...
[ "def", "populate_single_cdm", "(", "course_id", ",", "date_for", "=", "None", ",", "force_update", "=", "False", ")", ":", "if", "date_for", ":", "date_for", "=", "as_date", "(", "date_for", ")", "learner_count", "=", "CourseEnrollment", ".", "objects", ".", ...
Populates a CourseDailyMetrics record for the given date and course
[ "Populates", "a", "CourseDailyMetrics", "record", "for", "the", "given", "date", "and", "course" ]
[ "'''Populates a CourseDailyMetrics record for the given date and course\n '''", "# Provide info in celery log" ]
[ { "param": "course_id", "type": null }, { "param": "date_for", "type": null }, { "param": "force_update", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "course_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "date_for", "type": null, "docstring": null, "docstring_t...
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
populate_daily_metrics
null
def populate_daily_metrics(date_for=None, force_update=False): '''Populates the daily metrics models for the given date This method populates CourseDailyMetrics for all the courses in the site, then populates SiteDailyMetrics It calls the individual tasks, ``populate_single_cdm`` and ``populate_si...
Populates the daily metrics models for the given date This method populates CourseDailyMetrics for all the courses in the site, then populates SiteDailyMetrics It calls the individual tasks, ``populate_single_cdm`` and ``populate_site_daily_metrics`` as immediate calls so that no courses are misse...
Populates the daily metrics models for the given date This method populates CourseDailyMetrics for all the courses in the site, then populates SiteDailyMetrics We have an experimental task that runs the course populators in parallel, then when they are all done, populates the site metrics. See the function ``experi...
[ "Populates", "the", "daily", "metrics", "models", "for", "the", "given", "date", "This", "method", "populates", "CourseDailyMetrics", "for", "all", "the", "courses", "in", "the", "site", "then", "populates", "SiteDailyMetrics", "We", "have", "an", "experimental", ...
def populate_daily_metrics(date_for=None, force_update=False): if date_for: date_for = as_date(date_for) else: date_for = datetime.datetime.utcnow().replace(tzinfo=utc).date() logger.info('Starting task "figures.populate_daily_metrics" for date "{}"'.format( date_for)) sites_coun...
[ "def", "populate_daily_metrics", "(", "date_for", "=", "None", ",", "force_update", "=", "False", ")", ":", "if", "date_for", ":", "date_for", "=", "as_date", "(", "date_for", ")", "else", ":", "date_for", "=", "datetime", ".", "datetime", ".", "utcnow", "...
Populates the daily metrics models for the given date This method populates CourseDailyMetrics for all the courses in the site, then populates SiteDailyMetrics
[ "Populates", "the", "daily", "metrics", "models", "for", "the", "given", "date", "This", "method", "populates", "CourseDailyMetrics", "for", "all", "the", "courses", "in", "the", "site", "then", "populates", "SiteDailyMetrics" ]
[ "'''Populates the daily metrics models for the given date\n\n This method populates CourseDailyMetrics for all the courses in the site,\n then populates SiteDailyMetrics\n\n It calls the individual tasks, ``populate_single_cdm`` and\n ``populate_site_daily_metrics`` as immediate calls so that no courses...
[ { "param": "date_for", "type": null }, { "param": "force_update", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "date_for", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "force_update", "type": null, "docstring": null, "docstrin...
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
experimental_populate_daily_metrics
<not_specific>
def experimental_populate_daily_metrics(date_for=None, force_update=False): '''Experimental task to populate daily metrics WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of processing course metrics. Not all the courses get processed and the site metrics doesn't get called. ...
Experimental task to populate daily metrics WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of processing course metrics. Not all the courses get processed and the site metrics doesn't get called. We're keeping it in the tasks so that we can continue to debug this. Enablin...
Experimental task to populate daily metrics WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of processing course metrics. Not all the courses get processed and the site metrics doesn't get called. We're keeping it in the tasks so that we can continue to debug this. Enabling parallel course tas...
[ "Experimental", "task", "to", "populate", "daily", "metrics", "WARNING", ":", "In", "Ginkgo", "devstack", "this", "task", "tends", "to", "gets", "stuck", "in", "the", "middle", "of", "processing", "course", "metrics", ".", "Not", "all", "the", "courses", "ge...
def experimental_populate_daily_metrics(date_for=None, force_update=False): def include_course(course_overview, threshold=50): count = CourseEnrollment.objects.filter(course_id=course_overview.id).count() return False if count > threshold else True if date_for: date_for = as_date(date_fo...
[ "def", "experimental_populate_daily_metrics", "(", "date_for", "=", "None", ",", "force_update", "=", "False", ")", ":", "def", "include_course", "(", "course_overview", ",", "threshold", "=", "50", ")", ":", "'''This function let's us skip over courses with many enrollme...
Experimental task to populate daily metrics WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of processing course metrics.
[ "Experimental", "task", "to", "populate", "daily", "metrics", "WARNING", ":", "In", "Ginkgo", "devstack", "this", "task", "tends", "to", "gets", "stuck", "in", "the", "middle", "of", "processing", "course", "metrics", "." ]
[ "'''Experimental task to populate daily metrics\n\n WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of\n processing course metrics. Not all the courses get processed and the site\n metrics doesn't get called.\n\n We're keeping it in the tasks so that we can continue to debug thi...
[ { "param": "date_for", "type": null }, { "param": "force_update", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "date_for", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "force_update", "type": null, "docstring": null, "docstrin...
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
include_course
<not_specific>
def include_course(course_overview, threshold=50): '''This function let's us skip over courses with many enrollments, speeding up testing. Do not use for production ''' count = CourseEnrollment.objects.filter(course_id=course_overview.id).count() return False if count > threshold...
This function let's us skip over courses with many enrollments, speeding up testing. Do not use for production
This function let's us skip over courses with many enrollments, speeding up testing. Do not use for production
[ "This", "function", "let", "'", "s", "us", "skip", "over", "courses", "with", "many", "enrollments", "speeding", "up", "testing", ".", "Do", "not", "use", "for", "production" ]
def include_course(course_overview, threshold=50): count = CourseEnrollment.objects.filter(course_id=course_overview.id).count() return False if count > threshold else True
[ "def", "include_course", "(", "course_overview", ",", "threshold", "=", "50", ")", ":", "count", "=", "CourseEnrollment", ".", "objects", ".", "filter", "(", "course_id", "=", "course_overview", ".", "id", ")", ".", "count", "(", ")", "return", "False", "i...
This function let's us skip over courses with many enrollments, speeding up testing.
[ "This", "function", "let", "'", "s", "us", "skip", "over", "courses", "with", "many", "enrollments", "speeding", "up", "testing", "." ]
[ "'''This function let's us skip over courses with many enrollments, speeding\n up testing. Do not use for production\n '''" ]
[ { "param": "course_overview", "type": null }, { "param": "threshold", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "course_overview", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "threshold", "type": null, "docstring": null, "docs...
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
populate_course_mau
null
def populate_course_mau(site_id, course_id, month_for=None, force_update=False): """Populates the MAU for the given site, course, and month """ if month_for: month_for = as_date(month_for) else: month_for = datetime.datetime.utcnow().date() site = Site.objects.get(id=site_id) sta...
Populates the MAU for the given site, course, and month
Populates the MAU for the given site, course, and month
[ "Populates", "the", "MAU", "for", "the", "given", "site", "course", "and", "month" ]
def populate_course_mau(site_id, course_id, month_for=None, force_update=False): if month_for: month_for = as_date(month_for) else: month_for = datetime.datetime.utcnow().date() site = Site.objects.get(id=site_id) start_time = time.time() obj, _created = collect_course_mau(site=site,...
[ "def", "populate_course_mau", "(", "site_id", ",", "course_id", ",", "month_for", "=", "None", ",", "force_update", "=", "False", ")", ":", "if", "month_for", ":", "month_for", "=", "as_date", "(", "month_for", ")", "else", ":", "month_for", "=", "datetime",...
Populates the MAU for the given site, course, and month
[ "Populates", "the", "MAU", "for", "the", "given", "site", "course", "and", "month" ]
[ "\"\"\"Populates the MAU for the given site, course, and month\n \"\"\"" ]
[ { "param": "site_id", "type": null }, { "param": "course_id", "type": null }, { "param": "month_for", "type": null }, { "param": "force_update", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "site_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "course_id", "type": null, "docstring": null, "docstring_to...
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
populate_mau_metrics_for_site
null
def populate_mau_metrics_for_site(site_id, month_for=None, force_update=False): """ Collect (save) MAU metrics for the specified site Iterates over all courses in the site to collect MAU counts TODO: Decide how sites would be excluded and create filter TODO: Check results of 'store_mau_metrics' to ...
Collect (save) MAU metrics for the specified site Iterates over all courses in the site to collect MAU counts TODO: Decide how sites would be excluded and create filter TODO: Check results of 'store_mau_metrics' to log unexpected results
Collect (save) MAU metrics for the specified site Iterates over all courses in the site to collect MAU counts TODO: Decide how sites would be excluded and create filter TODO: Check results of 'store_mau_metrics' to log unexpected results
[ "Collect", "(", "save", ")", "MAU", "metrics", "for", "the", "specified", "site", "Iterates", "over", "all", "courses", "in", "the", "site", "to", "collect", "MAU", "counts", "TODO", ":", "Decide", "how", "sites", "would", "be", "excluded", "and", "create"...
def populate_mau_metrics_for_site(site_id, month_for=None, force_update=False): site = Site.objects.get(id=site_id) msg = 'Starting figures' logger.info(msg) for course_key in figures.sites.get_course_keys_for_site(site): populate_course_mau(site_id=site_id, course_id...
[ "def", "populate_mau_metrics_for_site", "(", "site_id", ",", "month_for", "=", "None", ",", "force_update", "=", "False", ")", ":", "site", "=", "Site", ".", "objects", ".", "get", "(", "id", "=", "site_id", ")", "msg", "=", "'Starting figures'", "logger", ...
Collect (save) MAU metrics for the specified site Iterates over all courses in the site to collect MAU counts TODO: Decide how sites would be excluded and create filter TODO: Check results of 'store_mau_metrics' to log unexpected results
[ "Collect", "(", "save", ")", "MAU", "metrics", "for", "the", "specified", "site", "Iterates", "over", "all", "courses", "in", "the", "site", "to", "collect", "MAU", "counts", "TODO", ":", "Decide", "how", "sites", "would", "be", "excluded", "and", "create"...
[ "\"\"\"\n Collect (save) MAU metrics for the specified site\n\n Iterates over all courses in the site to collect MAU counts\n TODO: Decide how sites would be excluded and create filter\n TODO: Check results of 'store_mau_metrics' to log unexpected results\n \"\"\"" ]
[ { "param": "site_id", "type": null }, { "param": "month_for", "type": null }, { "param": "force_update", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "site_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "month_for", "type": null, "docstring": null, "docstring_to...
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
populate_all_mau
null
def populate_all_mau(): """ Top level task to kick off MAU collection Initially, run it every day to observe monthly active user accumulation for the month and evaluate the results """ for site in Site.objects.all(): populate_mau_metrics_for_site(site_id=site.id, force_update=False)
Top level task to kick off MAU collection Initially, run it every day to observe monthly active user accumulation for the month and evaluate the results
Top level task to kick off MAU collection Initially, run it every day to observe monthly active user accumulation for the month and evaluate the results
[ "Top", "level", "task", "to", "kick", "off", "MAU", "collection", "Initially", "run", "it", "every", "day", "to", "observe", "monthly", "active", "user", "accumulation", "for", "the", "month", "and", "evaluate", "the", "results" ]
def populate_all_mau(): for site in Site.objects.all(): populate_mau_metrics_for_site(site_id=site.id, force_update=False)
[ "def", "populate_all_mau", "(", ")", ":", "for", "site", "in", "Site", ".", "objects", ".", "all", "(", ")", ":", "populate_mau_metrics_for_site", "(", "site_id", "=", "site", ".", "id", ",", "force_update", "=", "False", ")" ]
Top level task to kick off MAU collection Initially, run it every day to observe monthly active user accumulation for the month and evaluate the results
[ "Top", "level", "task", "to", "kick", "off", "MAU", "collection", "Initially", "run", "it", "every", "day", "to", "observe", "monthly", "active", "user", "accumulation", "for", "the", "month", "and", "evaluate", "the", "results" ]
[ "\"\"\"\n Top level task to kick off MAU collection\n\n Initially, run it every day to observe monthly active user accumulation for\n the month and evaluate the results\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
bfa16ba5a32981109998657f90e7b693fc27ac9c
0xbs0d/figures
figures/tasks.py
[ "MIT" ]
Python
run_figures_monthly_metrics
null
def run_figures_monthly_metrics(): """ TODO: only run for active sites. Requires knowing which sites we can skip """ logger.info('Starting figures.tasks.run_figures_monthly_metrics...') for site in Site.objects.all(): populate_monthly_metrics_for_site.delay(site_id=site.id)
TODO: only run for active sites. Requires knowing which sites we can skip
only run for active sites. Requires knowing which sites we can skip
[ "only", "run", "for", "active", "sites", ".", "Requires", "knowing", "which", "sites", "we", "can", "skip" ]
def run_figures_monthly_metrics(): logger.info('Starting figures.tasks.run_figures_monthly_metrics...') for site in Site.objects.all(): populate_monthly_metrics_for_site.delay(site_id=site.id)
[ "def", "run_figures_monthly_metrics", "(", ")", ":", "logger", ".", "info", "(", "'Starting figures.tasks.run_figures_monthly_metrics...'", ")", "for", "site", "in", "Site", ".", "objects", ".", "all", "(", ")", ":", "populate_monthly_metrics_for_site", ".", "delay", ...
TODO: only run for active sites.
[ "TODO", ":", "only", "run", "for", "active", "sites", "." ]
[ "\"\"\"\n TODO: only run for active sites. Requires knowing which sites we can skip\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
aac684e37c8b10ebc504d86848f64855ed9e56a2
0xbs0d/figures
figures/views.py
[ "MIT" ]
Python
completed
<not_specific>
def completed(self, request): """Experimental endpoint to return completed LCGM records This is the same as `/figures/api/enrollment-metrics/?only_completed=True Return matching LearnerCourseGradeMetric rows that have completed enrollments """ site = django.contrib.site...
Experimental endpoint to return completed LCGM records This is the same as `/figures/api/enrollment-metrics/?only_completed=True Return matching LearnerCourseGradeMetric rows that have completed enrollments
Experimental endpoint to return completed LCGM records This is the same as `/figures/api/enrollment-metrics/?only_completed=True Return matching LearnerCourseGradeMetric rows that have completed enrollments
[ "Experimental", "endpoint", "to", "return", "completed", "LCGM", "records", "This", "is", "the", "same", "as", "`", "/", "figures", "/", "api", "/", "enrollment", "-", "metrics", "/", "?only_completed", "=", "True", "Return", "matching", "LearnerCourseGradeMetri...
def completed(self, request): site = django.contrib.sites.shortcuts.get_current_site(request) qs = self.model.objects.completed_for_site(site=site) page = self.paginate_queryset(qs) if page is not None: serializer = self.get_serializer(page, many=True) return self...
[ "def", "completed", "(", "self", ",", "request", ")", ":", "site", "=", "django", ".", "contrib", ".", "sites", ".", "shortcuts", ".", "get_current_site", "(", "request", ")", "qs", "=", "self", ".", "model", ".", "objects", ".", "completed_for_site", "(...
Experimental endpoint to return completed LCGM records This is the same as `/figures/api/enrollment-metrics/?only_completed=True
[ "Experimental", "endpoint", "to", "return", "completed", "LCGM", "records", "This", "is", "the", "same", "as", "`", "/", "figures", "/", "api", "/", "enrollment", "-", "metrics", "/", "?only_completed", "=", "True" ]
[ "\"\"\"Experimental endpoint to return completed LCGM records\n\n This is the same as `/figures/api/enrollment-metrics/?only_completed=True\n\n Return matching LearnerCourseGradeMetric rows that have completed\n enrollments\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "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"...
aac684e37c8b10ebc504d86848f64855ed9e56a2
0xbs0d/figures
figures/views.py
[ "MIT" ]
Python
list
<not_specific>
def list(self, request): """ Returns site metrics data for current month TODO: NEXT Add query params to get data from previous months TODO: Add paginagation """ site = django.contrib.sites.shortcuts.get_current_site(request) course_keys = figures.sites.get_course...
Returns site metrics data for current month TODO: NEXT Add query params to get data from previous months TODO: Add paginagation
Returns site metrics data for current month TODO: NEXT Add query params to get data from previous months TODO: Add paginagation
[ "Returns", "site", "metrics", "data", "for", "current", "month", "TODO", ":", "NEXT", "Add", "query", "params", "to", "get", "data", "from", "previous", "months", "TODO", ":", "Add", "paginagation" ]
def list(self, request): site = django.contrib.sites.shortcuts.get_current_site(request) course_keys = figures.sites.get_course_keys_for_site(site) date_for = datetime.utcnow().date() month_for = '{}/{}'.format(date_for.month, date_for.year) data = [] for course_key in co...
[ "def", "list", "(", "self", ",", "request", ")", ":", "site", "=", "django", ".", "contrib", ".", "sites", ".", "shortcuts", ".", "get_current_site", "(", "request", ")", "course_keys", "=", "figures", ".", "sites", ".", "get_course_keys_for_site", "(", "s...
Returns site metrics data for current month TODO: NEXT Add query params to get data from previous months TODO: Add paginagation
[ "Returns", "site", "metrics", "data", "for", "current", "month", "TODO", ":", "NEXT", "Add", "query", "params", "to", "get", "data", "from", "previous", "months", "TODO", ":", "Add", "paginagation" ]
[ "\"\"\"\n Returns site metrics data for current month\n\n TODO: NEXT Add query params to get data from previous months\n TODO: Add paginagation\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "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"...
aac684e37c8b10ebc504d86848f64855ed9e56a2
0xbs0d/figures
figures/views.py
[ "MIT" ]
Python
list
<not_specific>
def list(self, request): """ Returns site metrics data for current month """ site = django.contrib.sites.shortcuts.get_current_site(request) data = metrics.get_current_month_site_metrics(site) return Response(data)
Returns site metrics data for current month
Returns site metrics data for current month
[ "Returns", "site", "metrics", "data", "for", "current", "month" ]
def list(self, request): site = django.contrib.sites.shortcuts.get_current_site(request) data = metrics.get_current_month_site_metrics(site) return Response(data)
[ "def", "list", "(", "self", ",", "request", ")", ":", "site", "=", "django", ".", "contrib", ".", "sites", ".", "shortcuts", ".", "get_current_site", "(", "request", ")", "data", "=", "metrics", ".", "get_current_month_site_metrics", "(", "site", ")", "ret...
Returns site metrics data for current month
[ "Returns", "site", "metrics", "data", "for", "current", "month" ]
[ "\"\"\"\n Returns site metrics data for current month\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "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"...
aac684e37c8b10ebc504d86848f64855ed9e56a2
0xbs0d/figures
figures/views.py
[ "MIT" ]
Python
new_users
<not_specific>
def new_users(self, request): """ TODO: Rename the metrics module function to "new_users" to match this """ site = django.contrib.sites.shortcuts.get_current_site(request) date_for = datetime.utcnow().date() months_back = 6 new_users = metrics.get_monthly_history...
TODO: Rename the metrics module function to "new_users" to match this
Rename the metrics module function to "new_users" to match this
[ "Rename", "the", "metrics", "module", "function", "to", "\"", "new_users", "\"", "to", "match", "this" ]
def new_users(self, request): site = django.contrib.sites.shortcuts.get_current_site(request) date_for = datetime.utcnow().date() months_back = 6 new_users = metrics.get_monthly_history_metric( func=metrics.get_total_site_users_joined_for_time_period, site=site, ...
[ "def", "new_users", "(", "self", ",", "request", ")", ":", "site", "=", "django", ".", "contrib", ".", "sites", ".", "shortcuts", ".", "get_current_site", "(", "request", ")", "date_for", "=", "datetime", ".", "utcnow", "(", ")", ".", "date", "(", ")",...
TODO: Rename the metrics module function to "new_users" to match this
[ "TODO", ":", "Rename", "the", "metrics", "module", "function", "to", "\"", "new_users", "\"", "to", "match", "this" ]
[ "\"\"\"\n TODO: Rename the metrics module function to \"new_users\" to match this\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "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"...
aac684e37c8b10ebc504d86848f64855ed9e56a2
0xbs0d/figures
figures/views.py
[ "MIT" ]
Python
list
<not_specific>
def list(self, request): """ We use list instead of retrieve because retrieve requires a resource identifier, like a PK """ site = django.contrib.sites.shortcuts.get_current_site(request) data = retrieve_live_site_mau_data(site) serializer = self.serializer_class(...
We use list instead of retrieve because retrieve requires a resource identifier, like a PK
We use list instead of retrieve because retrieve requires a resource identifier, like a PK
[ "We", "use", "list", "instead", "of", "retrieve", "because", "retrieve", "requires", "a", "resource", "identifier", "like", "a", "PK" ]
def list(self, request): site = django.contrib.sites.shortcuts.get_current_site(request) data = retrieve_live_site_mau_data(site) serializer = self.serializer_class(data) return Response(serializer.data)
[ "def", "list", "(", "self", ",", "request", ")", ":", "site", "=", "django", ".", "contrib", ".", "sites", ".", "shortcuts", ".", "get_current_site", "(", "request", ")", "data", "=", "retrieve_live_site_mau_data", "(", "site", ")", "serializer", "=", "sel...
We use list instead of retrieve because retrieve requires a resource identifier, like a PK
[ "We", "use", "list", "instead", "of", "retrieve", "because", "retrieve", "requires", "a", "resource", "identifier", "like", "a", "PK" ]
[ "\"\"\"\n We use list instead of retrieve because retrieve requires a resource\n identifier, like a PK\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "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"...
058ff30b2aef3298cf9698a8d4607656a3eb32d1
rfzeg/pp_unit3_exercises
unit5_pp/scripts/gradient_descent_solution.py
[ "BSD-3-Clause" ]
Python
euclidean_distance
<not_specific>
def euclidean_distance(index_a, index_b, map_width): """ Euclidean distance between grid cells provided as linear indexes on a flat map """ a = indexToGridCell(index_a, map_width) b = indexToGridCell(index_b, map_width) return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5
Euclidean distance between grid cells provided as linear indexes on a flat map
Euclidean distance between grid cells provided as linear indexes on a flat map
[ "Euclidean", "distance", "between", "grid", "cells", "provided", "as", "linear", "indexes", "on", "a", "flat", "map" ]
def euclidean_distance(index_a, index_b, map_width): a = indexToGridCell(index_a, map_width) b = indexToGridCell(index_b, map_width) return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5
[ "def", "euclidean_distance", "(", "index_a", ",", "index_b", ",", "map_width", ")", ":", "a", "=", "indexToGridCell", "(", "index_a", ",", "map_width", ")", "b", "=", "indexToGridCell", "(", "index_b", ",", "map_width", ")", "return", "(", "(", "a", "[", ...
Euclidean distance between grid cells provided as linear indexes on a flat map
[ "Euclidean", "distance", "between", "grid", "cells", "provided", "as", "linear", "indexes", "on", "a", "flat", "map" ]
[ "\"\"\"\n Euclidean distance between grid cells provided as linear indexes on a flat map\n \"\"\"" ]
[ { "param": "index_a", "type": null }, { "param": "index_b", "type": null }, { "param": "map_width", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "index_a", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index_b", "type": null, "docstring": null, "docstring_toke...
058ff30b2aef3298cf9698a8d4607656a3eb32d1
rfzeg/pp_unit3_exercises
unit5_pp/scripts/gradient_descent_solution.py
[ "BSD-3-Clause" ]
Python
indexToGridCell
<not_specific>
def indexToGridCell(flat_map_index, map_width): """ Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates """ grid_cell_map_...
Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates
Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates
[ "Converts", "a", "linear", "index", "of", "a", "flat", "map", "to", "grid", "cell", "coordinate", "values", "flat_map_index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "map_width", ...
def indexToGridCell(flat_map_index, map_width): grid_cell_map_x = flat_map_index % map_width grid_cell_map_y = flat_map_index // map_width return [grid_cell_map_x, grid_cell_map_y]
[ "def", "indexToGridCell", "(", "flat_map_index", ",", "map_width", ")", ":", "grid_cell_map_x", "=", "flat_map_index", "%", "map_width", "grid_cell_map_y", "=", "flat_map_index", "//", "map_width", "return", "[", "grid_cell_map_x", ",", "grid_cell_map_y", "]" ]
Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates
[ "Converts", "a", "linear", "index", "of", "a", "flat", "map", "to", "grid", "cell", "coordinate", "values", "flat_map_index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "map_width", ...
[ "\"\"\"\n Converts a linear index of a flat map to grid cell coordinate values\n flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array\n map_width: the map's width \n returns: list with [x,y] grid cell coordinates\n \"\"\"" ]
[ { "param": "flat_map_index", "type": null }, { "param": "map_width", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "flat_map_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "map_width", "type": null, "docstring": null, "docst...
058ff30b2aef3298cf9698a8d4607656a3eb32d1
rfzeg/pp_unit3_exercises
unit5_pp/scripts/gradient_descent_solution.py
[ "BSD-3-Clause" ]
Python
gradient_descent
<not_specific>
def gradient_descent(start_index, goal_index, width, height, potential_field_data, descent_viz): ''' Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field ''' # Iterations limit max_iterations = 1000 # Iteration counter current_iteratio...
Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field
Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field
[ "Performs", "gradient", "descent", "on", "an", "artificial", "potential", "field", "with", "a", "given", "start", "goal", "node", "and", "a", "total", "potential", "field" ]
def gradient_descent(start_index, goal_index, width, height, potential_field_data, descent_viz): max_iterations = 1000 current_iteration = 0 goal_tolerance = 4 path_found = False current = start_index path = [] rospy.loginfo('Gradient descent: Done with initialization') while (current_iteration < max_it...
[ "def", "gradient_descent", "(", "start_index", ",", "goal_index", ",", "width", ",", "height", ",", "potential_field_data", ",", "descent_viz", ")", ":", "max_iterations", "=", "1000", "current_iteration", "=", "0", "goal_tolerance", "=", "4", "path_found", "=", ...
Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field
[ "Performs", "gradient", "descent", "on", "an", "artificial", "potential", "field", "with", "a", "given", "start", "goal", "node", "and", "a", "total", "potential", "field" ]
[ "''' \n Performs gradient descent on an artificial potential field \n with a given start, goal node and a total potential field\n '''", "# Iterations limit", "# Iteration counter", "# Tolerance margin allowed around goal position (in grid cells)", "# Boolean flag indicating whether the goal was reached o...
[ { "param": "start_index", "type": null }, { "param": "goal_index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "potential_field_data", "type": null }, { "param": "descent_viz", "type": null ...
{ "returns": [], "raises": [], "params": [ { "identifier": "start_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "goal_index", "type": null, "docstring": null, "docstri...
c14ab152e7a6fa2004bbe1f137adcd7c35fc9df1
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise.py
[ "BSD-3-Clause" ]
Python
calculate_distance
<not_specific>
def calculate_distance(p1, p2): """ Calculates distance between two [x,y] coordinates. p1: the point (as list containing x and y values) from which to measure p2: the point (as list containing x and y values) to which to measure returns: the distance """ dx = p2[0] - p1[0] dy = p2[1] - p1[1] distance...
Calculates distance between two [x,y] coordinates. p1: the point (as list containing x and y values) from which to measure p2: the point (as list containing x and y values) to which to measure returns: the distance
Calculates distance between two [x,y] coordinates. p1: the point (as list containing x and y values) from which to measure p2: the point (as list containing x and y values) to which to measure returns: the distance
[ "Calculates", "distance", "between", "two", "[", "x", "y", "]", "coordinates", ".", "p1", ":", "the", "point", "(", "as", "list", "containing", "x", "and", "y", "values", ")", "from", "which", "to", "measure", "p2", ":", "the", "point", "(", "as", "l...
def calculate_distance(p1, p2): dx = p2[0] - p1[0] dy = p2[1] - p1[1] distance = (dx ** 2 + dy ** 2)**0.5 return distance
[ "def", "calculate_distance", "(", "p1", ",", "p2", ")", ":", "dx", "=", "p2", "[", "0", "]", "-", "p1", "[", "0", "]", "dy", "=", "p2", "[", "1", "]", "-", "p1", "[", "1", "]", "distance", "=", "(", "dx", "**", "2", "+", "dy", "**", "2", ...
Calculates distance between two [x,y] coordinates.
[ "Calculates", "distance", "between", "two", "[", "x", "y", "]", "coordinates", "." ]
[ "\"\"\"\n Calculates distance between two [x,y] coordinates.\n p1: the point (as list containing x and y values) from which to measure \n p2: the point (as list containing x and y values) to which to measure\n returns: the distance\n \"\"\"" ]
[ { "param": "p1", "type": null }, { "param": "p2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2", "type": null, "docstring": null, "docstring_tokens": [], ...
c14ab152e7a6fa2004bbe1f137adcd7c35fc9df1
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise.py
[ "BSD-3-Clause" ]
Python
calculate_angle
<not_specific>
def calculate_angle(p1, p2): """ Calculates the angle of a straight line between two [x,y] coordinates. p1: the point (as list containing x and y values) from which to measure p2: the point (as list containing x and y values) to which to measure returns: the angle in radians """ dx = p2[0] - p1[0] dy =...
Calculates the angle of a straight line between two [x,y] coordinates. p1: the point (as list containing x and y values) from which to measure p2: the point (as list containing x and y values) to which to measure returns: the angle in radians
Calculates the angle of a straight line between two [x,y] coordinates. p1: the point (as list containing x and y values) from which to measure p2: the point (as list containing x and y values) to which to measure returns: the angle in radians
[ "Calculates", "the", "angle", "of", "a", "straight", "line", "between", "two", "[", "x", "y", "]", "coordinates", ".", "p1", ":", "the", "point", "(", "as", "list", "containing", "x", "and", "y", "values", ")", "from", "which", "to", "measure", "p2", ...
def calculate_angle(p1, p2): dx = p2[0] - p1[0] dy = p2[1] - p1[1] theta = atan2(dy, dx) return theta
[ "def", "calculate_angle", "(", "p1", ",", "p2", ")", ":", "dx", "=", "p2", "[", "0", "]", "-", "p1", "[", "0", "]", "dy", "=", "p2", "[", "1", "]", "-", "p1", "[", "1", "]", "theta", "=", "atan2", "(", "dy", ",", "dx", ")", "return", "the...
Calculates the angle of a straight line between two [x,y] coordinates.
[ "Calculates", "the", "angle", "of", "a", "straight", "line", "between", "two", "[", "x", "y", "]", "coordinates", "." ]
[ "\"\"\"\n Calculates the angle of a straight line between two [x,y] coordinates.\n p1: the point (as list containing x and y values) from which to measure \n p2: the point (as list containing x and y values) to which to measure\n returns: the angle in radians\n \"\"\"" ]
[ { "param": "p1", "type": null }, { "param": "p2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2", "type": null, "docstring": null, "docstring_tokens": [], ...
c14ab152e7a6fa2004bbe1f137adcd7c35fc9df1
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise.py
[ "BSD-3-Clause" ]
Python
find_closest_node
null
def find_closest_node(random_pt, node_list): """ Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree """ ## Add your code ## pass
Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree
Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree
[ "Finds", "the", "closest", "node", "in", "the", "tree", "random_pt", ":", "a", "[", "x", "y", "]", "point", "(", "as", "a", "list", ")", "node_list", ":", "list", "that", "keeps", "all", "nodes", "in", "the", "tree", "returns", ":", "Node", "instance...
def find_closest_node(random_pt, node_list): pass
[ "def", "find_closest_node", "(", "random_pt", ",", "node_list", ")", ":", "pass" ]
Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree
[ "Finds", "the", "closest", "node", "in", "the", "tree", "random_pt", ":", "a", "[", "x", "y", "]", "point", "(", "as", "a", "list", ")", "node_list", ":", "list", "that", "keeps", "all", "nodes", "in", "the", "tree", "returns", ":", "Node", "instance...
[ "\"\"\"\n Finds the closest node in the tree\n random_pt: a [x,y] point (as a list)\n node_list: list that keeps all nodes in the tree\n returns: Node instance that is the closest node in the tree\n \"\"\"", "## Add your code ##" ]
[ { "param": "random_pt", "type": null }, { "param": "node_list", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "random_pt", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node_list", "type": null, "docstring": null, "docstring_...
c14ab152e7a6fa2004bbe1f137adcd7c35fc9df1
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise.py
[ "BSD-3-Clause" ]
Python
create_new_branch_point
null
def create_new_branch_point(p1, p2, max_distance): """ Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new poi...
Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new point as a list containing x and y values
Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new point as a list containing x and y values
[ "Creates", "a", "new", "point", "at", "the", "max_distance", "towards", "a", "second", "point", "p1", ":", "the", "point", "to", "go", "from", "(", "as", "a", "list", "containing", "x", "and", "y", "values", ")", "p2", ":", "the", "point", "to", "go"...
def create_new_branch_point(p1, p2, max_distance): pass
[ "def", "create_new_branch_point", "(", "p1", ",", "p2", ",", "max_distance", ")", ":", "pass" ]
Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new point as a list containing x and y values
[ "Creates", "a", "new", "point", "at", "the", "max_distance", "towards", "a", "second", "point", "p1", ":", "the", "point", "to", "go", "from", "(", "as", "a", "list", "containing", "x", "and", "y", "values", ")", "p2", ":", "the", "point", "to", "go"...
[ "\"\"\"\n Creates a new point at the max_distance towards a second point\n p1: the point to go from (as a list containing x and y values)\n p2: the point to go to (as a list containing x and y values)\n max_distance: the expand distance (in grid cells)\n returns: new point as a list containing x and y values\n...
[ { "param": "p1", "type": null }, { "param": "p2", "type": null }, { "param": "max_distance", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2", "type": null, "docstring": null, "docstring_tokens": [], ...
c14ab152e7a6fa2004bbe1f137adcd7c35fc9df1
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise.py
[ "BSD-3-Clause" ]
Python
rrt
null
def rrt(initial_position, target_position, width, height, map, map_resolution, map_origin, tree_viz): ''' Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node ''' ## Add your code ## pass
Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node
Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node
[ "Performs", "Rapidly", "-", "Exploring", "Random", "Trees", "(", "RRT", ")", "algorithm", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
def rrt(initial_position, target_position, width, height, map, map_resolution, map_origin, tree_viz): pass
[ "def", "rrt", "(", "initial_position", ",", "target_position", ",", "width", ",", "height", ",", "map", ",", "map_resolution", ",", "map_origin", ",", "tree_viz", ")", ":", "pass" ]
Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node
[ "Performs", "Rapidly", "-", "Exploring", "Random", "Trees", "(", "RRT", ")", "algorithm", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
[ "''' \n Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node\n '''", "## Add your code ##" ]
[ { "param": "initial_position", "type": null }, { "param": "target_position", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "map", "type": null }, { "param": "map_resolution", "type": null }, ...
{ "returns": [], "raises": [], "params": [ { "identifier": "initial_position", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_position", "type": null, "docstring": null, ...
e41a847415557fa2440bb7b39dc8cff07d08e112
rfzeg/pp_unit3_exercises
unit5_pp/scripts/unit5_exercise.py
[ "BSD-3-Clause" ]
Python
random_force
<not_specific>
def random_force(K = 1.0): """ Toy function that calculates a random force for one grid cell returns: a random force value scaled by the constant K """ return K * random.uniform(0, 100)
Toy function that calculates a random force for one grid cell returns: a random force value scaled by the constant K
Toy function that calculates a random force for one grid cell returns: a random force value scaled by the constant K
[ "Toy", "function", "that", "calculates", "a", "random", "force", "for", "one", "grid", "cell", "returns", ":", "a", "random", "force", "value", "scaled", "by", "the", "constant", "K" ]
def random_force(K = 1.0): return K * random.uniform(0, 100)
[ "def", "random_force", "(", "K", "=", "1.0", ")", ":", "return", "K", "*", "random", ".", "uniform", "(", "0", ",", "100", ")" ]
Toy function that calculates a random force for one grid cell returns: a random force value scaled by the constant K
[ "Toy", "function", "that", "calculates", "a", "random", "force", "for", "one", "grid", "cell", "returns", ":", "a", "random", "force", "value", "scaled", "by", "the", "constant", "K" ]
[ "\"\"\"\n Toy function that calculates a random force for one grid cell\n returns: a random force value scaled by the constant K\n \"\"\"" ]
[ { "param": "K", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "K", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e41a847415557fa2440bb7b39dc8cff07d08e112
rfzeg/pp_unit3_exercises
unit5_pp/scripts/unit5_exercise.py
[ "BSD-3-Clause" ]
Python
populate_attractive_field
null
def populate_attractive_field(height, width, goal_xy): """ Creates an attractive field returns: 1D flat grid map """ pass
Creates an attractive field returns: 1D flat grid map
Creates an attractive field returns: 1D flat grid map
[ "Creates", "an", "attractive", "field", "returns", ":", "1D", "flat", "grid", "map" ]
def populate_attractive_field(height, width, goal_xy): pass
[ "def", "populate_attractive_field", "(", "height", ",", "width", ",", "goal_xy", ")", ":", "pass" ]
Creates an attractive field returns: 1D flat grid map
[ "Creates", "an", "attractive", "field", "returns", ":", "1D", "flat", "grid", "map" ]
[ "\"\"\" \n Creates an attractive field\n returns: 1D flat grid map\n \"\"\"" ]
[ { "param": "height", "type": null }, { "param": "width", "type": null }, { "param": "goal_xy", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "height", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "width", "type": null, "docstring": null, "docstring_tokens"...
e41a847415557fa2440bb7b39dc8cff07d08e112
rfzeg/pp_unit3_exercises
unit5_pp/scripts/unit5_exercise.py
[ "BSD-3-Clause" ]
Python
rescale_to_max_value
<not_specific>
def rescale_to_max_value(max_value, input_list): """ Rescale each value inside input_list into a target range of 0 to max_value """ scale_factor = max_value / float(max(input_list)) # Multiply each item by the scale_factor input_list_rescaled = [int(x * scale_factor) for x in input_list] return inpu...
Rescale each value inside input_list into a target range of 0 to max_value
Rescale each value inside input_list into a target range of 0 to max_value
[ "Rescale", "each", "value", "inside", "input_list", "into", "a", "target", "range", "of", "0", "to", "max_value" ]
def rescale_to_max_value(max_value, input_list): scale_factor = max_value / float(max(input_list)) input_list_rescaled = [int(x * scale_factor) for x in input_list] return input_list_rescaled
[ "def", "rescale_to_max_value", "(", "max_value", ",", "input_list", ")", ":", "scale_factor", "=", "max_value", "/", "float", "(", "max", "(", "input_list", ")", ")", "input_list_rescaled", "=", "[", "int", "(", "x", "*", "scale_factor", ")", "for", "x", "...
Rescale each value inside input_list into a target range of 0 to max_value
[ "Rescale", "each", "value", "inside", "input_list", "into", "a", "target", "range", "of", "0", "to", "max_value" ]
[ "\"\"\" Rescale each value inside input_list into a target range of 0 to max_value \"\"\"", "# Multiply each item by the scale_factor" ]
[ { "param": "max_value", "type": null }, { "param": "input_list", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "max_value", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_list", "type": null, "docstring": null, "docstring...
e41a847415557fa2440bb7b39dc8cff07d08e112
rfzeg/pp_unit3_exercises
unit5_pp/scripts/unit5_exercise.py
[ "BSD-3-Clause" ]
Python
world_to_grid_map
<not_specific>
def world_to_grid_map(world_pose): """ Convert Pose() message in world frame of reference to grid map cell/pixel coordinates """ grid_cell_x = int((world_pose.position.x - attractive_field.info.origin.position.x) / attractive_field.info.resolution) grid_cell_y = int((world_pose.position.y - attractive_field...
Convert Pose() message in world frame of reference to grid map cell/pixel coordinates
Convert Pose() message in world frame of reference to grid map cell/pixel coordinates
[ "Convert", "Pose", "()", "message", "in", "world", "frame", "of", "reference", "to", "grid", "map", "cell", "/", "pixel", "coordinates" ]
def world_to_grid_map(world_pose): grid_cell_x = int((world_pose.position.x - attractive_field.info.origin.position.x) / attractive_field.info.resolution) grid_cell_y = int((world_pose.position.y - attractive_field.info.origin.position.y) / attractive_field.info.resolution) return [grid_cell_x, grid_cell_y]
[ "def", "world_to_grid_map", "(", "world_pose", ")", ":", "grid_cell_x", "=", "int", "(", "(", "world_pose", ".", "position", ".", "x", "-", "attractive_field", ".", "info", ".", "origin", ".", "position", ".", "x", ")", "/", "attractive_field", ".", "info"...
Convert Pose() message in world frame of reference to grid map cell/pixel coordinates
[ "Convert", "Pose", "()", "message", "in", "world", "frame", "of", "reference", "to", "grid", "map", "cell", "/", "pixel", "coordinates" ]
[ "\"\"\" Convert Pose() message in world frame of reference to grid map cell/pixel coordinates \"\"\"" ]
[ { "param": "world_pose", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "world_pose", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f651bc23499d8eec0741f83ad2802d8bdd6f2452
rfzeg/pp_unit3_exercises
unit2_pp/scripts/unit2_solution_server.py
[ "BSD-3-Clause" ]
Python
make_plan
<not_specific>
def make_plan(req): ''' Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse ''' # costmap as 1-D array representation costmap = req.costmap_ros # number of columns in the occupancy grid width = req.width # number of rows ...
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", ".", "It", "returns", "a", "msg", "of", "type", "PathPlanningPluginResponse" ]
def make_plan(req): costmap = req.costmap_ros width = req.width height = req.height start_index = req.start goal_index = req.goal resolution = 0.2 origin = [-7.4, -7.4, 0] viz = GridViz(costmap, resolution, origin, start_index, goal_index, width) start_time = rospy.Time.now() path = dijkstra(start_i...
[ "def", "make_plan", "(", "req", ")", ":", "costmap", "=", "req", ".", "costmap_ros", "width", "=", "req", ".", "width", "height", "=", "req", ".", "height", "start_index", "=", "req", ".", "start", "goal_index", "=", "req", ".", "goal", "resolution", "...
Callback function used by the service server to process requests from clients.
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", "." ]
[ "''' \n Callback function used by the service server to process\n requests from clients. It returns a msg of type PathPlanningPluginResponse\n '''", "# costmap as 1-D array representation", "# number of columns in the occupancy grid", "# number of rows in the occupancy grid", "# side of each grid map squ...
[ { "param": "req", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "req", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6dd31e4e55cc740be4b16f0ca285414a2fd1cac7
rfzeg/pp_unit3_exercises
unit5_pp/scripts/gradient_descent.py
[ "BSD-3-Clause" ]
Python
gradient_descent
null
def gradient_descent(start_index, goal_index, width, height, potential_field_data, descent_viz): ''' Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field ''' pass
Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field
Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field
[ "Performs", "gradient", "descent", "on", "an", "artificial", "potential", "field", "with", "a", "given", "start", "goal", "node", "and", "a", "total", "potential", "field" ]
def gradient_descent(start_index, goal_index, width, height, potential_field_data, descent_viz): pass
[ "def", "gradient_descent", "(", "start_index", ",", "goal_index", ",", "width", ",", "height", ",", "potential_field_data", ",", "descent_viz", ")", ":", "pass" ]
Performs gradient descent on an artificial potential field with a given start, goal node and a total potential field
[ "Performs", "gradient", "descent", "on", "an", "artificial", "potential", "field", "with", "a", "given", "start", "goal", "node", "and", "a", "total", "potential", "field" ]
[ "''' \n Performs gradient descent on an artificial potential field \n with a given start, goal node and a total potential field\n '''" ]
[ { "param": "start_index", "type": null }, { "param": "goal_index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "potential_field_data", "type": null }, { "param": "descent_viz", "type": null ...
{ "returns": [], "raises": [], "params": [ { "identifier": "start_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "goal_index", "type": null, "docstring": null, "docstri...
51e390807dd3601f364492ecc606070ea12af6c6
rfzeg/pp_unit3_exercises
unit3_pp/scripts/unit3_gbfs_exercise_server.py
[ "BSD-3-Clause" ]
Python
make_plan
<not_specific>
def make_plan(req): ''' Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse ''' # costmap as 1-D array representation costmap = req.costmap_ros # number of columns in the occupancy grid width = req.width # number of rows ...
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", ".", "It", "returns", "a", "msg", "of", "type", "PathPlanningPluginResponse" ]
def make_plan(req): costmap = req.costmap_ros width = req.width height = req.height start_index = req.start goal_index = req.goal resolution = 0.2 origin = [-7.4, -7.4, 0] viz = GridViz(costmap, resolution, origin, start_index, goal_index, width) start_time = rospy.Time.now() path = greedy_bfs(start...
[ "def", "make_plan", "(", "req", ")", ":", "costmap", "=", "req", ".", "costmap_ros", "width", "=", "req", ".", "width", "height", "=", "req", ".", "height", "start_index", "=", "req", ".", "start", "goal_index", "=", "req", ".", "goal", "resolution", "...
Callback function used by the service server to process requests from clients.
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", "." ]
[ "''' \n Callback function used by the service server to process\n requests from clients. It returns a msg of type PathPlanningPluginResponse\n '''", "# costmap as 1-D array representation", "# number of columns in the occupancy grid", "# number of rows in the occupancy grid", "# side of each grid map squ...
[ { "param": "req", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "req", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
78d13e65958bdc0e38670c0f8fbe78836e056725
rfzeg/pp_unit3_exercises
unit2_pp/scripts/unit2_solution.py
[ "BSD-3-Clause" ]
Python
find_neighbors
<not_specific>
def find_neighbors(index, width, height, costmap, orthogonal_step_cost): """ Identifies neighbor nodes inspecting the 8 adjacent neighbors Checks if neighbor is inside the map boundaries and if is not an obstacle according to a threshold Returns a list with valid neighbour nodes as [index, step_cost] pairs ""...
Identifies neighbor nodes inspecting the 8 adjacent neighbors Checks if neighbor is inside the map boundaries and if is not an obstacle according to a threshold Returns a list with valid neighbour nodes as [index, step_cost] pairs
Identifies neighbor nodes inspecting the 8 adjacent neighbors Checks if neighbor is inside the map boundaries and if is not an obstacle according to a threshold Returns a list with valid neighbour nodes as [index, step_cost] pairs
[ "Identifies", "neighbor", "nodes", "inspecting", "the", "8", "adjacent", "neighbors", "Checks", "if", "neighbor", "is", "inside", "the", "map", "boundaries", "and", "if", "is", "not", "an", "obstacle", "according", "to", "a", "threshold", "Returns", "a", "list...
def find_neighbors(index, width, height, costmap, orthogonal_step_cost): neighbors = [] diagonal_step_cost = orthogonal_step_cost * 1.41421 lethal_cost = 1 upper = index - width if upper > 0: if costmap[upper] < lethal_cost: step_cost = orthogonal_step_cost + costmap[upper]/255 neighbors.appen...
[ "def", "find_neighbors", "(", "index", ",", "width", ",", "height", ",", "costmap", ",", "orthogonal_step_cost", ")", ":", "neighbors", "=", "[", "]", "diagonal_step_cost", "=", "orthogonal_step_cost", "*", "1.41421", "lethal_cost", "=", "1", "upper", "=", "in...
Identifies neighbor nodes inspecting the 8 adjacent neighbors Checks if neighbor is inside the map boundaries and if is not an obstacle according to a threshold Returns a list with valid neighbour nodes as [index, step_cost] pairs
[ "Identifies", "neighbor", "nodes", "inspecting", "the", "8", "adjacent", "neighbors", "Checks", "if", "neighbor", "is", "inside", "the", "map", "boundaries", "and", "if", "is", "not", "an", "obstacle", "according", "to", "a", "threshold", "Returns", "a", "list...
[ "\"\"\"\n Identifies neighbor nodes inspecting the 8 adjacent neighbors\n Checks if neighbor is inside the map boundaries and if is not an obstacle according to a threshold\n Returns a list with valid neighbour nodes as [index, step_cost] pairs\n \"\"\"", "# length of diagonal = length of one side by the squa...
[ { "param": "index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "costmap", "type": null }, { "param": "orthogonal_step_cost", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "width", "type": null, "docstring": null, "docstring_tokens":...
78d13e65958bdc0e38670c0f8fbe78836e056725
rfzeg/pp_unit3_exercises
unit2_pp/scripts/unit2_solution.py
[ "BSD-3-Clause" ]
Python
dijkstra
<not_specific>
def dijkstra(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz): ''' Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node ''' # create an open_list open_list = [] # set to hold already processed nodes closed_list = set() # dict f...
Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node
Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node
[ "Performs", "Dijkstra", "'", "s", "shortes", "path", "algorithm", "search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
def dijkstra(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz): open_list = [] closed_list = set() parents = dict() g_costs = dict() g_costs[start_index] = 0 open_list.append([start_index, 0]) shortest_path = [] path_found = False rospy.loginfo('Dijkstra: Done with initial...
[ "def", "dijkstra", "(", "start_index", ",", "goal_index", ",", "width", ",", "height", ",", "costmap", ",", "resolution", ",", "origin", ",", "grid_viz", ")", ":", "open_list", "=", "[", "]", "closed_list", "=", "set", "(", ")", "parents", "=", "dict", ...
Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node
[ "Performs", "Dijkstra", "'", "s", "shortes", "path", "algorithm", "search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
[ "''' \n Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node\n '''", "# create an open_list", "# set to hold already processed nodes", "# dict for mapping children to parent", "# dict for mapping g costs (travel costs) to nodes", "# set the start's node g_cost"...
[ { "param": "start_index", "type": null }, { "param": "goal_index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "costmap", "type": null }, { "param": "resolution", "type": null }, { "pa...
{ "returns": [], "raises": [], "params": [ { "identifier": "start_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "goal_index", "type": null, "docstring": null, "docstri...
5cc88305e0cb26bcae8d0eca3a9ff52805989579
rfzeg/pp_unit3_exercises
unit5_pp/scripts/unit5_pp_server.py
[ "BSD-3-Clause" ]
Python
make_plan
<not_specific>
def make_plan(req): ''' Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse ''' global got_potential_field_update # costmap as 1-D array representation costmap = req.costmap_ros # number of columns in the occupancy grid wi...
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", ".", "It", "returns", "a", "msg", "of", "type", "PathPlanningPluginResponse" ]
def make_plan(req): global got_potential_field_update costmap = req.costmap_ros width = req.width height = req.height start_index = req.start goal_index = req.goal resolution = 0.2 origin = [-7.4, -7.4, 0] got_potential_field_update = False while not got_potential_field_update: pass viz = Desc...
[ "def", "make_plan", "(", "req", ")", ":", "global", "got_potential_field_update", "costmap", "=", "req", ".", "costmap_ros", "width", "=", "req", ".", "width", "height", "=", "req", ".", "height", "start_index", "=", "req", ".", "start", "goal_index", "=", ...
Callback function used by the service server to process requests from clients.
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", "." ]
[ "''' \n Callback function used by the service server to process\n requests from clients. It returns a msg of type PathPlanningPluginResponse\n '''", "# costmap as 1-D array representation", "# number of columns in the occupancy grid", "# number of rows in the occupancy grid", "# side of each grid map squ...
[ { "param": "req", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "req", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3f8e1f8bef34916bf1eee2f9dda967d2b4adfcb6
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise_solution.py
[ "BSD-3-Clause" ]
Python
find_closest_node
<not_specific>
def find_closest_node(random_pt, node_list): """ Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree """ nearest_distance = float('inf') for n in node_list: current_distan...
Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree
Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree
[ "Finds", "the", "closest", "node", "in", "the", "tree", "random_pt", ":", "a", "[", "x", "y", "]", "point", "(", "as", "a", "list", ")", "node_list", ":", "list", "that", "keeps", "all", "nodes", "in", "the", "tree", "returns", ":", "Node", "instance...
def find_closest_node(random_pt, node_list): nearest_distance = float('inf') for n in node_list: current_distance = calculate_distance(random_pt, n.coordinates) if current_distance < nearest_distance: nearest_node = n nearest_distance = current_distance return nearest_node
[ "def", "find_closest_node", "(", "random_pt", ",", "node_list", ")", ":", "nearest_distance", "=", "float", "(", "'inf'", ")", "for", "n", "in", "node_list", ":", "current_distance", "=", "calculate_distance", "(", "random_pt", ",", "n", ".", "coordinates", ")...
Finds the closest node in the tree random_pt: a [x,y] point (as a list) node_list: list that keeps all nodes in the tree returns: Node instance that is the closest node in the tree
[ "Finds", "the", "closest", "node", "in", "the", "tree", "random_pt", ":", "a", "[", "x", "y", "]", "point", "(", "as", "a", "list", ")", "node_list", ":", "list", "that", "keeps", "all", "nodes", "in", "the", "tree", "returns", ":", "Node", "instance...
[ "\"\"\"\n Finds the closest node in the tree\n random_pt: a [x,y] point (as a list)\n node_list: list that keeps all nodes in the tree\n returns: Node instance that is the closest node in the tree\n \"\"\"" ]
[ { "param": "random_pt", "type": null }, { "param": "node_list", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "random_pt", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node_list", "type": null, "docstring": null, "docstring_...
3f8e1f8bef34916bf1eee2f9dda967d2b4adfcb6
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise_solution.py
[ "BSD-3-Clause" ]
Python
create_new_branch_point
<not_specific>
def create_new_branch_point(p1, p2, max_distance): """ Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new poi...
Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new point as a list containing x and y values
Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new point as a list containing x and y values
[ "Creates", "a", "new", "point", "at", "the", "max_distance", "towards", "a", "second", "point", "p1", ":", "the", "point", "to", "go", "from", "(", "as", "a", "list", "containing", "x", "and", "y", "values", ")", "p2", ":", "the", "point", "to", "go"...
def create_new_branch_point(p1, p2, max_distance): new_point = list(p1) d = calculate_distance(new_point, p2) theta = calculate_angle(new_point, p2) if max_distance > d: max_distance = d new_point[0] += int(max_distance * cos(theta)) new_point[1] += int(max_distance * sin(theta)) return new_point
[ "def", "create_new_branch_point", "(", "p1", ",", "p2", ",", "max_distance", ")", ":", "new_point", "=", "list", "(", "p1", ")", "d", "=", "calculate_distance", "(", "new_point", ",", "p2", ")", "theta", "=", "calculate_angle", "(", "new_point", ",", "p2",...
Creates a new point at the max_distance towards a second point p1: the point to go from (as a list containing x and y values) p2: the point to go to (as a list containing x and y values) max_distance: the expand distance (in grid cells) returns: new point as a list containing x and y values
[ "Creates", "a", "new", "point", "at", "the", "max_distance", "towards", "a", "second", "point", "p1", ":", "the", "point", "to", "go", "from", "(", "as", "a", "list", "containing", "x", "and", "y", "values", ")", "p2", ":", "the", "point", "to", "go"...
[ "\"\"\"\n Creates a new point at the max_distance towards a second point\n p1: the point to go from (as a list containing x and y values)\n p2: the point to go to (as a list containing x and y values)\n max_distance: the expand distance (in grid cells)\n returns: new point as a list containing x and y values\n...
[ { "param": "p1", "type": null }, { "param": "p2", "type": null }, { "param": "max_distance", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2", "type": null, "docstring": null, "docstring_tokens": [], ...
3f8e1f8bef34916bf1eee2f9dda967d2b4adfcb6
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise_solution.py
[ "BSD-3-Clause" ]
Python
rrt
<not_specific>
def rrt(initial_position, target_position, width, height, map, map_resolution, map_origin, tree_viz): ''' Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node ''' # Create the root node root_node = Node(initial_position) # A list to keep all nodes in the tre...
Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node
Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node
[ "Performs", "Rapidly", "-", "Exploring", "Random", "Trees", "(", "RRT", ")", "algorithm", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
def rrt(initial_position, target_position, width, height, map, map_resolution, map_origin, tree_viz): root_node = Node(initial_position) nodes = [root_node] interations = 0 max_iterations = 10000 max_branch_lenght = 20 goal_tolerance = 20 path = [] while True: interations += 1 if interations > m...
[ "def", "rrt", "(", "initial_position", ",", "target_position", ",", "width", ",", "height", ",", "map", ",", "map_resolution", ",", "map_origin", ",", "tree_viz", ")", ":", "root_node", "=", "Node", "(", "initial_position", ")", "nodes", "=", "[", "root_node...
Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node
[ "Performs", "Rapidly", "-", "Exploring", "Random", "Trees", "(", "RRT", ")", "algorithm", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
[ "''' \n Performs Rapidly-Exploring Random Trees (RRT) algorithm on a costmap with a given start and goal node\n '''", "# Create the root node", "# A list to keep all nodes in the tree", "# Iteration counter", "# Iterations limit", "# Incremental distance (for simplicity value is expressed in grid cells)...
[ { "param": "initial_position", "type": null }, { "param": "target_position", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "map", "type": null }, { "param": "map_resolution", "type": null }, ...
{ "returns": [], "raises": [], "params": [ { "identifier": "initial_position", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_position", "type": null, "docstring": null, ...
8a4c4fad7f26d4d1dd67f7b88494a5812c150c0c
rfzeg/pp_unit3_exercises
unit3_pp/scripts/unit3_astar_solution.py
[ "BSD-3-Clause" ]
Python
indexToWorld
<not_specific>
def indexToWorld(flatmap_index, map_width, map_resolution, map_origin = [0,0]): """ Converts a flatmap index value to world coordinates (meters) flatmap_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: number of columns in the occupancy grid map_resolution: side lenght...
Converts a flatmap index value to world coordinates (meters) flatmap_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: number of columns in the occupancy grid map_resolution: side lenght of each grid map cell in meters map_origin: the x,y position in grid cell coordina...
Converts a flatmap index value to world coordinates (meters) flatmap_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: number of columns in the occupancy grid map_resolution: side lenght of each grid map cell in meters map_origin: the x,y position in grid cell coordinates of the world's co...
[ "Converts", "a", "flatmap", "index", "value", "to", "world", "coordinates", "(", "meters", ")", "flatmap_index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "map_width", ":", "number", ...
def indexToWorld(flatmap_index, map_width, map_resolution, map_origin = [0,0]): grid_cell_map_x = flatmap_index % map_width grid_cell_map_y = flatmap_index // map_width x = map_resolution * grid_cell_map_x + map_origin[0] y = map_resolution * grid_cell_map_y + map_origin[1] return [x,y]
[ "def", "indexToWorld", "(", "flatmap_index", ",", "map_width", ",", "map_resolution", ",", "map_origin", "=", "[", "0", ",", "0", "]", ")", ":", "grid_cell_map_x", "=", "flatmap_index", "%", "map_width", "grid_cell_map_y", "=", "flatmap_index", "//", "map_width"...
Converts a flatmap index value to world coordinates (meters) flatmap_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: number of columns in the occupancy grid map_resolution: side lenght of each grid map cell in meters map_origin: the x,y position in grid cell coordinates of the world's co...
[ "Converts", "a", "flatmap", "index", "value", "to", "world", "coordinates", "(", "meters", ")", "flatmap_index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "map_width", ":", "number", ...
[ "\"\"\"\n Converts a flatmap index value to world coordinates (meters)\n flatmap_index: a linear index value, specifying a cell/pixel in an 1-D array\n map_width: number of columns in the occupancy grid\n map_resolution: side lenght of each grid map cell in meters\n map_origin: the x,y position in gr...
[ { "param": "flatmap_index", "type": null }, { "param": "map_width", "type": null }, { "param": "map_resolution", "type": null }, { "param": "map_origin", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "flatmap_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "map_width", "type": null, "docstring": null, "docstr...
8a4c4fad7f26d4d1dd67f7b88494a5812c150c0c
rfzeg/pp_unit3_exercises
unit3_pp/scripts/unit3_astar_solution.py
[ "BSD-3-Clause" ]
Python
a_star
<not_specific>
def a_star(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz): ''' Performs A-star's shortes path algorithm search on a costmap with a given start and goal node ''' # create an open_list open_list = [] # set to hold already processed nodes closed_list = set() # dict for m...
Performs A-star's shortes path algorithm search on a costmap with a given start and goal node
Performs A-star's shortes path algorithm search on a costmap with a given start and goal node
[ "Performs", "A", "-", "star", "'", "s", "shortes", "path", "algorithm", "search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
def a_star(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz): open_list = [] closed_list = set() parents = dict() g_costs = dict() f_costs = dict() g_costs[start_index] = 0 from_xy = indexToWorld(start_index, width, resolution, origin) to_xy = indexToWorld(goal_index, width,...
[ "def", "a_star", "(", "start_index", ",", "goal_index", ",", "width", ",", "height", ",", "costmap", ",", "resolution", ",", "origin", ",", "grid_viz", ")", ":", "open_list", "=", "[", "]", "closed_list", "=", "set", "(", ")", "parents", "=", "dict", "...
Performs A-star's shortes path algorithm search on a costmap with a given start and goal node
[ "Performs", "A", "-", "star", "'", "s", "shortes", "path", "algorithm", "search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
[ "''' \n Performs A-star's shortes path algorithm search on a costmap with a given start and goal node\n '''", "# create an open_list", "# set to hold already processed nodes", "# dict for mapping children to parent", "# dict for mapping g costs (travel costs) to nodes", "# dict for mapping f costs (tota...
[ { "param": "start_index", "type": null }, { "param": "goal_index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "costmap", "type": null }, { "param": "resolution", "type": null }, { "pa...
{ "returns": [], "raises": [], "params": [ { "identifier": "start_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "goal_index", "type": null, "docstring": null, "docstri...
7d73397a011e7053212201c7b8f805b9877be267
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise_server.py
[ "BSD-3-Clause" ]
Python
make_plan
<not_specific>
def make_plan(req): ''' Callback function used by the service server to process requests. It returns a PathPlanningPluginResponse ''' # Convert costmap from a 1-D tuple flat map representation map = list(req.costmap_ros) # Change values on the map from unknown to free space map[map==255] = 1 width = ...
Callback function used by the service server to process requests. It returns a PathPlanningPluginResponse
Callback function used by the service server to process requests. It returns a PathPlanningPluginResponse
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", ".", "It", "returns", "a", "PathPlanningPluginResponse" ]
def make_plan(req): map = list(req.costmap_ros) map[map==255] = 1 width = req.width height = req.height start_index = req.start goal_index = req.goal map_resolution = 0.1 map_origin = [-20.0, -20.0] initial_position = indexToGridCell(start_index, width) target_position = indexToGridCell(goal_index, ...
[ "def", "make_plan", "(", "req", ")", ":", "map", "=", "list", "(", "req", ".", "costmap_ros", ")", "map", "[", "map", "==", "255", "]", "=", "1", "width", "=", "req", ".", "width", "height", "=", "req", ".", "height", "start_index", "=", "req", "...
Callback function used by the service server to process requests.
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "." ]
[ "''' \n Callback function used by the service server to process requests.\n It returns a PathPlanningPluginResponse\n '''", "# Convert costmap from a 1-D tuple flat map representation", "# Change values on the map from unknown to free space", "# side of each grid map square in meters", "# origin of grid ...
[ { "param": "req", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "req", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d73397a011e7053212201c7b8f805b9877be267
rfzeg/pp_unit3_exercises
unit4_pp/scripts/unit4_exercise_server.py
[ "BSD-3-Clause" ]
Python
indexToGridCell
<not_specific>
def indexToGridCell(flat_map_index, map_width): """ Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates """ grid_cell_map_x = flat_map_i...
Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates
Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates
[ "Converts", "a", "linear", "index", "of", "a", "flat", "map", "to", "grid", "cell", "coordinate", "values", "flat_map_index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "map_width", ...
def indexToGridCell(flat_map_index, map_width): grid_cell_map_x = flat_map_index % map_width grid_cell_map_y = flat_map_index // map_width return [grid_cell_map_x, grid_cell_map_y]
[ "def", "indexToGridCell", "(", "flat_map_index", ",", "map_width", ")", ":", "grid_cell_map_x", "=", "flat_map_index", "%", "map_width", "grid_cell_map_y", "=", "flat_map_index", "//", "map_width", "return", "[", "grid_cell_map_x", ",", "grid_cell_map_y", "]" ]
Converts a linear index of a flat map to grid cell coordinate values flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array map_width: the map's width returns: list with [x,y] grid cell coordinates
[ "Converts", "a", "linear", "index", "of", "a", "flat", "map", "to", "grid", "cell", "coordinate", "values", "flat_map_index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "map_width", ...
[ "\"\"\"\n Converts a linear index of a flat map to grid cell coordinate values\n flat_map_index: a linear index value, specifying a cell/pixel in an 1-D array\n map_width: the map's width \n returns: list with [x,y] grid cell coordinates\n \"\"\"" ]
[ { "param": "flat_map_index", "type": null }, { "param": "map_width", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "flat_map_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "map_width", "type": null, "docstring": null, "docst...
c9deb650839257dd6c511ae0ee8bb6b306ff1de9
rfzeg/pp_unit3_exercises
unit6_pp/scripts/planner_solution.py
[ "BSD-3-Clause" ]
Python
geo_path
<not_specific>
def geo_path(self, req): """ Plan the shortest path between a start and a destination geopoint. The 'geo_path' method can receive GeoPoints out of the graph, upon such a case, the nearest segments on the OSM map are detected, and the planning is carried out. :pram req: The requ...
Plan the shortest path between a start and a destination geopoint. The 'geo_path' method can receive GeoPoints out of the graph, upon such a case, the nearest segments on the OSM map are detected, and the planning is carried out. :pram req: The request message. :param req: geo...
Plan the shortest path between a start and a destination geopoint. The 'geo_path' method can receive GeoPoints out of the graph, upon such a case, the nearest segments on the OSM map are detected, and the planning is carried out.
[ "Plan", "the", "shortest", "path", "between", "a", "start", "and", "a", "destination", "geopoint", ".", "The", "'", "geo_path", "'", "method", "can", "receive", "GeoPoints", "out", "of", "the", "graph", "upon", "such", "a", "case", "the", "nearest", "segme...
def geo_path(self, req): if math.isnan(req.start.latitude) or math.isnan(req.start.longitude): raise ValueError('NaN in starting point: ' + str(req.start)) if math.isnan(req.goal.latitude) or math.isnan(req.goal.longitude): raise ValueError('NaN in starting point: ' + str(req.sta...
[ "def", "geo_path", "(", "self", ",", "req", ")", ":", "if", "math", ".", "isnan", "(", "req", ".", "start", ".", "latitude", ")", "or", "math", ".", "isnan", "(", "req", ".", "start", ".", "longitude", ")", ":", "raise", "ValueError", "(", "'NaN in...
Plan the shortest path between a start and a destination geopoint.
[ "Plan", "the", "shortest", "path", "between", "a", "start", "and", "a", "destination", "geopoint", "." ]
[ "\"\"\" Plan the shortest path between a start and a destination geopoint.\n\n The 'geo_path' method can receive GeoPoints out of the graph, upon such a case, the nearest segments on the OSM map are detected,\n and the planning is carried out.\n \n :pram req: The request message.\n ...
[ { "param": "self", "type": null }, { "param": "req", "type": null } ]
{ "returns": [ { "docstring": "The computed path, as well as the ids of the RouteNetwork and the start and end segments, plus the length of the path. The length is set to -1 in case of failure.", "docstring_tokens": [ "The", "computed", "path", "as", "well", ...
c9deb650839257dd6c511ae0ee8bb6b306ff1de9
rfzeg/pp_unit3_exercises
unit6_pp/scripts/planner_solution.py
[ "BSD-3-Clause" ]
Python
dijkstra_geo_planner
<not_specific>
def dijkstra_geo_planner(self, start_segment, goal_segment): """ Plan route from start to goal. The actual search algorithm to find a path is executed here. start_segment: The nearest segment to the start point, as type 'geographic_msgs/RouteSegment' goal_segment: The nearest segment...
Plan route from start to goal. The actual search algorithm to find a path is executed here. start_segment: The nearest segment to the start point, as type 'geographic_msgs/RouteSegment' goal_segment: The nearest segment to the goal point, as type 'geographic_msgs/RouteSegment' retur...
Plan route from start to goal. The actual search algorithm to find a path is executed here.
[ "Plan", "route", "from", "start", "to", "goal", ".", "The", "actual", "search", "algorithm", "to", "find", "a", "path", "is", "executed", "here", "." ]
def dijkstra_geo_planner(self, start_segment, goal_segment): start_idx = self.points.index(start_segment.start.uuid) goal_idx = self.points.index(goal_segment.start.uuid) plan = RoutePath(network=self.graph.id) open_list = [] open_list.append([0, start_idx]) closed_list =...
[ "def", "dijkstra_geo_planner", "(", "self", ",", "start_segment", ",", "goal_segment", ")", ":", "start_idx", "=", "self", ".", "points", ".", "index", "(", "start_segment", ".", "start", ".", "uuid", ")", "goal_idx", "=", "self", ".", "points", ".", "inde...
Plan route from start to goal.
[ "Plan", "route", "from", "start", "to", "goal", "." ]
[ "\"\"\" \n Plan route from start to goal. The actual search algorithm to find a path is executed here. \n start_segment: The nearest segment to the start point, as type 'geographic_msgs/RouteSegment'\n goal_segment: The nearest segment to the goal point, as type 'geographic_msgs/RouteSegment'...
[ { "param": "self", "type": null }, { "param": "start_segment", "type": null }, { "param": "goal_segment", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_segment", "type": null, "docstring": null, "docstring_t...
c9deb650839257dd6c511ae0ee8bb6b306ff1de9
rfzeg/pp_unit3_exercises
unit6_pp/scripts/planner_solution.py
[ "BSD-3-Clause" ]
Python
_get_min_point
<not_specific>
def _get_min_point(self, seg, lot): """ Chooses between the orthogonal projection, and the start and end points of the segment. If the given orthogonal projection lies out of the segment, the whether the start or end point of the segment must be chosen as the minimum point. ...
Chooses between the orthogonal projection, and the start and end points of the segment. If the given orthogonal projection lies out of the segment, the whether the start or end point of the segment must be chosen as the minimum point. :param seg: The segment. :type seg: ge...
Chooses between the orthogonal projection, and the start and end points of the segment. If the given orthogonal projection lies out of the segment, the whether the start or end point of the segment must be chosen as the minimum point.
[ "Chooses", "between", "the", "orthogonal", "projection", "and", "the", "start", "and", "end", "points", "of", "the", "segment", ".", "If", "the", "given", "orthogonal", "projection", "lies", "out", "of", "the", "segment", "the", "whether", "the", "start", "o...
def _get_min_point(self, seg, lot): utm_seg_start = self.utm_points[self.points.index(seg.start.uuid)] utm_seg_end = self.utm_points[self.points.index(seg.end.uuid)] length_seg = self.distance2D(utm_seg_start, utm_seg_end) length_lot2start = self.distance2D(lot, utm_seg_start) le...
[ "def", "_get_min_point", "(", "self", ",", "seg", ",", "lot", ")", ":", "utm_seg_start", "=", "self", ".", "utm_points", "[", "self", ".", "points", ".", "index", "(", "seg", ".", "start", ".", "uuid", ")", "]", "utm_seg_end", "=", "self", ".", "utm_...
Chooses between the orthogonal projection, and the start and end points of the segment.
[ "Chooses", "between", "the", "orthogonal", "projection", "and", "the", "start", "and", "end", "points", "of", "the", "segment", "." ]
[ "\"\"\" Chooses between the orthogonal projection, and the start and end points\n of the segment.\n\n If the given orthogonal projection lies out of the segment, the whether the start\n or end point of the segment must be chosen as the minimum point.\n\n :param seg: The segment.\n ...
[ { "param": "self", "type": null }, { "param": "seg", "type": null }, { "param": "lot", "type": null } ]
{ "returns": [ { "docstring": "The perpendicular point if it is on the segment, else the start or end\npoint of the segment.", "docstring_tokens": [ "The", "perpendicular", "point", "if", "it", "is", "on", "the", "segment", ...
c9deb650839257dd6c511ae0ee8bb6b306ff1de9
rfzeg/pp_unit3_exercises
unit6_pp/scripts/planner_solution.py
[ "BSD-3-Clause" ]
Python
_getSegment
<not_specific>
def _getSegment(self, uuid): """ Get the segment that corresponds to the given ID. :param uuid: The id of the segment. :type uuid: uuid_msgs/UniqueID :return: The segment for the given uuid. :rtype: geographic_msgs/RouteSegment if the segment is found, None otherwise. "...
Get the segment that corresponds to the given ID. :param uuid: The id of the segment. :type uuid: uuid_msgs/UniqueID :return: The segment for the given uuid. :rtype: geographic_msgs/RouteSegment if the segment is found, None otherwise.
Get the segment that corresponds to the given ID.
[ "Get", "the", "segment", "that", "corresponds", "to", "the", "given", "ID", "." ]
def _getSegment(self, uuid): for seg in self.graph.segments: if seg.id == uuid: return seg return None
[ "def", "_getSegment", "(", "self", ",", "uuid", ")", ":", "for", "seg", "in", "self", ".", "graph", ".", "segments", ":", "if", "seg", ".", "id", "==", "uuid", ":", "return", "seg", "return", "None" ]
Get the segment that corresponds to the given ID.
[ "Get", "the", "segment", "that", "corresponds", "to", "the", "given", "ID", "." ]
[ "\"\"\" Get the segment that corresponds to the given ID.\n\n :param uuid: The id of the segment.\n :type uuid: uuid_msgs/UniqueID\n\n :return: The segment for the given uuid.\n :rtype: geographic_msgs/RouteSegment if the segment is found, None otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "uuid", "type": null } ]
{ "returns": [ { "docstring": "The segment for the given uuid.", "docstring_tokens": [ "The", "segment", "for", "the", "given", "uuid", "." ], "type": "geographic_msgs/RouteSegment if the segment is found, None otherwise." } ], ...
c9deb650839257dd6c511ae0ee8bb6b306ff1de9
rfzeg/pp_unit3_exercises
unit6_pp/scripts/planner_solution.py
[ "BSD-3-Clause" ]
Python
_getSegmentLength
<not_specific>
def _getSegmentLength(self, start_point_id, seg_id): """ Searches the segment with given id with given start point in a pre-cached list and return its length. :param start_point_id: The id of start point of the segment. :type start_point_id: uuid_msgs/UniqueID :param seg_id:...
Searches the segment with given id with given start point in a pre-cached list and return its length. :param start_point_id: The id of start point of the segment. :type start_point_id: uuid_msgs/UniqueID :param seg_id: The id of the segment. :type seg_id: uuid_msgs/UniqueID...
Searches the segment with given id with given start point in a pre-cached list and return its length.
[ "Searches", "the", "segment", "with", "given", "id", "with", "given", "start", "point", "in", "a", "pre", "-", "cached", "list", "and", "return", "its", "length", "." ]
def _getSegmentLength(self, start_point_id, seg_id): edges = self.edges[self.points.index(start_point_id.uuid)] for edge in edges: if edge.seg == seg_id: return edge.step_cost return None
[ "def", "_getSegmentLength", "(", "self", ",", "start_point_id", ",", "seg_id", ")", ":", "edges", "=", "self", ".", "edges", "[", "self", ".", "points", ".", "index", "(", "start_point_id", ".", "uuid", ")", "]", "for", "edge", "in", "edges", ":", "if"...
Searches the segment with given id with given start point in a pre-cached list and return its length.
[ "Searches", "the", "segment", "with", "given", "id", "with", "given", "start", "point", "in", "a", "pre", "-", "cached", "list", "and", "return", "its", "length", "." ]
[ "\"\"\" Searches the segment with given id with given start point in a pre-cached list\n and return its length.\n\n :param start_point_id: The id of start point of the segment.\n :type start_point_id: uuid_msgs/UniqueID\n :param seg_id: The id of the segment.\n :type seg_id: u...
[ { "param": "self", "type": null }, { "param": "start_point_id", "type": null }, { "param": "seg_id", "type": null } ]
{ "returns": [ { "docstring": "Length of a segment.", "docstring_tokens": [ "Length", "of", "a", "segment", "." ], "type": "float if the segment is found, None otherwise." } ], "raises": [], "params": [ { "identifier": "self", ...
c9deb650839257dd6c511ae0ee8bb6b306ff1de9
rfzeg/pp_unit3_exercises
unit6_pp/scripts/planner_solution.py
[ "BSD-3-Clause" ]
Python
distance2D
<not_specific>
def distance2D(utm1, utm2): """ Compute 2D Euclidean distance between two utm points. :param utm1: The first point. :type utm1: geodesy.utm.UTMPoint :param utm2: The second point. :type utm2: geodey.utm.UTMPoint :return: Distance in meters within the UTM XY plane. Altit...
Compute 2D Euclidean distance between two utm points. :param utm1: The first point. :type utm1: geodesy.utm.UTMPoint :param utm2: The second point. :type utm2: geodey.utm.UTMPoint :return: Distance in meters within the UTM XY plane. Altitudes are ignored. :rtype: float...
Compute 2D Euclidean distance between two utm points.
[ "Compute", "2D", "Euclidean", "distance", "between", "two", "utm", "points", "." ]
def distance2D(utm1, utm2): dx = utm2.easting - utm1.easting dy = utm2.northing - utm1.northing return numpy.sqrt(dx*dx + dy*dy)
[ "def", "distance2D", "(", "utm1", ",", "utm2", ")", ":", "dx", "=", "utm2", ".", "easting", "-", "utm1", ".", "easting", "dy", "=", "utm2", ".", "northing", "-", "utm1", ".", "northing", "return", "numpy", ".", "sqrt", "(", "dx", "*", "dx", "+", ...
Compute 2D Euclidean distance between two utm points.
[ "Compute", "2D", "Euclidean", "distance", "between", "two", "utm", "points", "." ]
[ "\"\"\" Compute 2D Euclidean distance between two utm points.\n\n :param utm1: The first point.\n :type utm1: geodesy.utm.UTMPoint\n :param utm2: The second point.\n :type utm2: geodey.utm.UTMPoint\n\n :return: Distance in meters within the UTM XY plane. Altitudes are ignored.\n ...
[ { "param": "utm1", "type": null }, { "param": "utm2", "type": null } ]
{ "returns": [ { "docstring": "Distance in meters within the UTM XY plane. Altitudes are ignored.", "docstring_tokens": [ "Distance", "in", "meters", "within", "the", "UTM", "XY", "plane", ".", "Altitudes", "are", ...
92126ac18a5a89ebf72e7e97e5c03c10630565b4
rfzeg/pp_unit3_exercises
unit5_pp/scripts/descentviz.py
[ "BSD-3-Clause" ]
Python
index_to_world_coord
<not_specific>
def index_to_world_coord(self, index): """ Converts a flatmap index value to world coordinates (meters) index: a linear index value, specifying a cell/pixel in an 1-D array Returns a list containing x,y coordinates in the world frame of reference """ # convert to x,y grid...
Converts a flatmap index value to world coordinates (meters) index: a linear index value, specifying a cell/pixel in an 1-D array Returns a list containing x,y coordinates in the world frame of reference
Converts a flatmap index value to world coordinates (meters) index: a linear index value, specifying a cell/pixel in an 1-D array Returns a list containing x,y coordinates in the world frame of reference
[ "Converts", "a", "flatmap", "index", "value", "to", "world", "coordinates", "(", "meters", ")", "index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "Returns", "a", "list", "containin...
def index_to_world_coord(self, index): grid_cell_map_x = index % self.width grid_cell_map_y = index // self.width world_coordinates = [] world_coordinates.append(self.resolution * grid_cell_map_x + self.origin[0]) world_coordinates.append(self.resolution * grid_cell_map_y + self....
[ "def", "index_to_world_coord", "(", "self", ",", "index", ")", ":", "grid_cell_map_x", "=", "index", "%", "self", ".", "width", "grid_cell_map_y", "=", "index", "//", "self", ".", "width", "world_coordinates", "=", "[", "]", "world_coordinates", ".", "append",...
Converts a flatmap index value to world coordinates (meters) index: a linear index value, specifying a cell/pixel in an 1-D array Returns a list containing x,y coordinates in the world frame of reference
[ "Converts", "a", "flatmap", "index", "value", "to", "world", "coordinates", "(", "meters", ")", "index", ":", "a", "linear", "index", "value", "specifying", "a", "cell", "/", "pixel", "in", "an", "1", "-", "D", "array", "Returns", "a", "list", "containin...
[ "\"\"\"\n Converts a flatmap index value to world coordinates (meters)\n index: a linear index value, specifying a cell/pixel in an 1-D array\n Returns a list containing x,y coordinates in the world frame of reference\n \"\"\"", "# convert to x,y grid cell/pixel coordinates", "# conv...
[ { "param": "self", "type": null }, { "param": "index", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": null, "docstring": null, "docstring_tokens": ...
0f3410ec5a2795a303ea9e8ac165d482bc4d618c
rfzeg/pp_unit3_exercises
unit3_pp/scripts/unit3_dijkstra.py
[ "BSD-3-Clause" ]
Python
make_plan
<not_specific>
def make_plan(req): ''' Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse ''' # costmap as 1-D array representation costmap = req.costmap_ros # number of columns in the occupancy grid width = req.width # number of rows ...
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
Callback function used by the service server to process requests from clients. It returns a msg of type PathPlanningPluginResponse
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", ".", "It", "returns", "a", "msg", "of", "type", "PathPlanningPluginResponse" ]
def make_plan(req): costmap = req.costmap_ros width = req.width height = req.height start_index = req.start goal_index = req.goal resolution = 0.2 origin = [-7.4, -7.4, 0] viz = GridViz(costmap, resolution, origin, start_index, goal_index, width) start_time = rospy.Time.now() path = dijkstra(start_i...
[ "def", "make_plan", "(", "req", ")", ":", "costmap", "=", "req", ".", "costmap_ros", "width", "=", "req", ".", "width", "height", "=", "req", ".", "height", "start_index", "=", "req", ".", "start", "goal_index", "=", "req", ".", "goal", "resolution", "...
Callback function used by the service server to process requests from clients.
[ "Callback", "function", "used", "by", "the", "service", "server", "to", "process", "requests", "from", "clients", "." ]
[ "''' \n Callback function used by the service server to process\n requests from clients. It returns a msg of type PathPlanningPluginResponse\n '''", "# costmap as 1-D array representation", "# number of columns in the occupancy grid", "# number of rows in the occupancy grid", "# side of each grid map squ...
[ { "param": "req", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "req", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
df694000084b816f85fe01f6ce6f8add562ed937
rfzeg/pp_unit3_exercises
unit3_pp/scripts/unit3_gbfs_exercise.py
[ "BSD-3-Clause" ]
Python
greedy_bfs
<not_specific>
def greedy_bfs(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz): ''' Performs Greedy Best-First Search on a costmap with a given start and goal node ''' # create an open_list open_list = [] # set to hold already processed nodes closed_list = set() # dict for mapping chi...
Performs Greedy Best-First Search on a costmap with a given start and goal node
Performs Greedy Best-First Search on a costmap with a given start and goal node
[ "Performs", "Greedy", "Best", "-", "First", "Search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
def greedy_bfs(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz): open_list = [] closed_list = set() parents = dict() g_costs = dict() g_costs[start_index] = 0 open_list.append([start_index, 0]) shortest_path = [] path_found = False rospy.loginfo('Dijkstra: Done with initi...
[ "def", "greedy_bfs", "(", "start_index", ",", "goal_index", ",", "width", ",", "height", ",", "costmap", ",", "resolution", ",", "origin", ",", "grid_viz", ")", ":", "open_list", "=", "[", "]", "closed_list", "=", "set", "(", ")", "parents", "=", "dict",...
Performs Greedy Best-First Search on a costmap with a given start and goal node
[ "Performs", "Greedy", "Best", "-", "First", "Search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
[ "''' \n Performs Greedy Best-First Search on a costmap with a given start and goal node\n '''", "# create an open_list", "# set to hold already processed nodes", "# dict for mapping children to parent", "# dict for mapping g costs (travel costs) to nodes", "# set the start's node g_cost", "# add start...
[ { "param": "start_index", "type": null }, { "param": "goal_index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "costmap", "type": null }, { "param": "resolution", "type": null }, { "pa...
{ "returns": [], "raises": [], "params": [ { "identifier": "start_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "goal_index", "type": null, "docstring": null, "docstri...
d481528b18818ea262c20e7e449b36d1d6fefc73
rfzeg/pp_unit3_exercises
unit2_pp/scripts/unit2_exercise.py
[ "BSD-3-Clause" ]
Python
dijkstra
null
def dijkstra(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz = None): ''' Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node ''' #### To-do: complete all exercises below #### pass
Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node
Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node
[ "Performs", "Dijkstra", "'", "s", "shortes", "path", "algorithm", "search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
def dijkstra(start_index, goal_index, width, height, costmap, resolution, origin, grid_viz = None): pass
[ "def", "dijkstra", "(", "start_index", ",", "goal_index", ",", "width", ",", "height", ",", "costmap", ",", "resolution", ",", "origin", ",", "grid_viz", "=", "None", ")", ":", "pass" ]
Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node
[ "Performs", "Dijkstra", "'", "s", "shortes", "path", "algorithm", "search", "on", "a", "costmap", "with", "a", "given", "start", "and", "goal", "node" ]
[ "''' \n Performs Dijkstra's shortes path algorithm search on a costmap with a given start and goal node\n '''", "#### To-do: complete all exercises below ####" ]
[ { "param": "start_index", "type": null }, { "param": "goal_index", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "costmap", "type": null }, { "param": "resolution", "type": null }, { "pa...
{ "returns": [], "raises": [], "params": [ { "identifier": "start_index", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "goal_index", "type": null, "docstring": null, "docstri...
d5e0cbd29c239e41b881c07902797dadc185f3ab
rfzeg/pp_unit3_exercises
route_network/tests/test_planner.py
[ "BSD-3-Clause" ]
Python
tiny_graph
<not_specific>
def tiny_graph(): 'initialize test data: two points with segments between them' r = RouteNetwork() r.points.append(makeWayPoint('da7c242f-2efe-5175-9961-49cc621b80b9', 30.3840168, -97.72821)) r.points.append(makeWayPoint('812f1c08-a34b-5a21-92b9-18b2b0cf4950', ...
initialize test data: two points with segments between them
initialize test data: two points with segments between them
[ "initialize", "test", "data", ":", "two", "points", "with", "segments", "between", "them" ]
def tiny_graph(): r = RouteNetwork() r.points.append(makeWayPoint('da7c242f-2efe-5175-9961-49cc621b80b9', 30.3840168, -97.72821)) r.points.append(makeWayPoint('812f1c08-a34b-5a21-92b9-18b2b0cf4950', 30.385729, -97.7316754)) r.segments.app...
[ "def", "tiny_graph", "(", ")", ":", "r", "=", "RouteNetwork", "(", ")", "r", ".", "points", ".", "append", "(", "makeWayPoint", "(", "'da7c242f-2efe-5175-9961-49cc621b80b9'", ",", "30.3840168", ",", "-", "97.72821", ")", ")", "r", ".", "points", ".", "appe...
initialize test data: two points with segments between them
[ "initialize", "test", "data", ":", "two", "points", "with", "segments", "between", "them" ]
[ "'initialize test data: two points with segments between them'" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
d5e0cbd29c239e41b881c07902797dadc185f3ab
rfzeg/pp_unit3_exercises
route_network/tests/test_planner.py
[ "BSD-3-Clause" ]
Python
tiny_oneway
<not_specific>
def tiny_oneway(): 'initialize test data: two points with one segment from first to second' r = RouteNetwork() r.points.append(makeWayPoint('da7c242f-2efe-5175-9961-49cc621b80b9', 30.3840168, -97.72821)) r.points.append(makeWayPoint('812f1c08-a34b-5a21-92b9-18b2b0cf4950'...
initialize test data: two points with one segment from first to second
initialize test data: two points with one segment from first to second
[ "initialize", "test", "data", ":", "two", "points", "with", "one", "segment", "from", "first", "to", "second" ]
def tiny_oneway(): r = RouteNetwork() r.points.append(makeWayPoint('da7c242f-2efe-5175-9961-49cc621b80b9', 30.3840168, -97.72821)) r.points.append(makeWayPoint('812f1c08-a34b-5a21-92b9-18b2b0cf4950', 30.385729, -97.7316754)) s = makeSegme...
[ "def", "tiny_oneway", "(", ")", ":", "r", "=", "RouteNetwork", "(", ")", "r", ".", "points", ".", "append", "(", "makeWayPoint", "(", "'da7c242f-2efe-5175-9961-49cc621b80b9'", ",", "30.3840168", ",", "-", "97.72821", ")", ")", "r", ".", "points", ".", "app...
initialize test data: two points with one segment from first to second
[ "initialize", "test", "data", ":", "two", "points", "with", "one", "segment", "from", "first", "to", "second" ]
[ "'initialize test data: two points with one segment from first to second'" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
d5e0cbd29c239e41b881c07902797dadc185f3ab
rfzeg/pp_unit3_exercises
route_network/tests/test_planner.py
[ "BSD-3-Clause" ]
Python
triangle_graph
<not_specific>
def triangle_graph(): 'initialize test data: three points with one-way segments between them' r = RouteNetwork() r.points.append(makeWayPoint('da7c242f-2efe-5175-9961-49cc621b80b9', 30.3840168, -97.72821)) r.points.append(makeWayPoint('812f1c08-a34b-5a21-92b9-18b2b0cf495...
initialize test data: three points with one-way segments between them
initialize test data: three points with one-way segments between them
[ "initialize", "test", "data", ":", "three", "points", "with", "one", "-", "way", "segments", "between", "them" ]
def triangle_graph(): r = RouteNetwork() r.points.append(makeWayPoint('da7c242f-2efe-5175-9961-49cc621b80b9', 30.3840168, -97.72821)) r.points.append(makeWayPoint('812f1c08-a34b-5a21-92b9-18b2b0cf4950', 30.385729, -97.7316754)) r.points.a...
[ "def", "triangle_graph", "(", ")", ":", "r", "=", "RouteNetwork", "(", ")", "r", ".", "points", ".", "append", "(", "makeWayPoint", "(", "'da7c242f-2efe-5175-9961-49cc621b80b9'", ",", "30.3840168", ",", "-", "97.72821", ")", ")", "r", ".", "points", ".", "...
initialize test data: three points with one-way segments between them
[ "initialize", "test", "data", ":", "three", "points", "with", "one", "-", "way", "segments", "between", "them" ]
[ "'initialize test data: three points with one-way segments between them'" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
d5e0cbd29c239e41b881c07902797dadc185f3ab
rfzeg/pp_unit3_exercises
route_network/tests/test_planner.py
[ "BSD-3-Clause" ]
Python
grid_graph
<not_specific>
def grid_graph(min_lat, min_lon, max_lat, max_lon, step=0.001): """Generate a fully-connected rectangular grid. :param min_lat: Initial latitude [degrees]. :param min_lon: Initial longitude [degrees]. :param max_lat: Latitude limit [degrees]. :param max_lon: Longitude limit [degrees]. :param st...
Generate a fully-connected rectangular grid. :param min_lat: Initial latitude [degrees]. :param min_lon: Initial longitude [degrees]. :param max_lat: Latitude limit [degrees]. :param max_lon: Longitude limit [degrees]. :param step: Step size [degrees]. :returns: RouteNetwork message.
Generate a fully-connected rectangular grid.
[ "Generate", "a", "fully", "-", "connected", "rectangular", "grid", "." ]
def grid_graph(min_lat, min_lon, max_lat, max_lon, step=0.001): nid = unique_id.toMsg(unique_id.fromURL(PKG_URL + '/test_network')) r = RouteNetwork(id=nid) prev_row = None for latitude in float_range(min_lat, max_lat, step): prev_col = None this_row = len(r.points) for longitude...
[ "def", "grid_graph", "(", "min_lat", ",", "min_lon", ",", "max_lat", ",", "max_lon", ",", "step", "=", "0.001", ")", ":", "nid", "=", "unique_id", ".", "toMsg", "(", "unique_id", ".", "fromURL", "(", "PKG_URL", "+", "'/test_network'", ")", ")", "r", "=...
Generate a fully-connected rectangular grid.
[ "Generate", "a", "fully", "-", "connected", "rectangular", "grid", "." ]
[ "\"\"\"Generate a fully-connected rectangular grid.\n\n :param min_lat: Initial latitude [degrees].\n :param min_lon: Initial longitude [degrees].\n :param max_lat: Latitude limit [degrees].\n :param max_lon: Longitude limit [degrees].\n :param step: Step size [degrees].\n :returns: RouteNetwork m...
[ { "param": "min_lat", "type": null }, { "param": "min_lon", "type": null }, { "param": "max_lat", "type": null }, { "param": "max_lon", "type": null }, { "param": "step", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "min_lat", "type": null, "docstring": "Initial latitude [degrees].", "docstring_tokens": [ "Initial", ...
983edccbd0effb2fe190c3b23525e13a6259a22d
TomCallingham/Agama_Cautun_Contraction
contraction_agama.py
[ "MIT" ]
Python
contract_agama_potential
<not_specific>
def contract_agama_potential(dm_pot, baryon_pot, fbar=0.157,rmax=500, rmin=0.1): '''Given spherical DM and axisymmetric baryon agama potentials, creates a contracted DM agama potential using procedure found in Cautun 20''' r_space = np.geomspace(rmin,rmax,501) xyz = np.stack((r_space,np.zeros_like(r_sp...
Given spherical DM and axisymmetric baryon agama potentials, creates a contracted DM agama potential using procedure found in Cautun 20
Given spherical DM and axisymmetric baryon agama potentials, creates a contracted DM agama potential using procedure found in Cautun 20
[ "Given", "spherical", "DM", "and", "axisymmetric", "baryon", "agama", "potentials", "creates", "a", "contracted", "DM", "agama", "potential", "using", "procedure", "found", "in", "Cautun", "20" ]
def contract_agama_potential(dm_pot, baryon_pot, fbar=0.157,rmax=500, rmin=0.1): r_space = np.geomspace(rmin,rmax,501) xyz = np.stack((r_space,np.zeros_like(r_space),np.zeros_like(r_space))).transpose() dens_dm = dm_pot.density(xyz) try: Mcum_dm = np.array([dm_pot.totalMass(r) for r in r_space]...
[ "def", "contract_agama_potential", "(", "dm_pot", ",", "baryon_pot", ",", "fbar", "=", "0.157", ",", "rmax", "=", "500", ",", "rmin", "=", "0.1", ")", ":", "r_space", "=", "np", ".", "geomspace", "(", "rmin", ",", "rmax", ",", "501", ")", "xyz", "=",...
Given spherical DM and axisymmetric baryon agama potentials, creates a contracted DM agama potential using procedure found in Cautun 20
[ "Given", "spherical", "DM", "and", "axisymmetric", "baryon", "agama", "potentials", "creates", "a", "contracted", "DM", "agama", "potential", "using", "procedure", "found", "in", "Cautun", "20" ]
[ "'''Given spherical DM and axisymmetric baryon agama potentials,\n creates a contracted DM agama potential using procedure found in Cautun 20'''", "# Assume Old agama, no totalMass ", "#note spherical average", "# create a cubic spline interpolator in log-log space" ]
[ { "param": "dm_pot", "type": null }, { "param": "baryon_pot", "type": null }, { "param": "fbar", "type": null }, { "param": "rmax", "type": null }, { "param": "rmin", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dm_pot", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "baryon_pot", "type": null, "docstring": null, "docstring_to...
983edccbd0effb2fe190c3b23525e13a6259a22d
TomCallingham/Agama_Cautun_Contraction
contraction_agama.py
[ "MIT" ]
Python
contract_density_fit
<not_specific>
def contract_density_fit( density_DM, density_bar, mass_DM, mass_bar, f_bar=0.157 ): """ Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution. It uses the differential (d/dr) form of Eq. (11) from Cautun et al (2020). WARNING: This function is...
Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution. It uses the differential (d/dr) form of Eq. (11) from Cautun et al (2020). WARNING: This function is based on a fit to the iterative calculated result of the 'contract_enclosed_mass' and works...
Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution. It uses the differential (d/dr) form of Eq. This function is based on a fit to the iterative calculated result of the 'contract_enclosed_mass' and works best when the baryonic fraction is close to the Plan...
[ "Returns", "the", "contracted", "DM", "density", "profile", "given", "the", "'", "uncontracted", "'", "density", "and", "that", "of", "the", "baryonic", "distribution", ".", "It", "uses", "the", "differential", "(", "d", "/", "dr", ")", "form", "of", "Eq",...
def contract_density_fit( density_DM, density_bar, mass_DM, mass_bar, f_bar=0.157 ): eta_bar = mass_bar / mass_DM * (1.-f_bar) / f_bar first_factor = 0.45 + 0.41 * (eta_bar + 0.98)**0.53 temp = density_bar - eta_bar * density_DM * f_bar / (1.-f_bar) const_term = 0.41 * 0.53 * (eta_bar + 0.98...
[ "def", "contract_density_fit", "(", "density_DM", ",", "density_bar", ",", "mass_DM", ",", "mass_bar", ",", "f_bar", "=", "0.157", ")", ":", "eta_bar", "=", "mass_bar", "/", "mass_DM", "*", "(", "1.", "-", "f_bar", ")", "/", "f_bar", "first_factor", "=", ...
Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.
[ "Returns", "the", "contracted", "DM", "density", "profile", "given", "the", "'", "uncontracted", "'", "density", "and", "that", "of", "the", "baryonic", "distribution", "." ]
[ "\"\"\" Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.\n It uses the differential (d/dr) form of Eq. (11) from Cautun et al (2020).\n \n WARNING: This function is based on a fit to the iterative calculated result of the 'contract_enclosed_m...
[ { "param": "density_DM", "type": null }, { "param": "density_bar", "type": null }, { "param": "mass_DM", "type": null }, { "param": "mass_bar", "type": null }, { "param": "f_bar", "type": null } ]
{ "returns": [ { "docstring": "Array of 'contracted' DM densities.", "docstring_tokens": [ "Array", "of", "'", "contracted", "'", "DM", "densities", "." ], "type": null } ], "raises": [], "params": [ { "ide...
983edccbd0effb2fe190c3b23525e13a6259a22d
TomCallingham/Agama_Cautun_Contraction
contraction_agama.py
[ "MIT" ]
Python
contract_enclosed_mass
<not_specific>
def contract_enclosed_mass( mass_DM, mass_bar, f_bar=0.157 ): """ Returns the contracted DM enclosed mass given the 'uncontracted' profile and that of the baryonic distribution. It uses Eq. (10) from Cautun et al (2020). Args: mass_DM : enclosed mass in the DM component in the absence of bary...
Returns the contracted DM enclosed mass given the 'uncontracted' profile and that of the baryonic distribution. It uses Eq. (10) from Cautun et al (2020). Args: mass_DM : enclosed mass in the DM component in the absence of baryons. It corresponds to '(1-baryon_fraction...
Returns the contracted DM enclosed mass given the 'uncontracted' profile and that of the baryonic distribution. It uses Eq.
[ "Returns", "the", "contracted", "DM", "enclosed", "mass", "given", "the", "'", "uncontracted", "'", "profile", "and", "that", "of", "the", "baryonic", "distribution", ".", "It", "uses", "Eq", "." ]
def contract_enclosed_mass( mass_DM, mass_bar, f_bar=0.157 ): func_M_DM_contract = lambda M, M_DMO, M_bar: 1.023 * (M_DMO/(1.-f_bar)/(M+M_bar))**-0.540 * M_DMO return optimize.fixed_point( func_M_DM_contract, mass_DM.copy(), args=(mass_DM,mass_bar), xtol=1.e-6 )
[ "def", "contract_enclosed_mass", "(", "mass_DM", ",", "mass_bar", ",", "f_bar", "=", "0.157", ")", ":", "func_M_DM_contract", "=", "lambda", "M", ",", "M_DMO", ",", "M_bar", ":", "1.023", "*", "(", "M_DMO", "/", "(", "1.", "-", "f_bar", ")", "/", "(", ...
Returns the contracted DM enclosed mass given the 'uncontracted' profile and that of the baryonic distribution.
[ "Returns", "the", "contracted", "DM", "enclosed", "mass", "given", "the", "'", "uncontracted", "'", "profile", "and", "that", "of", "the", "baryonic", "distribution", "." ]
[ "\"\"\" Returns the contracted DM enclosed mass given the 'uncontracted' profile and that of the baryonic distribution.\n It uses Eq. (10) from Cautun et al (2020).\n \n Args:\n mass_DM : enclosed mass in the DM component in the absence of baryons. \n It corresponds to '(1...
[ { "param": "mass_DM", "type": null }, { "param": "mass_bar", "type": null }, { "param": "f_bar", "type": null } ]
{ "returns": [ { "docstring": "Array of 'contracted' enclosed masses.", "docstring_tokens": [ "Array", "of", "'", "contracted", "'", "enclosed", "masses", "." ], "type": null } ], "raises": [], "params": [ { ...
983edccbd0effb2fe190c3b23525e13a6259a22d
TomCallingham/Agama_Cautun_Contraction
contraction_agama.py
[ "MIT" ]
Python
density_from_enclosed_mass
<not_specific>
def density_from_enclosed_mass( r_bins, enclosed_mass, out_r_bins ): """ Converts an array of enclosed masses to 3D densities. Args: r_bins : the radial bins at which the enclosed mass is defined. enclosed_mass : array of enclosed masses. out_r_bins : array of radia...
Converts an array of enclosed masses to 3D densities. Args: r_bins : the radial bins at which the enclosed mass is defined. enclosed_mass : array of enclosed masses. out_r_bins : array of radial distances at which the density will be interpolated. Returns: Arr...
Converts an array of enclosed masses to 3D densities.
[ "Converts", "an", "array", "of", "enclosed", "masses", "to", "3D", "densities", "." ]
def density_from_enclosed_mass( r_bins, enclosed_mass, out_r_bins ): bin_mass = enclosed_mass[1:] - enclosed_mass[:-1] shell_vol= 4.*np.pi/3. * (r_bins[1:]**3 - r_bins[:-1]**3) bin_dens = bin_mass / shell_vol r_vals = np.sqrt( r_bins[1:] * r_bins[:-1] ) return np.interp( out_r_bins, r_vals, bin_dens...
[ "def", "density_from_enclosed_mass", "(", "r_bins", ",", "enclosed_mass", ",", "out_r_bins", ")", ":", "bin_mass", "=", "enclosed_mass", "[", "1", ":", "]", "-", "enclosed_mass", "[", ":", "-", "1", "]", "shell_vol", "=", "4.", "*", "np", ".", "pi", "/",...
Converts an array of enclosed masses to 3D densities.
[ "Converts", "an", "array", "of", "enclosed", "masses", "to", "3D", "densities", "." ]
[ "\"\"\" Converts an array of enclosed masses to 3D densities.\n \n Args:\n r_bins : the radial bins at which the enclosed mass is defined.\n enclosed_mass : array of enclosed masses.\n out_r_bins : array of radial distances at which the density will be interpolated.\n R...
[ { "param": "r_bins", "type": null }, { "param": "enclosed_mass", "type": null }, { "param": "out_r_bins", "type": null } ]
{ "returns": [ { "docstring": "Array of densities at the location of the output radial distances.", "docstring_tokens": [ "Array", "of", "densities", "at", "the", "location", "of", "the", "output", "radial", "dista...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
partitions
<not_specific>
def partitions(n, K): """Split array with n samples into K (nearly) equal partitions Input ----- n -- number of elements to partition into K subsets K -- number of partitions Output ------ K arrays whose elements are contiguous intervals of an array of sequential integers with length n. ""...
Split array with n samples into K (nearly) equal partitions Input ----- n -- number of elements to partition into K subsets K -- number of partitions Output ------ K arrays whose elements are contiguous intervals of an array of sequential integers with length n.
Split array with n samples into K (nearly) equal partitions Input - number of elements to partition into K subsets K -- number of partitions Output K arrays whose elements are contiguous intervals of an array of sequential integers with length n.
[ "Split", "array", "with", "n", "samples", "into", "K", "(", "nearly", ")", "equal", "partitions", "Input", "-", "number", "of", "elements", "to", "partition", "into", "K", "subsets", "K", "--", "number", "of", "partitions", "Output", "K", "arrays", "whose"...
def partitions(n, K): assert n >= K, "Number of partitions must not exceed number of samples." return np.asarray( np.array_split(np.arange(n), K) )
[ "def", "partitions", "(", "n", ",", "K", ")", ":", "assert", "n", ">=", "K", ",", "\"Number of partitions must not exceed number of samples.\"", "return", "np", ".", "asarray", "(", "np", ".", "array_split", "(", "np", ".", "arange", "(", "n", ")", ",", "K...
Split array with n samples into K (nearly) equal partitions Input
[ "Split", "array", "with", "n", "samples", "into", "K", "(", "nearly", ")", "equal", "partitions", "Input" ]
[ "\"\"\"Split array with n samples into K (nearly) equal partitions\n \n Input\n -----\n n -- number of elements to partition into K subsets\n K -- number of partitions\n \n Output\n ------\n K arrays whose elements are contiguous intervals of an array of\n sequential integers with length n.\n \"\"\""...
[ { "param": "n", "type": null }, { "param": "K", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "K", "type": null, "docstring": null, "docstring_tokens": [], ...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
random_partitions
<not_specific>
def random_partitions(n, K): """Split array with n samples into K (nearly) equal partitions of non-overlapping random subsets. Input ----- n -- number of elements to partition into K subsets K -- number of partitions Output ------ K arrays whose elements are randomly drawn from an array of ...
Split array with n samples into K (nearly) equal partitions of non-overlapping random subsets. Input ----- n -- number of elements to partition into K subsets K -- number of partitions Output ------ K arrays whose elements are randomly drawn from an array of sequential integers with length...
Split array with n samples into K (nearly) equal partitions of non-overlapping random subsets. Input - number of elements to partition into K subsets K -- number of partitions Output K arrays whose elements are randomly drawn from an array of sequential integers with length n.
[ "Split", "array", "with", "n", "samples", "into", "K", "(", "nearly", ")", "equal", "partitions", "of", "non", "-", "overlapping", "random", "subsets", ".", "Input", "-", "number", "of", "elements", "to", "partition", "into", "K", "subsets", "K", "--", "...
def random_partitions(n, K): assert n >= K, "Number of partitions must not exceed number of samples." rand = np.random.choice(range(n), n, replace=False) return [np.sort(rand[pp]) for pp in partitions(n, K)]
[ "def", "random_partitions", "(", "n", ",", "K", ")", ":", "assert", "n", ">=", "K", ",", "\"Number of partitions must not exceed number of samples.\"", "rand", "=", "np", ".", "random", ".", "choice", "(", "range", "(", "n", ")", ",", "n", ",", "replace", ...
Split array with n samples into K (nearly) equal partitions of non-overlapping random subsets.
[ "Split", "array", "with", "n", "samples", "into", "K", "(", "nearly", ")", "equal", "partitions", "of", "non", "-", "overlapping", "random", "subsets", "." ]
[ "\"\"\"Split array with n samples into K (nearly) equal \n partitions of non-overlapping random subsets.\n \n Input\n -----\n n -- number of elements to partition into K subsets\n K -- number of partitions\n \n Output\n ------\n K arrays whose elements are randomly drawn from an array of \n sequentia...
[ { "param": "n", "type": null }, { "param": "K", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "K", "type": null, "docstring": null, "docstring_tokens": [], ...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
partitions_to_sets
<not_specific>
def partitions_to_sets(p_label, partitions, sort=True): """Split partitions into a validation set (indexed by p_label) and the rest into a training set Input ----- p_label -- index of partition to use as a validation set partitions -- set of partitions containing ...
Split partitions into a validation set (indexed by p_label) and the rest into a training set Input ----- p_label -- index of partition to use as a validation set partitions -- set of partitions containing array indices for validation and training...
Split partitions into a validation set (indexed by p_label) and the rest into a training set Input
[ "Split", "partitions", "into", "a", "validation", "set", "(", "indexed", "by", "p_label", ")", "and", "the", "rest", "into", "a", "training", "set", "Input" ]
def partitions_to_sets(p_label, partitions, sort=True): validation = partitions[p_label] training = [] for ii, pp in enumerate(partitions): if ii != p_label: training = np.hstack([training, pp]) training = np.sort(training) return validation, np.asarray(training, dtype='int')
[ "def", "partitions_to_sets", "(", "p_label", ",", "partitions", ",", "sort", "=", "True", ")", ":", "validation", "=", "partitions", "[", "p_label", "]", "training", "=", "[", "]", "for", "ii", ",", "pp", "in", "enumerate", "(", "partitions", ")", ":", ...
Split partitions into a validation set (indexed by p_label) and the rest into a training set
[ "Split", "partitions", "into", "a", "validation", "set", "(", "indexed", "by", "p_label", ")", "and", "the", "rest", "into", "a", "training", "set" ]
[ "\"\"\"Split partitions into a validation set (indexed by p_label)\n and the rest into a training set\n \n Input\n -----\n p_label -- index of partition to use\n as a validation set\n partitions -- set of partitions containing\n array indices for validation\n ...
[ { "param": "p_label", "type": null }, { "param": "partitions", "type": null }, { "param": "sort", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p_label", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "partitions", "type": null, "docstring": null, "docstring_t...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
integrate
<not_specific>
def integrate(y, x, weight=None, partial=False): """Trapezoidal rule for integration. Inputs ====== y -- data values or responses x -- data samples weight -- Weighting factor in the integrand (default is None) partial -- Output partial sums instead of the integral ...
Trapezoidal rule for integration. Inputs ====== y -- data values or responses x -- data samples weight -- Weighting factor in the integrand (default is None) partial -- Output partial sums instead of the integral (default is False) Outputs =======...
Trapezoidal rule for integration. Inputs Outputs Scalar equal to the numerical integration of y over x using the trapezoidal quadrature rule. If partial is True then the output is an array of partial sums for each element of y over the previous x values. Comments The trapezoidal rule is second-order convergent in...
[ "Trapezoidal", "rule", "for", "integration", ".", "Inputs", "Outputs", "Scalar", "equal", "to", "the", "numerical", "integration", "of", "y", "over", "x", "using", "the", "trapezoidal", "quadrature", "rule", ".", "If", "partial", "is", "True", "then", "the", ...
def integrate(y, x, weight=None, partial=False): assert len(y) == len(x), "Expecting arrays `y` and `x` to have equal lengths." dx = x[1]-x[0] quad_weights = np.ones(len(x))*dx quad_weights[0] *= 0.5 quad_weights[-1] *= 0.5 if weight is not None: assert len(x) == len(weight), "Expecting `weight` option ...
[ "def", "integrate", "(", "y", ",", "x", ",", "weight", "=", "None", ",", "partial", "=", "False", ")", ":", "assert", "len", "(", "y", ")", "==", "len", "(", "x", ")", ",", "\"Expecting arrays `y` and `x` to have equal lengths.\"", "dx", "=", "x", "[", ...
Trapezoidal rule for integration.
[ "Trapezoidal", "rule", "for", "integration", "." ]
[ "\"\"\"Trapezoidal rule for integration.\n \n Inputs\n ======\n y -- data values or responses\n x -- data samples\n weight -- Weighting factor in the integrand\n (default is None)\n partial -- Output partial sums instead of the integral\n (default is False)\n ...
[ { "param": "y", "type": null }, { "param": "x", "type": null }, { "param": "weight", "type": null }, { "param": "partial", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
conditional_median
<not_specific>
def conditional_median(x, y, k=0, repeat=0): """Compute the median of y conditioned on x. Input ----- x -- samples y -- distributed values, possibly at same x samples k -- number of nearest neighbors to condition the median on (default 0) repeat -- iterates the resu...
Compute the median of y conditioned on x. Input ----- x -- samples y -- distributed values, possibly at same x samples k -- number of nearest neighbors to condition the median on (default 0) repeat -- iterates the result of conditional_median a "repeat" ...
Compute the median of y conditioned on x. Input Output x_unique -- number of unique samples y_medians -- conditional median for each unique sample Comments When k is not zero then the median is conditioned on the k nearest neighbors for each sample value. A non-zero k should be used when there are at most one y ...
[ "Compute", "the", "median", "of", "y", "conditioned", "on", "x", ".", "Input", "Output", "x_unique", "--", "number", "of", "unique", "samples", "y_medians", "--", "conditional", "median", "for", "each", "unique", "sample", "Comments", "When", "k", "is", "not...
def conditional_median(x, y, k=0, repeat=0): assert len(x) == len(y), "Expecting arrays x and y to have the same length." x_unique = np.unique(x) x_args = np.arange(len(x)) isort = np.argsort(x) y_sorted = y[isort] y_medians = np.zeros(len(x_unique), dtype='double') for rr in range(repeat+1): for ii i...
[ "def", "conditional_median", "(", "x", ",", "y", ",", "k", "=", "0", ",", "repeat", "=", "0", ")", ":", "assert", "len", "(", "x", ")", "==", "len", "(", "y", ")", ",", "\"Expecting arrays x and y to have the same length.\"", "x_unique", "=", "np", ".", ...
Compute the median of y conditioned on x.
[ "Compute", "the", "median", "of", "y", "conditioned", "on", "x", "." ]
[ "\"\"\"Compute the median of y conditioned on x.\n \n Input\n -----\n x -- samples\n y -- distributed values, possibly at same x samples\n k -- number of nearest neighbors to condition the median on\n (default 0)\n repeat -- iterates the result of conditional_median a \"re...
[ { "param": "x", "type": null }, { "param": "y", "type": null }, { "param": "k", "type": null }, { "param": "repeat", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
conditional_mean
<not_specific>
def conditional_mean(x, y, k=0, repeat=0): """Compute the mean of y conditioned on x. Input ----- x -- samples y -- distributed values, possibly at same x samples k -- number of nearest neighbors to condition the mean on (default 0) repeat -- iterates the result of ...
Compute the mean of y conditioned on x. Input ----- x -- samples y -- distributed values, possibly at same x samples k -- number of nearest neighbors to condition the mean on (default 0) repeat -- iterates the result of conditional_mean a "repeat" number...
Compute the mean of y conditioned on x. Input Output x_unique -- number of unique samples y_medians -- conditional mean for each unique sample Comments When k is not zero then the mean is conditioned on the k nearest neighbors for each sample value. A non-zero k should be used when there are at most one y values...
[ "Compute", "the", "mean", "of", "y", "conditioned", "on", "x", ".", "Input", "Output", "x_unique", "--", "number", "of", "unique", "samples", "y_medians", "--", "conditional", "mean", "for", "each", "unique", "sample", "Comments", "When", "k", "is", "not", ...
def conditional_mean(x, y, k=0, repeat=0): assert len(x) == len(y), "Expecting arrays x and y to have the same length." x_unique = np.unique(x) x_args = np.arange(len(x)) isort = np.argsort(x) y_sorted = y[isort] y_means = np.zeros(len(x_unique), dtype='double') for rr in range(repeat+1): for ii in ra...
[ "def", "conditional_mean", "(", "x", ",", "y", ",", "k", "=", "0", ",", "repeat", "=", "0", ")", ":", "assert", "len", "(", "x", ")", "==", "len", "(", "y", ")", ",", "\"Expecting arrays x and y to have the same length.\"", "x_unique", "=", "np", ".", ...
Compute the mean of y conditioned on x.
[ "Compute", "the", "mean", "of", "y", "conditioned", "on", "x", "." ]
[ "\"\"\"Compute the mean of y conditioned on x.\n \n Input\n -----\n x -- samples\n y -- distributed values, possibly at same x samples\n k -- number of nearest neighbors to condition the mean on\n (default 0)\n repeat -- iterates the result of conditional_mean a \"repeat\"...
[ { "param": "x", "type": null }, { "param": "y", "type": null }, { "param": "k", "type": null }, { "param": "repeat", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
total_compression_from_sizes
<not_specific>
def total_compression_from_sizes(full_sizes, reduced_sizes): """Compute the total amount of compression achieved for multiple datasets that may have possibly different numbers of samples. Input ----- full_sizes - list or array containing sizes of multiple full datasets redu...
Compute the total amount of compression achieved for multiple datasets that may have possibly different numbers of samples. Input ----- full_sizes - list or array containing sizes of multiple full datasets reduced_sizes - list or array containing sizes of ...
Compute the total amount of compression achieved for multiple datasets that may have possibly different numbers of samples. Input full_sizes - list or array containing sizes of multiple full datasets reduced_sizes - list or array containing sizes of corresponding reduced datasets Output The total compression fac...
[ "Compute", "the", "total", "amount", "of", "compression", "achieved", "for", "multiple", "datasets", "that", "may", "have", "possibly", "different", "numbers", "of", "samples", ".", "Input", "full_sizes", "-", "list", "or", "array", "containing", "sizes", "of", ...
def total_compression_from_sizes(full_sizes, reduced_sizes): return float(np.sum(full_sizes)) / np.sum(reduced_sizes)
[ "def", "total_compression_from_sizes", "(", "full_sizes", ",", "reduced_sizes", ")", ":", "return", "float", "(", "np", ".", "sum", "(", "full_sizes", ")", ")", "/", "np", ".", "sum", "(", "reduced_sizes", ")" ]
Compute the total amount of compression achieved for multiple datasets that may have possibly different numbers of samples.
[ "Compute", "the", "total", "amount", "of", "compression", "achieved", "for", "multiple", "datasets", "that", "may", "have", "possibly", "different", "numbers", "of", "samples", "." ]
[ "\"\"\"Compute the total amount of compression achieved for\n multiple datasets that may have possibly different numbers \n of samples.\n \n Input\n -----\n full_sizes - list or array containing sizes of \n multiple full datasets\n reduced_sizes - list or array containing sizes of\n...
[ { "param": "full_sizes", "type": null }, { "param": "reduced_sizes", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "full_sizes", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reduced_sizes", "type": null, "docstring": null, "docst...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
total_compression
<not_specific>
def total_compression(*compressions): """Compute the total amount of compression achieved for multiple datasets that have the same number of samples. Input ----- compressions -- list or array containing the compression factors for each dataset Output ------ The total compre...
Compute the total amount of compression achieved for multiple datasets that have the same number of samples. Input ----- compressions -- list or array containing the compression factors for each dataset Output ------ The total compression factor is defined as the sum of th...
Compute the total amount of compression achieved for multiple datasets that have the same number of samples. Input - list or array containing the compression factors for each dataset Output The total compression factor is defined as the sum of the full dataset sizes divided by the sum of the reduced dataset sizes. ...
[ "Compute", "the", "total", "amount", "of", "compression", "achieved", "for", "multiple", "datasets", "that", "have", "the", "same", "number", "of", "samples", ".", "Input", "-", "list", "or", "array", "containing", "the", "compression", "factors", "for", "each...
def total_compression(*compressions): _sum = 0. for cc in compressions: _sum += 1./cc return len(compressions) / _sum
[ "def", "total_compression", "(", "*", "compressions", ")", ":", "_sum", "=", "0.", "for", "cc", "in", "compressions", ":", "_sum", "+=", "1.", "/", "cc", "return", "len", "(", "compressions", ")", "/", "_sum" ]
Compute the total amount of compression achieved for multiple datasets that have the same number of samples.
[ "Compute", "the", "total", "amount", "of", "compression", "achieved", "for", "multiple", "datasets", "that", "have", "the", "same", "number", "of", "samples", "." ]
[ "\"\"\"Compute the total amount of compression achieved for\n multiple datasets that have the same number of samples.\n \n Input\n -----\n compressions -- list or array containing the compression\n factors for each dataset\n \n Output\n ------\n The total compression factor is define...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
D
<not_specific>
def D(y, x, dx=1, order=4): """Deriviative(s) of y with respect to x using finite differencing""" # Look up finite differencing weights h = x[1]-x[0] weights = _FD_weights(dx, order, order/2., h) # Compute finite difference derivatives ans = np.zeros(y.size, dtype=y.dtype) for ii, xx in enumerate(x): ...
Deriviative(s) of y with respect to x using finite differencing
Deriviative(s) of y with respect to x using finite differencing
[ "Deriviative", "(", "s", ")", "of", "y", "with", "respect", "to", "x", "using", "finite", "differencing" ]
def D(y, x, dx=1, order=4): h = x[1]-x[0] weights = _FD_weights(dx, order, order/2., h) ans = np.zeros(y.size, dtype=y.dtype) for ii, xx in enumerate(x): ix_patch, _, ix = _make_patch(xx, x, order) if float(ix) != order/2.: weights = _FD_weights(dx, order, ix, h) ans[ii] = np.dot(y[ix_patch], ...
[ "def", "D", "(", "y", ",", "x", ",", "dx", "=", "1", ",", "order", "=", "4", ")", ":", "h", "=", "x", "[", "1", "]", "-", "x", "[", "0", "]", "weights", "=", "_FD_weights", "(", "dx", ",", "order", ",", "order", "/", "2.", ",", "h", ")"...
Deriviative(s) of y with respect to x using finite differencing
[ "Deriviative", "(", "s", ")", "of", "y", "with", "respect", "to", "x", "using", "finite", "differencing" ]
[ "\"\"\"Deriviative(s) of y with respect to x using finite differencing\"\"\"", "# Look up finite differencing weights", "# Compute finite difference derivatives" ]
[ { "param": "y", "type": null }, { "param": "x", "type": null }, { "param": "dx", "type": null }, { "param": "order", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
_make_patch
<not_specific>
def _make_patch(x, x_grid, dim): """Make patch with dim elements centered around x""" # Find grid points closest to x ix = _get_arg(x_grid, x) # Find how many elements to take on either side of x if dim % 2: # Check if dim is odd... a = int((dim+1)/2.) b = a else: #...or even a...
Make patch with dim elements centered around x
Make patch with dim elements centered around x
[ "Make", "patch", "with", "dim", "elements", "centered", "around", "x" ]
def _make_patch(x, x_grid, dim): ix = _get_arg(x_grid, x) if dim % 2: a = int((dim+1)/2.) b = a else: a = int(dim/2.) b = a+1 ix = _check_patch(ix, a, b, x_grid.size) ipatch = np.arange(ix-a, ix+b) return ipatch, ix, _get_arg(ipatch, ix)
[ "def", "_make_patch", "(", "x", ",", "x_grid", ",", "dim", ")", ":", "ix", "=", "_get_arg", "(", "x_grid", ",", "x", ")", "if", "dim", "%", "2", ":", "a", "=", "int", "(", "(", "dim", "+", "1", ")", "/", "2.", ")", "b", "=", "a", "else", ...
Make patch with dim elements centered around x
[ "Make", "patch", "with", "dim", "elements", "centered", "around", "x" ]
[ "\"\"\"Make patch with dim elements centered around x\"\"\"", "# Find grid points closest to x", "# Find how many elements to take on either side of x", "# Check if dim is odd...", "#...or even", "# Ensure patch doesn't cross the training grid boundary", "# Indices of the patch " ]
[ { "param": "x", "type": null }, { "param": "x_grid", "type": null }, { "param": "dim", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x_grid", "type": null, "docstring": null, "docstring_tokens": []...
604f4b41a897d956a6dbb83fb5388fe3c97768a8
crgalley/romspline
romspline/helpers.py
[ "MIT" ]
Python
_check_patch
<not_specific>
def _check_patch(i, dileft, diright, dim): """Check if i is too close to interval endpoints and adjust if so.""" if i <= dileft: ans = dileft elif dim-i <= diright: ans = dim-diright else: ans = i return ans
Check if i is too close to interval endpoints and adjust if so.
Check if i is too close to interval endpoints and adjust if so.
[ "Check", "if", "i", "is", "too", "close", "to", "interval", "endpoints", "and", "adjust", "if", "so", "." ]
def _check_patch(i, dileft, diright, dim): if i <= dileft: ans = dileft elif dim-i <= diright: ans = dim-diright else: ans = i return ans
[ "def", "_check_patch", "(", "i", ",", "dileft", ",", "diright", ",", "dim", ")", ":", "if", "i", "<=", "dileft", ":", "ans", "=", "dileft", "elif", "dim", "-", "i", "<=", "diright", ":", "ans", "=", "dim", "-", "diright", "else", ":", "ans", "=",...
Check if i is too close to interval endpoints and adjust if so.
[ "Check", "if", "i", "is", "too", "close", "to", "interval", "endpoints", "and", "adjust", "if", "so", "." ]
[ "\"\"\"Check if i is too close to interval endpoints and adjust if so.\"\"\"" ]
[ { "param": "i", "type": null }, { "param": "dileft", "type": null }, { "param": "diright", "type": null }, { "param": "dim", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "i", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dileft", "type": null, "docstring": null, "docstring_tokens": []...
9e6765ad53ce1c9781af4ab255893c2136eb1437
crgalley/romspline
romspline/build_spline.py
[ "MIT" ]
Python
build_spline
<not_specific>
def build_spline(x, y, tol=1e-6, deg=None, rel=False, seeds=None, small=True, cv=True, K=10, parallel=True, verbose=True): """Build a reduced-order spline interpolant with requested tolerance and degree. Options include `small`, for randomly sampling the initial seed points to find a smallest reduced data set, a...
Build a reduced-order spline interpolant with requested tolerance and degree. Options include `small`, for randomly sampling the initial seed points to find a smallest reduced data set, and `cv` for performing a Monte Carlo K-fold cross-validation in order to estimate a global interpolation error. Input -...
Build a reduced-order spline interpolant with requested tolerance and degree. Options include `small`, for randomly sampling the initial seed points to find a smallest reduced data set, and `cv` for performing a Monte Carlo K-fold cross-validation in order to estimate a global interpolation error. Input Output C...
[ "Build", "a", "reduced", "-", "order", "spline", "interpolant", "with", "requested", "tolerance", "and", "degree", ".", "Options", "include", "`", "small", "`", "for", "randomly", "sampling", "the", "initial", "seed", "points", "to", "find", "a", "smallest", ...
def build_spline(x, y, tol=1e-6, deg=None, rel=False, seeds=None, small=True, cv=True, K=10, parallel=True, verbose=True): if small is False: if verbose: print("\nBuilding the reduced-order spline...",) if deg is None: deg = 5 spline = greedy.ReducedOrderSpline(x, y, tol=tol, deg=deg, rel=rel,...
[ "def", "build_spline", "(", "x", ",", "y", ",", "tol", "=", "1e-6", ",", "deg", "=", "None", ",", "rel", "=", "False", ",", "seeds", "=", "None", ",", "small", "=", "True", ",", "cv", "=", "True", ",", "K", "=", "10", ",", "parallel", "=", "T...
Build a reduced-order spline interpolant with requested tolerance and degree.
[ "Build", "a", "reduced", "-", "order", "spline", "interpolant", "with", "requested", "tolerance", "and", "degree", "." ]
[ "\"\"\"Build a reduced-order spline interpolant with requested tolerance and degree.\n Options include `small`, for randomly sampling the initial seed points to \n find a smallest reduced data set, and `cv` for performing a Monte Carlo\n K-fold cross-validation in order to estimate a global interpolation error.\...
[ { "param": "x", "type": null }, { "param": "y", "type": null }, { "param": "tol", "type": null }, { "param": "deg", "type": null }, { "param": "rel", "type": null }, { "param": "seeds", "type": null }, { "param": "small", "type": null ...
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
0d2939abfb34717f2d595a7d4da9bf3a39e52861
crgalley/romspline
romspline/random_seeds.py
[ "MIT" ]
Python
_randomSeeds
<not_specific>
def _randomSeeds(x, y, seeds, tol=1e-6, rel=False, deg=5): """Build reduced-order splines from an arbitrary seed for the greedy algorithm. See RandomSeeds for further details. Input ----- x -- samples y -- data to be downsampled seeds -- list of integers specifying the array indexes of ...
Build reduced-order splines from an arbitrary seed for the greedy algorithm. See RandomSeeds for further details. Input ----- x -- samples y -- data to be downsampled seeds -- list of integers specifying the array indexes of the samples used to seed the greedy algorithm tol...
Build reduced-order splines from an arbitrary seed for the greedy algorithm. See RandomSeeds for further details. Input
[ "Build", "reduced", "-", "order", "splines", "from", "an", "arbitrary", "seed", "for", "the", "greedy", "algorithm", ".", "See", "RandomSeeds", "for", "further", "details", ".", "Input" ]
def _randomSeeds(x, y, seeds, tol=1e-6, rel=False, deg=5): seeds = np.sort(seeds) spline = greedy.ReducedOrderSpline(x, y, tol=tol, rel=rel, deg=deg, seeds=seeds) return spline.errors[-1], spline.size, seeds, spline.X
[ "def", "_randomSeeds", "(", "x", ",", "y", ",", "seeds", ",", "tol", "=", "1e-6", ",", "rel", "=", "False", ",", "deg", "=", "5", ")", ":", "seeds", "=", "np", ".", "sort", "(", "seeds", ")", "spline", "=", "greedy", ".", "ReducedOrderSpline", "(...
Build reduced-order splines from an arbitrary seed for the greedy algorithm.
[ "Build", "reduced", "-", "order", "splines", "from", "an", "arbitrary", "seed", "for", "the", "greedy", "algorithm", "." ]
[ "\"\"\"Build reduced-order splines from an arbitrary seed for the greedy algorithm.\n See RandomSeeds for further details.\n \n Input\n -----\n x -- samples\n y -- data to be downsampled\n seeds -- list of integers specifying the array indexes of\n the samples used to seed the greed...
[ { "param": "x", "type": null }, { "param": "y", "type": null }, { "param": "seeds", "type": null }, { "param": "tol", "type": null }, { "param": "rel", "type": null }, { "param": "deg", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...