repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
seyriz/taiga-contrib-google-auth
back/taiga_contrib_google_auth/connector.py
_build_url
def _build_url(*args, **kwargs) -> str: """ Return a valid url. """ resource_url = API_RESOURCES_URLS for key in args: resource_url = resource_url[key] if kwargs: resource_url = resource_url.format(**kwargs) return urljoin(URL, resource_url)
python
def _build_url(*args, **kwargs) -> str: """ Return a valid url. """ resource_url = API_RESOURCES_URLS for key in args: resource_url = resource_url[key] if kwargs: resource_url = resource_url.format(**kwargs) return urljoin(URL, resource_url)
[ "def", "_build_url", "(", "*", "args", ",", "*", "*", "kwargs", ")", "->", "str", ":", "resource_url", "=", "API_RESOURCES_URLS", "for", "key", "in", "args", ":", "resource_url", "=", "resource_url", "[", "key", "]", "if", "kwargs", ":", "resource_url", ...
Return a valid url.
[ "Return", "a", "valid", "url", "." ]
e9fb5d062027a055e09f7614aa2e48eab7a8604b
https://github.com/seyriz/taiga-contrib-google-auth/blob/e9fb5d062027a055e09f7614aa2e48eab7a8604b/back/taiga_contrib_google_auth/connector.py#L64-L75
train
57,100
seyriz/taiga-contrib-google-auth
back/taiga_contrib_google_auth/connector.py
_get
def _get(url:str, headers:dict) -> dict: """ Make a GET call. """ response = requests.get(url, headers=headers) data = response.json() if response.status_code != 200: raise GoogleApiError({"status_code": response.status_code, "error": data.get("error", ...
python
def _get(url:str, headers:dict) -> dict: """ Make a GET call. """ response = requests.get(url, headers=headers) data = response.json() if response.status_code != 200: raise GoogleApiError({"status_code": response.status_code, "error": data.get("error", ...
[ "def", "_get", "(", "url", ":", "str", ",", "headers", ":", "dict", ")", "->", "dict", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "headers", ")", "data", "=", "response", ".", "json", "(", ")", "if", "response", ...
Make a GET call.
[ "Make", "a", "GET", "call", "." ]
e9fb5d062027a055e09f7614aa2e48eab7a8604b
https://github.com/seyriz/taiga-contrib-google-auth/blob/e9fb5d062027a055e09f7614aa2e48eab7a8604b/back/taiga_contrib_google_auth/connector.py#L78-L88
train
57,101
seyriz/taiga-contrib-google-auth
back/taiga_contrib_google_auth/connector.py
_post
def _post(url:str, params:dict, headers:dict) -> dict: """ Make a POST call. """ response = requests.post(url, params=params, headers=headers) data = response.json() if response.status_code != 200 or "error" in data: raise GoogleApiError({"status_code": response.status_code, ...
python
def _post(url:str, params:dict, headers:dict) -> dict: """ Make a POST call. """ response = requests.post(url, params=params, headers=headers) data = response.json() if response.status_code != 200 or "error" in data: raise GoogleApiError({"status_code": response.status_code, ...
[ "def", "_post", "(", "url", ":", "str", ",", "params", ":", "dict", ",", "headers", ":", "dict", ")", "->", "dict", ":", "response", "=", "requests", ".", "post", "(", "url", ",", "params", "=", "params", ",", "headers", "=", "headers", ")", "data"...
Make a POST call.
[ "Make", "a", "POST", "call", "." ]
e9fb5d062027a055e09f7614aa2e48eab7a8604b
https://github.com/seyriz/taiga-contrib-google-auth/blob/e9fb5d062027a055e09f7614aa2e48eab7a8604b/back/taiga_contrib_google_auth/connector.py#L91-L100
train
57,102
pcattori/deep-blue-talks
kasparobot/__init__.py
MoveAnalyzer.dims_knight
def dims_knight(self, move): '''Knight on the rim is dim''' if self.board.piece_type_at(move.from_square) == chess.KNIGHT: rim = SquareSet( chess.BB_RANK_1 | \ chess.BB_RANK_8 | \ chess.BB_FILE_A | \ chess.BB_FILE_H) return move.to_square in rim
python
def dims_knight(self, move): '''Knight on the rim is dim''' if self.board.piece_type_at(move.from_square) == chess.KNIGHT: rim = SquareSet( chess.BB_RANK_1 | \ chess.BB_RANK_8 | \ chess.BB_FILE_A | \ chess.BB_FILE_H) return move.to_square in rim
[ "def", "dims_knight", "(", "self", ",", "move", ")", ":", "if", "self", ".", "board", ".", "piece_type_at", "(", "move", ".", "from_square", ")", "==", "chess", ".", "KNIGHT", ":", "rim", "=", "SquareSet", "(", "chess", ".", "BB_RANK_1", "|", "chess", ...
Knight on the rim is dim
[ "Knight", "on", "the", "rim", "is", "dim" ]
7af7c740e8ec03dd30f1291ecf174078890eec89
https://github.com/pcattori/deep-blue-talks/blob/7af7c740e8ec03dd30f1291ecf174078890eec89/kasparobot/__init__.py#L95-L103
train
57,103
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_comment_collection
def get_comment_collection(cmt_id): """ Extract the collection where the comment is written """ query = """SELECT id_bibrec FROM "cmtRECORDCOMMENT" WHERE id=%s""" recid = run_sql(query, (cmt_id,)) record_primary_collection = guess_primary_collection_of_a_record( recid[0][0]) return r...
python
def get_comment_collection(cmt_id): """ Extract the collection where the comment is written """ query = """SELECT id_bibrec FROM "cmtRECORDCOMMENT" WHERE id=%s""" recid = run_sql(query, (cmt_id,)) record_primary_collection = guess_primary_collection_of_a_record( recid[0][0]) return r...
[ "def", "get_comment_collection", "(", "cmt_id", ")", ":", "query", "=", "\"\"\"SELECT id_bibrec FROM \"cmtRECORDCOMMENT\" WHERE id=%s\"\"\"", "recid", "=", "run_sql", "(", "query", ",", "(", "cmt_id", ",", ")", ")", "record_primary_collection", "=", "guess_primary_collect...
Extract the collection where the comment is written
[ "Extract", "the", "collection", "where", "the", "comment", "is", "written" ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L487-L495
train
57,104
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_collection_moderators
def get_collection_moderators(collection): """ Return the list of comment moderators for the given collection. """ from invenio_access.engine import acc_get_authorized_emails res = list( acc_get_authorized_emails( 'moderatecomments', collection=collection)) if no...
python
def get_collection_moderators(collection): """ Return the list of comment moderators for the given collection. """ from invenio_access.engine import acc_get_authorized_emails res = list( acc_get_authorized_emails( 'moderatecomments', collection=collection)) if no...
[ "def", "get_collection_moderators", "(", "collection", ")", ":", "from", "invenio_access", ".", "engine", "import", "acc_get_authorized_emails", "res", "=", "list", "(", "acc_get_authorized_emails", "(", "'moderatecomments'", ",", "collection", "=", "collection", ")", ...
Return the list of comment moderators for the given collection.
[ "Return", "the", "list", "of", "comment", "moderators", "for", "the", "given", "collection", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L498-L510
train
57,105
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_reply_order_cache_data
def get_reply_order_cache_data(comid): """ Prepare a representation of the comment ID given as parameter so that it is suitable for byte ordering in MySQL. """ return "%s%s%s%s" % (chr((comid >> 24) % 256), chr((comid >> 16) % 256), chr((comid >> 8) % 256), chr(comid % 256))
python
def get_reply_order_cache_data(comid): """ Prepare a representation of the comment ID given as parameter so that it is suitable for byte ordering in MySQL. """ return "%s%s%s%s" % (chr((comid >> 24) % 256), chr((comid >> 16) % 256), chr((comid >> 8) % 256), chr(comid % 256))
[ "def", "get_reply_order_cache_data", "(", "comid", ")", ":", "return", "\"%s%s%s%s\"", "%", "(", "chr", "(", "(", "comid", ">>", "24", ")", "%", "256", ")", ",", "chr", "(", "(", "comid", ">>", "16", ")", "%", "256", ")", ",", "chr", "(", "(", "c...
Prepare a representation of the comment ID given as parameter so that it is suitable for byte ordering in MySQL.
[ "Prepare", "a", "representation", "of", "the", "comment", "ID", "given", "as", "parameter", "so", "that", "it", "is", "suitable", "for", "byte", "ordering", "in", "MySQL", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L945-L951
train
57,106
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
move_attached_files_to_storage
def move_attached_files_to_storage(attached_files, recID, comid): """ Move the files that were just attached to a new comment to their final location. :param attached_files: the mappings of desired filename to attach and path where to find the original file :type attached...
python
def move_attached_files_to_storage(attached_files, recID, comid): """ Move the files that were just attached to a new comment to their final location. :param attached_files: the mappings of desired filename to attach and path where to find the original file :type attached...
[ "def", "move_attached_files_to_storage", "(", "attached_files", ",", "recID", ",", "comid", ")", ":", "for", "filename", ",", "filepath", "in", "iteritems", "(", "attached_files", ")", ":", "dest_dir", "=", "os", ".", "path", ".", "join", "(", "CFG_COMMENTSDIR...
Move the files that were just attached to a new comment to their final location. :param attached_files: the mappings of desired filename to attach and path where to find the original file :type attached_files: dict {filename, filepath} :param recID: the record ID to which we ...
[ "Move", "the", "files", "that", "were", "just", "attached", "to", "a", "new", "comment", "to", "their", "final", "location", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1124-L1143
train
57,107
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
subscribe_user_to_discussion
def subscribe_user_to_discussion(recID, uid): """ Subscribe a user to a discussion, so the she receives by emails all new new comments for this record. :param recID: record ID corresponding to the discussion we want to subscribe the user :param uid: user id """ query = """...
python
def subscribe_user_to_discussion(recID, uid): """ Subscribe a user to a discussion, so the she receives by emails all new new comments for this record. :param recID: record ID corresponding to the discussion we want to subscribe the user :param uid: user id """ query = """...
[ "def", "subscribe_user_to_discussion", "(", "recID", ",", "uid", ")", ":", "query", "=", "\"\"\"INSERT INTO \"cmtSUBSCRIPTION\" (id_bibrec, id_user, creation_time)\n VALUES (%s, %s, %s)\"\"\"", "params", "=", "(", "recID", ",", "uid", ",", "convert_datestruct_t...
Subscribe a user to a discussion, so the she receives by emails all new new comments for this record. :param recID: record ID corresponding to the discussion we want to subscribe the user :param uid: user id
[ "Subscribe", "a", "user", "to", "a", "discussion", "so", "the", "she", "receives", "by", "emails", "all", "new", "new", "comments", "for", "this", "record", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1177-L1193
train
57,108
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
unsubscribe_user_from_discussion
def unsubscribe_user_from_discussion(recID, uid): """ Unsubscribe users from a discussion. :param recID: record ID corresponding to the discussion we want to unsubscribe the user :param uid: user id :return 1 if successful, 0 if not """ query = """DELETE FROM "cmtSUBSCRIPT...
python
def unsubscribe_user_from_discussion(recID, uid): """ Unsubscribe users from a discussion. :param recID: record ID corresponding to the discussion we want to unsubscribe the user :param uid: user id :return 1 if successful, 0 if not """ query = """DELETE FROM "cmtSUBSCRIPT...
[ "def", "unsubscribe_user_from_discussion", "(", "recID", ",", "uid", ")", ":", "query", "=", "\"\"\"DELETE FROM \"cmtSUBSCRIPTION\"\n WHERE id_bibrec=%s AND id_user=%s\"\"\"", "params", "=", "(", "recID", ",", "uid", ")", "try", ":", "res", "=", "run_s...
Unsubscribe users from a discussion. :param recID: record ID corresponding to the discussion we want to unsubscribe the user :param uid: user id :return 1 if successful, 0 if not
[ "Unsubscribe", "users", "from", "a", "discussion", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1196-L1214
train
57,109
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_users_subscribed_to_discussion
def get_users_subscribed_to_discussion(recID, check_authorizations=True): """ Returns the lists of users subscribed to a given discussion. Two lists are returned: the first one is the list of emails for users who can unsubscribe from the discussion, the second list contains the emails of users who ...
python
def get_users_subscribed_to_discussion(recID, check_authorizations=True): """ Returns the lists of users subscribed to a given discussion. Two lists are returned: the first one is the list of emails for users who can unsubscribe from the discussion, the second list contains the emails of users who ...
[ "def", "get_users_subscribed_to_discussion", "(", "recID", ",", "check_authorizations", "=", "True", ")", ":", "subscribers_emails", "=", "{", "}", "# Get users that have subscribed to this discussion", "query", "=", "\"\"\"SELECT id_user FROM \"cmtSUBSCRIPTION\" WHERE id_bibrec=%s...
Returns the lists of users subscribed to a given discussion. Two lists are returned: the first one is the list of emails for users who can unsubscribe from the discussion, the second list contains the emails of users who cannot unsubscribe (for eg. author of the document, etc). Users appear in onl...
[ "Returns", "the", "lists", "of", "users", "subscribed", "to", "a", "given", "discussion", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1241-L1302
train
57,110
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_record_status
def get_record_status(recid): """ Returns the current status of the record, i.e. current restriction to apply for newly submitted comments, and current commenting round. The restriction to apply can be found in the record metadata, in field(s) defined by config CFG_WEBCOMMENT_RESTRICTION_DATAFIELD....
python
def get_record_status(recid): """ Returns the current status of the record, i.e. current restriction to apply for newly submitted comments, and current commenting round. The restriction to apply can be found in the record metadata, in field(s) defined by config CFG_WEBCOMMENT_RESTRICTION_DATAFIELD....
[ "def", "get_record_status", "(", "recid", ")", ":", "collections_with_rounds", "=", "CFG_WEBCOMMENT_ROUND_DATAFIELD", ".", "keys", "(", ")", "commenting_round", "=", "\"\"", "for", "collection", "in", "collections_with_rounds", ":", "# Find the first collection defines roun...
Returns the current status of the record, i.e. current restriction to apply for newly submitted comments, and current commenting round. The restriction to apply can be found in the record metadata, in field(s) defined by config CFG_WEBCOMMENT_RESTRICTION_DATAFIELD. The restriction is empty string "" in...
[ "Returns", "the", "current", "status", "of", "the", "record", "i", ".", "e", ".", "current", "restriction", "to", "apply", "for", "newly", "submitted", "comments", "and", "current", "commenting", "round", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1430-L1475
train
57,111
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
group_comments_by_round
def group_comments_by_round(comments, ranking=0): """ Group comments by the round to which they belong """ comment_rounds = {} ordered_comment_round_names = [] for comment in comments: comment_round_name = ranking and comment[11] or comment[7] if comment_round_name not in comment...
python
def group_comments_by_round(comments, ranking=0): """ Group comments by the round to which they belong """ comment_rounds = {} ordered_comment_round_names = [] for comment in comments: comment_round_name = ranking and comment[11] or comment[7] if comment_round_name not in comment...
[ "def", "group_comments_by_round", "(", "comments", ",", "ranking", "=", "0", ")", ":", "comment_rounds", "=", "{", "}", "ordered_comment_round_names", "=", "[", "]", "for", "comment", "in", "comments", ":", "comment_round_name", "=", "ranking", "and", "comment",...
Group comments by the round to which they belong
[ "Group", "comments", "by", "the", "round", "to", "which", "they", "belong" ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1680-L1693
train
57,112
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_mini_reviews
def get_mini_reviews(recid, ln=CFG_SITE_LANG): """ Returns the web controls to add reviews to a record from the detailed record pages mini-panel. :param recid: the id of the displayed record :param ln: the user's language """ if CFG_WEBCOMMENT_ALLOW_SHORT_REVIEWS: action = 'SUBMIT' ...
python
def get_mini_reviews(recid, ln=CFG_SITE_LANG): """ Returns the web controls to add reviews to a record from the detailed record pages mini-panel. :param recid: the id of the displayed record :param ln: the user's language """ if CFG_WEBCOMMENT_ALLOW_SHORT_REVIEWS: action = 'SUBMIT' ...
[ "def", "get_mini_reviews", "(", "recid", ",", "ln", "=", "CFG_SITE_LANG", ")", ":", "if", "CFG_WEBCOMMENT_ALLOW_SHORT_REVIEWS", ":", "action", "=", "'SUBMIT'", "else", ":", "action", "=", "'DISPLAY'", "reviews", "=", "query_retrieve_comments_or_remarks", "(", "recid...
Returns the web controls to add reviews to a record from the detailed record pages mini-panel. :param recid: the id of the displayed record :param ln: the user's language
[ "Returns", "the", "web", "controls", "to", "add", "reviews", "to", "a", "record", "from", "the", "detailed", "record", "pages", "mini", "-", "panel", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2252-L2272
train
57,113
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
check_user_can_view_comments
def check_user_can_view_comments(user_info, recid): """Check if the user is authorized to view comments for given recid. Returns the same type as acc_authorize_action """ # Check user can view the record itself first (auth_code, auth_msg) = check_user_can_view_record(user_info, recid) if au...
python
def check_user_can_view_comments(user_info, recid): """Check if the user is authorized to view comments for given recid. Returns the same type as acc_authorize_action """ # Check user can view the record itself first (auth_code, auth_msg) = check_user_can_view_record(user_info, recid) if au...
[ "def", "check_user_can_view_comments", "(", "user_info", ",", "recid", ")", ":", "# Check user can view the record itself first", "(", "auth_code", ",", "auth_msg", ")", "=", "check_user_can_view_record", "(", "user_info", ",", "recid", ")", "if", "auth_code", ":", "r...
Check if the user is authorized to view comments for given recid. Returns the same type as acc_authorize_action
[ "Check", "if", "the", "user", "is", "authorized", "to", "view", "comments", "for", "given", "recid", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2275-L2294
train
57,114
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
check_user_can_view_comment
def check_user_can_view_comment(user_info, comid, restriction=None): """Check if the user is authorized to view a particular comment, given the comment restriction. Note that this function does not check if the record itself is restricted to the user, which would mean that the user should not see the co...
python
def check_user_can_view_comment(user_info, comid, restriction=None): """Check if the user is authorized to view a particular comment, given the comment restriction. Note that this function does not check if the record itself is restricted to the user, which would mean that the user should not see the co...
[ "def", "check_user_can_view_comment", "(", "user_info", ",", "comid", ",", "restriction", "=", "None", ")", ":", "if", "restriction", "is", "None", ":", "comment", "=", "query_get_comment", "(", "comid", ")", "if", "comment", ":", "restriction", "=", "comment"...
Check if the user is authorized to view a particular comment, given the comment restriction. Note that this function does not check if the record itself is restricted to the user, which would mean that the user should not see the comment. You can omit 'comid' if you already know the 'restriction' ...
[ "Check", "if", "the", "user", "is", "authorized", "to", "view", "a", "particular", "comment", "given", "the", "comment", "restriction", ".", "Note", "that", "this", "function", "does", "not", "check", "if", "the", "record", "itself", "is", "restricted", "to"...
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2297-L2320
train
57,115
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
check_user_can_send_comments
def check_user_can_send_comments(user_info, recid): """Check if the user is authorized to comment the given recid. This function does not check that user can view the record or view the comments Returns the same type as acc_authorize_action """ # First can we find an authorization for this case...
python
def check_user_can_send_comments(user_info, recid): """Check if the user is authorized to comment the given recid. This function does not check that user can view the record or view the comments Returns the same type as acc_authorize_action """ # First can we find an authorization for this case...
[ "def", "check_user_can_send_comments", "(", "user_info", ",", "recid", ")", ":", "# First can we find an authorization for this case, action + collection", "record_primary_collection", "=", "guess_primary_collection_of_a_record", "(", "recid", ")", "return", "acc_authorize_action", ...
Check if the user is authorized to comment the given recid. This function does not check that user can view the record or view the comments Returns the same type as acc_authorize_action
[ "Check", "if", "the", "user", "is", "authorized", "to", "comment", "the", "given", "recid", ".", "This", "function", "does", "not", "check", "that", "user", "can", "view", "the", "record", "or", "view", "the", "comments" ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2323-L2336
train
57,116
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
check_user_can_attach_file_to_comments
def check_user_can_attach_file_to_comments(user_info, recid): """Check if the user is authorized to attach a file to comments for given recid. This function does not check that user can view the comments or send comments. Returns the same type as acc_authorize_action """ # First can we find an ...
python
def check_user_can_attach_file_to_comments(user_info, recid): """Check if the user is authorized to attach a file to comments for given recid. This function does not check that user can view the comments or send comments. Returns the same type as acc_authorize_action """ # First can we find an ...
[ "def", "check_user_can_attach_file_to_comments", "(", "user_info", ",", "recid", ")", ":", "# First can we find an authorization for this case action, for", "# this collection?", "record_primary_collection", "=", "guess_primary_collection_of_a_record", "(", "recid", ")", "return", ...
Check if the user is authorized to attach a file to comments for given recid. This function does not check that user can view the comments or send comments. Returns the same type as acc_authorize_action
[ "Check", "if", "the", "user", "is", "authorized", "to", "attach", "a", "file", "to", "comments", "for", "given", "recid", ".", "This", "function", "does", "not", "check", "that", "user", "can", "view", "the", "comments", "or", "send", "comments", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2356-L2370
train
57,117
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
get_user_collapsed_comments_for_record
def get_user_collapsed_comments_for_record(uid, recid): """ Get the comments collapsed for given user on given recid page """ # Collapsed state is not an attribute of cmtRECORDCOMMENT table # (vary per user) so it cannot be found when querying for the # comment. We must therefore provide a effic...
python
def get_user_collapsed_comments_for_record(uid, recid): """ Get the comments collapsed for given user on given recid page """ # Collapsed state is not an attribute of cmtRECORDCOMMENT table # (vary per user) so it cannot be found when querying for the # comment. We must therefore provide a effic...
[ "def", "get_user_collapsed_comments_for_record", "(", "uid", ",", "recid", ")", ":", "# Collapsed state is not an attribute of cmtRECORDCOMMENT table", "# (vary per user) so it cannot be found when querying for the", "# comment. We must therefore provide a efficient way to retrieve", "# the co...
Get the comments collapsed for given user on given recid page
[ "Get", "the", "comments", "collapsed", "for", "given", "user", "on", "given", "recid", "page" ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2417-L2427
train
57,118
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
is_comment_deleted
def is_comment_deleted(comid): """ Return True of the comment is deleted. Else False :param comid: ID of comment to check """ query = """SELECT status from "cmtRECORDCOMMENT" WHERE id=%s""" params = (comid,) res = run_sql(query, params) if res and res[0][0] != 'ok': return True ...
python
def is_comment_deleted(comid): """ Return True of the comment is deleted. Else False :param comid: ID of comment to check """ query = """SELECT status from "cmtRECORDCOMMENT" WHERE id=%s""" params = (comid,) res = run_sql(query, params) if res and res[0][0] != 'ok': return True ...
[ "def", "is_comment_deleted", "(", "comid", ")", ":", "query", "=", "\"\"\"SELECT status from \"cmtRECORDCOMMENT\" WHERE id=%s\"\"\"", "params", "=", "(", "comid", ",", ")", "res", "=", "run_sql", "(", "query", ",", "params", ")", "if", "res", "and", "res", "[", ...
Return True of the comment is deleted. Else False :param comid: ID of comment to check
[ "Return", "True", "of", "the", "comment", "is", "deleted", ".", "Else", "False" ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2430-L2442
train
57,119
openstack/stacktach-winchester
winchester/trigger_manager.py
EventCondenser._fix_time
def _fix_time(self, dt): """Stackdistiller converts all times to utc. We store timestamps as utc datetime. However, the explicit UTC timezone on incoming datetimes causes comparison issues deep in sqlalchemy. We fix this by converting all datetimes to naive utc timestamps ...
python
def _fix_time(self, dt): """Stackdistiller converts all times to utc. We store timestamps as utc datetime. However, the explicit UTC timezone on incoming datetimes causes comparison issues deep in sqlalchemy. We fix this by converting all datetimes to naive utc timestamps ...
[ "def", "_fix_time", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", ":", "dt", "=", "dt", ".", "replace", "(", "tzinfo", "=", "None", ")", "return", "dt" ]
Stackdistiller converts all times to utc. We store timestamps as utc datetime. However, the explicit UTC timezone on incoming datetimes causes comparison issues deep in sqlalchemy. We fix this by converting all datetimes to naive utc timestamps
[ "Stackdistiller", "converts", "all", "times", "to", "utc", "." ]
54f3ffc4a8fd84b6fb29ad9b65adb018e8927956
https://github.com/openstack/stacktach-winchester/blob/54f3ffc4a8fd84b6fb29ad9b65adb018e8927956/winchester/trigger_manager.py#L64-L74
train
57,120
Cecca/lydoc
lydoc/collector.py
strip_leading_comments
def strip_leading_comments(text): """Strips the leading whitespaces and % from the given text. Adapted from textwrap.dedent """ # Look for the longest leading string of spaces and tabs common to # all lines. margin = None text = _whitespace_only_re.sub('', text) indents = _leading_white...
python
def strip_leading_comments(text): """Strips the leading whitespaces and % from the given text. Adapted from textwrap.dedent """ # Look for the longest leading string of spaces and tabs common to # all lines. margin = None text = _whitespace_only_re.sub('', text) indents = _leading_white...
[ "def", "strip_leading_comments", "(", "text", ")", ":", "# Look for the longest leading string of spaces and tabs common to", "# all lines.", "margin", "=", "None", "text", "=", "_whitespace_only_re", ".", "sub", "(", "''", ",", "text", ")", "indents", "=", "_leading_wh...
Strips the leading whitespaces and % from the given text. Adapted from textwrap.dedent
[ "Strips", "the", "leading", "whitespaces", "and", "%", "from", "the", "given", "text", "." ]
cd01dd5ed902b2574fb412c55bdc684276a88505
https://github.com/Cecca/lydoc/blob/cd01dd5ed902b2574fb412c55bdc684276a88505/lydoc/collector.py#L23-L61
train
57,121
Cecca/lydoc
lydoc/collector.py
parse
def parse(target, trace=False, **kwargs): """Parse the given target. If it is a file-like object, then parse its contents. If given a string, perform one of the following actions - If the string is a valid file path, then open and parse it - If the string is a valid directory path, then recursively l...
python
def parse(target, trace=False, **kwargs): """Parse the given target. If it is a file-like object, then parse its contents. If given a string, perform one of the following actions - If the string is a valid file path, then open and parse it - If the string is a valid directory path, then recursively l...
[ "def", "parse", "(", "target", ",", "trace", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Beware! This function, that actually is the core of all the", "# business, is written to minimize the responsibilities of each", "# chunk of code, keeping things simple. Performance may d...
Parse the given target. If it is a file-like object, then parse its contents. If given a string, perform one of the following actions - If the string is a valid file path, then open and parse it - If the string is a valid directory path, then recursively look for files ending in .ly or .ily -...
[ "Parse", "the", "given", "target", ".", "If", "it", "is", "a", "file", "-", "like", "object", "then", "parse", "its", "contents", ".", "If", "given", "a", "string", "perform", "one", "of", "the", "following", "actions" ]
cd01dd5ed902b2574fb412c55bdc684276a88505
https://github.com/Cecca/lydoc/blob/cd01dd5ed902b2574fb412c55bdc684276a88505/lydoc/collector.py#L127-L189
train
57,122
concordusapps/flask-components
src/flask_components/utils.py
find
def find(name, app=None, components=None, raw=False): """ Discover any named attributes, modules, or packages and coalesces the results. Looks in any module or package declared in the the 'COMPONENTS' key in the application config. Order of found results are persisted from the order that the ...
python
def find(name, app=None, components=None, raw=False): """ Discover any named attributes, modules, or packages and coalesces the results. Looks in any module or package declared in the the 'COMPONENTS' key in the application config. Order of found results are persisted from the order that the ...
[ "def", "find", "(", "name", ",", "app", "=", "None", ",", "components", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "components", "is", "None", ":", "if", "app", "is", "None", ":", "from", "flask", "import", "current_app", "as", "app", "...
Discover any named attributes, modules, or packages and coalesces the results. Looks in any module or package declared in the the 'COMPONENTS' key in the application config. Order of found results are persisted from the order that the component was declared in. @param[in] components A...
[ "Discover", "any", "named", "attributes", "modules", "or", "packages", "and", "coalesces", "the", "results", "." ]
99d798cbc77147649651eda6e386de2c10f293e2
https://github.com/concordusapps/flask-components/blob/99d798cbc77147649651eda6e386de2c10f293e2/src/flask_components/utils.py#L11-L64
train
57,123
tradenity/python-sdk
tradenity/resources/cart_settings.py
CartSettings.auto_clear_shopping_cart
def auto_clear_shopping_cart(self, auto_clear_shopping_cart): """Sets the auto_clear_shopping_cart of this CartSettings. :param auto_clear_shopping_cart: The auto_clear_shopping_cart of this CartSettings. :type: str """ allowed_values = ["never", "orderCreated", "orderCompleted...
python
def auto_clear_shopping_cart(self, auto_clear_shopping_cart): """Sets the auto_clear_shopping_cart of this CartSettings. :param auto_clear_shopping_cart: The auto_clear_shopping_cart of this CartSettings. :type: str """ allowed_values = ["never", "orderCreated", "orderCompleted...
[ "def", "auto_clear_shopping_cart", "(", "self", ",", "auto_clear_shopping_cart", ")", ":", "allowed_values", "=", "[", "\"never\"", ",", "\"orderCreated\"", ",", "\"orderCompleted\"", "]", "# noqa: E501", "if", "auto_clear_shopping_cart", "is", "not", "None", "and", "...
Sets the auto_clear_shopping_cart of this CartSettings. :param auto_clear_shopping_cart: The auto_clear_shopping_cart of this CartSettings. :type: str
[ "Sets", "the", "auto_clear_shopping_cart", "of", "this", "CartSettings", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/cart_settings.py#L52-L66
train
57,124
nuSTORM/gnomon
gnomon/SensitiveDetector.py
ScintSD.getView
def getView(self, lv): """Determine the detector view starting with a G4LogicalVolume""" view = None if str(lv.GetName())[-1] == 'X': return 'X' elif str(lv.GetName())[-1] == 'Y': return 'Y' self.log.error('Cannot determine view for %s', lv.GetName()) ...
python
def getView(self, lv): """Determine the detector view starting with a G4LogicalVolume""" view = None if str(lv.GetName())[-1] == 'X': return 'X' elif str(lv.GetName())[-1] == 'Y': return 'Y' self.log.error('Cannot determine view for %s', lv.GetName()) ...
[ "def", "getView", "(", "self", ",", "lv", ")", ":", "view", "=", "None", "if", "str", "(", "lv", ".", "GetName", "(", ")", ")", "[", "-", "1", "]", "==", "'X'", ":", "return", "'X'", "elif", "str", "(", "lv", ".", "GetName", "(", ")", ")", ...
Determine the detector view starting with a G4LogicalVolume
[ "Determine", "the", "detector", "view", "starting", "with", "a", "G4LogicalVolume" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/SensitiveDetector.py#L78-L88
train
57,125
trevisanj/a99
a99/gui/parameter.py
Parameter.RenderWidget
def RenderWidget(self): """Returns a QWidget subclass instance. Exact class depends on self.type""" t = self.type if t == int: ret = QSpinBox() ret.setMaximum(999999999) ret.setValue(self.value) elif t == float: ret = QLineEdit() ...
python
def RenderWidget(self): """Returns a QWidget subclass instance. Exact class depends on self.type""" t = self.type if t == int: ret = QSpinBox() ret.setMaximum(999999999) ret.setValue(self.value) elif t == float: ret = QLineEdit() ...
[ "def", "RenderWidget", "(", "self", ")", ":", "t", "=", "self", ".", "type", "if", "t", "==", "int", ":", "ret", "=", "QSpinBox", "(", ")", "ret", ".", "setMaximum", "(", "999999999", ")", "ret", ".", "setValue", "(", "self", ".", "value", ")", "...
Returns a QWidget subclass instance. Exact class depends on self.type
[ "Returns", "a", "QWidget", "subclass", "instance", ".", "Exact", "class", "depends", "on", "self", ".", "type" ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/parameter.py#L123-L144
train
57,126
dbuscher/pois
pois/PhaseScreen.py
ScreenGenerator
def ScreenGenerator(nfft, r0, nx, ny): """Generate an infinite series of rectangular phase screens Uses an FFT screen generator to make a large screen and then returns non-overlapping subsections of it""" while 1: layers = GenerateTwoScreens(nfft, r0) for iLayer in range(2): ...
python
def ScreenGenerator(nfft, r0, nx, ny): """Generate an infinite series of rectangular phase screens Uses an FFT screen generator to make a large screen and then returns non-overlapping subsections of it""" while 1: layers = GenerateTwoScreens(nfft, r0) for iLayer in range(2): ...
[ "def", "ScreenGenerator", "(", "nfft", ",", "r0", ",", "nx", ",", "ny", ")", ":", "while", "1", ":", "layers", "=", "GenerateTwoScreens", "(", "nfft", ",", "r0", ")", "for", "iLayer", "in", "range", "(", "2", ")", ":", "for", "iy", "in", "range", ...
Generate an infinite series of rectangular phase screens Uses an FFT screen generator to make a large screen and then returns non-overlapping subsections of it
[ "Generate", "an", "infinite", "series", "of", "rectangular", "phase", "screens", "Uses", "an", "FFT", "screen", "generator", "to", "make", "a", "large", "screen", "and", "then", "returns", "non", "-", "overlapping", "subsections", "of", "it" ]
bb9d9a932e716b5d385221768027384691803aa3
https://github.com/dbuscher/pois/blob/bb9d9a932e716b5d385221768027384691803aa3/pois/PhaseScreen.py#L5-L14
train
57,127
consbio/parserutils
parserutils/dates.py
parse_dates
def parse_dates(d, default='today'): """ Parses one or more dates from d """ if default == 'today': default = datetime.datetime.today() if d is None: return default elif isinstance(d, _parsed_date_types): return d elif is_number(d): # Treat as milliseconds since 1...
python
def parse_dates(d, default='today'): """ Parses one or more dates from d """ if default == 'today': default = datetime.datetime.today() if d is None: return default elif isinstance(d, _parsed_date_types): return d elif is_number(d): # Treat as milliseconds since 1...
[ "def", "parse_dates", "(", "d", ",", "default", "=", "'today'", ")", ":", "if", "default", "==", "'today'", ":", "default", "=", "datetime", ".", "datetime", ".", "today", "(", ")", "if", "d", "is", "None", ":", "return", "default", "elif", "isinstance...
Parses one or more dates from d
[ "Parses", "one", "or", "more", "dates", "from", "d" ]
f13f80db99ed43479336b116e38512e3566e4623
https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/dates.py#L9-L40
train
57,128
trevisanj/f311
f311/util.py
load_with_classes
def load_with_classes(filename, classes): """Attempts to load file by trial-and-error using a given list of classes. Arguments: filename -- full path to file classes -- list of classes having a load() method Returns: DataFile object if loaded successfully, or None if not. Note: it will st...
python
def load_with_classes(filename, classes): """Attempts to load file by trial-and-error using a given list of classes. Arguments: filename -- full path to file classes -- list of classes having a load() method Returns: DataFile object if loaded successfully, or None if not. Note: it will st...
[ "def", "load_with_classes", "(", "filename", ",", "classes", ")", ":", "ok", "=", "False", "for", "class_", "in", "classes", ":", "obj", "=", "class_", "(", ")", "try", ":", "obj", ".", "load", "(", "filename", ")", "ok", "=", "True", "# # cannot let I...
Attempts to load file by trial-and-error using a given list of classes. Arguments: filename -- full path to file classes -- list of classes having a load() method Returns: DataFile object if loaded successfully, or None if not. Note: it will stop at the first successful load. Attention: ...
[ "Attempts", "to", "load", "file", "by", "trial", "-", "and", "-", "error", "using", "a", "given", "list", "of", "classes", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L32-L71
train
57,129
trevisanj/f311
f311/util.py
load_any_file
def load_any_file(filename): """ Attempts to load filename by trial-and-error Returns: file: A DataFile descendant, whose specific class depends on the file format detected, or None if the file canonot be loaded """ import f311 # Splits attempts using ((binary X text) file) cri...
python
def load_any_file(filename): """ Attempts to load filename by trial-and-error Returns: file: A DataFile descendant, whose specific class depends on the file format detected, or None if the file canonot be loaded """ import f311 # Splits attempts using ((binary X text) file) cri...
[ "def", "load_any_file", "(", "filename", ")", ":", "import", "f311", "# Splits attempts using ((binary X text) file) criterion", "if", "a99", ".", "is_text_file", "(", "filename", ")", ":", "return", "load_with_classes", "(", "filename", ",", "f311", ".", "classes_txt...
Attempts to load filename by trial-and-error Returns: file: A DataFile descendant, whose specific class depends on the file format detected, or None if the file canonot be loaded
[ "Attempts", "to", "load", "filename", "by", "trial", "-", "and", "-", "error" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L74-L88
train
57,130
trevisanj/f311
f311/util.py
load_spectrum
def load_spectrum(filename): """ Attempts to load spectrum as one of the supported types. Returns: a Spectrum, or None """ import f311 f = load_with_classes(filename, f311.classes_sp()) if f: return f.spectrum return None
python
def load_spectrum(filename): """ Attempts to load spectrum as one of the supported types. Returns: a Spectrum, or None """ import f311 f = load_with_classes(filename, f311.classes_sp()) if f: return f.spectrum return None
[ "def", "load_spectrum", "(", "filename", ")", ":", "import", "f311", "f", "=", "load_with_classes", "(", "filename", ",", "f311", ".", "classes_sp", "(", ")", ")", "if", "f", ":", "return", "f", ".", "spectrum", "return", "None" ]
Attempts to load spectrum as one of the supported types. Returns: a Spectrum, or None
[ "Attempts", "to", "load", "spectrum", "as", "one", "of", "the", "supported", "types", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L107-L119
train
57,131
trevisanj/f311
f311/util.py
load_spectrum_fits_messed_x
def load_spectrum_fits_messed_x(filename, sp_ref=None): """Loads FITS file spectrum that does not have the proper headers. Returns a Spectrum""" import f311.filetypes as ft # First tries to load as usual f = load_with_classes(filename, (ft.FileSpectrumFits,)) if f is not None: ret = f.spec...
python
def load_spectrum_fits_messed_x(filename, sp_ref=None): """Loads FITS file spectrum that does not have the proper headers. Returns a Spectrum""" import f311.filetypes as ft # First tries to load as usual f = load_with_classes(filename, (ft.FileSpectrumFits,)) if f is not None: ret = f.spec...
[ "def", "load_spectrum_fits_messed_x", "(", "filename", ",", "sp_ref", "=", "None", ")", ":", "import", "f311", ".", "filetypes", "as", "ft", "# First tries to load as usual", "f", "=", "load_with_classes", "(", "filename", ",", "(", "ft", ".", "FileSpectrumFits", ...
Loads FITS file spectrum that does not have the proper headers. Returns a Spectrum
[ "Loads", "FITS", "file", "spectrum", "that", "does", "not", "have", "the", "proper", "headers", ".", "Returns", "a", "Spectrum" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L122-L152
train
57,132
trevisanj/f311
f311/util.py
get_filetypes_info
def get_filetypes_info(editor_quote="`", flag_leaf=True): """ Reports available data types Args: editor_quote: character to enclose the name of the editor script between. flag_leaf: see tabulate_filetypes_rest() Returns: list: list of FileTypeInfo """ NONE_REPL = "" ...
python
def get_filetypes_info(editor_quote="`", flag_leaf=True): """ Reports available data types Args: editor_quote: character to enclose the name of the editor script between. flag_leaf: see tabulate_filetypes_rest() Returns: list: list of FileTypeInfo """ NONE_REPL = "" ...
[ "def", "get_filetypes_info", "(", "editor_quote", "=", "\"`\"", ",", "flag_leaf", "=", "True", ")", ":", "NONE_REPL", "=", "\"\"", "import", "f311", "data", "=", "[", "]", "# [FileTypeInfo, ...]", "for", "attr", "in", "f311", ".", "classes_file", "(", "flag_...
Reports available data types Args: editor_quote: character to enclose the name of the editor script between. flag_leaf: see tabulate_filetypes_rest() Returns: list: list of FileTypeInfo
[ "Reports", "available", "data", "types" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L160-L191
train
57,133
trevisanj/f311
f311/util.py
tabulate_filetypes_rest
def tabulate_filetypes_rest(attrnames=None, header=None, flag_wrap_description=True, description_width=40, flag_leaf=True): """ Generates a reST multirow table Args: attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS). Defaults to all att...
python
def tabulate_filetypes_rest(attrnames=None, header=None, flag_wrap_description=True, description_width=40, flag_leaf=True): """ Generates a reST multirow table Args: attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS). Defaults to all att...
[ "def", "tabulate_filetypes_rest", "(", "attrnames", "=", "None", ",", "header", "=", "None", ",", "flag_wrap_description", "=", "True", ",", "description_width", "=", "40", ",", "flag_leaf", "=", "True", ")", ":", "infos", "=", "get_filetypes_info", "(", "edit...
Generates a reST multirow table Args: attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS). Defaults to all attributes header: list of strings containing headers. If not passed, uses default names flag_wrap_description: whether to wrap the description text ...
[ "Generates", "a", "reST", "multirow", "table" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L246-L266
train
57,134
tradenity/python-sdk
tradenity/resources/return_settings.py
ReturnSettings.return_action
def return_action(self, return_action): """Sets the return_action of this ReturnSettings. :param return_action: The return_action of this ReturnSettings. :type: str """ allowed_values = ["refund", "storeCredit"] # noqa: E501 if return_action is not None and return_acti...
python
def return_action(self, return_action): """Sets the return_action of this ReturnSettings. :param return_action: The return_action of this ReturnSettings. :type: str """ allowed_values = ["refund", "storeCredit"] # noqa: E501 if return_action is not None and return_acti...
[ "def", "return_action", "(", "self", ",", "return_action", ")", ":", "allowed_values", "=", "[", "\"refund\"", ",", "\"storeCredit\"", "]", "# noqa: E501", "if", "return_action", "is", "not", "None", "and", "return_action", "not", "in", "allowed_values", ":", "r...
Sets the return_action of this ReturnSettings. :param return_action: The return_action of this ReturnSettings. :type: str
[ "Sets", "the", "return_action", "of", "this", "ReturnSettings", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/return_settings.py#L88-L102
train
57,135
blockadeio/analyst_toolbench
blockade/cli/config.py
show_config
def show_config(config): """Show the current configuration.""" print("\nCurrent Configuration:\n") for k, v in sorted(config.config.items()): print("{0:15}: {1}".format(k, v))
python
def show_config(config): """Show the current configuration.""" print("\nCurrent Configuration:\n") for k, v in sorted(config.config.items()): print("{0:15}: {1}".format(k, v))
[ "def", "show_config", "(", "config", ")", ":", "print", "(", "\"\\nCurrent Configuration:\\n\"", ")", "for", "k", ",", "v", "in", "sorted", "(", "config", ".", "config", ".", "items", "(", ")", ")", ":", "print", "(", "\"{0:15}: {1}\"", ".", "format", "(...
Show the current configuration.
[ "Show", "the", "current", "configuration", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/config.py#L10-L14
train
57,136
blockadeio/analyst_toolbench
blockade/cli/config.py
create_cloud_user
def create_cloud_user(cfg, args): """Attempt to create the user on the cloud node.""" url = cfg['api_server'] + "admin/add-user" params = {'user_email': args.user_email, 'user_name': args.user_name, 'user_role': args.user_role, 'email': cfg['email'], 'api_key': cfg['api_key']} ...
python
def create_cloud_user(cfg, args): """Attempt to create the user on the cloud node.""" url = cfg['api_server'] + "admin/add-user" params = {'user_email': args.user_email, 'user_name': args.user_name, 'user_role': args.user_role, 'email': cfg['email'], 'api_key': cfg['api_key']} ...
[ "def", "create_cloud_user", "(", "cfg", ",", "args", ")", ":", "url", "=", "cfg", "[", "'api_server'", "]", "+", "\"admin/add-user\"", "params", "=", "{", "'user_email'", ":", "args", ".", "user_email", ",", "'user_name'", ":", "args", ".", "user_name", ",...
Attempt to create the user on the cloud node.
[ "Attempt", "to", "create", "the", "user", "on", "the", "cloud", "node", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/config.py#L17-L29
train
57,137
chrlie/shorten
shorten/__init__.py
make_store
def make_store(name, min_length=4, **kwargs): """\ Creates a store with a reasonable keygen. .. deprecated:: 2.0.0 Instantiate stores directly e.g. ``shorten.MemoryStore(min_length=4)`` """ if name not in stores: raise ValueError('valid stores are {0}'.format(', '.join(stores))) if n...
python
def make_store(name, min_length=4, **kwargs): """\ Creates a store with a reasonable keygen. .. deprecated:: 2.0.0 Instantiate stores directly e.g. ``shorten.MemoryStore(min_length=4)`` """ if name not in stores: raise ValueError('valid stores are {0}'.format(', '.join(stores))) if n...
[ "def", "make_store", "(", "name", ",", "min_length", "=", "4", ",", "*", "*", "kwargs", ")", ":", "if", "name", "not", "in", "stores", ":", "raise", "ValueError", "(", "'valid stores are {0}'", ".", "format", "(", "', '", ".", "join", "(", "stores", ")...
\ Creates a store with a reasonable keygen. .. deprecated:: 2.0.0 Instantiate stores directly e.g. ``shorten.MemoryStore(min_length=4)``
[ "\\", "Creates", "a", "store", "with", "a", "reasonable", "keygen", "." ]
fb762a199979aefaa28c88fa035e88ea8ce4d639
https://github.com/chrlie/shorten/blob/fb762a199979aefaa28c88fa035e88ea8ce4d639/shorten/__init__.py#L23-L42
train
57,138
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_copy
def do_copy(self, line): ''' Copy packages between repos copy SOURCE DESTINATION Where SOURCE can be either LOCAL-FILE or REPO:PACKAGE-SPEC DESTINATION can be either a REPO: or a directory. ''' words = line.split() source, destination = words d...
python
def do_copy(self, line): ''' Copy packages between repos copy SOURCE DESTINATION Where SOURCE can be either LOCAL-FILE or REPO:PACKAGE-SPEC DESTINATION can be either a REPO: or a directory. ''' words = line.split() source, destination = words d...
[ "def", "do_copy", "(", "self", ",", "line", ")", ":", "words", "=", "line", ".", "split", "(", ")", "source", ",", "destination", "=", "words", "destination_repo", "=", "self", ".", "_get_destination_repo", "(", "destination", ")", "local_file_source", "=", ...
Copy packages between repos copy SOURCE DESTINATION Where SOURCE can be either LOCAL-FILE or REPO:PACKAGE-SPEC DESTINATION can be either a REPO: or a directory.
[ "Copy", "packages", "between", "repos" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L192-L222
train
57,139
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_work_on
def do_work_on(self, repo): ''' Make repo the active one. Commands working on a repo will use it as default for repo parameter. ''' self.abort_on_nonexisting_repo(repo, 'work_on') self.network.active_repo = repo
python
def do_work_on(self, repo): ''' Make repo the active one. Commands working on a repo will use it as default for repo parameter. ''' self.abort_on_nonexisting_repo(repo, 'work_on') self.network.active_repo = repo
[ "def", "do_work_on", "(", "self", ",", "repo", ")", ":", "self", ".", "abort_on_nonexisting_repo", "(", "repo", ",", "'work_on'", ")", "self", ".", "network", ".", "active_repo", "=", "repo" ]
Make repo the active one. Commands working on a repo will use it as default for repo parameter.
[ "Make", "repo", "the", "active", "one", ".", "Commands", "working", "on", "a", "repo", "will", "use", "it", "as", "default", "for", "repo", "parameter", "." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L224-L230
train
57,140
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_status
def do_status(self, line): ''' Show python packaging configuration status ''' # Pyrene version print('{} {}'.format(bold('Pyrene version'), green(get_version()))) # .pip/pip.conf - Pyrene repo name | exists or not pip_conf = os.path.expanduser('~/.pip/pip.conf') ...
python
def do_status(self, line): ''' Show python packaging configuration status ''' # Pyrene version print('{} {}'.format(bold('Pyrene version'), green(get_version()))) # .pip/pip.conf - Pyrene repo name | exists or not pip_conf = os.path.expanduser('~/.pip/pip.conf') ...
[ "def", "do_status", "(", "self", ",", "line", ")", ":", "# Pyrene version", "print", "(", "'{} {}'", ".", "format", "(", "bold", "(", "'Pyrene version'", ")", ",", "green", "(", "get_version", "(", ")", ")", ")", ")", "# .pip/pip.conf - Pyrene repo name | exis...
Show python packaging configuration status
[ "Show", "python", "packaging", "configuration", "status" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L272-L303
train
57,141
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_forget
def do_forget(self, repo): ''' Drop definition of a repo. forget REPO ''' self.abort_on_nonexisting_repo(repo, 'forget') self.network.forget(repo)
python
def do_forget(self, repo): ''' Drop definition of a repo. forget REPO ''' self.abort_on_nonexisting_repo(repo, 'forget') self.network.forget(repo)
[ "def", "do_forget", "(", "self", ",", "repo", ")", ":", "self", ".", "abort_on_nonexisting_repo", "(", "repo", ",", "'forget'", ")", "self", ".", "network", ".", "forget", "(", "repo", ")" ]
Drop definition of a repo. forget REPO
[ "Drop", "definition", "of", "a", "repo", "." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L305-L312
train
57,142
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_set
def do_set(self, line): ''' Set repository attributes on the active repo. set attribute=value # intended use: # directory repos: work_on developer-repo set type=directory set directory=package-directory # http repos: work_on company-pri...
python
def do_set(self, line): ''' Set repository attributes on the active repo. set attribute=value # intended use: # directory repos: work_on developer-repo set type=directory set directory=package-directory # http repos: work_on company-pri...
[ "def", "do_set", "(", "self", ",", "line", ")", ":", "self", ".", "abort_on_invalid_active_repo", "(", "'set'", ")", "repo", "=", "self", ".", "network", ".", "active_repo", "attribute", ",", "eq", ",", "value", "=", "line", ".", "partition", "(", "'='",...
Set repository attributes on the active repo. set attribute=value # intended use: # directory repos: work_on developer-repo set type=directory set directory=package-directory # http repos: work_on company-private-repo set type=http set ...
[ "Set", "repository", "attributes", "on", "the", "active", "repo", "." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L321-L349
train
57,143
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_list
def do_list(self, line): ''' List known repos ''' repo_names = self.network.repo_names print('Known repos:') print(' ' + '\n '.join(repo_names))
python
def do_list(self, line): ''' List known repos ''' repo_names = self.network.repo_names print('Known repos:') print(' ' + '\n '.join(repo_names))
[ "def", "do_list", "(", "self", ",", "line", ")", ":", "repo_names", "=", "self", ".", "network", ".", "repo_names", "print", "(", "'Known repos:'", ")", "print", "(", "' '", "+", "'\\n '", ".", "join", "(", "repo_names", ")", ")" ]
List known repos
[ "List", "known", "repos" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L386-L392
train
57,144
e3krisztian/pyrene
pyrene/shell.py
PyreneCmd.do_show
def do_show(self, repo): ''' List repo attributes ''' self.abort_on_nonexisting_effective_repo(repo, 'show') repo = self.network.get_repo(repo) repo.print_attributes()
python
def do_show(self, repo): ''' List repo attributes ''' self.abort_on_nonexisting_effective_repo(repo, 'show') repo = self.network.get_repo(repo) repo.print_attributes()
[ "def", "do_show", "(", "self", ",", "repo", ")", ":", "self", ".", "abort_on_nonexisting_effective_repo", "(", "repo", ",", "'show'", ")", "repo", "=", "self", ".", "network", ".", "get_repo", "(", "repo", ")", "repo", ".", "print_attributes", "(", ")" ]
List repo attributes
[ "List", "repo", "attributes" ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/shell.py#L394-L401
train
57,145
DS-100/nb-to-gradescope
gs100/converter.py
convert
def convert(filename, num_questions=None, solution=False, pages_per_q=DEFAULT_PAGES_PER_Q, folder='question_pdfs', output='gradescope.pdf', zoom=1): """ Public method that exports nb to PDF and pads all the questions. If num_questions ...
python
def convert(filename, num_questions=None, solution=False, pages_per_q=DEFAULT_PAGES_PER_Q, folder='question_pdfs', output='gradescope.pdf', zoom=1): """ Public method that exports nb to PDF and pads all the questions. If num_questions ...
[ "def", "convert", "(", "filename", ",", "num_questions", "=", "None", ",", "solution", "=", "False", ",", "pages_per_q", "=", "DEFAULT_PAGES_PER_Q", ",", "folder", "=", "'question_pdfs'", ",", "output", "=", "'gradescope.pdf'", ",", "zoom", "=", "1", ")", ":...
Public method that exports nb to PDF and pads all the questions. If num_questions is specified, will also check the final PDF for missing questions. If the output font size is too small/large, increase or decrease the zoom argument until the size looks correct. If solution=True, we'll export solu...
[ "Public", "method", "that", "exports", "nb", "to", "PDF", "and", "pads", "all", "the", "questions", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L36-L87
train
57,146
DS-100/nb-to-gradescope
gs100/converter.py
check_for_wkhtmltohtml
def check_for_wkhtmltohtml(): """ Checks to see if the wkhtmltohtml binary is installed. Raises error if not. """ locator = 'where' if sys.platform == 'win32' else 'which' wkhtmltopdf = (subprocess.Popen([locator, 'wkhtmltopdf'], stdout=subprocess.PIPE) ...
python
def check_for_wkhtmltohtml(): """ Checks to see if the wkhtmltohtml binary is installed. Raises error if not. """ locator = 'where' if sys.platform == 'win32' else 'which' wkhtmltopdf = (subprocess.Popen([locator, 'wkhtmltopdf'], stdout=subprocess.PIPE) ...
[ "def", "check_for_wkhtmltohtml", "(", ")", ":", "locator", "=", "'where'", "if", "sys", ".", "platform", "==", "'win32'", "else", "'which'", "wkhtmltopdf", "=", "(", "subprocess", ".", "Popen", "(", "[", "locator", ",", "'wkhtmltopdf'", "]", ",", "stdout", ...
Checks to see if the wkhtmltohtml binary is installed. Raises error if not.
[ "Checks", "to", "see", "if", "the", "wkhtmltohtml", "binary", "is", "installed", ".", "Raises", "error", "if", "not", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L94-L110
train
57,147
DS-100/nb-to-gradescope
gs100/converter.py
read_nb
def read_nb(filename, solution) -> nbformat.NotebookNode: """ Takes in a filename of a notebook and returns a notebook object containing only the cell outputs to export. """ with open(filename, 'r') as f: nb = nbformat.read(f, as_version=4) email = find_student_email(nb) preamble = ...
python
def read_nb(filename, solution) -> nbformat.NotebookNode: """ Takes in a filename of a notebook and returns a notebook object containing only the cell outputs to export. """ with open(filename, 'r') as f: nb = nbformat.read(f, as_version=4) email = find_student_email(nb) preamble = ...
[ "def", "read_nb", "(", "filename", ",", "solution", ")", "->", "nbformat", ".", "NotebookNode", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "nb", "=", "nbformat", ".", "read", "(", "f", ",", "as_version", "=", "4", ")", "...
Takes in a filename of a notebook and returns a notebook object containing only the cell outputs to export.
[ "Takes", "in", "a", "filename", "of", "a", "notebook", "and", "returns", "a", "notebook", "object", "containing", "only", "the", "cell", "outputs", "to", "export", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L180-L198
train
57,148
DS-100/nb-to-gradescope
gs100/converter.py
nb_to_html_cells
def nb_to_html_cells(nb) -> list: """ Converts notebook to an iterable of BS4 HTML nodes. Images are inline. """ html_exporter = HTMLExporter() html_exporter.template_file = 'basic' (body, resources) = html_exporter.from_notebook_node(nb) return BeautifulSoup(body, 'html.parser').findAll('d...
python
def nb_to_html_cells(nb) -> list: """ Converts notebook to an iterable of BS4 HTML nodes. Images are inline. """ html_exporter = HTMLExporter() html_exporter.template_file = 'basic' (body, resources) = html_exporter.from_notebook_node(nb) return BeautifulSoup(body, 'html.parser').findAll('d...
[ "def", "nb_to_html_cells", "(", "nb", ")", "->", "list", ":", "html_exporter", "=", "HTMLExporter", "(", ")", "html_exporter", ".", "template_file", "=", "'basic'", "(", "body", ",", "resources", ")", "=", "html_exporter", ".", "from_notebook_node", "(", "nb",...
Converts notebook to an iterable of BS4 HTML nodes. Images are inline.
[ "Converts", "notebook", "to", "an", "iterable", "of", "BS4", "HTML", "nodes", ".", "Images", "are", "inline", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L201-L209
train
57,149
DS-100/nb-to-gradescope
gs100/converter.py
nb_to_q_nums
def nb_to_q_nums(nb) -> list: """ Gets question numbers from each cell in the notebook """ def q_num(cell): assert cell.metadata.tags return first(filter(lambda t: 'q' in t, cell.metadata.tags)) return [q_num(cell) for cell in nb['cells']]
python
def nb_to_q_nums(nb) -> list: """ Gets question numbers from each cell in the notebook """ def q_num(cell): assert cell.metadata.tags return first(filter(lambda t: 'q' in t, cell.metadata.tags)) return [q_num(cell) for cell in nb['cells']]
[ "def", "nb_to_q_nums", "(", "nb", ")", "->", "list", ":", "def", "q_num", "(", "cell", ")", ":", "assert", "cell", ".", "metadata", ".", "tags", "return", "first", "(", "filter", "(", "lambda", "t", ":", "'q'", "in", "t", ",", "cell", ".", "metadat...
Gets question numbers from each cell in the notebook
[ "Gets", "question", "numbers", "from", "each", "cell", "in", "the", "notebook" ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L212-L220
train
57,150
DS-100/nb-to-gradescope
gs100/converter.py
pad_pdf_pages
def pad_pdf_pages(pdf_name, pages_per_q) -> None: """ Checks if PDF has the correct number of pages. If it has too many, warns the user. If it has too few, adds blank pages until the right length is reached. """ pdf = PyPDF2.PdfFileReader(pdf_name) output = PyPDF2.PdfFileWriter() num_pag...
python
def pad_pdf_pages(pdf_name, pages_per_q) -> None: """ Checks if PDF has the correct number of pages. If it has too many, warns the user. If it has too few, adds blank pages until the right length is reached. """ pdf = PyPDF2.PdfFileReader(pdf_name) output = PyPDF2.PdfFileWriter() num_pag...
[ "def", "pad_pdf_pages", "(", "pdf_name", ",", "pages_per_q", ")", "->", "None", ":", "pdf", "=", "PyPDF2", ".", "PdfFileReader", "(", "pdf_name", ")", "output", "=", "PyPDF2", ".", "PdfFileWriter", "(", ")", "num_pages", "=", "pdf", ".", "getNumPages", "("...
Checks if PDF has the correct number of pages. If it has too many, warns the user. If it has too few, adds blank pages until the right length is reached.
[ "Checks", "if", "PDF", "has", "the", "correct", "number", "of", "pages", ".", "If", "it", "has", "too", "many", "warns", "the", "user", ".", "If", "it", "has", "too", "few", "adds", "blank", "pages", "until", "the", "right", "length", "is", "reached", ...
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L223-L248
train
57,151
DS-100/nb-to-gradescope
gs100/converter.py
create_question_pdfs
def create_question_pdfs(nb, pages_per_q, folder, zoom) -> list: """ Converts each cells in tbe notebook to a PDF named something like 'q04c.pdf'. Places PDFs in the specified folder and returns the list of created PDF locations. """ html_cells = nb_to_html_cells(nb) q_nums = nb_to_q_nums(nb...
python
def create_question_pdfs(nb, pages_per_q, folder, zoom) -> list: """ Converts each cells in tbe notebook to a PDF named something like 'q04c.pdf'. Places PDFs in the specified folder and returns the list of created PDF locations. """ html_cells = nb_to_html_cells(nb) q_nums = nb_to_q_nums(nb...
[ "def", "create_question_pdfs", "(", "nb", ",", "pages_per_q", ",", "folder", ",", "zoom", ")", "->", "list", ":", "html_cells", "=", "nb_to_html_cells", "(", "nb", ")", "q_nums", "=", "nb_to_q_nums", "(", "nb", ")", "os", ".", "makedirs", "(", "folder", ...
Converts each cells in tbe notebook to a PDF named something like 'q04c.pdf'. Places PDFs in the specified folder and returns the list of created PDF locations.
[ "Converts", "each", "cells", "in", "tbe", "notebook", "to", "a", "PDF", "named", "something", "like", "q04c", ".", "pdf", ".", "Places", "PDFs", "in", "the", "specified", "folder", "and", "returns", "the", "list", "of", "created", "PDF", "locations", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L266-L291
train
57,152
DS-100/nb-to-gradescope
gs100/converter.py
merge_pdfs
def merge_pdfs(pdf_names, output) -> None: """ Merges all pdfs together into a single long PDF. """ merger = PyPDF2.PdfFileMerger() for filename in pdf_names: merger.append(filename) merger.write(output) merger.close()
python
def merge_pdfs(pdf_names, output) -> None: """ Merges all pdfs together into a single long PDF. """ merger = PyPDF2.PdfFileMerger() for filename in pdf_names: merger.append(filename) merger.write(output) merger.close()
[ "def", "merge_pdfs", "(", "pdf_names", ",", "output", ")", "->", "None", ":", "merger", "=", "PyPDF2", ".", "PdfFileMerger", "(", ")", "for", "filename", "in", "pdf_names", ":", "merger", ".", "append", "(", "filename", ")", "merger", ".", "write", "(", ...
Merges all pdfs together into a single long PDF.
[ "Merges", "all", "pdfs", "together", "into", "a", "single", "long", "PDF", "." ]
1a2b37753c4913689557328a796543a767eb3932
https://github.com/DS-100/nb-to-gradescope/blob/1a2b37753c4913689557328a796543a767eb3932/gs100/converter.py#L294-L303
train
57,153
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.connection_count
def connection_count(self): """Number of currently open connections to the database. (Stored in table sqlarray_master.) """ return self.sql("SELECT value FROM %(master)s WHERE name = 'connection_counter'" % vars(self), cache=False, asrecarray=False)[0][0]
python
def connection_count(self): """Number of currently open connections to the database. (Stored in table sqlarray_master.) """ return self.sql("SELECT value FROM %(master)s WHERE name = 'connection_counter'" % vars(self), cache=False, asrecarray=False)[0][0]
[ "def", "connection_count", "(", "self", ")", ":", "return", "self", ".", "sql", "(", "\"SELECT value FROM %(master)s WHERE name = 'connection_counter'\"", "%", "vars", "(", "self", ")", ",", "cache", "=", "False", ",", "asrecarray", "=", "False", ")", "[", "0", ...
Number of currently open connections to the database. (Stored in table sqlarray_master.)
[ "Number", "of", "currently", "open", "connections", "to", "the", "database", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L241-L247
train
57,154
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.sql_select
def sql_select(self,fields,*args,**kwargs): """Execute a simple SQL ``SELECT`` statement and returns values as new numpy rec array. The arguments *fields* and the additional optional arguments are simply concatenated with additional SQL statements according to the template:: ...
python
def sql_select(self,fields,*args,**kwargs): """Execute a simple SQL ``SELECT`` statement and returns values as new numpy rec array. The arguments *fields* and the additional optional arguments are simply concatenated with additional SQL statements according to the template:: ...
[ "def", "sql_select", "(", "self", ",", "fields", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "SQL", "=", "\"SELECT \"", "+", "str", "(", "fields", ")", "+", "\" FROM __self__ \"", "+", "\" \"", ".", "join", "(", "args", ")", "return", "self"...
Execute a simple SQL ``SELECT`` statement and returns values as new numpy rec array. The arguments *fields* and the additional optional arguments are simply concatenated with additional SQL statements according to the template:: SELECT <fields> FROM __self__ [args] The simp...
[ "Execute", "a", "simple", "SQL", "SELECT", "statement", "and", "returns", "values", "as", "new", "numpy", "rec", "array", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L348-L386
train
57,155
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.sql
def sql(self,SQL,parameters=None,asrecarray=True,cache=True): """Execute sql statement. :Arguments: SQL : string Full SQL command; can contain the ``?`` place holder so that values supplied with the ``parameters`` keyword can be interpolated using th...
python
def sql(self,SQL,parameters=None,asrecarray=True,cache=True): """Execute sql statement. :Arguments: SQL : string Full SQL command; can contain the ``?`` place holder so that values supplied with the ``parameters`` keyword can be interpolated using th...
[ "def", "sql", "(", "self", ",", "SQL", ",", "parameters", "=", "None", ",", "asrecarray", "=", "True", ",", "cache", "=", "True", ")", ":", "SQL", "=", "SQL", ".", "replace", "(", "'__self__'", ",", "self", ".", "name", ")", "# Cache the last N (query,...
Execute sql statement. :Arguments: SQL : string Full SQL command; can contain the ``?`` place holder so that values supplied with the ``parameters`` keyword can be interpolated using the ``pysqlite`` interface. parameters : tuple Par...
[ "Execute", "sql", "statement", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L390-L464
train
57,156
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.limits
def limits(self,variable): """Return minimum and maximum of variable across all rows of data.""" (vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars()) return vmin,vmax
python
def limits(self,variable): """Return minimum and maximum of variable across all rows of data.""" (vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars()) return vmin,vmax
[ "def", "limits", "(", "self", ",", "variable", ")", ":", "(", "vmin", ",", "vmax", ")", ",", "=", "self", ".", "SELECT", "(", "'min(%(variable)s), max(%(variable)s)'", "%", "vars", "(", ")", ")", "return", "vmin", ",", "vmax" ]
Return minimum and maximum of variable across all rows of data.
[ "Return", "minimum", "and", "maximum", "of", "variable", "across", "all", "rows", "of", "data", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L466-L469
train
57,157
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray.selection
def selection(self, SQL, parameters=None, **kwargs): """Return a new SQLarray from a SELECT selection. This method is useful to build complicated selections and essentially new tables from existing data. The result of the SQL query is stored as a new table in the database. By de...
python
def selection(self, SQL, parameters=None, **kwargs): """Return a new SQLarray from a SELECT selection. This method is useful to build complicated selections and essentially new tables from existing data. The result of the SQL query is stored as a new table in the database. By de...
[ "def", "selection", "(", "self", ",", "SQL", ",", "parameters", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# TODO: under development", "# - could use VIEW", "force", "=", "kwargs", ".", "pop", "(", "'force'", ",", "False", ")", "# pretty unsafe... I hope...
Return a new SQLarray from a SELECT selection. This method is useful to build complicated selections and essentially new tables from existing data. The result of the SQL query is stored as a new table in the database. By default, a unique name is created but this can be overridden ...
[ "Return", "a", "new", "SQLarray", "from", "a", "SELECT", "selection", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L471-L551
train
57,158
orbeckst/RecSQL
recsql/sqlarray.py
SQLarray._init_sqlite_functions
def _init_sqlite_functions(self): """additional SQL functions to the database""" self.connection.create_function("sqrt", 1,sqlfunctions._sqrt) self.connection.create_function("sqr", 1,sqlfunctions._sqr) self.connection.create_function("periodic", 1,sqlfunctions._periodic) self.c...
python
def _init_sqlite_functions(self): """additional SQL functions to the database""" self.connection.create_function("sqrt", 1,sqlfunctions._sqrt) self.connection.create_function("sqr", 1,sqlfunctions._sqr) self.connection.create_function("periodic", 1,sqlfunctions._periodic) self.c...
[ "def", "_init_sqlite_functions", "(", "self", ")", ":", "self", ".", "connection", ".", "create_function", "(", "\"sqrt\"", ",", "1", ",", "sqlfunctions", ".", "_sqrt", ")", "self", ".", "connection", ".", "create_function", "(", "\"sqr\"", ",", "1", ",", ...
additional SQL functions to the database
[ "additional", "SQL", "functions", "to", "the", "database" ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L553-L574
train
57,159
orbeckst/RecSQL
recsql/sqlarray.py
KRingbuffer._prune
def _prune(self): """Primitive way to keep dict in sync with RB.""" delkeys = [k for k in self.keys() if k not in self.__ringbuffer] for k in delkeys: # necessary because dict is changed during iterations super(KRingbuffer,self).__delitem__(k)
python
def _prune(self): """Primitive way to keep dict in sync with RB.""" delkeys = [k for k in self.keys() if k not in self.__ringbuffer] for k in delkeys: # necessary because dict is changed during iterations super(KRingbuffer,self).__delitem__(k)
[ "def", "_prune", "(", "self", ")", ":", "delkeys", "=", "[", "k", "for", "k", "in", "self", ".", "keys", "(", ")", "if", "k", "not", "in", "self", ".", "__ringbuffer", "]", "for", "k", "in", "delkeys", ":", "# necessary because dict is changed during ite...
Primitive way to keep dict in sync with RB.
[ "Primitive", "way", "to", "keep", "dict", "in", "sync", "with", "RB", "." ]
6acbf821022361719391697c9c2f0822f9f8022a
https://github.com/orbeckst/RecSQL/blob/6acbf821022361719391697c9c2f0822f9f8022a/recsql/sqlarray.py#L692-L696
train
57,160
CodyKochmann/generators
generators/chunk_on.py
chunk_on
def chunk_on(pipeline, new_chunk_signal, output_type=tuple): ''' split the stream into seperate chunks based on a new chunk signal ''' assert iterable(pipeline), 'chunks needs pipeline to be iterable' assert callable(new_chunk_signal), 'chunks needs new_chunk_signal to be callable' assert callable(outpu...
python
def chunk_on(pipeline, new_chunk_signal, output_type=tuple): ''' split the stream into seperate chunks based on a new chunk signal ''' assert iterable(pipeline), 'chunks needs pipeline to be iterable' assert callable(new_chunk_signal), 'chunks needs new_chunk_signal to be callable' assert callable(outpu...
[ "def", "chunk_on", "(", "pipeline", ",", "new_chunk_signal", ",", "output_type", "=", "tuple", ")", ":", "assert", "iterable", "(", "pipeline", ")", ",", "'chunks needs pipeline to be iterable'", "assert", "callable", "(", "new_chunk_signal", ")", ",", "'chunks need...
split the stream into seperate chunks based on a new chunk signal
[ "split", "the", "stream", "into", "seperate", "chunks", "based", "on", "a", "new", "chunk", "signal" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/chunk_on.py#L12-L26
train
57,161
XRDX/pyleap
pyleap/shape/sprite.py
Sprite.center_image
def center_image(self, img): """Sets an image's anchor point to its center""" img.anchor_x = img.width // 2 # int img.anchor_y = img.height // 2
python
def center_image(self, img): """Sets an image's anchor point to its center""" img.anchor_x = img.width // 2 # int img.anchor_y = img.height // 2
[ "def", "center_image", "(", "self", ",", "img", ")", ":", "img", ".", "anchor_x", "=", "img", ".", "width", "//", "2", "# int", "img", ".", "anchor_y", "=", "img", ".", "height", "//", "2" ]
Sets an image's anchor point to its center
[ "Sets", "an", "image", "s", "anchor", "point", "to", "its", "center" ]
234c722cfbe66814254ab0d8f67d16b0b774f4d5
https://github.com/XRDX/pyleap/blob/234c722cfbe66814254ab0d8f67d16b0b774f4d5/pyleap/shape/sprite.py#L84-L87
train
57,162
fantastic001/pyfb
pyfacebook/conversation.py
Conversation.get_persons
def get_persons(self): """ Returns list of strings which represents persons being chated with """ cs = self.data["to"]["data"] res = [] for c in cs: res.append(c["name"]) return res
python
def get_persons(self): """ Returns list of strings which represents persons being chated with """ cs = self.data["to"]["data"] res = [] for c in cs: res.append(c["name"]) return res
[ "def", "get_persons", "(", "self", ")", ":", "cs", "=", "self", ".", "data", "[", "\"to\"", "]", "[", "\"data\"", "]", "res", "=", "[", "]", "for", "c", "in", "cs", ":", "res", ".", "append", "(", "c", "[", "\"name\"", "]", ")", "return", "res"...
Returns list of strings which represents persons being chated with
[ "Returns", "list", "of", "strings", "which", "represents", "persons", "being", "chated", "with" ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/conversation.py#L21-L29
train
57,163
fantastic001/pyfb
pyfacebook/conversation.py
Conversation.get_messages
def get_messages(self): """ Returns list of Message objects which represents messages being transported. """ cs = self.data["comments"]["data"] res = [] for c in cs: res.append(Message(c,self)) return res
python
def get_messages(self): """ Returns list of Message objects which represents messages being transported. """ cs = self.data["comments"]["data"] res = [] for c in cs: res.append(Message(c,self)) return res
[ "def", "get_messages", "(", "self", ")", ":", "cs", "=", "self", ".", "data", "[", "\"comments\"", "]", "[", "\"data\"", "]", "res", "=", "[", "]", "for", "c", "in", "cs", ":", "res", ".", "append", "(", "Message", "(", "c", ",", "self", ")", "...
Returns list of Message objects which represents messages being transported.
[ "Returns", "list", "of", "Message", "objects", "which", "represents", "messages", "being", "transported", "." ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/conversation.py#L31-L39
train
57,164
fantastic001/pyfb
pyfacebook/conversation.py
Conversation.next
def next(self): """ Returns next paging """ c = Conversation(self.data, requests.get(self.data["comments"]["paging"]["next"]).json()) if "error" in c.data["comments"] and c.data["comments"]["error"]["code"] == 613: raise LimitExceededException() return c
python
def next(self): """ Returns next paging """ c = Conversation(self.data, requests.get(self.data["comments"]["paging"]["next"]).json()) if "error" in c.data["comments"] and c.data["comments"]["error"]["code"] == 613: raise LimitExceededException() return c
[ "def", "next", "(", "self", ")", ":", "c", "=", "Conversation", "(", "self", ".", "data", ",", "requests", ".", "get", "(", "self", ".", "data", "[", "\"comments\"", "]", "[", "\"paging\"", "]", "[", "\"next\"", "]", ")", ".", "json", "(", ")", "...
Returns next paging
[ "Returns", "next", "paging" ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/conversation.py#L41-L48
train
57,165
jkitzes/macroeco
macroeco/empirical/_empirical.py
_subset_table
def _subset_table(full_table, subset): """ Return subtable matching all conditions in subset Parameters ---------- full_table : dataframe Entire data table subset : str String describing subset of data to use for analysis Returns ------- dataframe Subtable w...
python
def _subset_table(full_table, subset): """ Return subtable matching all conditions in subset Parameters ---------- full_table : dataframe Entire data table subset : str String describing subset of data to use for analysis Returns ------- dataframe Subtable w...
[ "def", "_subset_table", "(", "full_table", ",", "subset", ")", ":", "if", "not", "subset", ":", "return", "full_table", "# TODO: Figure out syntax for logical or", "conditions", "=", "subset", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "';'...
Return subtable matching all conditions in subset Parameters ---------- full_table : dataframe Entire data table subset : str String describing subset of data to use for analysis Returns ------- dataframe Subtable with records from table meeting requirements in subs...
[ "Return", "subtable", "matching", "all", "conditions", "in", "subset" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L275-L308
train
57,166
jkitzes/macroeco
macroeco/empirical/_empirical.py
_subset_meta
def _subset_meta(full_meta, subset, incremented=False): """ Return metadata reflecting all conditions in subset Parameters ---------- full_meta : ConfigParser obj Metadata object subset : str String describing subset of data to use for analysis incremented : bool If ...
python
def _subset_meta(full_meta, subset, incremented=False): """ Return metadata reflecting all conditions in subset Parameters ---------- full_meta : ConfigParser obj Metadata object subset : str String describing subset of data to use for analysis incremented : bool If ...
[ "def", "_subset_meta", "(", "full_meta", ",", "subset", ",", "incremented", "=", "False", ")", ":", "if", "not", "subset", ":", "return", "full_meta", ",", "False", "meta", "=", "{", "}", "# Make deepcopy of entire meta (all section dicts in meta dict)", "for", "k...
Return metadata reflecting all conditions in subset Parameters ---------- full_meta : ConfigParser obj Metadata object subset : str String describing subset of data to use for analysis incremented : bool If True, the metadata has already been incremented Returns ---...
[ "Return", "metadata", "reflecting", "all", "conditions", "in", "subset" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L310-L373
train
57,167
jkitzes/macroeco
macroeco/empirical/_empirical.py
sad
def sad(patch, cols, splits, clean=True): """ Calculates an empirical species abundance distribution Parameters ---------- {0} clean : bool If True, all species with zero abundance are removed from SAD results. Default False. Returns ------- {1} Result has two colum...
python
def sad(patch, cols, splits, clean=True): """ Calculates an empirical species abundance distribution Parameters ---------- {0} clean : bool If True, all species with zero abundance are removed from SAD results. Default False. Returns ------- {1} Result has two colum...
[ "def", "sad", "(", "patch", ",", "cols", ",", "splits", ",", "clean", "=", "True", ")", ":", "(", "spp_col", ",", "count_col", ")", ",", "patch", "=", "_get_cols", "(", "[", "'spp_col'", ",", "'count_col'", "]", ",", "cols", ",", "patch", ")", "ful...
Calculates an empirical species abundance distribution Parameters ---------- {0} clean : bool If True, all species with zero abundance are removed from SAD results. Default False. Returns ------- {1} Result has two columns: spp (species identifier) and y (individuals of ...
[ "Calculates", "an", "empirical", "species", "abundance", "distribution" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L378-L504
train
57,168
jkitzes/macroeco
macroeco/empirical/_empirical.py
ssad
def ssad(patch, cols, splits): """ Calculates an empirical intra-specific spatial abundance distribution Parameters ---------- {0} Returns ------- {1} Result has one column giving the individuals of species in each subplot. Notes ----- {2} {3} Examples --...
python
def ssad(patch, cols, splits): """ Calculates an empirical intra-specific spatial abundance distribution Parameters ---------- {0} Returns ------- {1} Result has one column giving the individuals of species in each subplot. Notes ----- {2} {3} Examples --...
[ "def", "ssad", "(", "patch", ",", "cols", ",", "splits", ")", ":", "# Get and check SAD", "sad_results", "=", "sad", "(", "patch", ",", "cols", ",", "splits", ",", "clean", "=", "False", ")", "# Create dataframe with col for spp name and numbered col for each split"...
Calculates an empirical intra-specific spatial abundance distribution Parameters ---------- {0} Returns ------- {1} Result has one column giving the individuals of species in each subplot. Notes ----- {2} {3} Examples -------- {4} >>> # Get the spatial ...
[ "Calculates", "an", "empirical", "intra", "-", "specific", "spatial", "abundance", "distribution" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L509-L585
train
57,169
jkitzes/macroeco
macroeco/empirical/_empirical.py
sar
def sar(patch, cols, splits, divs, ear=False): """ Calculates an empirical species area or endemics area relationship Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. See notes. ear : bool If True, calculates an endemics area relationship ...
python
def sar(patch, cols, splits, divs, ear=False): """ Calculates an empirical species area or endemics area relationship Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. See notes. ear : bool If True, calculates an endemics area relationship ...
[ "def", "sar", "(", "patch", ",", "cols", ",", "splits", ",", "divs", ",", "ear", "=", "False", ")", ":", "def", "sar_y_func", "(", "spatial_table", ",", "all_spp", ")", ":", "return", "np", ".", "mean", "(", "spatial_table", "[", "'n_spp'", "]", ")",...
Calculates an empirical species area or endemics area relationship Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. See notes. ear : bool If True, calculates an endemics area relationship Returns ------- {1} Result has 5 columns; div, x...
[ "Calculates", "an", "empirical", "species", "area", "or", "endemics", "area", "relationship" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L591-L673
train
57,170
jkitzes/macroeco
macroeco/empirical/_empirical.py
_sar_ear_inner
def _sar_ear_inner(patch, cols, splits, divs, y_func): """ y_func is function calculating the mean number of species or endemics, respectively, for the SAR or EAR """ (spp_col, count_col, x_col, y_col), patch = \ _get_cols(['spp_col', 'count_col', 'x_col', 'y_col'], cols, patch) # Loop...
python
def _sar_ear_inner(patch, cols, splits, divs, y_func): """ y_func is function calculating the mean number of species or endemics, respectively, for the SAR or EAR """ (spp_col, count_col, x_col, y_col), patch = \ _get_cols(['spp_col', 'count_col', 'x_col', 'y_col'], cols, patch) # Loop...
[ "def", "_sar_ear_inner", "(", "patch", ",", "cols", ",", "splits", ",", "divs", ",", "y_func", ")", ":", "(", "spp_col", ",", "count_col", ",", "x_col", ",", "y_col", ")", ",", "patch", "=", "_get_cols", "(", "[", "'spp_col'", ",", "'count_col'", ",", ...
y_func is function calculating the mean number of species or endemics, respectively, for the SAR or EAR
[ "y_func", "is", "function", "calculating", "the", "mean", "number", "of", "species", "or", "endemics", "respectively", "for", "the", "SAR", "or", "EAR" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L676-L713
train
57,171
jkitzes/macroeco
macroeco/empirical/_empirical.py
comm_grid
def comm_grid(patch, cols, splits, divs, metric='Sorensen'): """ Calculates commonality as a function of distance for a gridded patch Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. ...
python
def comm_grid(patch, cols, splits, divs, metric='Sorensen'): """ Calculates commonality as a function of distance for a gridded patch Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. ...
[ "def", "comm_grid", "(", "patch", ",", "cols", ",", "splits", ",", "divs", ",", "metric", "=", "'Sorensen'", ")", ":", "(", "spp_col", ",", "count_col", ",", "x_col", ",", "y_col", ")", ",", "patch", "=", "_get_cols", "(", "[", "'spp_col'", ",", "'co...
Calculates commonality as a function of distance for a gridded patch Parameters ---------- {0} divs : str Description of how to divide x_col and y_col. Unlike SAR and EAR, only one division can be given at a time. See notes. metric : str One of Sorensen or Jaccard, giving th...
[ "Calculates", "commonality", "as", "a", "function", "of", "distance", "for", "a", "gridded", "patch" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L729-L804
train
57,172
jkitzes/macroeco
macroeco/empirical/_empirical.py
_yield_spatial_table
def _yield_spatial_table(patch, div, spp_col, count_col, x_col, y_col): """ Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality ...
python
def _yield_spatial_table(patch, div, spp_col, count_col, x_col, y_col): """ Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality ...
[ "def", "_yield_spatial_table", "(", "patch", ",", "div", ",", "spp_col", ",", "count_col", ",", "x_col", ",", "y_col", ")", ":", "# Catch error if you don't use ; after divs in comm_grid in MacroecoDesktop", "try", ":", "div_split_list", "=", "div", ".", "replace", "(...
Calculates an empirical spatial table Yields ------- DataFrame Spatial table for each division. See Notes. Notes ----- The spatial table is the precursor to the SAR, EAR, and grid-based commonality metrics. Each row in the table corresponds to a cell created by a given division...
[ "Calculates", "an", "empirical", "spatial", "table" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L807-L860
train
57,173
jkitzes/macroeco
macroeco/empirical/_empirical.py
_get_cols
def _get_cols(special_col_names, cols, patch): """ Retrieve values of special_cols from cols string or patch metadata """ # If cols not given, try to fall back on cols from metadata if not cols: if 'cols' in patch.meta['Description'].keys(): cols = patch.meta['Description']['col...
python
def _get_cols(special_col_names, cols, patch): """ Retrieve values of special_cols from cols string or patch metadata """ # If cols not given, try to fall back on cols from metadata if not cols: if 'cols' in patch.meta['Description'].keys(): cols = patch.meta['Description']['col...
[ "def", "_get_cols", "(", "special_col_names", ",", "cols", ",", "patch", ")", ":", "# If cols not given, try to fall back on cols from metadata", "if", "not", "cols", ":", "if", "'cols'", "in", "patch", ".", "meta", "[", "'Description'", "]", ".", "keys", "(", "...
Retrieve values of special_cols from cols string or patch metadata
[ "Retrieve", "values", "of", "special_cols", "from", "cols", "string", "or", "patch", "metadata" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1146-L1181
train
57,174
jkitzes/macroeco
macroeco/empirical/_empirical.py
_yield_subpatches
def _yield_subpatches(patch, splits, name='split'): """ Iterator for subtables defined by a splits string Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Yields ------ ...
python
def _yield_subpatches(patch, splits, name='split'): """ Iterator for subtables defined by a splits string Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Yields ------ ...
[ "def", "_yield_subpatches", "(", "patch", ",", "splits", ",", "name", "=", "'split'", ")", ":", "if", "splits", ":", "subset_list", "=", "_parse_splits", "(", "patch", ",", "splits", ")", "for", "subset", "in", "subset_list", ":", "logging", ".", "info", ...
Iterator for subtables defined by a splits string Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Yields ------ tuple First element is subset string, second is subt...
[ "Iterator", "for", "subtables", "defined", "by", "a", "splits", "string" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1185-L1218
train
57,175
jkitzes/macroeco
macroeco/empirical/_empirical.py
_parse_splits
def _parse_splits(patch, splits): """ Parse splits string to get list of all associated subset strings. Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Returns ------- ...
python
def _parse_splits(patch, splits): """ Parse splits string to get list of all associated subset strings. Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Returns ------- ...
[ "def", "_parse_splits", "(", "patch", ",", "splits", ")", ":", "split_list", "=", "splits", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "';'", ")", "subset_list", "=", "[", "]", "# List of all subset strings", "for", "split", "in", "sp...
Parse splits string to get list of all associated subset strings. Parameters ---------- patch : obj Patch object containing data to subset splits : str Specifies how a column of a dataset should be split. See Notes. Returns ------- list List of subset strings derive...
[ "Parse", "splits", "string", "to", "get", "list", "of", "all", "associated", "subset", "strings", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1222-L1264
train
57,176
jkitzes/macroeco
macroeco/empirical/_empirical.py
_product
def _product(*args, **kwds): """ Generates cartesian product of lists given as arguments From itertools.product documentation """ pools = map(tuple, args) * kwds.get('repeat', 1) result = [[]] for pool in pools: result = [x+[y] for x in result for y in pool] return result
python
def _product(*args, **kwds): """ Generates cartesian product of lists given as arguments From itertools.product documentation """ pools = map(tuple, args) * kwds.get('repeat', 1) result = [[]] for pool in pools: result = [x+[y] for x in result for y in pool] return result
[ "def", "_product", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "pools", "=", "map", "(", "tuple", ",", "args", ")", "*", "kwds", ".", "get", "(", "'repeat'", ",", "1", ")", "result", "=", "[", "[", "]", "]", "for", "pool", "in", "pools...
Generates cartesian product of lists given as arguments From itertools.product documentation
[ "Generates", "cartesian", "product", "of", "lists", "given", "as", "arguments" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1296-L1307
train
57,177
jkitzes/macroeco
macroeco/empirical/_empirical.py
empirical_cdf
def empirical_cdf(data): """ Generates an empirical cdf from data Parameters ---------- data : iterable Empirical data Returns -------- DataFrame Columns 'data' and 'ecdf'. 'data' contains ordered data and 'ecdf' contains the corresponding ecdf values for the da...
python
def empirical_cdf(data): """ Generates an empirical cdf from data Parameters ---------- data : iterable Empirical data Returns -------- DataFrame Columns 'data' and 'ecdf'. 'data' contains ordered data and 'ecdf' contains the corresponding ecdf values for the da...
[ "def", "empirical_cdf", "(", "data", ")", ":", "vals", "=", "pd", ".", "Series", "(", "data", ")", ".", "value_counts", "(", ")", "ecdf", "=", "pd", ".", "DataFrame", "(", "data", ")", ".", "set_index", "(", "keys", "=", "0", ")", "probs", "=", "...
Generates an empirical cdf from data Parameters ---------- data : iterable Empirical data Returns -------- DataFrame Columns 'data' and 'ecdf'. 'data' contains ordered data and 'ecdf' contains the corresponding ecdf values for the data.
[ "Generates", "an", "empirical", "cdf", "from", "data" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L1341-L1365
train
57,178
jkitzes/macroeco
macroeco/empirical/_empirical.py
Patch._load_table
def _load_table(self, metadata_path, data_path): """ Load data table, taking subset if needed Parameters ---------- metadata_path : str Path to metadata file data_path : str Path to data file, absolute or relative to metadata file Returns...
python
def _load_table(self, metadata_path, data_path): """ Load data table, taking subset if needed Parameters ---------- metadata_path : str Path to metadata file data_path : str Path to data file, absolute or relative to metadata file Returns...
[ "def", "_load_table", "(", "self", ",", "metadata_path", ",", "data_path", ")", ":", "metadata_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "expanduser", "(", "metadata_path", ")", ")", "data_path", "=", "os", ".", "path", ...
Load data table, taking subset if needed Parameters ---------- metadata_path : str Path to metadata file data_path : str Path to data file, absolute or relative to metadata file Returns ------- dataframe Table for analysis
[ "Load", "data", "table", "taking", "subset", "if", "needed" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L177-L211
train
57,179
jkitzes/macroeco
macroeco/empirical/_empirical.py
Patch._get_db_table
def _get_db_table(self, data_path, extension): """ Query a database and return query result as a recarray Parameters ---------- data_path : str Path to the database file extension : str Type of database, either sql or db Returns -...
python
def _get_db_table(self, data_path, extension): """ Query a database and return query result as a recarray Parameters ---------- data_path : str Path to the database file extension : str Type of database, either sql or db Returns -...
[ "def", "_get_db_table", "(", "self", ",", "data_path", ",", "extension", ")", ":", "# TODO: This is probably broken", "raise", "NotImplementedError", ",", "\"SQL and db file formats not yet supported\"", "# Load table", "if", "extension", "==", "'sql'", ":", "con", "=", ...
Query a database and return query result as a recarray Parameters ---------- data_path : str Path to the database file extension : str Type of database, either sql or db Returns ------- table : recarray The database query as a...
[ "Query", "a", "database", "and", "return", "query", "result", "as", "a", "recarray" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L213-L272
train
57,180
jkitzes/macroeco
macroeco/misc/misc.py
doc_sub
def doc_sub(*sub): """ Decorator for performing substitutions in docstrings. Using @doc_sub(some_note, other_note) on a function with {0} and {1} in the docstring will substitute the contents of some_note and other_note for {0} and {1}, respectively. Decorator appears to work properly both wit...
python
def doc_sub(*sub): """ Decorator for performing substitutions in docstrings. Using @doc_sub(some_note, other_note) on a function with {0} and {1} in the docstring will substitute the contents of some_note and other_note for {0} and {1}, respectively. Decorator appears to work properly both wit...
[ "def", "doc_sub", "(", "*", "sub", ")", ":", "def", "dec", "(", "obj", ")", ":", "obj", ".", "__doc__", "=", "obj", ".", "__doc__", ".", "format", "(", "*", "sub", ")", "return", "obj", "return", "dec" ]
Decorator for performing substitutions in docstrings. Using @doc_sub(some_note, other_note) on a function with {0} and {1} in the docstring will substitute the contents of some_note and other_note for {0} and {1}, respectively. Decorator appears to work properly both with IPython help (tab completion ...
[ "Decorator", "for", "performing", "substitutions", "in", "docstrings", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/misc.py#L60-L75
train
57,181
jkitzes/macroeco
macroeco/misc/misc.py
log_start_end
def log_start_end(f): """ Decorator to log start and end of function Use of decorator module here ensures that argspec will inspect wrapped function, not the decorator itself. http://micheles.googlecode.com/hg/decorator/documentation.html """ def inner(f, *args, **kwargs): logging.i...
python
def log_start_end(f): """ Decorator to log start and end of function Use of decorator module here ensures that argspec will inspect wrapped function, not the decorator itself. http://micheles.googlecode.com/hg/decorator/documentation.html """ def inner(f, *args, **kwargs): logging.i...
[ "def", "log_start_end", "(", "f", ")", ":", "def", "inner", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logging", ".", "info", "(", "'Starting %s'", "%", "f", ".", "__name__", ")", "res", "=", "f", "(", "*", "args", ",", "*"...
Decorator to log start and end of function Use of decorator module here ensures that argspec will inspect wrapped function, not the decorator itself. http://micheles.googlecode.com/hg/decorator/documentation.html
[ "Decorator", "to", "log", "start", "and", "end", "of", "function" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/misc.py#L77-L90
train
57,182
jkitzes/macroeco
macroeco/misc/misc.py
check_parameter_file
def check_parameter_file(filename): """ Function does a rudimentary check whether the cols, splits and divs columns in the parameter files are formatted properly. Just provides a preliminary check. Will only catch basic mistakes Parameters ---------- filename : str Path to paramete...
python
def check_parameter_file(filename): """ Function does a rudimentary check whether the cols, splits and divs columns in the parameter files are formatted properly. Just provides a preliminary check. Will only catch basic mistakes Parameters ---------- filename : str Path to paramete...
[ "def", "check_parameter_file", "(", "filename", ")", ":", "# Load file", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "fin", ":", "content", "=", "fin", ".", "read", "(", ")", "# Check cols and splits strings", "bad_names", "=", "[", "]", "line_...
Function does a rudimentary check whether the cols, splits and divs columns in the parameter files are formatted properly. Just provides a preliminary check. Will only catch basic mistakes Parameters ---------- filename : str Path to parameters file Returns ------- : list ...
[ "Function", "does", "a", "rudimentary", "check", "whether", "the", "cols", "splits", "and", "divs", "columns", "in", "the", "parameter", "files", "are", "formatted", "properly", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/misc.py#L93-L147
train
57,183
inveniosoftware-attic/invenio-utils
invenio_utils/htmlwasher.py
EmailWasher.handle_starttag
def handle_starttag(self, tag, attrs): """Function called for new opening tags""" if tag.lower() in self.allowed_tag_whitelist: if tag.lower() == 'ol': # we need a list to store the last # number used in the previous ordered lists self.previou...
python
def handle_starttag(self, tag, attrs): """Function called for new opening tags""" if tag.lower() in self.allowed_tag_whitelist: if tag.lower() == 'ol': # we need a list to store the last # number used in the previous ordered lists self.previou...
[ "def", "handle_starttag", "(", "self", ",", "tag", ",", "attrs", ")", ":", "if", "tag", ".", "lower", "(", ")", "in", "self", ".", "allowed_tag_whitelist", ":", "if", "tag", ".", "lower", "(", ")", "==", "'ol'", ":", "# we need a list to store the last", ...
Function called for new opening tags
[ "Function", "called", "for", "new", "opening", "tags" ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/htmlwasher.py#L37-L72
train
57,184
inveniosoftware-attic/invenio-utils
invenio_utils/htmlwasher.py
EmailWasher.handle_entityref
def handle_entityref(self, name): """Process a general entity reference of the form "&name;". Transform to text whenever possible.""" char_code = html_entities.name2codepoint.get(name, None) if char_code is not None: try: self.result += unichr(char_code).encod...
python
def handle_entityref(self, name): """Process a general entity reference of the form "&name;". Transform to text whenever possible.""" char_code = html_entities.name2codepoint.get(name, None) if char_code is not None: try: self.result += unichr(char_code).encod...
[ "def", "handle_entityref", "(", "self", ",", "name", ")", ":", "char_code", "=", "html_entities", ".", "name2codepoint", ".", "get", "(", "name", ",", "None", ")", "if", "char_code", "is", "not", "None", ":", "try", ":", "self", ".", "result", "+=", "u...
Process a general entity reference of the form "&name;". Transform to text whenever possible.
[ "Process", "a", "general", "entity", "reference", "of", "the", "form", "&name", ";", ".", "Transform", "to", "text", "whenever", "possible", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/htmlwasher.py#L117-L125
train
57,185
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_lattice
def bethe_lattice(energy, hopping): """Bethe lattice in inf dim density of states""" energy = np.asarray(energy).clip(-2*hopping, 2*hopping) return np.sqrt(4*hopping**2 - energy**2) / (2*np.pi*hopping**2)
python
def bethe_lattice(energy, hopping): """Bethe lattice in inf dim density of states""" energy = np.asarray(energy).clip(-2*hopping, 2*hopping) return np.sqrt(4*hopping**2 - energy**2) / (2*np.pi*hopping**2)
[ "def", "bethe_lattice", "(", "energy", ",", "hopping", ")", ":", "energy", "=", "np", ".", "asarray", "(", "energy", ")", ".", "clip", "(", "-", "2", "*", "hopping", ",", "2", "*", "hopping", ")", "return", "np", ".", "sqrt", "(", "4", "*", "hopp...
Bethe lattice in inf dim density of states
[ "Bethe", "lattice", "in", "inf", "dim", "density", "of", "states" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L11-L14
train
57,186
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_fermi
def bethe_fermi(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution""" return fermi_dist(quasipart * energy - shift, beta) \ * bethe_lattice(energy, hopping)
python
def bethe_fermi(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution""" return fermi_dist(quasipart * energy - shift, beta) \ * bethe_lattice(energy, hopping)
[ "def", "bethe_fermi", "(", "energy", ",", "quasipart", ",", "shift", ",", "hopping", ",", "beta", ")", ":", "return", "fermi_dist", "(", "quasipart", "*", "energy", "-", "shift", ",", "beta", ")", "*", "bethe_lattice", "(", "energy", ",", "hopping", ")" ...
product of the bethe lattice dos, fermi distribution
[ "product", "of", "the", "bethe", "lattice", "dos", "fermi", "distribution" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L16-L19
train
57,187
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_fermi_ene
def bethe_fermi_ene(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution an weighted by energy""" return energy * bethe_fermi(energy, quasipart, shift, hopping, beta)
python
def bethe_fermi_ene(energy, quasipart, shift, hopping, beta): """product of the bethe lattice dos, fermi distribution an weighted by energy""" return energy * bethe_fermi(energy, quasipart, shift, hopping, beta)
[ "def", "bethe_fermi_ene", "(", "energy", ",", "quasipart", ",", "shift", ",", "hopping", ",", "beta", ")", ":", "return", "energy", "*", "bethe_fermi", "(", "energy", ",", "quasipart", ",", "shift", ",", "hopping", ",", "beta", ")" ]
product of the bethe lattice dos, fermi distribution an weighted by energy
[ "product", "of", "the", "bethe", "lattice", "dos", "fermi", "distribution", "an", "weighted", "by", "energy" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L21-L24
train
57,188
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_filling_zeroT
def bethe_filling_zeroT(fermi_energy, hopping): """Returns the particle average count given a certan fermi energy, for the semicircular density of states of the bethe lattice""" fermi_energy = np.asarray(fermi_energy).clip(-2*hopping, 2*hopping) return 1/2. + fermi_energy/2 * bethe_lattice(fermi_ener...
python
def bethe_filling_zeroT(fermi_energy, hopping): """Returns the particle average count given a certan fermi energy, for the semicircular density of states of the bethe lattice""" fermi_energy = np.asarray(fermi_energy).clip(-2*hopping, 2*hopping) return 1/2. + fermi_energy/2 * bethe_lattice(fermi_ener...
[ "def", "bethe_filling_zeroT", "(", "fermi_energy", ",", "hopping", ")", ":", "fermi_energy", "=", "np", ".", "asarray", "(", "fermi_energy", ")", ".", "clip", "(", "-", "2", "*", "hopping", ",", "2", "*", "hopping", ")", "return", "1", "/", "2.", "+", ...
Returns the particle average count given a certan fermi energy, for the semicircular density of states of the bethe lattice
[ "Returns", "the", "particle", "average", "count", "given", "a", "certan", "fermi", "energy", "for", "the", "semicircular", "density", "of", "states", "of", "the", "bethe", "lattice" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L27-L32
train
57,189
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_findfill_zeroT
def bethe_findfill_zeroT(particles, orbital_e, hopping): """Return the fermi energy that correspond to the given particle quantity in a semicircular density of states of a bethe lattice in a multi orbital case that can be non-degenerate""" assert 0. <= particles <= len(orbital_e) zero = lamb...
python
def bethe_findfill_zeroT(particles, orbital_e, hopping): """Return the fermi energy that correspond to the given particle quantity in a semicircular density of states of a bethe lattice in a multi orbital case that can be non-degenerate""" assert 0. <= particles <= len(orbital_e) zero = lamb...
[ "def", "bethe_findfill_zeroT", "(", "particles", ",", "orbital_e", ",", "hopping", ")", ":", "assert", "0.", "<=", "particles", "<=", "len", "(", "orbital_e", ")", "zero", "=", "lambda", "e", ":", "np", ".", "sum", "(", "[", "bethe_filling_zeroT", "(", "...
Return the fermi energy that correspond to the given particle quantity in a semicircular density of states of a bethe lattice in a multi orbital case that can be non-degenerate
[ "Return", "the", "fermi", "energy", "that", "correspond", "to", "the", "given", "particle", "quantity", "in", "a", "semicircular", "density", "of", "states", "of", "a", "bethe", "lattice", "in", "a", "multi", "orbital", "case", "that", "can", "be", "non", ...
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L35-L44
train
57,190
Titan-C/slaveparticles
slaveparticles/quantum/dos.py
bethe_find_crystalfield
def bethe_find_crystalfield(populations, hopping): """Return the orbital energies to have the system populates as desired by the given individual populations""" zero = lambda orb: [bethe_filling_zeroT(-em, tz) - pop \ for em, tz, pop in zip(orb, hopping, populations)] return...
python
def bethe_find_crystalfield(populations, hopping): """Return the orbital energies to have the system populates as desired by the given individual populations""" zero = lambda orb: [bethe_filling_zeroT(-em, tz) - pop \ for em, tz, pop in zip(orb, hopping, populations)] return...
[ "def", "bethe_find_crystalfield", "(", "populations", ",", "hopping", ")", ":", "zero", "=", "lambda", "orb", ":", "[", "bethe_filling_zeroT", "(", "-", "em", ",", "tz", ")", "-", "pop", "for", "em", ",", "tz", ",", "pop", "in", "zip", "(", "orb", ",...
Return the orbital energies to have the system populates as desired by the given individual populations
[ "Return", "the", "orbital", "energies", "to", "have", "the", "system", "populates", "as", "desired", "by", "the", "given", "individual", "populations" ]
e4c2f5afb1a7b195517ef2f1b5cc758965036aab
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L46-L53
train
57,191
wuher/devil
devil/perm/management.py
_get_var_from_string
def _get_var_from_string(item): """ Get resource variable. """ modname, varname = _split_mod_var_names(item) if modname: mod = __import__(modname, globals(), locals(), [varname], -1) return getattr(mod, varname) else: return globals()[varname]
python
def _get_var_from_string(item): """ Get resource variable. """ modname, varname = _split_mod_var_names(item) if modname: mod = __import__(modname, globals(), locals(), [varname], -1) return getattr(mod, varname) else: return globals()[varname]
[ "def", "_get_var_from_string", "(", "item", ")", ":", "modname", ",", "varname", "=", "_split_mod_var_names", "(", "item", ")", "if", "modname", ":", "mod", "=", "__import__", "(", "modname", ",", "globals", "(", ")", ",", "locals", "(", ")", ",", "[", ...
Get resource variable.
[ "Get", "resource", "variable", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L28-L35
train
57,192
wuher/devil
devil/perm/management.py
_handle_list
def _handle_list(reclist): """ Return list of resources that have access_controller defined. """ ret = [] for item in reclist: recs = _handle_resource_setting(item) ret += [resource for resource in recs if resource.access_controller] return ret
python
def _handle_list(reclist): """ Return list of resources that have access_controller defined. """ ret = [] for item in reclist: recs = _handle_resource_setting(item) ret += [resource for resource in recs if resource.access_controller] return ret
[ "def", "_handle_list", "(", "reclist", ")", ":", "ret", "=", "[", "]", "for", "item", "in", "reclist", ":", "recs", "=", "_handle_resource_setting", "(", "item", ")", "ret", "+=", "[", "resource", "for", "resource", "in", "recs", "if", "resource", ".", ...
Return list of resources that have access_controller defined.
[ "Return", "list", "of", "resources", "that", "have", "access_controller", "defined", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L76-L82
train
57,193
wuher/devil
devil/perm/management.py
_ensure_content_type
def _ensure_content_type(): """ Add the bulldog content type to the database if it's missing. """ from django.contrib.contenttypes.models import ContentType try: row = ContentType.objects.get(app_label=PERM_APP_NAME) except ContentType.DoesNotExist: row = ContentType(name=PERM_APP_NAME, ...
python
def _ensure_content_type(): """ Add the bulldog content type to the database if it's missing. """ from django.contrib.contenttypes.models import ContentType try: row = ContentType.objects.get(app_label=PERM_APP_NAME) except ContentType.DoesNotExist: row = ContentType(name=PERM_APP_NAME, ...
[ "def", "_ensure_content_type", "(", ")", ":", "from", "django", ".", "contrib", ".", "contenttypes", ".", "models", "import", "ContentType", "try", ":", "row", "=", "ContentType", ".", "objects", ".", "get", "(", "app_label", "=", "PERM_APP_NAME", ")", "exce...
Add the bulldog content type to the database if it's missing.
[ "Add", "the", "bulldog", "content", "type", "to", "the", "database", "if", "it", "s", "missing", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L96-L104
train
57,194
wuher/devil
devil/perm/management.py
_get_permission_description
def _get_permission_description(permission_name): """ Generate a descriptive string based on the permission name. For example: 'resource_Order_get' -> 'Can GET order' todo: add support for the resource name to have underscores """ parts = permission_name.split('_') parts.pop(0) method =...
python
def _get_permission_description(permission_name): """ Generate a descriptive string based on the permission name. For example: 'resource_Order_get' -> 'Can GET order' todo: add support for the resource name to have underscores """ parts = permission_name.split('_') parts.pop(0) method =...
[ "def", "_get_permission_description", "(", "permission_name", ")", ":", "parts", "=", "permission_name", ".", "split", "(", "'_'", ")", "parts", ".", "pop", "(", "0", ")", "method", "=", "parts", ".", "pop", "(", ")", "resource", "=", "(", "'_'", ".", ...
Generate a descriptive string based on the permission name. For example: 'resource_Order_get' -> 'Can GET order' todo: add support for the resource name to have underscores
[ "Generate", "a", "descriptive", "string", "based", "on", "the", "permission", "name", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L107-L119
train
57,195
wuher/devil
devil/perm/management.py
_populate_permissions
def _populate_permissions(resources, content_type_id): """ Add all missing permissions to the database. """ from django.contrib.auth.models import Permission # read the whole auth_permission table into memory db_perms = [perm.codename for perm in Permission.objects.all()] for resource in resources:...
python
def _populate_permissions(resources, content_type_id): """ Add all missing permissions to the database. """ from django.contrib.auth.models import Permission # read the whole auth_permission table into memory db_perms = [perm.codename for perm in Permission.objects.all()] for resource in resources:...
[ "def", "_populate_permissions", "(", "resources", ",", "content_type_id", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "models", "import", "Permission", "# read the whole auth_permission table into memory", "db_perms", "=", "[", "perm", ".", "codename...
Add all missing permissions to the database.
[ "Add", "all", "missing", "permissions", "to", "the", "database", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/perm/management.py#L133-L143
train
57,196
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB.init_default
def init_default(self): """Overriden to take default database and save locally The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using *memory* here) Should not keep default file open either (as it is...
python
def init_default(self): """Overriden to take default database and save locally The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using *memory* here) Should not keep default file open either (as it is...
[ "def", "init_default", "(", "self", ")", ":", "import", "f311", "if", "self", ".", "default_filename", "is", "None", ":", "raise", "RuntimeError", "(", "\"Class '{}' has no default filename\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ")", ...
Overriden to take default database and save locally The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using *memory* here) Should not keep default file open either (as it is in the API directory and shouldn't...
[ "Overriden", "to", "take", "default", "database", "and", "save", "locally" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L54-L70
train
57,197
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB._do_save_as
def _do_save_as(self, filename): """Closes connection, copies DB file, and opens again pointing to new file **Note** if filename equals current filename, does nothing! """ if filename != self.filename: self._ensure_filename() self._close_if_open() shu...
python
def _do_save_as(self, filename): """Closes connection, copies DB file, and opens again pointing to new file **Note** if filename equals current filename, does nothing! """ if filename != self.filename: self._ensure_filename() self._close_if_open() shu...
[ "def", "_do_save_as", "(", "self", ",", "filename", ")", ":", "if", "filename", "!=", "self", ".", "filename", ":", "self", ".", "_ensure_filename", "(", ")", "self", ".", "_close_if_open", "(", ")", "shutil", ".", "copyfile", "(", "self", ".", "filename...
Closes connection, copies DB file, and opens again pointing to new file **Note** if filename equals current filename, does nothing!
[ "Closes", "connection", "copies", "DB", "file", "and", "opens", "again", "pointing", "to", "new", "file" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L77-L86
train
57,198
trevisanj/f311
f311/filetypes/filesqlitedb.py
FileSQLiteDB.ensure_schema
def ensure_schema(self): """Create file and schema if it does not exist yet.""" self._ensure_filename() if not os.path.isfile(self.filename): self.create_schema()
python
def ensure_schema(self): """Create file and schema if it does not exist yet.""" self._ensure_filename() if not os.path.isfile(self.filename): self.create_schema()
[ "def", "ensure_schema", "(", "self", ")", ":", "self", ".", "_ensure_filename", "(", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "self", ".", "filename", ")", ":", "self", ".", "create_schema", "(", ")" ]
Create file and schema if it does not exist yet.
[ "Create", "file", "and", "schema", "if", "it", "does", "not", "exist", "yet", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filesqlitedb.py#L103-L107
train
57,199