repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
Arkq/flake8-requirements
src/flake8_requirements/checker.py
https://github.com/Arkq/flake8-requirements/blob/d7cb84af2429a63635528b531111a5da527bf2d1/src/flake8_requirements/checker.py#L205-L243
def visit_Call(self, node): """Call visitor - used for finding setup() call.""" self.generic_visit(node) # Setup() is a keywords-only function. if node.args: return keywords = set() for k in node.keywords: if k.arg is not None: ke...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "self", ".", "generic_visit", "(", "node", ")", "# Setup() is a keywords-only function.", "if", "node", ".", "args", ":", "return", "keywords", "=", "set", "(", ")", "for", "k", "in", "node", ".", ...
Call visitor - used for finding setup() call.
[ "Call", "visitor", "-", "used", "for", "finding", "setup", "()", "call", "." ]
python
train
worstcase/blockade
blockade/config.py
https://github.com/worstcase/blockade/blob/3dc6ad803f0b0d56586dec9542a6a06aa06cf569/blockade/config.py#L122-L161
def from_dict(values): ''' Instantiate a BlockadeConfig instance based on a given dictionary of configuration values ''' try: containers = values['containers'] parsed_containers = {} for name, container_dict in containers.items(): ...
[ "def", "from_dict", "(", "values", ")", ":", "try", ":", "containers", "=", "values", "[", "'containers'", "]", "parsed_containers", "=", "{", "}", "for", "name", ",", "container_dict", "in", "containers", ".", "items", "(", ")", ":", "try", ":", "# one ...
Instantiate a BlockadeConfig instance based on a given dictionary of configuration values
[ "Instantiate", "a", "BlockadeConfig", "instance", "based", "on", "a", "given", "dictionary", "of", "configuration", "values" ]
python
valid
scanny/python-pptx
pptx/shapes/freeform.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/shapes/freeform.py#L193-L203
def _local_to_shape(self, local_x, local_y): """Translate local coordinates point to shape coordinates. Shape coordinates have the same unit as local coordinates, but are offset such that the origin of the shape coordinate system (0, 0) is located at the top-left corner of the shape bou...
[ "def", "_local_to_shape", "(", "self", ",", "local_x", ",", "local_y", ")", ":", "return", "(", "local_x", "-", "self", ".", "shape_offset_x", ",", "local_y", "-", "self", ".", "shape_offset_y", ")" ]
Translate local coordinates point to shape coordinates. Shape coordinates have the same unit as local coordinates, but are offset such that the origin of the shape coordinate system (0, 0) is located at the top-left corner of the shape bounding box.
[ "Translate", "local", "coordinates", "point", "to", "shape", "coordinates", "." ]
python
train
AltSchool/dynamic-rest
dynamic_rest/fields/fields.py
https://github.com/AltSchool/dynamic-rest/blob/5b0338c3dd8bc638d60c3bb92645857c5b89c920/dynamic_rest/fields/fields.py#L161-L176
def root_serializer(self): """Return the root serializer (serializer for the primary resource).""" if not self.parent: # Don't cache, so that we'd recompute if parent is set. return None node = self seen = set() while True: seen.add(node) ...
[ "def", "root_serializer", "(", "self", ")", ":", "if", "not", "self", ".", "parent", ":", "# Don't cache, so that we'd recompute if parent is set.", "return", "None", "node", "=", "self", "seen", "=", "set", "(", ")", "while", "True", ":", "seen", ".", "add", ...
Return the root serializer (serializer for the primary resource).
[ "Return", "the", "root", "serializer", "(", "serializer", "for", "the", "primary", "resource", ")", "." ]
python
train
mikemaccana/python-docx
docx.py
https://github.com/mikemaccana/python-docx/blob/4c9b46dbebe3d2a9b82dbcd35af36584a36fd9fe/docx.py#L759-L907
def advReplace(document, search, replace, bs=3): """ Replace all occurences of string with a different string, return updated document This is a modified version of python-docx.replace() that takes into account blocks of <bs> elements at a time. The replace element can also be a string or an xm...
[ "def", "advReplace", "(", "document", ",", "search", ",", "replace", ",", "bs", "=", "3", ")", ":", "# Enables debug output", "DEBUG", "=", "False", "newdocument", "=", "document", "# Compile the search regexp", "searchre", "=", "re", ".", "compile", "(", "sea...
Replace all occurences of string with a different string, return updated document This is a modified version of python-docx.replace() that takes into account blocks of <bs> elements at a time. The replace element can also be a string or an xml etree element. What it does: It searches the entir...
[ "Replace", "all", "occurences", "of", "string", "with", "a", "different", "string", "return", "updated", "document" ]
python
train
BlackEarth/bf
bf/styles.py
https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/styles.py#L14-L23
def styleProperties(Class, style): """return a properties dict from a given cssutils style """ properties = Dict() for property in style.getProperties(all=True): stylename = property.name + ':' properties[stylename] = property.value if property.priorit...
[ "def", "styleProperties", "(", "Class", ",", "style", ")", ":", "properties", "=", "Dict", "(", ")", "for", "property", "in", "style", ".", "getProperties", "(", "all", "=", "True", ")", ":", "stylename", "=", "property", ".", "name", "+", "':'", "prop...
return a properties dict from a given cssutils style
[ "return", "a", "properties", "dict", "from", "a", "given", "cssutils", "style" ]
python
train
cos-archives/modular-odm
modularodm/cache.py
https://github.com/cos-archives/modular-odm/blob/8a34891892b8af69b21fdc46701c91763a5c1cf9/modularodm/cache.py#L3-L21
def set_nested(data, value, *keys): """Assign to a nested dictionary. :param dict data: Dictionary to mutate :param value: Value to set :param list *keys: List of nested keys >>> data = {} >>> set_nested(data, 'hi', 'k0', 'k1', 'k2') >>> data {'k0': {'k1': {'k2': 'hi'}}} """ i...
[ "def", "set_nested", "(", "data", ",", "value", ",", "*", "keys", ")", ":", "if", "len", "(", "keys", ")", "==", "1", ":", "data", "[", "keys", "[", "0", "]", "]", "=", "value", "else", ":", "if", "keys", "[", "0", "]", "not", "in", "data", ...
Assign to a nested dictionary. :param dict data: Dictionary to mutate :param value: Value to set :param list *keys: List of nested keys >>> data = {} >>> set_nested(data, 'hi', 'k0', 'k1', 'k2') >>> data {'k0': {'k1': {'k2': 'hi'}}}
[ "Assign", "to", "a", "nested", "dictionary", "." ]
python
valid
kragniz/python-etcd3
etcd3/client.py
https://github.com/kragniz/python-etcd3/blob/0adb14840d4a6011a2023a13f07e247e4c336a80/etcd3/client.py#L531-L553
def status(self): """Get the status of the responding member.""" status_request = etcdrpc.StatusRequest() status_response = self.maintenancestub.Status( status_request, self.timeout, credentials=self.call_credentials, metadata=self.metadata ...
[ "def", "status", "(", "self", ")", ":", "status_request", "=", "etcdrpc", ".", "StatusRequest", "(", ")", "status_response", "=", "self", ".", "maintenancestub", ".", "Status", "(", "status_request", ",", "self", ".", "timeout", ",", "credentials", "=", "sel...
Get the status of the responding member.
[ "Get", "the", "status", "of", "the", "responding", "member", "." ]
python
train
RiotGames/cloud-inquisitor
backend/cloud_inquisitor/plugins/views/roles.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/plugins/views/roles.py#L40-L54
def post(self): """Create a new role""" self.reqparse.add_argument('name', type=str, required=True) self.reqparse.add_argument('color', type=str, required=True) args = self.reqparse.parse_args() role = Role() role.name = args['name'] role.color = args['color'] ...
[ "def", "post", "(", "self", ")", ":", "self", ".", "reqparse", ".", "add_argument", "(", "'name'", ",", "type", "=", "str", ",", "required", "=", "True", ")", "self", ".", "reqparse", ".", "add_argument", "(", "'color'", ",", "type", "=", "str", ",",...
Create a new role
[ "Create", "a", "new", "role" ]
python
train
saltstack/salt
salt/modules/lxd.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3607-L3643
def _set_property_dict_item(obj, prop, key, value): ''' Sets the dict item key of the attr from obj. Basicaly it does getattr(obj, prop)[key] = value. For the disk device we added some checks to make device changes on the CLI saver. ''' attr = getattr(obj, prop) if prop == 'de...
[ "def", "_set_property_dict_item", "(", "obj", ",", "prop", ",", "key", ",", "value", ")", ":", "attr", "=", "getattr", "(", "obj", ",", "prop", ")", "if", "prop", "==", "'devices'", ":", "device_type", "=", "value", "[", "'type'", "]", "if", "device_ty...
Sets the dict item key of the attr from obj. Basicaly it does getattr(obj, prop)[key] = value. For the disk device we added some checks to make device changes on the CLI saver.
[ "Sets", "the", "dict", "item", "key", "of", "the", "attr", "from", "obj", "." ]
python
train
google/openhtf
openhtf/util/conf.py
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L544-L616
def inject_positional_args(self, method): """Decorator for injecting positional arguments from the configuration. This decorator wraps the given method, so that any positional arguments are passed with corresponding values from the configuration. The name of the positional argument must match the conf...
[ "def", "inject_positional_args", "(", "self", ",", "method", ")", ":", "inspect", "=", "self", ".", "_modules", "[", "'inspect'", "]", "argspec", "=", "inspect", ".", "getargspec", "(", "method", ")", "# Index in argspec.args of the first keyword argument. This index...
Decorator for injecting positional arguments from the configuration. This decorator wraps the given method, so that any positional arguments are passed with corresponding values from the configuration. The name of the positional argument must match the configuration key. Keyword arguments are *NEVER*...
[ "Decorator", "for", "injecting", "positional", "arguments", "from", "the", "configuration", "." ]
python
train
mardix/Mocha
mocha/decorators.py
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/decorators.py#L42-L78
def cors(*args, **kwargs): """ A wrapper around flask-cors cross_origin, to also act on classes **An extra note about cors, a response must be available before the cors is applied. Dynamic return is applied after the fact, so use the decorators, json, xml, or return self.render() for txt/html i...
[ "def", "cors", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "fn", ")", ":", "cors_fn", "=", "flask_cors", ".", "cross_origin", "(", "automatic_options", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ...
A wrapper around flask-cors cross_origin, to also act on classes **An extra note about cors, a response must be available before the cors is applied. Dynamic return is applied after the fact, so use the decorators, json, xml, or return self.render() for txt/html ie: @cors() class Index(Mocha): ...
[ "A", "wrapper", "around", "flask", "-", "cors", "cross_origin", "to", "also", "act", "on", "classes" ]
python
train
graphql-python/graphql-core-next
graphql/type/validate.py
https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/type/validate.py#L40-L68
def validate_schema(schema: GraphQLSchema) -> List[GraphQLError]: """Validate a GraphQL schema. Implements the "Type Validation" sub-sections of the specification's "Type System" section. Validation runs synchronously, returning a list of encountered errors, or an empty list if no errors were enco...
[ "def", "validate_schema", "(", "schema", ":", "GraphQLSchema", ")", "->", "List", "[", "GraphQLError", "]", ":", "# First check to ensure the provided value is in fact a GraphQLSchema.", "assert_schema", "(", "schema", ")", "# If this Schema has already been validated, return the...
Validate a GraphQL schema. Implements the "Type Validation" sub-sections of the specification's "Type System" section. Validation runs synchronously, returning a list of encountered errors, or an empty list if no errors were encountered and the Schema is valid.
[ "Validate", "a", "GraphQL", "schema", "." ]
python
train
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/spv.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L542-L590
def get_target(cls, path, index, chain=None): """ Calculate the target difficulty at a particular difficulty interval (index). Return (bits, target) on success """ if chain is None: chain = [] # Do not use mutables as default values! max_target = 0x00000000F...
[ "def", "get_target", "(", "cls", ",", "path", ",", "index", ",", "chain", "=", "None", ")", ":", "if", "chain", "is", "None", ":", "chain", "=", "[", "]", "# Do not use mutables as default values!", "max_target", "=", "0x00000000FFFF0000000000000000000000000000000...
Calculate the target difficulty at a particular difficulty interval (index). Return (bits, target) on success
[ "Calculate", "the", "target", "difficulty", "at", "a", "particular", "difficulty", "interval", "(", "index", ")", ".", "Return", "(", "bits", "target", ")", "on", "success" ]
python
train
googleads/googleads-python-lib
googleads/common.py
https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/common.py#L1218-L1240
def _PackArguments(self, method_name, args, set_type_attrs=False): """Properly pack input dictionaries for zeep. Pack a list of python dictionaries into XML objects. Dictionaries which contain an 'xsi_type' entry are converted into that type instead of the argument default. This allows creation of comp...
[ "def", "_PackArguments", "(", "self", ",", "method_name", ",", "args", ",", "set_type_attrs", "=", "False", ")", ":", "# Get the params for the method to find the initial types to instantiate.", "op_params", "=", "self", ".", "zeep_client", ".", "get_element", "(", "'{%...
Properly pack input dictionaries for zeep. Pack a list of python dictionaries into XML objects. Dictionaries which contain an 'xsi_type' entry are converted into that type instead of the argument default. This allows creation of complex objects which include inherited types. Args: method_nam...
[ "Properly", "pack", "input", "dictionaries", "for", "zeep", "." ]
python
train
saltstack/salt
salt/cli/daemons.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/daemons.py#L534-L568
def prepare(self): ''' Run the preparation sequence required to start a salt syndic minion. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).prepare() ''' super(Syndic, self).prepare() try: if self.config['verify_env']: ...
[ "def", "prepare", "(", "self", ")", ":", "super", "(", "Syndic", ",", "self", ")", ".", "prepare", "(", ")", "try", ":", "if", "self", ".", "config", "[", "'verify_env'", "]", ":", "verify_env", "(", "[", "self", ".", "config", "[", "'pki_dir'", "]...
Run the preparation sequence required to start a salt syndic minion. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).prepare()
[ "Run", "the", "preparation", "sequence", "required", "to", "start", "a", "salt", "syndic", "minion", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/install.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/install.py#L128-L134
def _set_pip_ssl(anaconda_dir): """Set PIP SSL certificate to installed conda certificate to avoid SSL errors """ if anaconda_dir: cert_file = os.path.join(anaconda_dir, "ssl", "cert.pem") if os.path.exists(cert_file): os.environ["PIP_CERT"] = cert_file
[ "def", "_set_pip_ssl", "(", "anaconda_dir", ")", ":", "if", "anaconda_dir", ":", "cert_file", "=", "os", ".", "path", ".", "join", "(", "anaconda_dir", ",", "\"ssl\"", ",", "\"cert.pem\"", ")", "if", "os", ".", "path", ".", "exists", "(", "cert_file", ")...
Set PIP SSL certificate to installed conda certificate to avoid SSL errors
[ "Set", "PIP", "SSL", "certificate", "to", "installed", "conda", "certificate", "to", "avoid", "SSL", "errors" ]
python
train
linkhub-sdk/popbill.py
popbill/statementService.py
https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/statementService.py#L204-L235
def issue(self, CorpNum, ItemCode, MgtKey, Memo=None, EmailSubject=None, UserID=None): """ 발행 args CorpNum : 팝빌회원 사업자번호 ItemCode : 명세서 종류 코드 [121 - 거래명세서], [122 - 청구서], [123 - 견적서], [124 - 발주서], [125 - 입금표], [126 - 영수증] ...
[ "def", "issue", "(", "self", ",", "CorpNum", ",", "ItemCode", ",", "MgtKey", ",", "Memo", "=", "None", ",", "EmailSubject", "=", "None", ",", "UserID", "=", "None", ")", ":", "if", "MgtKey", "==", "None", "or", "MgtKey", "==", "\"\"", ":", "raise", ...
발행 args CorpNum : 팝빌회원 사업자번호 ItemCode : 명세서 종류 코드 [121 - 거래명세서], [122 - 청구서], [123 - 견적서], [124 - 발주서], [125 - 입금표], [126 - 영수증] MgtKey : 파트너 문서관리번호 Memo : 처리메모 EmailSubject : 발행메일...
[ "발행", "args", "CorpNum", ":", "팝빌회원", "사업자번호", "ItemCode", ":", "명세서", "종류", "코드", "[", "121", "-", "거래명세서", "]", "[", "122", "-", "청구서", "]", "[", "123", "-", "견적서", "]", "[", "124", "-", "발주서", "]", "[", "125", "-", "입금표", "]", "[", "126", ...
python
train
atlassian-api/atlassian-python-api
atlassian/jira.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L671-L678
def delete_issue_remote_link_by_id(self, issue_key, link_id): """ Deletes Remote Link on Issue :param issue_key: str :param link_id: str """ url = 'rest/api/2/issue/{issue_key}/remotelink/{link_id}'.format(issue_key=issue_key, link_id=link_id) return self.delete(u...
[ "def", "delete_issue_remote_link_by_id", "(", "self", ",", "issue_key", ",", "link_id", ")", ":", "url", "=", "'rest/api/2/issue/{issue_key}/remotelink/{link_id}'", ".", "format", "(", "issue_key", "=", "issue_key", ",", "link_id", "=", "link_id", ")", "return", "se...
Deletes Remote Link on Issue :param issue_key: str :param link_id: str
[ "Deletes", "Remote", "Link", "on", "Issue", ":", "param", "issue_key", ":", "str", ":", "param", "link_id", ":", "str" ]
python
train
quintusdias/glymur
glymur/jp2box.py
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2box.py#L1255-L1277
def _validate(self, writing=False): """ Validate the box before writing to file. """ if self.brand not in ['jp2 ', 'jpx ']: msg = ("The file type brand was '{brand}'. " "It should be either 'jp2 ' or 'jpx '.") msg = msg.format(brand=self.brand)...
[ "def", "_validate", "(", "self", ",", "writing", "=", "False", ")", ":", "if", "self", ".", "brand", "not", "in", "[", "'jp2 '", ",", "'jpx '", "]", ":", "msg", "=", "(", "\"The file type brand was '{brand}'. \"", "\"It should be either 'jp2 ' or 'jpx '.\"", ")...
Validate the box before writing to file.
[ "Validate", "the", "box", "before", "writing", "to", "file", "." ]
python
train
Hackerfleet/hfos
hfos/ui/clientmanager.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L223-L245
def who(self, *args): """Display a table of connected users and clients""" if len(self._users) == 0: self.log('No users connected') if len(self._clients) == 0: self.log('No clients connected') return Row = namedtuple("Row", ['User', 'Clien...
[ "def", "who", "(", "self", ",", "*", "args", ")", ":", "if", "len", "(", "self", ".", "_users", ")", "==", "0", ":", "self", ".", "log", "(", "'No users connected'", ")", "if", "len", "(", "self", ".", "_clients", ")", "==", "0", ":", "self", "...
Display a table of connected users and clients
[ "Display", "a", "table", "of", "connected", "users", "and", "clients" ]
python
train
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L252-L261
def set_default_region(self, region): """ This sets the default region for detecting license plates. For example, setting region to "md" for Maryland or "fr" for France. :param region: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ ...
[ "def", "set_default_region", "(", "self", ",", "region", ")", ":", "region", "=", "_convert_to_charp", "(", "region", ")", "self", ".", "_set_default_region_func", "(", "self", ".", "alpr_pointer", ",", "region", ")" ]
This sets the default region for detecting license plates. For example, setting region to "md" for Maryland or "fr" for France. :param region: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None
[ "This", "sets", "the", "default", "region", "for", "detecting", "license", "plates", ".", "For", "example", "setting", "region", "to", "md", "for", "Maryland", "or", "fr", "for", "France", "." ]
python
train
zqfang/GSEApy
gseapy/algorithm.py
https://github.com/zqfang/GSEApy/blob/673e9ec1391e3b14d3e8a4353117151fd2cb9345/gseapy/algorithm.py#L191-L253
def ranking_metric_tensor(exprs, method, permutation_num, pos, neg, classes, ascending, rs=np.random.RandomState()): """Build shuffled ranking matrix when permutation_type eq to phenotype. :param exprs: gene_expression DataFrame, gene_name indexed. :param str method: calc...
[ "def", "ranking_metric_tensor", "(", "exprs", ",", "method", ",", "permutation_num", ",", "pos", ",", "neg", ",", "classes", ",", "ascending", ",", "rs", "=", "np", ".", "random", ".", "RandomState", "(", ")", ")", ":", "# S: samples, G: gene number", "G", ...
Build shuffled ranking matrix when permutation_type eq to phenotype. :param exprs: gene_expression DataFrame, gene_name indexed. :param str method: calculate correlation or ranking. methods including: 1. 'signal_to_noise'. 2. 't_test'. ...
[ "Build", "shuffled", "ranking", "matrix", "when", "permutation_type", "eq", "to", "phenotype", "." ]
python
test
Contraz/demosys-py
demosys/scene/scene.py
https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/scene/scene.py#L76-L95
def draw_bbox(self, projection_matrix=None, camera_matrix=None, all=True): """Draw scene and mesh bounding boxes""" projection_matrix = projection_matrix.astype('f4').tobytes() camera_matrix = camera_matrix.astype('f4').tobytes() # Scene bounding box self.bbox_program["m_proj"]....
[ "def", "draw_bbox", "(", "self", ",", "projection_matrix", "=", "None", ",", "camera_matrix", "=", "None", ",", "all", "=", "True", ")", ":", "projection_matrix", "=", "projection_matrix", ".", "astype", "(", "'f4'", ")", ".", "tobytes", "(", ")", "camera_...
Draw scene and mesh bounding boxes
[ "Draw", "scene", "and", "mesh", "bounding", "boxes" ]
python
valid
django-salesforce/django-salesforce
salesforce/dbapi/subselect.py
https://github.com/django-salesforce/django-salesforce/blob/6fd5643dba69d49c5881de50875cf90204a8f808/salesforce/dbapi/subselect.py#L194-L214
def mark_quoted_strings(sql): """Mark all quoted strings in the SOQL by '@' and get them as params, with respect to all escaped backslashes and quotes. """ # pattern of a string parameter (pm), a char escaped by backslash (bs) # out_pattern: characters valid in SOQL pm_pattern = re.compile(r"'[^...
[ "def", "mark_quoted_strings", "(", "sql", ")", ":", "# pattern of a string parameter (pm), a char escaped by backslash (bs)", "# out_pattern: characters valid in SOQL", "pm_pattern", "=", "re", ".", "compile", "(", "r\"'[^\\\\']*(?:\\\\[\\\\'][^\\\\']*)*'\"", ")", "bs_pattern", "="...
Mark all quoted strings in the SOQL by '@' and get them as params, with respect to all escaped backslashes and quotes.
[ "Mark", "all", "quoted", "strings", "in", "the", "SOQL", "by" ]
python
train
tmontaigu/pylas
pylas/point/dims.py
https://github.com/tmontaigu/pylas/blob/8335a1a7d7677f0e4bc391bb6fa3c75b42ed5b06/pylas/point/dims.py#L271-L278
def min_file_version_for_point_format(point_format_id): """ Returns the minimum file version that supports the given point_format_id """ for version, point_formats in sorted(VERSION_TO_POINT_FMT.items()): if point_format_id in point_formats: return version else: raise errors...
[ "def", "min_file_version_for_point_format", "(", "point_format_id", ")", ":", "for", "version", ",", "point_formats", "in", "sorted", "(", "VERSION_TO_POINT_FMT", ".", "items", "(", ")", ")", ":", "if", "point_format_id", "in", "point_formats", ":", "return", "ver...
Returns the minimum file version that supports the given point_format_id
[ "Returns", "the", "minimum", "file", "version", "that", "supports", "the", "given", "point_format_id" ]
python
test
apache/incubator-superset
superset/utils/dict_import_export.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/dict_import_export.py#L66-L82
def import_from_dict(session, data, sync=[]): """Imports databases and druid clusters from dictionary""" if isinstance(data, dict): logging.info('Importing %d %s', len(data.get(DATABASES_KEY, [])), DATABASES_KEY) for database in data.get(DATABASES_KEY, [...
[ "def", "import_from_dict", "(", "session", ",", "data", ",", "sync", "=", "[", "]", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "logging", ".", "info", "(", "'Importing %d %s'", ",", "len", "(", "data", ".", "get", "(", "DATABAS...
Imports databases and druid clusters from dictionary
[ "Imports", "databases", "and", "druid", "clusters", "from", "dictionary" ]
python
train
softlayer/softlayer-python
SoftLayer/managers/object_storage.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/object_storage.py#L66-L78
def delete_credential(self, identifier, credential_id=None): """Delete the object storage credential. :param int id: The object storage account identifier. :param int credential_id: The credential id to be deleted. """ credential = { 'id': credential_id } ...
[ "def", "delete_credential", "(", "self", ",", "identifier", ",", "credential_id", "=", "None", ")", ":", "credential", "=", "{", "'id'", ":", "credential_id", "}", "return", "self", ".", "client", ".", "call", "(", "'SoftLayer_Network_Storage_Hub_Cleversafe_Accoun...
Delete the object storage credential. :param int id: The object storage account identifier. :param int credential_id: The credential id to be deleted.
[ "Delete", "the", "object", "storage", "credential", "." ]
python
train
razorpay/razorpay-python
razorpay/resources/payment.py
https://github.com/razorpay/razorpay-python/blob/5bc63fd8452165a4b54556888492e555222c8afe/razorpay/resources/payment.py#L37-L50
def capture(self, payment_id, amount, data={}, **kwargs): """" Capture Payment for given Id Args: payment_id : Id for which payment object has to be retrieved Amount : Amount for which the payment has to be retrieved Returns: Payment dict after getti...
[ "def", "capture", "(", "self", ",", "payment_id", ",", "amount", ",", "data", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "url", "=", "\"{}/{}/capture\"", ".", "format", "(", "self", ".", "base_url", ",", "payment_id", ")", "data", "[", "'amoun...
Capture Payment for given Id Args: payment_id : Id for which payment object has to be retrieved Amount : Amount for which the payment has to be retrieved Returns: Payment dict after getting captured
[ "Capture", "Payment", "for", "given", "Id" ]
python
train
CyberZHG/keras-word-char-embd
keras_wc_embd/word_char_embd.py
https://github.com/CyberZHG/keras-word-char-embd/blob/cca6ddff01b6264dd0d12613bb9ed308e1367b8c/keras_wc_embd/word_char_embd.py#L201-L251
def get_dicts_generator(word_min_freq=4, char_min_freq=2, word_ignore_case=False, char_ignore_case=False): """Get word and character dictionaries from sentences. :param word_min_freq: The minimum frequency of a word. :param char_min_fr...
[ "def", "get_dicts_generator", "(", "word_min_freq", "=", "4", ",", "char_min_freq", "=", "2", ",", "word_ignore_case", "=", "False", ",", "char_ignore_case", "=", "False", ")", ":", "word_count", ",", "char_count", "=", "{", "}", ",", "{", "}", "def", "get...
Get word and character dictionaries from sentences. :param word_min_freq: The minimum frequency of a word. :param char_min_freq: The minimum frequency of a character. :param word_ignore_case: Word will be transformed to lower case before saving to dictionary. :param char_ignore_case: Character will be ...
[ "Get", "word", "and", "character", "dictionaries", "from", "sentences", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/history.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/history.py#L257-L280
def search(self, pattern="*", raw=True, search_raw=True, output=False): """Search the database using unix glob-style matching (wildcards * and ?). Parameters ---------- pattern : str The wildcarded pattern to matc...
[ "def", "search", "(", "self", ",", "pattern", "=", "\"*\"", ",", "raw", "=", "True", ",", "search_raw", "=", "True", ",", "output", "=", "False", ")", ":", "tosearch", "=", "\"source_raw\"", "if", "search_raw", "else", "\"source\"", "if", "output", ":", ...
Search the database using unix glob-style matching (wildcards * and ?). Parameters ---------- pattern : str The wildcarded pattern to match when searching search_raw : bool If True, search the raw input, otherwise, the parsed input raw, output : bool ...
[ "Search", "the", "database", "using", "unix", "glob", "-", "style", "matching", "(", "wildcards", "*", "and", "?", ")", "." ]
python
test
CityOfZion/neo-python
neo/Network/NodeLeader.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Network/NodeLeader.py#L243-L293
def Start(self, seed_list: List[str] = None, skip_seeds: bool = False) -> None: """ Start connecting to the seed list. Args: seed_list: a list of host:port strings if not supplied use list from `protocol.xxx.json` skip_seeds: skip connecting to seed list """ ...
[ "def", "Start", "(", "self", ",", "seed_list", ":", "List", "[", "str", "]", "=", "None", ",", "skip_seeds", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "not", "seed_list", ":", "seed_list", "=", "settings", ".", "SEED_LIST", "logger", "...
Start connecting to the seed list. Args: seed_list: a list of host:port strings if not supplied use list from `protocol.xxx.json` skip_seeds: skip connecting to seed list
[ "Start", "connecting", "to", "the", "seed", "list", "." ]
python
train
stevelittlefish/littlefish
littlefish/lfsmailer.py
https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/lfsmailer.py#L69-L85
def parse_address(formatted_address): """ :param formatted_address: A string like "email@address.com" or "My Email <email@address.com>" :return: Tuple: (address, name) """ if email_regex.match(formatted_address): # Just a raw address return (formatted_address, None) mat...
[ "def", "parse_address", "(", "formatted_address", ")", ":", "if", "email_regex", ".", "match", "(", "formatted_address", ")", ":", "# Just a raw address", "return", "(", "formatted_address", ",", "None", ")", "match", "=", "formatted_address_regex", ".", "match", ...
:param formatted_address: A string like "email@address.com" or "My Email <email@address.com>" :return: Tuple: (address, name)
[ ":", "param", "formatted_address", ":", "A", "string", "like", "email" ]
python
test
benley/butcher
butcher/buildfile.py
https://github.com/benley/butcher/blob/8b18828ea040af56b7835beab5fd03eab23cc9ee/butcher/buildfile.py#L116-L119
def crossref_paths(self): """Just like crossrefs, but all the targets are munged to :all.""" return set( [address.new(repo=x.repo, path=x.path) for x in self.crossrefs])
[ "def", "crossref_paths", "(", "self", ")", ":", "return", "set", "(", "[", "address", ".", "new", "(", "repo", "=", "x", ".", "repo", ",", "path", "=", "x", ".", "path", ")", "for", "x", "in", "self", ".", "crossrefs", "]", ")" ]
Just like crossrefs, but all the targets are munged to :all.
[ "Just", "like", "crossrefs", "but", "all", "the", "targets", "are", "munged", "to", ":", "all", "." ]
python
train
aaugustin/websockets
src/websockets/server.py
https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/server.py#L436-L469
def select_subprotocol( self, client_subprotocols: Sequence[Subprotocol], server_subprotocols: Sequence[Subprotocol], ) -> Optional[Subprotocol]: """ Pick a subprotocol among those offered by the client. If several subprotocols are supported by the client and the ser...
[ "def", "select_subprotocol", "(", "self", ",", "client_subprotocols", ":", "Sequence", "[", "Subprotocol", "]", ",", "server_subprotocols", ":", "Sequence", "[", "Subprotocol", "]", ",", ")", "->", "Optional", "[", "Subprotocol", "]", ":", "if", "self", ".", ...
Pick a subprotocol among those offered by the client. If several subprotocols are supported by the client and the server, the default implementation selects the preferred subprotocols by giving equal value to the priorities of the client and the server. If no subprotocols are supported...
[ "Pick", "a", "subprotocol", "among", "those", "offered", "by", "the", "client", "." ]
python
train
pauleveritt/kaybee
kaybee/plugins/articles/handlers.py
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/articles/handlers.py#L114-L140
def stamp_excerpt(kb_app: kb, sphinx_app: Sphinx, doctree: doctree): """ Walk the tree and extract excert into resource.excerpt """ # First, find out which resource this is. Won't be easy. resources = sphinx_app.env.resources confdir = sphinx_app.confdir source =...
[ "def", "stamp_excerpt", "(", "kb_app", ":", "kb", ",", "sphinx_app", ":", "Sphinx", ",", "doctree", ":", "doctree", ")", ":", "# First, find out which resource this is. Won't be easy.", "resources", "=", "sphinx_app", ".", "env", ".", "resources", "confdir", "=", ...
Walk the tree and extract excert into resource.excerpt
[ "Walk", "the", "tree", "and", "extract", "excert", "into", "resource", ".", "excerpt" ]
python
train
buildbot/buildbot
master/buildbot/steps/source/git.py
https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/master/buildbot/steps/source/git.py#L437-L447
def _fullCloneOrFallback(self): """Wrapper for _fullClone(). In the case of failure, if clobberOnFailure is set to True remove the build directory and try a full clone again. """ res = yield self._fullClone() if res != RC_SUCCESS: if not self.clobberOnFailure: ...
[ "def", "_fullCloneOrFallback", "(", "self", ")", ":", "res", "=", "yield", "self", ".", "_fullClone", "(", ")", "if", "res", "!=", "RC_SUCCESS", ":", "if", "not", "self", ".", "clobberOnFailure", ":", "raise", "buildstep", ".", "BuildStepFailed", "(", ")",...
Wrapper for _fullClone(). In the case of failure, if clobberOnFailure is set to True remove the build directory and try a full clone again.
[ "Wrapper", "for", "_fullClone", "()", ".", "In", "the", "case", "of", "failure", "if", "clobberOnFailure", "is", "set", "to", "True", "remove", "the", "build", "directory", "and", "try", "a", "full", "clone", "again", "." ]
python
train
projectshift/shift-schema
shiftschema/schema.py
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L278-L306
def validate(self, model=None, context=None): """ Validate model and return validation result object :param model: object or dict :param context: object, dict or None :return: shiftschema.result.Result """ # inject with settings result = Result(translato...
[ "def", "validate", "(", "self", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "# inject with settings", "result", "=", "Result", "(", "translator", "=", "self", ".", "translator", ",", "locale", "=", "self", ".", "locale", ")", "# val...
Validate model and return validation result object :param model: object or dict :param context: object, dict or None :return: shiftschema.result.Result
[ "Validate", "model", "and", "return", "validation", "result", "object", ":", "param", "model", ":", "object", "or", "dict", ":", "param", "context", ":", "object", "dict", "or", "None", ":", "return", ":", "shiftschema", ".", "result", ".", "Result" ]
python
train
ejeschke/ginga
ginga/rv/plugins/ChangeHistory.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/ChangeHistory.py#L238-L257
def remove_image_info_cb(self, gshell, channel, iminfo): """Delete entries related to deleted image.""" chname = channel.name if chname not in self.name_dict: return fileDict = self.name_dict[chname] name = iminfo.name if name not in fileDict: re...
[ "def", "remove_image_info_cb", "(", "self", ",", "gshell", ",", "channel", ",", "iminfo", ")", ":", "chname", "=", "channel", ".", "name", "if", "chname", "not", "in", "self", ".", "name_dict", ":", "return", "fileDict", "=", "self", ".", "name_dict", "[...
Delete entries related to deleted image.
[ "Delete", "entries", "related", "to", "deleted", "image", "." ]
python
train
ktbyers/netmiko
netmiko/_textfsm/_clitable.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L344-L360
def AddKeys(self, key_list): """Mark additional columns as being part of the superkey. Supplements the Keys already extracted from the FSM template. Useful when adding new columns to existing tables. Note: This will impact attempts to further 'extend' the table as the superkey must be common bet...
[ "def", "AddKeys", "(", "self", ",", "key_list", ")", ":", "for", "keyname", "in", "key_list", ":", "if", "keyname", "not", "in", "self", ".", "header", ":", "raise", "KeyError", "(", "\"'%s'\"", "%", "keyname", ")", "self", ".", "_keys", "=", "self", ...
Mark additional columns as being part of the superkey. Supplements the Keys already extracted from the FSM template. Useful when adding new columns to existing tables. Note: This will impact attempts to further 'extend' the table as the superkey must be common between tables for successful extension. ...
[ "Mark", "additional", "columns", "as", "being", "part", "of", "the", "superkey", ".", "Supplements", "the", "Keys", "already", "extracted", "from", "the", "FSM", "template", ".", "Useful", "when", "adding", "new", "columns", "to", "existing", "tables", ".", ...
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/security/security_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/security/security_client.py#L205-L223
def query_security_namespaces(self, security_namespace_id=None, local_only=None): """QuerySecurityNamespaces. List all security namespaces or just the specified namespace. :param str security_namespace_id: Security namespace identifier. :param bool local_only: If true, retrieve only loca...
[ "def", "query_security_namespaces", "(", "self", ",", "security_namespace_id", "=", "None", ",", "local_only", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "security_namespace_id", "is", "not", "None", ":", "route_values", "[", "'securityNamespaceId...
QuerySecurityNamespaces. List all security namespaces or just the specified namespace. :param str security_namespace_id: Security namespace identifier. :param bool local_only: If true, retrieve only local security namespaces. :rtype: [SecurityNamespaceDescription]
[ "QuerySecurityNamespaces", ".", "List", "all", "security", "namespaces", "or", "just", "the", "specified", "namespace", ".", ":", "param", "str", "security_namespace_id", ":", "Security", "namespace", "identifier", ".", ":", "param", "bool", "local_only", ":", "If...
python
train
theislab/scanpy
scanpy/plotting/_anndata.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_anndata.py#L1624-L1822
def matrixplot(adata, var_names, groupby=None, use_raw=None, log=False, num_categories=7, figsize=None, dendrogram=False, gene_symbols=None, var_group_positions=None, var_group_labels=None, var_group_rotation=None, layer=None, standard_scale=None, swap_axes=False, show=None, ...
[ "def", "matrixplot", "(", "adata", ",", "var_names", ",", "groupby", "=", "None", ",", "use_raw", "=", "None", ",", "log", "=", "False", ",", "num_categories", "=", "7", ",", "figsize", "=", "None", ",", "dendrogram", "=", "False", ",", "gene_symbols", ...
\ Creates a heatmap of the mean expression values per cluster of each var_names If groupby is not given, the matrixplot assumes that all data belongs to a single category. Parameters ---------- {common_plot_args} standard_scale : {{'var', 'group'}}, optional (default: None) Whether ...
[ "\\", "Creates", "a", "heatmap", "of", "the", "mean", "expression", "values", "per", "cluster", "of", "each", "var_names", "If", "groupby", "is", "not", "given", "the", "matrixplot", "assumes", "that", "all", "data", "belongs", "to", "a", "single", "category...
python
train
novopl/peltak
src/peltak/extra/changelog/commands.py
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/changelog/commands.py#L24-L32
def changelog_cli(ctx): # type: () -> None """ Generate changelog from commit messages. """ if ctx.invoked_subcommand: return from peltak.core import shell from . import logic shell.cprint(logic.changelog())
[ "def", "changelog_cli", "(", "ctx", ")", ":", "# type: () -> None", "if", "ctx", ".", "invoked_subcommand", ":", "return", "from", "peltak", ".", "core", "import", "shell", "from", ".", "import", "logic", "shell", ".", "cprint", "(", "logic", ".", "changelog...
Generate changelog from commit messages.
[ "Generate", "changelog", "from", "commit", "messages", "." ]
python
train
chaosmail/python-fs
fs/fs.py
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L271-L276
def join(*args, **kwargs): """Join parts of a path together""" import os.path if _is_list(args[0]): return os.path.join(*args[0]) return os.path.join(*args, **kwargs)
[ "def", "join", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "os", ".", "path", "if", "_is_list", "(", "args", "[", "0", "]", ")", ":", "return", "os", ".", "path", ".", "join", "(", "*", "args", "[", "0", "]", ")", "return",...
Join parts of a path together
[ "Join", "parts", "of", "a", "path", "together" ]
python
train
basho/riak-python-client
riak/node.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/node.py#L46-L54
def incr(self, d): """ Increases the value by the argument. :param d: the value to increase by :type d: float """ with self.lock: self.p = self.value() + d
[ "def", "incr", "(", "self", ",", "d", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "p", "=", "self", ".", "value", "(", ")", "+", "d" ]
Increases the value by the argument. :param d: the value to increase by :type d: float
[ "Increases", "the", "value", "by", "the", "argument", "." ]
python
train
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L17021-L17040
def find_host_network_interface_by_name(self, name): """Searches through all host network interfaces for an interface with the given @c name. The method returns an error if the given @c name does not correspond to any host network interface. in name of type str ...
[ "def", "find_host_network_interface_by_name", "(", "self", ",", "name", ")", ":", "if", "not", "isinstance", "(", "name", ",", "basestring", ")", ":", "raise", "TypeError", "(", "\"name can only be an instance of type basestring\"", ")", "network_interface", "=", "sel...
Searches through all host network interfaces for an interface with the given @c name. The method returns an error if the given @c name does not correspond to any host network interface. in name of type str Name of the host network interface to search for. r...
[ "Searches", "through", "all", "host", "network", "interfaces", "for", "an", "interface", "with", "the", "given", "@c", "name", ".", "The", "method", "returns", "an", "error", "if", "the", "given", "@c", "name", "does", "not", "correspond", "to", "any", "ho...
python
train
pywbem/pywbem
pywbem/cim_obj.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L2955-L2985
def tocimxmlstr(self, indent=None, ignore_path=False): """ Return the CIM-XML representation of this CIM instance, as a :term:`unicode string`. *New in pywbem 0.9.* For the returned CIM-XML representation, see :meth:`~pywbem.CIMInstance.tocimxml`. Parameters: ...
[ "def", "tocimxmlstr", "(", "self", ",", "indent", "=", "None", ",", "ignore_path", "=", "False", ")", ":", "xml_elem", "=", "self", ".", "tocimxml", "(", "ignore_path", ")", "return", "tocimxmlstr", "(", "xml_elem", ",", "indent", ")" ]
Return the CIM-XML representation of this CIM instance, as a :term:`unicode string`. *New in pywbem 0.9.* For the returned CIM-XML representation, see :meth:`~pywbem.CIMInstance.tocimxml`. Parameters: indent (:term:`string` or :term:`integer`): `None` in...
[ "Return", "the", "CIM", "-", "XML", "representation", "of", "this", "CIM", "instance", "as", "a", ":", "term", ":", "unicode", "string", "." ]
python
train
ssato/python-anytemplate
anytemplate/utils.py
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L159-L169
def load_context(ctx_path, ctx_type, scm=None): """ :param ctx_path: context file path or '-' (read from stdin) :param ctx_type: context file type :param scm: JSON schema file in any formats anyconfig supports, to validate given context files """ if ctx_path == '-': return loads(...
[ "def", "load_context", "(", "ctx_path", ",", "ctx_type", ",", "scm", "=", "None", ")", ":", "if", "ctx_path", "==", "'-'", ":", "return", "loads", "(", "sys", ".", "stdin", ".", "read", "(", ")", ",", "ac_parser", "=", "ctx_type", ",", "ac_schema", "...
:param ctx_path: context file path or '-' (read from stdin) :param ctx_type: context file type :param scm: JSON schema file in any formats anyconfig supports, to validate given context files
[ ":", "param", "ctx_path", ":", "context", "file", "path", "or", "-", "(", "read", "from", "stdin", ")", ":", "param", "ctx_type", ":", "context", "file", "type", ":", "param", "scm", ":", "JSON", "schema", "file", "in", "any", "formats", "anyconfig", "...
python
train
benvanwerkhoven/kernel_tuner
kernel_tuner/strategies/firefly_algorithm.py
https://github.com/benvanwerkhoven/kernel_tuner/blob/cfcb5da5e510db494f8219c22566ab65d5fcbd9f/kernel_tuner/strategies/firefly_algorithm.py#L8-L90
def tune(runner, kernel_options, device_options, tuning_options): """ Find the best performing kernel configuration in the parameter space :params runner: A runner from kernel_tuner.runners :type runner: kernel_tuner.runner :param kernel_options: A dictionary with all options for the kernel. :type...
[ "def", "tune", "(", "runner", ",", "kernel_options", ",", "device_options", ",", "tuning_options", ")", ":", "results", "=", "[", "]", "cache", "=", "{", "}", "#scale variables in x because PSO works with velocities to visit different configurations", "tuning_options", "[...
Find the best performing kernel configuration in the parameter space :params runner: A runner from kernel_tuner.runners :type runner: kernel_tuner.runner :param kernel_options: A dictionary with all options for the kernel. :type kernel_options: dict :param device_options: A dictionary with all op...
[ "Find", "the", "best", "performing", "kernel", "configuration", "in", "the", "parameter", "space" ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2008.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2008.py#L323-L338
def _compute_intra_event_std(self, C, vs30, pga1100, sigma_pga): """ Returns the intra-event standard deviation at the site, as defined in equation 15, page 147 """ # Get intra-event standard deviation at the base of the site profile sig_lnyb = np.sqrt(C['s_lny'] ** 2. - ...
[ "def", "_compute_intra_event_std", "(", "self", ",", "C", ",", "vs30", ",", "pga1100", ",", "sigma_pga", ")", ":", "# Get intra-event standard deviation at the base of the site profile", "sig_lnyb", "=", "np", ".", "sqrt", "(", "C", "[", "'s_lny'", "]", "**", "2."...
Returns the intra-event standard deviation at the site, as defined in equation 15, page 147
[ "Returns", "the", "intra", "-", "event", "standard", "deviation", "at", "the", "site", "as", "defined", "in", "equation", "15", "page", "147" ]
python
train
openid/python-openid
openid/server/server.py
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/server.py#L1234-L1259
def createAssociation(self, dumb=True, assoc_type='HMAC-SHA1'): """Make a new association. @param dumb: Is this association for a dumb-mode transaction? @type dumb: bool @param assoc_type: The type of association to create. Currently there is only one type defined, C{HMAC-...
[ "def", "createAssociation", "(", "self", ",", "dumb", "=", "True", ",", "assoc_type", "=", "'HMAC-SHA1'", ")", ":", "secret", "=", "cryptutil", ".", "getBytes", "(", "getSecretSize", "(", "assoc_type", ")", ")", "uniq", "=", "oidutil", ".", "toBase64", "("...
Make a new association. @param dumb: Is this association for a dumb-mode transaction? @type dumb: bool @param assoc_type: The type of association to create. Currently there is only one type defined, C{HMAC-SHA1}. @type assoc_type: str @returns: the new association...
[ "Make", "a", "new", "association", "." ]
python
train
nschloe/accupy
accupy/sums.py
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/sums.py#L10-L30
def knuth_sum(a, b): """Error-free transformation of the sum of two floating point numbers according to D.E. Knuth. The Art of Computer Programming: Seminumerical Algorithms, volume 2. Addison Wesley, Reading, Massachusetts, second edition, 1981. The underlying problem is that the exact sum a+...
[ "def", "knuth_sum", "(", "a", ",", "b", ")", ":", "x", "=", "a", "+", "b", "z", "=", "x", "-", "a", "y", "=", "(", "a", "-", "(", "x", "-", "z", ")", ")", "+", "(", "b", "-", "z", ")", "return", "x", ",", "y" ]
Error-free transformation of the sum of two floating point numbers according to D.E. Knuth. The Art of Computer Programming: Seminumerical Algorithms, volume 2. Addison Wesley, Reading, Massachusetts, second edition, 1981. The underlying problem is that the exact sum a+b of two floating point ...
[ "Error", "-", "free", "transformation", "of", "the", "sum", "of", "two", "floating", "point", "numbers", "according", "to" ]
python
train
artisanofcode/python-broadway
broadway/app.py
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/broadway/app.py#L128-L146
def add_extension(self, extension): """ Specify a broadway extension to initialise .. code-block:: python factory = Factory() factory.add_extension('broadway_sqlalchemy') :param extension: import path to extension :type extension: str """ ...
[ "def", "add_extension", "(", "self", ",", "extension", ")", ":", "instance", "=", "werkzeug", ".", "utils", ".", "import_string", "(", "extension", ")", "if", "hasattr", "(", "instance", ",", "'register'", ")", ":", "instance", ".", "register", "(", "self"...
Specify a broadway extension to initialise .. code-block:: python factory = Factory() factory.add_extension('broadway_sqlalchemy') :param extension: import path to extension :type extension: str
[ "Specify", "a", "broadway", "extension", "to", "initialise" ]
python
train
ryukinix/decorating
decorating/stream.py
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/stream.py#L148-L155
def write(self, message, flush=True): if isinstance(message, bytes): # pragma: no cover message = message.decode('utf-8') """A Writting like write method, delayed at each char""" for char in message: time.sleep(self.delay * (4 if char == '\n' else 1)) super(...
[ "def", "write", "(", "self", ",", "message", ",", "flush", "=", "True", ")", ":", "if", "isinstance", "(", "message", ",", "bytes", ")", ":", "# pragma: no cover", "message", "=", "message", ".", "decode", "(", "'utf-8'", ")", "for", "char", "in", "mes...
A Writting like write method, delayed at each char
[ "A", "Writting", "like", "write", "method", "delayed", "at", "each", "char" ]
python
train
mikedh/trimesh
trimesh/scene/cameras.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/scene/cameras.py#L256-L270
def fov(self): """ Get the field of view in degrees. Returns ------------- fov : (2,) float XY field of view in degrees """ if self._fov is None: fov = [2.0 * np.degrees(np.arctan((px / 2.0) / f)) for px, f in zip(self._re...
[ "def", "fov", "(", "self", ")", ":", "if", "self", ".", "_fov", "is", "None", ":", "fov", "=", "[", "2.0", "*", "np", ".", "degrees", "(", "np", ".", "arctan", "(", "(", "px", "/", "2.0", ")", "/", "f", ")", ")", "for", "px", ",", "f", "i...
Get the field of view in degrees. Returns ------------- fov : (2,) float XY field of view in degrees
[ "Get", "the", "field", "of", "view", "in", "degrees", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/core/execution/execution_engine.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/execution/execution_engine.py#L164-L183
def join(self, timeout=None): """Blocking wait for the execution to finish :param float timeout: Maximum time to wait or None for infinitely :return: True if the execution finished, False if no state machine was started or a timeout occurred :rtype: bool """ if self.__wa...
[ "def", "join", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "__wait_for_finishing_thread", ":", "if", "not", "timeout", ":", "# signal handlers won't work if timeout is None and the thread is joined", "while", "True", ":", "self", ".", "__w...
Blocking wait for the execution to finish :param float timeout: Maximum time to wait or None for infinitely :return: True if the execution finished, False if no state machine was started or a timeout occurred :rtype: bool
[ "Blocking", "wait", "for", "the", "execution", "to", "finish" ]
python
train
Legobot/Legobot
Legobot/Connectors/Slack.py
https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/Slack.py#L75-L93
def on_message(self, event): '''Runs when a message event is received Args: event: RTM API event. Returns: Legobot.messge ''' metadata = self._parse_metadata(event) message = Message(text=metadata['text'], metadata=meta...
[ "def", "on_message", "(", "self", ",", "event", ")", ":", "metadata", "=", "self", ".", "_parse_metadata", "(", "event", ")", "message", "=", "Message", "(", "text", "=", "metadata", "[", "'text'", "]", ",", "metadata", "=", "metadata", ")", ".", "__di...
Runs when a message event is received Args: event: RTM API event. Returns: Legobot.messge
[ "Runs", "when", "a", "message", "event", "is", "received" ]
python
train
coinbase/coinbase-python
coinbase/wallet/client.py
https://github.com/coinbase/coinbase-python/blob/497c28158f529e8c7d0228521b4386a890baf088/coinbase/wallet/client.py#L613-L616
def create_checkout_order(self, checkout_id, **params): """https://developers.coinbase.com/api/v2#create-a-new-order-for-a-checkout""" response = self._post('v2', 'checkouts', checkout_id, 'orders', data=params) return self._make_api_object(response, Order)
[ "def", "create_checkout_order", "(", "self", ",", "checkout_id", ",", "*", "*", "params", ")", ":", "response", "=", "self", ".", "_post", "(", "'v2'", ",", "'checkouts'", ",", "checkout_id", ",", "'orders'", ",", "data", "=", "params", ")", "return", "s...
https://developers.coinbase.com/api/v2#create-a-new-order-for-a-checkout
[ "https", ":", "//", "developers", ".", "coinbase", ".", "com", "/", "api", "/", "v2#create", "-", "a", "-", "new", "-", "order", "-", "for", "-", "a", "-", "checkout" ]
python
train
CSchoel/nolds
nolds/measures.py
https://github.com/CSchoel/nolds/blob/8a5ecc472d67ac08b571bd68967287668ca9058e/nolds/measures.py#L345-L370
def lyap_e_len(**kwargs): """ Helper function that calculates the minimum number of data points required to use lyap_e. Note that none of the required parameters may be set to None. Kwargs: kwargs(dict): arguments used for lyap_e (required: emb_dim, matrix_dim, min_nb and min_tsep) Return...
[ "def", "lyap_e_len", "(", "*", "*", "kwargs", ")", ":", "m", "=", "(", "kwargs", "[", "'emb_dim'", "]", "-", "1", ")", "//", "(", "kwargs", "[", "'matrix_dim'", "]", "-", "1", ")", "# minimum length required to find single orbit vector", "min_len", "=", "k...
Helper function that calculates the minimum number of data points required to use lyap_e. Note that none of the required parameters may be set to None. Kwargs: kwargs(dict): arguments used for lyap_e (required: emb_dim, matrix_dim, min_nb and min_tsep) Returns: minimum number of data poin...
[ "Helper", "function", "that", "calculates", "the", "minimum", "number", "of", "data", "points", "required", "to", "use", "lyap_e", "." ]
python
train
lemieuxl/pyGenClean
pyGenClean/Ethnicity/find_outliers.py
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L34-L117
def main(argString=None): """The main function. :param argString: the options. :type argString: list of strings These are the steps of the modules: 1. Prints the options. 2. Reads the population file (:py:func:`read_population_file`). 3. Reads the ``mds`` file (:py:func:`read_mds_file`)....
[ "def", "main", "(", "argString", "=", "None", ")", ":", "# Getting and checking the options", "args", "=", "parseArgs", "(", "argString", ")", "checkArgs", "(", "args", ")", "logger", ".", "info", "(", "\"Options used:\"", ")", "for", "key", ",", "value", "i...
The main function. :param argString: the options. :type argString: list of strings These are the steps of the modules: 1. Prints the options. 2. Reads the population file (:py:func:`read_population_file`). 3. Reads the ``mds`` file (:py:func:`read_mds_file`). 4. Computes the three refere...
[ "The", "main", "function", "." ]
python
train
mitsei/dlkit
dlkit/handcar/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/managers.py#L1704-L1726
def get_repository_search_session(self): """Gets the repository search session. return: (osid.repository.RepositorySearchSession) - a RepositorySearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_search() is fals...
[ "def", "get_repository_search_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_repository_search", "(", ")", ":", "raise", "Unimplemented", "(", ")", "try", ":", "from", ".", "import", "sessions", "except", "ImportError", ":", "raise", "# O...
Gets the repository search session. return: (osid.repository.RepositorySearchSession) - a RepositorySearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_repository_search() is false compliance: optional - This method must be...
[ "Gets", "the", "repository", "search", "session", "." ]
python
train
TUNE-Archive/freight_forwarder
freight_forwarder/container_ship.py
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/container_ship.py#L663-L679
def _update_container_host_config(self, service): """ :param service: :return None: """ if not isinstance(service, Service): raise TypeError("service must be an instance of Service") if service.dependencies: self._load_dependency_containers(servi...
[ "def", "_update_container_host_config", "(", "self", ",", "service", ")", ":", "if", "not", "isinstance", "(", "service", ",", "Service", ")", ":", "raise", "TypeError", "(", "\"service must be an instance of Service\"", ")", "if", "service", ".", "dependencies", ...
:param service: :return None:
[ ":", "param", "service", ":", ":", "return", "None", ":" ]
python
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L387-L392
def __has_language(self, bundleId, languageId): """Returns ``True`` if the bundle has the language, ``False`` otherwise """ return True if self.__get_language_data(bundleId=bundleId, languageId=languageId) \ else False
[ "def", "__has_language", "(", "self", ",", "bundleId", ",", "languageId", ")", ":", "return", "True", "if", "self", ".", "__get_language_data", "(", "bundleId", "=", "bundleId", ",", "languageId", "=", "languageId", ")", "else", "False" ]
Returns ``True`` if the bundle has the language, ``False`` otherwise
[ "Returns", "True", "if", "the", "bundle", "has", "the", "language", "False", "otherwise" ]
python
train
pybel/pybel
src/pybel/struct/mutation/induction/random_subgraph.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/induction/random_subgraph.py#L168-L216
def get_random_subgraph(graph, number_edges=None, number_seed_edges=None, seed=None, invert_degrees=None): """Generate a random subgraph based on weighted random walks from random seed edges. :type graph: pybel.BELGraph graph :param Optional[int] number_edges: Maximum number of edges. Defaults to :dat...
[ "def", "get_random_subgraph", "(", "graph", ",", "number_edges", "=", "None", ",", "number_seed_edges", "=", "None", ",", "seed", "=", "None", ",", "invert_degrees", "=", "None", ")", ":", "if", "number_edges", "is", "None", ":", "number_edges", "=", "SAMPLE...
Generate a random subgraph based on weighted random walks from random seed edges. :type graph: pybel.BELGraph graph :param Optional[int] number_edges: Maximum number of edges. Defaults to :data:`pybel_tools.constants.SAMPLE_RANDOM_EDGE_COUNT` (250). :param Optional[int] number_seed_edges: Number of no...
[ "Generate", "a", "random", "subgraph", "based", "on", "weighted", "random", "walks", "from", "random", "seed", "edges", "." ]
python
train
StackStorm/pybind
pybind/slxos/v17r_1_01a/interface/ethernet/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/interface/ethernet/__init__.py#L768-L789
def _set_vepa(self, v, load=False): """ Setter method for vepa, mapped from YANG variable /interface/ethernet/vepa (container) If this variable is read-only (config: false) in the source YANG file, then _set_vepa is considered as a private method. Backends looking to populate this variable should ...
[ "def", "_set_vepa", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for vepa, mapped from YANG variable /interface/ethernet/vepa (container) If this variable is read-only (config: false) in the source YANG file, then _set_vepa is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_vepa() directly...
[ "Setter", "method", "for", "vepa", "mapped", "from", "YANG", "variable", "/", "interface", "/", "ethernet", "/", "vepa", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", ...
python
train
inasafe/inasafe
safe/definitions/minimum_needs.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/minimum_needs.py#L47-L92
def _initializes_minimum_needs_fields(): """Initialize minimum needs fields. Minimum needs definitions are taken from currently used profile. """ needs_profile = NeedsProfile() needs_profile.load() fields = [] needs_parameters = needs_profile.get_needs_parameters() for need_parameter ...
[ "def", "_initializes_minimum_needs_fields", "(", ")", ":", "needs_profile", "=", "NeedsProfile", "(", ")", "needs_profile", ".", "load", "(", ")", "fields", "=", "[", "]", "needs_parameters", "=", "needs_profile", ".", "get_needs_parameters", "(", ")", "for", "n...
Initialize minimum needs fields. Minimum needs definitions are taken from currently used profile.
[ "Initialize", "minimum", "needs", "fields", "." ]
python
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L21-L50
def _first_step_to_match(match_step): """Transform the very first MATCH step into a MATCH query string.""" parts = [] if match_step.root_block is not None: if not isinstance(match_step.root_block, QueryRoot): raise AssertionError(u'Expected None or QueryRoot root block, received: ' ...
[ "def", "_first_step_to_match", "(", "match_step", ")", ":", "parts", "=", "[", "]", "if", "match_step", ".", "root_block", "is", "not", "None", ":", "if", "not", "isinstance", "(", "match_step", ".", "root_block", ",", "QueryRoot", ")", ":", "raise", "Asse...
Transform the very first MATCH step into a MATCH query string.
[ "Transform", "the", "very", "first", "MATCH", "step", "into", "a", "MATCH", "query", "string", "." ]
python
train
fossasia/knittingpattern
knittingpattern/Parser.py
https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/Parser.py#L164-L172
def instruction_in_row(self, row, specification): """Parse an instruction. :param row: the row of the instruction :param specification: the specification of the instruction :return: the instruction in the row """ whole_instruction_ = self._as_instruction(specification) ...
[ "def", "instruction_in_row", "(", "self", ",", "row", ",", "specification", ")", ":", "whole_instruction_", "=", "self", ".", "_as_instruction", "(", "specification", ")", "return", "self", ".", "_spec", ".", "new_instruction_in_row", "(", "row", ",", "whole_ins...
Parse an instruction. :param row: the row of the instruction :param specification: the specification of the instruction :return: the instruction in the row
[ "Parse", "an", "instruction", "." ]
python
valid
chaoss/grimoirelab-cereslib
cereslib/dfutils/filter.py
https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/dfutils/filter.py#L54-L75
def filter_(self, columns, value): """ This method filter some of the rows where the 'value' is found in each of the 'columns'. :param column: list of strings :param value: any type :returns: filtered dataframe :rtype: pandas.DataFrame """ for column in...
[ "def", "filter_", "(", "self", ",", "columns", ",", "value", ")", ":", "for", "column", "in", "columns", ":", "if", "column", "not", "in", "self", ".", "data", ".", "columns", ":", "raise", "ValueError", "(", "\"Column %s not in DataFrame columns: %s\"", "%"...
This method filter some of the rows where the 'value' is found in each of the 'columns'. :param column: list of strings :param value: any type :returns: filtered dataframe :rtype: pandas.DataFrame
[ "This", "method", "filter", "some", "of", "the", "rows", "where", "the", "value", "is", "found", "in", "each", "of", "the", "columns", "." ]
python
train
bwesterb/mirte
src/mirteFile.py
https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L52-L92
def module_definition_from_mirteFile_dict(man, d): """ Creates a ModuleDefinition instance from the dictionary <d> from a mirte-file for the Manager instance <man>. """ m = ModuleDefinition() if 'inherits' not in d: d['inherits'] = list() if 'settings' not in d: d['settings'] = d...
[ "def", "module_definition_from_mirteFile_dict", "(", "man", ",", "d", ")", ":", "m", "=", "ModuleDefinition", "(", ")", "if", "'inherits'", "not", "in", "d", ":", "d", "[", "'inherits'", "]", "=", "list", "(", ")", "if", "'settings'", "not", "in", "d", ...
Creates a ModuleDefinition instance from the dictionary <d> from a mirte-file for the Manager instance <man>.
[ "Creates", "a", "ModuleDefinition", "instance", "from", "the", "dictionary", "<d", ">", "from", "a", "mirte", "-", "file", "for", "the", "Manager", "instance", "<man", ">", "." ]
python
train
ttinoco/OPTALG
optalg/opt_solver/opt_solver.py
https://github.com/ttinoco/OPTALG/blob/d4f141292f281eea4faa71473258139e7f433001/optalg/opt_solver/opt_solver.py#L173-L236
def line_search(self,x,p,F,GradF,func,smax=np.inf,maxiter=40): """ Finds steplength along search direction p that satisfies the strong Wolfe conditions. Parameters ---------- x : current point (ndarray) p : search direction (ndarray) F : function...
[ "def", "line_search", "(", "self", ",", "x", ",", "p", ",", "F", ",", "GradF", ",", "func", ",", "smax", "=", "np", ".", "inf", ",", "maxiter", "=", "40", ")", ":", "# Parameters of line search", "c1", "=", "1e-4", "c2", "=", "5e-1", "# Initialize lo...
Finds steplength along search direction p that satisfies the strong Wolfe conditions. Parameters ---------- x : current point (ndarray) p : search direction (ndarray) F : function value at `x` (float) GradF : gradient of function at `x` (ndarray) ...
[ "Finds", "steplength", "along", "search", "direction", "p", "that", "satisfies", "the", "strong", "Wolfe", "conditions", ".", "Parameters", "----------", "x", ":", "current", "point", "(", "ndarray", ")", "p", ":", "search", "direction", "(", "ndarray", ")", ...
python
train
petl-developers/petlx
petlx/bio/vcf.py
https://github.com/petl-developers/petlx/blob/54039e30388c7da12407d6b5c3cb865b00436004/petlx/bio/vcf.py#L9-L37
def fromvcf(filename, chrom=None, start=None, stop=None, samples=True): """ Returns a table providing access to data from a variant call file (VCF). E.g.:: >>> import petl as etl >>> # activate bio extensions ... import petlx.bio >>> table1 = etl.fromvcf('fixture/sample.vcf'...
[ "def", "fromvcf", "(", "filename", ",", "chrom", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "samples", "=", "True", ")", ":", "return", "VCFView", "(", "filename", ",", "chrom", "=", "chrom", ",", "start", "=", "start", ...
Returns a table providing access to data from a variant call file (VCF). E.g.:: >>> import petl as etl >>> # activate bio extensions ... import petlx.bio >>> table1 = etl.fromvcf('fixture/sample.vcf') >>> table1.look(truncate=20) +-------+---------+-------------+----...
[ "Returns", "a", "table", "providing", "access", "to", "data", "from", "a", "variant", "call", "file", "(", "VCF", ")", ".", "E", ".", "g", ".", "::" ]
python
train
tgbugs/pyontutils
nifstd/nifstd_tools/parcellation/__init__.py
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/parcellation/__init__.py#L43-L269
def swanson(): """ not really a parcellation scheme NOTE: the defining information up here is now deprecated it is kept around to keep the code further down happy """ source = Path(devconfig.resources, 'swanson_aligned.txt').as_posix() ONT_PATH = 'http://ontology.neuinfo.org/NIF/ttl/generat...
[ "def", "swanson", "(", ")", ":", "source", "=", "Path", "(", "devconfig", ".", "resources", ",", "'swanson_aligned.txt'", ")", ".", "as_posix", "(", ")", "ONT_PATH", "=", "'http://ontology.neuinfo.org/NIF/ttl/generated/'", "filename", "=", "'swanson_hierarchies'", "...
not really a parcellation scheme NOTE: the defining information up here is now deprecated it is kept around to keep the code further down happy
[ "not", "really", "a", "parcellation", "scheme", "NOTE", ":", "the", "defining", "information", "up", "here", "is", "now", "deprecated", "it", "is", "kept", "around", "to", "keep", "the", "code", "further", "down", "happy" ]
python
train
scottjbarr/bitfinex
bitfinex/client.py
https://github.com/scottjbarr/bitfinex/blob/03f7c71615fe38c2e28be0ebb761d3106ef0a51a/bitfinex/client.py#L56-L89
def place_order(self, amount, price, side, ord_type, symbol='btcusd', exchange='bitfinex'): """ Submit a new order. :param amount: :param price: :param side: :param ord_type: :param symbol: :param exchange: :return: """ payload = { ...
[ "def", "place_order", "(", "self", ",", "amount", ",", "price", ",", "side", ",", "ord_type", ",", "symbol", "=", "'btcusd'", ",", "exchange", "=", "'bitfinex'", ")", ":", "payload", "=", "{", "\"request\"", ":", "\"/v1/order/new\"", ",", "\"nonce\"", ":",...
Submit a new order. :param amount: :param price: :param side: :param ord_type: :param symbol: :param exchange: :return:
[ "Submit", "a", "new", "order", ".", ":", "param", "amount", ":", ":", "param", "price", ":", ":", "param", "side", ":", ":", "param", "ord_type", ":", ":", "param", "symbol", ":", ":", "param", "exchange", ":", ":", "return", ":" ]
python
train
moreati/subresource-integrity
subresource_integrity.py
https://github.com/moreati/subresource-integrity/blob/c9f6cecddea85f1c7bb5562551a41b9678fbda21/subresource_integrity.py#L118-L130
def render(data, algorithms=(DEFAULT_ALOGRITHM,), seperator=' '): """Returns a subresource integrity string for the given data & algorithms >>> data = b"alert('Hello, world.');" >>> render(data) 'sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO' >>> print(render(data, ['...
[ "def", "render", "(", "data", ",", "algorithms", "=", "(", "DEFAULT_ALOGRITHM", ",", ")", ",", "seperator", "=", "' '", ")", ":", "return", "seperator", ".", "join", "(", "str", "(", "ihash", ")", "for", "ihash", "in", "generate", "(", "data", ",", "...
Returns a subresource integrity string for the given data & algorithms >>> data = b"alert('Hello, world.');" >>> render(data) 'sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO' >>> print(render(data, ['sha256', 'sha384'], seperator='\\n')) sha256-qznLcsROx4GACP2dm0UCKCzC...
[ "Returns", "a", "subresource", "integrity", "string", "for", "the", "given", "data", "&", "algorithms" ]
python
train
pyroscope/pyrocore
src/pyrocore/torrent/formatting.py
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L231-L274
def expand_template(template, namespace): """ Expand the given (preparsed) template. Currently, only Tempita templates are supported. @param template: The template, in preparsed form, or as a string (which then will be preparsed). @param namespace: Custom namespace that is added to the pred...
[ "def", "expand_template", "(", "template", ",", "namespace", ")", ":", "# Create helper namespace", "formatters", "=", "dict", "(", "(", "name", "[", "4", ":", "]", ",", "method", ")", "for", "name", ",", "method", "in", "globals", "(", ")", ".", "items"...
Expand the given (preparsed) template. Currently, only Tempita templates are supported. @param template: The template, in preparsed form, or as a string (which then will be preparsed). @param namespace: Custom namespace that is added to the predefined defaults and takes precedence o...
[ "Expand", "the", "given", "(", "preparsed", ")", "template", ".", "Currently", "only", "Tempita", "templates", "are", "supported", "." ]
python
train
pypa/pipenv
pipenv/vendor/pyparsing.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pyparsing.py#L1042-L1067
def pprint(self, *args, **kwargs): """ Pretty-printer for parsed results as a list, using the `pprint <https://docs.python.org/3/library/pprint.html>`_ module. Accepts additional positional or keyword args as defined for `pprint.pprint <https://docs.python.org/3/library/pprint.ht...
[ "def", "pprint", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pprint", ".", "pprint", "(", "self", ".", "asList", "(", ")", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Pretty-printer for parsed results as a list, using the `pprint <https://docs.python.org/3/library/pprint.html>`_ module. Accepts additional positional or keyword args as defined for `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ . Example:: i...
[ "Pretty", "-", "printer", "for", "parsed", "results", "as", "a", "list", "using", "the", "pprint", "<https", ":", "//", "docs", ".", "python", ".", "org", "/", "3", "/", "library", "/", "pprint", ".", "html", ">", "_", "module", ".", "Accepts", "addi...
python
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L607-L621
def add_cluster_admin(self, new_username, new_password): """Add cluster admin.""" data = { 'name': new_username, 'password': new_password } self.request( url="cluster_admins", method='POST', data=data, expected_resp...
[ "def", "add_cluster_admin", "(", "self", ",", "new_username", ",", "new_password", ")", ":", "data", "=", "{", "'name'", ":", "new_username", ",", "'password'", ":", "new_password", "}", "self", ".", "request", "(", "url", "=", "\"cluster_admins\"", ",", "me...
Add cluster admin.
[ "Add", "cluster", "admin", "." ]
python
train
tumblr/pytumblr
pytumblr/__init__.py
https://github.com/tumblr/pytumblr/blob/4a5cd7c4b8ae78d12811d9fd52620afa1692a415/pytumblr/__init__.py#L514-L532
def _send_post(self, blogname, params): """ Formats parameters and sends the API request off. Validates common and per-post-type parameters and formats your tags for you. :param blogname: a string, the blogname of the blog you are posting to :param params: a dict, the key-value ...
[ "def", "_send_post", "(", "self", ",", "blogname", ",", "params", ")", ":", "url", "=", "\"/v2/blog/{}/post\"", ".", "format", "(", "blogname", ")", "valid_options", "=", "self", ".", "_post_valid_options", "(", "params", ".", "get", "(", "'type'", ",", "N...
Formats parameters and sends the API request off. Validates common and per-post-type parameters and formats your tags for you. :param blogname: a string, the blogname of the blog you are posting to :param params: a dict, the key-value of the parameters for the api request :param valid_o...
[ "Formats", "parameters", "and", "sends", "the", "API", "request", "off", ".", "Validates", "common", "and", "per", "-", "post", "-", "type", "parameters", "and", "formats", "your", "tags", "for", "you", "." ]
python
train
theonion/django-bulbs
bulbs/contributions/email.py
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/contributions/email.py#L80-L87
def contributions(self): """Apply a datetime filter against the contributor's contribution queryset.""" if self._contributions is None: self._contributions = self.contributor.contributions.filter( content__published__gte=self.start, content__published__lt=self...
[ "def", "contributions", "(", "self", ")", ":", "if", "self", ".", "_contributions", "is", "None", ":", "self", ".", "_contributions", "=", "self", ".", "contributor", ".", "contributions", ".", "filter", "(", "content__published__gte", "=", "self", ".", "sta...
Apply a datetime filter against the contributor's contribution queryset.
[ "Apply", "a", "datetime", "filter", "against", "the", "contributor", "s", "contribution", "queryset", "." ]
python
train
ska-sa/purr
Purr/LogEntry.py
https://github.com/ska-sa/purr/blob/4c848768d0485d0f88b30850d0d5372221b21b66/Purr/LogEntry.py#L16-L21
def _copy_update(sourcepath, destname): """Copy source to dest only if source is newer.""" if sys.platform.startswith('linux'): return os.system("/bin/cp -ua '%s' '%s'" % (sourcepath, destname)) else: return os.system("rsync -ua '%s' '%s'" % (sourcepath, destname))
[ "def", "_copy_update", "(", "sourcepath", ",", "destname", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "return", "os", ".", "system", "(", "\"/bin/cp -ua '%s' '%s'\"", "%", "(", "sourcepath", ",", "destname", ")", "...
Copy source to dest only if source is newer.
[ "Copy", "source", "to", "dest", "only", "if", "source", "is", "newer", "." ]
python
train
CalebBell/fluids
fluids/friction.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/friction.py#L3042-L3124
def friction_plate_Martin_1999(Re, plate_enlargement_factor): r'''Calculates Darcy friction factor for single-phase flow in a Chevron-style plate heat exchanger according to [1]_. .. math:: \frac{1}{\sqrt{f_f}} = \frac{\cos \phi}{\sqrt{0.045\tan\phi + 0.09\sin\phi + f_0/\cos(\phi)}} +...
[ "def", "friction_plate_Martin_1999", "(", "Re", ",", "plate_enlargement_factor", ")", ":", "phi", "=", "plate_enlargement_factor", "if", "Re", "<", "2000.", ":", "f0", "=", "16.", "/", "Re", "f1", "=", "149.", "/", "Re", "+", "0.9625", "else", ":", "f0", ...
r'''Calculates Darcy friction factor for single-phase flow in a Chevron-style plate heat exchanger according to [1]_. .. math:: \frac{1}{\sqrt{f_f}} = \frac{\cos \phi}{\sqrt{0.045\tan\phi + 0.09\sin\phi + f_0/\cos(\phi)}} + \frac{1-\cos\phi}{\sqrt{3.8f_1}} .. math:: f...
[ "r", "Calculates", "Darcy", "friction", "factor", "for", "single", "-", "phase", "flow", "in", "a", "Chevron", "-", "style", "plate", "heat", "exchanger", "according", "to", "[", "1", "]", "_", ".", "..", "math", "::", "\\", "frac", "{", "1", "}", "{...
python
train
Azure/azure-cli-extensions
src/aks-preview/azext_aks_preview/_validators.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/aks-preview/azext_aks_preview/_validators.py#L71-L83
def validate_linux_host_name(namespace): """Validates a string as a legal host name component. This validation will also occur server-side in the ARM API, but that may take a minute or two before the user sees it. So it's more user-friendly to validate in the CLI pre-flight. """ # https://stack...
[ "def", "validate_linux_host_name", "(", "namespace", ")", ":", "# https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address", "rfc1123_regex", "=", "re", ".", "compile", "(", "r'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])(\\.([a-zA-Z0-9...
Validates a string as a legal host name component. This validation will also occur server-side in the ARM API, but that may take a minute or two before the user sees it. So it's more user-friendly to validate in the CLI pre-flight.
[ "Validates", "a", "string", "as", "a", "legal", "host", "name", "component", "." ]
python
train
knipknap/exscript
Exscript/util/file.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/util/file.py#L206-L236
def load_lib(filename): """ Loads a Python file containing functions, and returns the content of the __lib__ variable. The __lib__ variable must contain a dictionary mapping function names to callables. Returns a dictionary mapping the namespaced function names to callables. The namespace is th...
[ "def", "load_lib", "(", "filename", ")", ":", "# Open the file.", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "raise", "IOError", "(", "'No such file: %s'", "%", "filename", ")", "name", "=", "os", ".", "path", ".", "splitex...
Loads a Python file containing functions, and returns the content of the __lib__ variable. The __lib__ variable must contain a dictionary mapping function names to callables. Returns a dictionary mapping the namespaced function names to callables. The namespace is the basename of the file, without file...
[ "Loads", "a", "Python", "file", "containing", "functions", "and", "returns", "the", "content", "of", "the", "__lib__", "variable", ".", "The", "__lib__", "variable", "must", "contain", "a", "dictionary", "mapping", "function", "names", "to", "callables", "." ]
python
train
SBRG/ssbio
ssbio/protein/sequence/properties/scratch.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/scratch.py#L68-L78
def sspro_results(self): """Parse the SSpro output file and return a dict of secondary structure compositions. Returns: dict: Keys are sequence IDs, values are the lists of secondary structure predictions. H: helix E: strand C: the rest ...
[ "def", "sspro_results", "(", "self", ")", ":", "return", "ssbio", ".", "protein", ".", "sequence", ".", "utils", ".", "fasta", ".", "load_fasta_file_as_dict_of_seqs", "(", "self", ".", "out_sspro", ")" ]
Parse the SSpro output file and return a dict of secondary structure compositions. Returns: dict: Keys are sequence IDs, values are the lists of secondary structure predictions. H: helix E: strand C: the rest
[ "Parse", "the", "SSpro", "output", "file", "and", "return", "a", "dict", "of", "secondary", "structure", "compositions", "." ]
python
train
swharden/SWHLab
swhlab/core.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L379-L385
def sweepYfiltered(self): """ Get the filtered sweepY of the current sweep. Only works if self.kernel has been generated. """ assert self.kernel is not None return swhlab.common.convolve(self.sweepY,self.kernel)
[ "def", "sweepYfiltered", "(", "self", ")", ":", "assert", "self", ".", "kernel", "is", "not", "None", "return", "swhlab", ".", "common", ".", "convolve", "(", "self", ".", "sweepY", ",", "self", ".", "kernel", ")" ]
Get the filtered sweepY of the current sweep. Only works if self.kernel has been generated.
[ "Get", "the", "filtered", "sweepY", "of", "the", "current", "sweep", ".", "Only", "works", "if", "self", ".", "kernel", "has", "been", "generated", "." ]
python
valid
FutunnOpen/futuquant
futuquant/trade/open_trade_context.py
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/trade/open_trade_context.py#L663-L727
def acctradinginfo_query(self, order_type, code, price, order_id=None, adjust_limit=0, trd_env=TrdEnv.REAL, acc_id=0, acc_index=0): """ 查询账户下最大可买卖数量 :param order_type: 订单类型,参见OrderType :param code: 证券代码,例如'HK.00700' :param price: 报价,3位精度 :param order_id: 订单号。如果是新下单,则可以传No...
[ "def", "acctradinginfo_query", "(", "self", ",", "order_type", ",", "code", ",", "price", ",", "order_id", "=", "None", ",", "adjust_limit", "=", "0", ",", "trd_env", "=", "TrdEnv", ".", "REAL", ",", "acc_id", "=", "0", ",", "acc_index", "=", "0", ")",...
查询账户下最大可买卖数量 :param order_type: 订单类型,参见OrderType :param code: 证券代码,例如'HK.00700' :param price: 报价,3位精度 :param order_id: 订单号。如果是新下单,则可以传None。如果是改单则要传单号。 :param adjust_limit: 调整方向和调整幅度百分比限制,正数代表向上调整,负数代表向下调整,具体值代表调整幅度限制,如:0.015代表向上调整且幅度不超过1.5%;-0.01代表向下调整且幅度不超过1%。默认0表示不调整 :p...
[ "查询账户下最大可买卖数量", ":", "param", "order_type", ":", "订单类型,参见OrderType", ":", "param", "code", ":", "证券代码,例如", "HK", ".", "00700", ":", "param", "price", ":", "报价,3位精度", ":", "param", "order_id", ":", "订单号。如果是新下单,则可以传None。如果是改单则要传单号。", ":", "param", "adjust_limit", ...
python
train
data-8/datascience
datascience/tables.py
https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/tables.py#L105-L108
def from_columns_dict(cls, columns): """Create a table from a mapping of column labels to column values. [Deprecated]""" warnings.warn("Table.from_columns_dict is deprecated. Use Table().with_columns(...)", FutureWarning) return cls().with_columns(columns.items())
[ "def", "from_columns_dict", "(", "cls", ",", "columns", ")", ":", "warnings", ".", "warn", "(", "\"Table.from_columns_dict is deprecated. Use Table().with_columns(...)\"", ",", "FutureWarning", ")", "return", "cls", "(", ")", ".", "with_columns", "(", "columns", ".", ...
Create a table from a mapping of column labels to column values. [Deprecated]
[ "Create", "a", "table", "from", "a", "mapping", "of", "column", "labels", "to", "column", "values", ".", "[", "Deprecated", "]" ]
python
train
arista-eosplus/pyeapi
pyeapi/api/stp.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/stp.py#L282-L312
def set_portfast(self, name, value=None, default=False, disable=False): """Configures the portfast value for the specified interface Args: name (string): The interface identifier to configure. The name must be the full interface name (eg Ethernet1, not Et1) val...
[ "def", "set_portfast", "(", "self", ",", "name", ",", "value", "=", "None", ",", "default", "=", "False", ",", "disable", "=", "False", ")", ":", "if", "value", "is", "False", ":", "disable", "=", "True", "string", "=", "'spanning-tree portfast'", "cmds"...
Configures the portfast value for the specified interface Args: name (string): The interface identifier to configure. The name must be the full interface name (eg Ethernet1, not Et1) value (bool): True if portfast is enabled otherwise False default (bool):...
[ "Configures", "the", "portfast", "value", "for", "the", "specified", "interface" ]
python
train
pylast/pylast
src/pylast/__init__.py
https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L2147-L2158
def get_album(self): """Returns the album object of this track.""" doc = self._request(self.ws_prefix + ".getInfo", True) albums = doc.getElementsByTagName("album") if len(albums) == 0: return node = doc.getElementsByTagName("album")[0] return Album(_extra...
[ "def", "get_album", "(", "self", ")", ":", "doc", "=", "self", ".", "_request", "(", "self", ".", "ws_prefix", "+", "\".getInfo\"", ",", "True", ")", "albums", "=", "doc", ".", "getElementsByTagName", "(", "\"album\"", ")", "if", "len", "(", "albums", ...
Returns the album object of this track.
[ "Returns", "the", "album", "object", "of", "this", "track", "." ]
python
train
openvax/mhcnames
mhcnames/mouse.py
https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/mouse.py#L21-L52
def parse_mouse_allele_name(name): """Parses mouse MHc alleles such as H2-Kd, H-2-Db, H2-IAb. Returns pair of (gene, allele_code). """ original = name if name.upper().startswith("H2"): name = name[2:] elif name.upper().startswith("H-2"): name = name[3:] _, name = parse_separa...
[ "def", "parse_mouse_allele_name", "(", "name", ")", ":", "original", "=", "name", "if", "name", ".", "upper", "(", ")", ".", "startswith", "(", "\"H2\"", ")", ":", "name", "=", "name", "[", "2", ":", "]", "elif", "name", ".", "upper", "(", ")", "."...
Parses mouse MHc alleles such as H2-Kd, H-2-Db, H2-IAb. Returns pair of (gene, allele_code).
[ "Parses", "mouse", "MHc", "alleles", "such", "as", "H2", "-", "Kd", "H", "-", "2", "-", "Db", "H2", "-", "IAb", ".", "Returns", "pair", "of", "(", "gene", "allele_code", ")", "." ]
python
train
tgsmith61591/pmdarima
pmdarima/utils/visualization.py
https://github.com/tgsmith61591/pmdarima/blob/a133de78ba5bd68da9785b061f519ba28cd514cc/pmdarima/utils/visualization.py#L178-L261
def plot_pacf(series, ax=None, lags=None, alpha=None, method='yw', use_vlines=True, title='Partial Autocorrelation', zero=True, vlines_kwargs=None, show=True, **kwargs): """Plot a series' partial auto-correlation as a line plot. A wrapper method for the statsmodels ``plot_pacf`` met...
[ "def", "plot_pacf", "(", "series", ",", "ax", "=", "None", ",", "lags", "=", "None", ",", "alpha", "=", "None", ",", "method", "=", "'yw'", ",", "use_vlines", "=", "True", ",", "title", "=", "'Partial Autocorrelation'", ",", "zero", "=", "True", ",", ...
Plot a series' partial auto-correlation as a line plot. A wrapper method for the statsmodels ``plot_pacf`` method. Parameters ---------- series : array-like, shape=(n_samples,) The series or numpy array for which to plot an auto-correlation. ax : Matplotlib AxesSubplot instance, optional ...
[ "Plot", "a", "series", "partial", "auto", "-", "correlation", "as", "a", "line", "plot", "." ]
python
train
quantopian/pgcontents
pgcontents/query.py
https://github.com/quantopian/pgcontents/blob/ed36268b7917332d16868208e1e565742a8753e1/pgcontents/query.py#L419-L451
def rename_file(db, user_id, old_api_path, new_api_path): """ Rename a file. """ # Overwriting existing files is disallowed. if file_exists(db, user_id, new_api_path): raise FileExists(new_api_path) old_dir, old_name = split_api_filepath(old_api_path) new_dir, new_name = split_api_...
[ "def", "rename_file", "(", "db", ",", "user_id", ",", "old_api_path", ",", "new_api_path", ")", ":", "# Overwriting existing files is disallowed.", "if", "file_exists", "(", "db", ",", "user_id", ",", "new_api_path", ")", ":", "raise", "FileExists", "(", "new_api_...
Rename a file.
[ "Rename", "a", "file", "." ]
python
test
achimnol/aiotools
src/aiotools/server.py
https://github.com/achimnol/aiotools/blob/9efc66a01fbd287f70ee3a937203d466aac4a765/src/aiotools/server.py#L198-L220
def _main_ctxmgr(func): ''' A decorator wrapper for :class:`ServerMainContextManager` Usage example: .. code:: python @aiotools.main def mymain(): server_args = do_init() stop_sig = yield server_args if stop_sig == signal.SIGINT: do_gracef...
[ "def", "_main_ctxmgr", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "helper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "ServerMainContextManager", "(", "func", ",", "args", ",", "kwargs", ")", ...
A decorator wrapper for :class:`ServerMainContextManager` Usage example: .. code:: python @aiotools.main def mymain(): server_args = do_init() stop_sig = yield server_args if stop_sig == signal.SIGINT: do_graceful_shutdown() else: ...
[ "A", "decorator", "wrapper", "for", ":", "class", ":", "ServerMainContextManager" ]
python
train
has2k1/plotnine
plotnine/guides/guide_colorbar.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L134-L239
def draw(self): """ Draw guide Returns ------- out : matplotlib.offsetbox.Offsetbox A drawing of this legend """ obverse = slice(0, None) reverse = slice(None, None, -1) width = self.barwidth height = self.barheight nba...
[ "def", "draw", "(", "self", ")", ":", "obverse", "=", "slice", "(", "0", ",", "None", ")", "reverse", "=", "slice", "(", "None", ",", "None", ",", "-", "1", ")", "width", "=", "self", ".", "barwidth", "height", "=", "self", ".", "barheight", "nba...
Draw guide Returns ------- out : matplotlib.offsetbox.Offsetbox A drawing of this legend
[ "Draw", "guide" ]
python
train
dsoprea/PySecure
pysecure/adapters/sftpa.py
https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/adapters/sftpa.py#L698-L709
def open(self): """This is the only way to open a file resource.""" self.__sf = _sftp_open(self.__sftp_session_int, self.__filepath, self.access_type_int, self.__create_mode) if self.access_type_is_...
[ "def", "open", "(", "self", ")", ":", "self", ".", "__sf", "=", "_sftp_open", "(", "self", ".", "__sftp_session_int", ",", "self", ".", "__filepath", ",", "self", ".", "access_type_int", ",", "self", ".", "__create_mode", ")", "if", "self", ".", "access_...
This is the only way to open a file resource.
[ "This", "is", "the", "only", "way", "to", "open", "a", "file", "resource", "." ]
python
train
google/textfsm
textfsm/terminal.py
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L385-L404
def _Scroll(self, lines=None): """Set attributes to scroll the buffer correctly. Args: lines: An int, number of lines to scroll. If None, scrolls by the terminal length. """ if lines is None: lines = self._cli_lines if lines < 0: self._displayed -= self._cli_lines s...
[ "def", "_Scroll", "(", "self", ",", "lines", "=", "None", ")", ":", "if", "lines", "is", "None", ":", "lines", "=", "self", ".", "_cli_lines", "if", "lines", "<", "0", ":", "self", ".", "_displayed", "-=", "self", ".", "_cli_lines", "self", ".", "_...
Set attributes to scroll the buffer correctly. Args: lines: An int, number of lines to scroll. If None, scrolls by the terminal length.
[ "Set", "attributes", "to", "scroll", "the", "buffer", "correctly", "." ]
python
train
openstax/cnx-archive
cnxarchive/sitemap.py
https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/sitemap.py#L153-L170
def generate(self, root_element=None): """Create <url> element under root_element.""" if root_element is not None: url = etree.SubElement(root_element, 'url') else: url = etree.Element('url') etree.SubElement(url, 'loc').text = self.loc if self.lastmod: ...
[ "def", "generate", "(", "self", ",", "root_element", "=", "None", ")", ":", "if", "root_element", "is", "not", "None", ":", "url", "=", "etree", ".", "SubElement", "(", "root_element", ",", "'url'", ")", "else", ":", "url", "=", "etree", ".", "Element"...
Create <url> element under root_element.
[ "Create", "<url", ">", "element", "under", "root_element", "." ]
python
train
ArchiveTeam/wpull
wpull/thirdparty/dammit.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/thirdparty/dammit.py#L383-L398
def _sub_ms_char(self, match): """Changes a MS smart quote character to an XML or HTML entity, or an ASCII character.""" orig = match.group(1) if self.smart_quotes_to == 'ascii': sub = self.MS_CHARS_TO_ASCII.get(orig).encode() else: sub = self.MS_CHARS.get...
[ "def", "_sub_ms_char", "(", "self", ",", "match", ")", ":", "orig", "=", "match", ".", "group", "(", "1", ")", "if", "self", ".", "smart_quotes_to", "==", "'ascii'", ":", "sub", "=", "self", ".", "MS_CHARS_TO_ASCII", ".", "get", "(", "orig", ")", "."...
Changes a MS smart quote character to an XML or HTML entity, or an ASCII character.
[ "Changes", "a", "MS", "smart", "quote", "character", "to", "an", "XML", "or", "HTML", "entity", "or", "an", "ASCII", "character", "." ]
python
train
atztogo/phonopy
phonopy/structure/cells.py
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L595-L741
def get_smallest_vectors(supercell_bases, supercell_pos, primitive_pos, symprec=1e-5): """Find shortest atomic pair vectors Note ---- Shortest vectors from an atom in primitive cell to an atom in supercell in the fractional ...
[ "def", "get_smallest_vectors", "(", "supercell_bases", ",", "supercell_pos", ",", "primitive_pos", ",", "symprec", "=", "1e-5", ")", ":", "reduced_bases", "=", "get_reduced_bases", "(", "supercell_bases", ",", "method", "=", "'delaunay'", ",", "tolerance", "=", "s...
Find shortest atomic pair vectors Note ---- Shortest vectors from an atom in primitive cell to an atom in supercell in the fractional coordinates of primitive cell. If an atom in supercell is on the border centered at an atom in primitive and there are multiple vectors that have the same di...
[ "Find", "shortest", "atomic", "pair", "vectors" ]
python
train