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
pypa/pipenv
pipenv/vendor/requests/utils.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/utils.py#L589-L608
def requote_uri(uri): """Re-quote the given URI. This function passes the given URI through an unquote/quote cycle to ensure that it is fully and consistently quoted. :rtype: str """ safe_with_percent = "!#$%&'()*+,/:;=?@[]~" safe_without_percent = "!#$&'()*+,/:;=?@[]~" try: # ...
[ "def", "requote_uri", "(", "uri", ")", ":", "safe_with_percent", "=", "\"!#$%&'()*+,/:;=?@[]~\"", "safe_without_percent", "=", "\"!#$&'()*+,/:;=?@[]~\"", "try", ":", "# Unquote only the unreserved characters", "# Then quote only illegal characters (do not quote reserved,", "# unreser...
Re-quote the given URI. This function passes the given URI through an unquote/quote cycle to ensure that it is fully and consistently quoted. :rtype: str
[ "Re", "-", "quote", "the", "given", "URI", "." ]
python
train
saltstack/salt
salt/modules/lxc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L3227-L3251
def systemd_running_state(name, path=None): ''' Get the operational state of a systemd based container path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion lxc.systemd_...
[ "def", "systemd_running_state", "(", "name", ",", "path", "=", "None", ")", ":", "try", ":", "ret", "=", "run_all", "(", "name", ",", "'systemctl is-system-running'", ",", "path", "=", "path", ",", "ignore_retcode", "=", "True", ")", "[", "'stdout'", "]", ...
Get the operational state of a systemd based container path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion lxc.systemd_running_state ubuntu
[ "Get", "the", "operational", "state", "of", "a", "systemd", "based", "container" ]
python
train
reingart/gui2py
gui/resource.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/resource.py#L126-L155
def build_component(res, parent=None): "Create a gui2py control based on the python resource" # control specs (parameters) kwargs = dict(res.items()) comtype = kwargs.pop('type') if 'components' in res: components = kwargs.pop('components') elif comtype == 'Menu' and 'items' in res: ...
[ "def", "build_component", "(", "res", ",", "parent", "=", "None", ")", ":", "# control specs (parameters)", "kwargs", "=", "dict", "(", "res", ".", "items", "(", ")", ")", "comtype", "=", "kwargs", ".", "pop", "(", "'type'", ")", "if", "'components'", "i...
Create a gui2py control based on the python resource
[ "Create", "a", "gui2py", "control", "based", "on", "the", "python", "resource" ]
python
test
juicer/juicer
juicer/common/Repo.py
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Repo.py#L113-L121
def to_juicer_repo(self): """Returns a JuicerRepo() object representing this pulp repo""" repo_def = {} defaults = juicer.common.Constants.REPO_DEF_DEFAULTS repo_def['name'] = self['name'] for key in juicer.common.Constants.REPO_DEF_OPT_KEYS: repo_def[key] = self.spec...
[ "def", "to_juicer_repo", "(", "self", ")", ":", "repo_def", "=", "{", "}", "defaults", "=", "juicer", ".", "common", ".", "Constants", ".", "REPO_DEF_DEFAULTS", "repo_def", "[", "'name'", "]", "=", "self", "[", "'name'", "]", "for", "key", "in", "juicer"...
Returns a JuicerRepo() object representing this pulp repo
[ "Returns", "a", "JuicerRepo", "()", "object", "representing", "this", "pulp", "repo" ]
python
train
nerox8664/pytorch2keras
pytorch2keras/operation_layers.py
https://github.com/nerox8664/pytorch2keras/blob/750eaf747323580e6732d0c5ba9f2f39cb096764/pytorch2keras/operation_layers.py#L60-L89
def convert_concat(params, w_name, scope_name, inputs, layers, weights, names): """ Convert concatenation. Args: params: dictionary with layer parameters w_name: name prefix in state_dict scope_name: pytorch scope name inputs: pytorch node inputs layers: dictionary w...
[ "def", "convert_concat", "(", "params", ",", "w_name", ",", "scope_name", ",", "inputs", ",", "layers", ",", "weights", ",", "names", ")", ":", "print", "(", "'Converting concat ...'", ")", "concat_nodes", "=", "[", "layers", "[", "i", "]", "for", "i", "...
Convert concatenation. Args: params: dictionary with layer parameters w_name: name prefix in state_dict scope_name: pytorch scope name inputs: pytorch node inputs layers: dictionary with keras tensors weights: pytorch state_dict names: use short names for ker...
[ "Convert", "concatenation", "." ]
python
valid
saltstack/salt
salt/states/rabbitmq_user.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rabbitmq_user.py#L232-L272
def absent(name, runas=None): ''' Ensure the named user is absent name The name of the user to remove runas User to run the command ''' ret = {'name': name, 'result': False, 'comment': '', 'changes': {}} try: user_exists = __salt__['rabbitmq.user_exists']...
[ "def", "absent", "(", "name", ",", "runas", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "try", ":", "user_exists", "=", "__salt__",...
Ensure the named user is absent name The name of the user to remove runas User to run the command
[ "Ensure", "the", "named", "user", "is", "absent" ]
python
train
oasis-open/cti-stix-validator
stix2validator/v21/shoulds.py
https://github.com/oasis-open/cti-stix-validator/blob/a607014e3fa500a7678f8b61b278456ca581f9d0/stix2validator/v21/shoulds.py#L733-L741
def network_traffic_ports(instance): """Ensure network-traffic objects contain both src_port and dst_port. """ for key, obj in instance['objects'].items(): if ('type' in obj and obj['type'] == 'network-traffic' and ('src_port' not in obj or 'dst_port' not in obj)): yield ...
[ "def", "network_traffic_ports", "(", "instance", ")", ":", "for", "key", ",", "obj", "in", "instance", "[", "'objects'", "]", ".", "items", "(", ")", ":", "if", "(", "'type'", "in", "obj", "and", "obj", "[", "'type'", "]", "==", "'network-traffic'", "a...
Ensure network-traffic objects contain both src_port and dst_port.
[ "Ensure", "network", "-", "traffic", "objects", "contain", "both", "src_port", "and", "dst_port", "." ]
python
train
saltstack/salt
salt/key.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L750-L768
def delete_all(self): ''' Delete all keys ''' for status, keys in six.iteritems(self.list_keys()): for key in keys: try: os.remove(os.path.join(self.opts['pki_dir'], status, key)) eload = {'result': True, ...
[ "def", "delete_all", "(", "self", ")", ":", "for", "status", ",", "keys", "in", "six", ".", "iteritems", "(", "self", ".", "list_keys", "(", ")", ")", ":", "for", "key", "in", "keys", ":", "try", ":", "os", ".", "remove", "(", "os", ".", "path", ...
Delete all keys
[ "Delete", "all", "keys" ]
python
train
stevearc/dynamo3
dynamo3/connection.py
https://github.com/stevearc/dynamo3/blob/f897c40ece28586272dbcab8f0d99a14a1831dda/dynamo3/connection.py#L378-L436
def create_table(self, tablename, hash_key, range_key=None, indexes=None, global_indexes=None, throughput=None, wait=False): """ Create a table Parameters ---------- tablename : str Name of the table hash_key : :class:`~dynamo3.fields.Dyn...
[ "def", "create_table", "(", "self", ",", "tablename", ",", "hash_key", ",", "range_key", "=", "None", ",", "indexes", "=", "None", ",", "global_indexes", "=", "None", ",", "throughput", "=", "None", ",", "wait", "=", "False", ")", ":", "if", "throughput"...
Create a table Parameters ---------- tablename : str Name of the table hash_key : :class:`~dynamo3.fields.DynamoKey` The key to use as the Hash key range_key : :class:`~dynamo3.fields.DynamoKey`, optional The key to use as the Range key ...
[ "Create", "a", "table" ]
python
train
signetlabdei/sem
sem/database.py
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/database.py#L329-L377
def get_complete_results(self, params=None, result_id=None): """ Return available results, analogously to what get_results does, but also read the corresponding output files for each result, and incorporate them in the result dictionary under the output key, as a dictionary of fi...
[ "def", "get_complete_results", "(", "self", ",", "params", "=", "None", ",", "result_id", "=", "None", ")", ":", "if", "result_id", "is", "not", "None", ":", "results", "=", "deepcopy", "(", "self", ".", "get_results", "(", "result_id", "=", "result_id", ...
Return available results, analogously to what get_results does, but also read the corresponding output files for each result, and incorporate them in the result dictionary under the output key, as a dictionary of filename: file_contents. Args: params (dict): parameter specific...
[ "Return", "available", "results", "analogously", "to", "what", "get_results", "does", "but", "also", "read", "the", "corresponding", "output", "files", "for", "each", "result", "and", "incorporate", "them", "in", "the", "result", "dictionary", "under", "the", "o...
python
train
pybel/pybel-tools
src/pybel_tools/summary/edge_summary.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/edge_summary.py#L41-L46
def group_dict_set(iterator: Iterable[Tuple[A, B]]) -> Mapping[A, Set[B]]: """Make a dict that accumulates the values for each key in an iterator of doubles.""" d = defaultdict(set) for key, value in iterator: d[key].add(value) return dict(d)
[ "def", "group_dict_set", "(", "iterator", ":", "Iterable", "[", "Tuple", "[", "A", ",", "B", "]", "]", ")", "->", "Mapping", "[", "A", ",", "Set", "[", "B", "]", "]", ":", "d", "=", "defaultdict", "(", "set", ")", "for", "key", ",", "value", "i...
Make a dict that accumulates the values for each key in an iterator of doubles.
[ "Make", "a", "dict", "that", "accumulates", "the", "values", "for", "each", "key", "in", "an", "iterator", "of", "doubles", "." ]
python
valid
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L171-L196
def set_sensors(self, sensors): """ Sets the 4 sensors with temperature in degree Celcius. :param sensors: list of 4 sensor temperatures corresponding to sensor 1 = I/0 controller inlet sensor 2 = I/0 controller outlet sensor 3 = NPE inlet sensor 4 = NPE outlet ...
[ "def", "set_sensors", "(", "self", ",", "sensors", ")", ":", "sensor_id", "=", "0", "for", "sensor", "in", "sensors", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'c7200 set_temp_sensor \"{name}\" {sensor_id} {temp}'", ".", "format", "(",...
Sets the 4 sensors with temperature in degree Celcius. :param sensors: list of 4 sensor temperatures corresponding to sensor 1 = I/0 controller inlet sensor 2 = I/0 controller outlet sensor 3 = NPE inlet sensor 4 = NPE outlet Example: [22, 22, 22, 22]
[ "Sets", "the", "4", "sensors", "with", "temperature", "in", "degree", "Celcius", "." ]
python
train
numenta/nupic
src/nupic/algorithms/backtracking_tm.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2190-L2298
def _learnBacktrack(self): """ This "backtracks" our learning state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref lrnActiveState['t'] if it does manage to lock on to a sequence that started e...
[ "def", "_learnBacktrack", "(", "self", ")", ":", "# How much input history have we accumulated?", "# The current input is always at the end of self._prevInfPatterns (at", "# index -1), and is not a valid startingOffset to evaluate.", "numPrevPatterns", "=", "len", "(", "self", ".", "_p...
This "backtracks" our learning state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref lrnActiveState['t'] if it does manage to lock on to a sequence that started earlier. :returns: >0 if w...
[ "This", "backtracks", "our", "learning", "state", "trying", "to", "see", "if", "we", "can", "lock", "onto", "the", "current", "set", "of", "inputs", "by", "assuming", "the", "sequence", "started", "up", "to", "N", "steps", "ago", "on", "start", "cells", ...
python
valid
tomnor/channelpack
channelpack/datautils.py
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L174-L192
def slicelist(b): """Produce a list of slices given the boolean array b. Start and stop in each slice describe the True sections in b.""" slicelst = [] started = False for i, e in enumerate(b): if e and not started: start = i started = True elif not e and st...
[ "def", "slicelist", "(", "b", ")", ":", "slicelst", "=", "[", "]", "started", "=", "False", "for", "i", ",", "e", "in", "enumerate", "(", "b", ")", ":", "if", "e", "and", "not", "started", ":", "start", "=", "i", "started", "=", "True", "elif", ...
Produce a list of slices given the boolean array b. Start and stop in each slice describe the True sections in b.
[ "Produce", "a", "list", "of", "slices", "given", "the", "boolean", "array", "b", "." ]
python
train
manrajgrover/halo
halo/halo.py
https://github.com/manrajgrover/halo/blob/0ac5149dea965b27b09f0776df9095ebf013fb4d/halo/halo.py#L359-L379
def frame(self): """Builds and returns the frame to be rendered Returns ------- self """ frames = self._spinner['frames'] frame = frames[self._frame_index] if self._color: frame = colored_frame(frame, self._color) self._frame_index +=...
[ "def", "frame", "(", "self", ")", ":", "frames", "=", "self", ".", "_spinner", "[", "'frames'", "]", "frame", "=", "frames", "[", "self", ".", "_frame_index", "]", "if", "self", ".", "_color", ":", "frame", "=", "colored_frame", "(", "frame", ",", "s...
Builds and returns the frame to be rendered Returns ------- self
[ "Builds", "and", "returns", "the", "frame", "to", "be", "rendered", "Returns", "-------", "self" ]
python
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/core_v1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L6391-L6416
def create_namespaced_pod_eviction(self, name, namespace, body, **kwargs): # noqa: E501 """create_namespaced_pod_eviction # noqa: E501 create eviction of a Pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asyn...
[ "def", "create_namespaced_pod_eviction", "(", "self", ",", "name", ",", "namespace", ",", "body", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ...
create_namespaced_pod_eviction # noqa: E501 create eviction of a Pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_namespaced_pod_eviction(name, namespace, body, async_req=...
[ "create_namespaced_pod_eviction", "#", "noqa", ":", "E501" ]
python
train
mitsei/dlkit
dlkit/json_/resource/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/sessions.py#L3012-L3031
def is_child_of_bin(self, id_, bin_id): """Tests if a bin is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: bin_id (osid.id.Id): the ``Id`` of a bin return: (boolean) - ``true`` if the ``id`` is a child of ``bin_id,`` ``false`` otherwise r...
[ "def", "is_child_of_bin", "(", "self", ",", "id_", ",", "bin_id", ")", ":", "# Implemented from template for", "# osid.resource.BinHierarchySession.is_child_of_bin", "if", "self", ".", "_catalog_session", "is", "not", "None", ":", "return", "self", ".", "_catalog_sessio...
Tests if a bin is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: bin_id (osid.id.Id): the ``Id`` of a bin return: (boolean) - ``true`` if the ``id`` is a child of ``bin_id,`` ``false`` otherwise raise: NotFound - ``bin_id`` is not found r...
[ "Tests", "if", "a", "bin", "is", "a", "direct", "child", "of", "another", "." ]
python
train
anjianshi/flask-restful-extend
flask_restful_extend/model_reqparse.py
https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/model_reqparse.py#L18-L61
def make_request_parser(model_or_inst, excludes=None, only=None, for_populate=False): """Pass a `model class` or `model instance` to this function, then, it will generate a `RequestParser` that extract user request data from `request.json` according to the model class's definition. Parameter `exclude...
[ "def", "make_request_parser", "(", "model_or_inst", ",", "excludes", "=", "None", ",", "only", "=", "None", ",", "for_populate", "=", "False", ")", ":", "is_inst", "=", "_is_inst", "(", "model_or_inst", ")", "if", "isinstance", "(", "excludes", ",", "six", ...
Pass a `model class` or `model instance` to this function, then, it will generate a `RequestParser` that extract user request data from `request.json` according to the model class's definition. Parameter `excludes` and `only` can be `str` or list of `str`, then are used to specify which columns shou...
[ "Pass", "a", "model", "class", "or", "model", "instance", "to", "this", "function", "then", "it", "will", "generate", "a", "RequestParser", "that", "extract", "user", "request", "data", "from", "request", ".", "json", "according", "to", "the", "model", "clas...
python
train
Shapeways/coyote_framework
coyote_framework/webdriver/webdriverwrapper/WebDriverWrapper.py
https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/webdriver/webdriverwrapper/WebDriverWrapper.py#L418-L446
def find_by_dynamic_locator(self, template_locator, variables, find_all=False, search_object=None): ''' Find with dynamic locator @type template_locator: webdriverwrapper.support.locator.Locator @param template_locator: Template locator w/ formatting bits to insert ...
[ "def", "find_by_dynamic_locator", "(", "self", ",", "template_locator", ",", "variables", ",", "find_all", "=", "False", ",", "search_object", "=", "None", ")", ":", "template_variable_character", "=", "'%'", "# raise an exception if user passed non-dictionary variables", ...
Find with dynamic locator @type template_locator: webdriverwrapper.support.locator.Locator @param template_locator: Template locator w/ formatting bits to insert @type variables: dict @param variables: Dictionary of variable substitutions ...
[ "Find", "with", "dynamic", "locator" ]
python
train
aodag/WebDispatch
webdispatch/urldispatcher.py
https://github.com/aodag/WebDispatch/blob/55f8658a2b4100498e098a80303a346c3940f1bc/webdispatch/urldispatcher.py#L65-L67
def make_full_qualified_url(self, path: str) -> str: """ append application url to path""" return self.application_uri.rstrip('/') + '/' + path.lstrip('/')
[ "def", "make_full_qualified_url", "(", "self", ",", "path", ":", "str", ")", "->", "str", ":", "return", "self", ".", "application_uri", ".", "rstrip", "(", "'/'", ")", "+", "'/'", "+", "path", ".", "lstrip", "(", "'/'", ")" ]
append application url to path
[ "append", "application", "url", "to", "path" ]
python
train
casebeer/python-hkdf
hkdf.py
https://github.com/casebeer/python-hkdf/blob/cc3c9dbf0a271b27a7ac5cd04cc1485bbc3b4307/hkdf.py#L10-L25
def hkdf_extract(salt, input_key_material, hash=hashlib.sha512): ''' Extract a pseudorandom key suitable for use with hkdf_expand from the input_key_material and a salt using HMAC with the provided hash (default SHA-512). salt should be a random, application-specific byte string. If salt is None or the empty str...
[ "def", "hkdf_extract", "(", "salt", ",", "input_key_material", ",", "hash", "=", "hashlib", ".", "sha512", ")", ":", "hash_len", "=", "hash", "(", ")", ".", "digest_size", "if", "salt", "==", "None", "or", "len", "(", "salt", ")", "==", "0", ":", "sa...
Extract a pseudorandom key suitable for use with hkdf_expand from the input_key_material and a salt using HMAC with the provided hash (default SHA-512). salt should be a random, application-specific byte string. If salt is None or the empty string, an all-zeros string of the same length as the hash's block size w...
[ "Extract", "a", "pseudorandom", "key", "suitable", "for", "use", "with", "hkdf_expand", "from", "the", "input_key_material", "and", "a", "salt", "using", "HMAC", "with", "the", "provided", "hash", "(", "default", "SHA", "-", "512", ")", "." ]
python
train
sorgerlab/indra
indra/sources/rlimsp/api.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/api.py#L62-L88
def process_from_json_file(filename, doc_id_type=None): """Process RLIMSP extractions from a bulk-download JSON file. Parameters ---------- filename : str Path to the JSON file. doc_id_type : Optional[str] In some cases the RLIMS-P paragraph info doesn't contain 'pmid' or 'p...
[ "def", "process_from_json_file", "(", "filename", ",", "doc_id_type", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'rt'", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "json_list", "=", "[", "]", "for", "line", ...
Process RLIMSP extractions from a bulk-download JSON file. Parameters ---------- filename : str Path to the JSON file. doc_id_type : Optional[str] In some cases the RLIMS-P paragraph info doesn't contain 'pmid' or 'pmcid' explicitly, instead if contains a 'docId' key. This param...
[ "Process", "RLIMSP", "extractions", "from", "a", "bulk", "-", "download", "JSON", "file", "." ]
python
train
tanghaibao/jcvi
jcvi/variation/phase.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/variation/phase.py#L53-L74
def counts(args): """ %prog counts vcffile Collect allele counts from RO and AO fields. """ p = OptionParser(counts.__doc__) opts, args = p.parse_args(args) if len(args) != 1: sys.exit(not p.print_help()) vcffile, = args vcf_reader = vcf.Reader(open(vcffile)) for r in ...
[ "def", "counts", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "counts", ".", "__doc__", ")", "opts", ",", "args", "=", "p", ".", "parse_args", "(", "args", ")", "if", "len", "(", "args", ")", "!=", "1", ":", "sys", ".", "exit", "(", "n...
%prog counts vcffile Collect allele counts from RO and AO fields.
[ "%prog", "counts", "vcffile" ]
python
train
google/grr
grr/server/grr_response_server/aff4_objects/filestore.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L84-L114
def AddFile(self, fd, external=True): """Create a new file in the file store. We delegate the actual file addition to our contained implementations. Implementations can either implement the AddFile() method, returning a file like object which will be written on, or directly support the AddBlobToSto...
[ "def", "AddFile", "(", "self", ",", "fd", ",", "external", "=", "True", ")", ":", "files_for_write", "=", "[", "]", "for", "sub_store", "in", "self", ".", "GetChildrenByPriority", "(", "allow_external", "=", "external", ")", ":", "new_file", "=", "sub_stor...
Create a new file in the file store. We delegate the actual file addition to our contained implementations. Implementations can either implement the AddFile() method, returning a file like object which will be written on, or directly support the AddBlobToStore() method which can copy the VFSBlobImage e...
[ "Create", "a", "new", "file", "in", "the", "file", "store", "." ]
python
train
cdgriffith/puremagic
puremagic/main.py
https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L171-L184
def from_string(string, mime=False, filename=None): """ Reads in string, attempts to identify content based off magic number and will return the file extension. If mime is True it will return the mime type instead. If filename is provided it will be used in the computation. :param string: string re...
[ "def", "from_string", "(", "string", ",", "mime", "=", "False", ",", "filename", "=", "None", ")", ":", "head", ",", "foot", "=", "_string_details", "(", "string", ")", "ext", "=", "ext_from_filename", "(", "filename", ")", "if", "filename", "else", "Non...
Reads in string, attempts to identify content based off magic number and will return the file extension. If mime is True it will return the mime type instead. If filename is provided it will be used in the computation. :param string: string representation to check :param mime: Return mime, not exte...
[ "Reads", "in", "string", "attempts", "to", "identify", "content", "based", "off", "magic", "number", "and", "will", "return", "the", "file", "extension", ".", "If", "mime", "is", "True", "it", "will", "return", "the", "mime", "type", "instead", ".", "If", ...
python
train
metacloud/gilt
gilt/config.py
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/config.py#L145-L156
def _get_dst_dir(dst_dir): """ Prefix the provided string with working directory and return a str. :param dst_dir: A string to be prefixed with the working dir. :return: str """ wd = os.getcwd() _makedirs(dst_dir) return os.path.join(wd, dst_dir)
[ "def", "_get_dst_dir", "(", "dst_dir", ")", ":", "wd", "=", "os", ".", "getcwd", "(", ")", "_makedirs", "(", "dst_dir", ")", "return", "os", ".", "path", ".", "join", "(", "wd", ",", "dst_dir", ")" ]
Prefix the provided string with working directory and return a str. :param dst_dir: A string to be prefixed with the working dir. :return: str
[ "Prefix", "the", "provided", "string", "with", "working", "directory", "and", "return", "a", "str", "." ]
python
train
orbingol/NURBS-Python
geomdl/fitting.py
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L212-L355
def approximate_surface(points, size_u, size_v, degree_u, degree_v, **kwargs): """ Surface approximation using least squares method with fixed number of control points. This algorithm interpolates the corner control points and approximates the remaining control points. Please refer to Algorithm A9.7 of The...
[ "def", "approximate_surface", "(", "points", ",", "size_u", ",", "size_v", ",", "degree_u", ",", "degree_v", ",", "*", "*", "kwargs", ")", ":", "# Keyword arguments", "use_centripetal", "=", "kwargs", ".", "get", "(", "'centripetal'", ",", "False", ")", "num...
Surface approximation using least squares method with fixed number of control points. This algorithm interpolates the corner control points and approximates the remaining control points. Please refer to Algorithm A9.7 of The NURBS Book (2nd Edition), pp.422-423 for details. Keyword Arguments: * ``...
[ "Surface", "approximation", "using", "least", "squares", "method", "with", "fixed", "number", "of", "control", "points", "." ]
python
train
iotile/coretools
iotilecore/iotile/core/hw/update/record.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/update/record.py#L82-L92
def LoadPlugins(cls): """Load all registered iotile.update_record plugins.""" if cls.PLUGINS_LOADED: return reg = ComponentRegistry() for _, record in reg.load_extensions('iotile.update_record'): cls.RegisterRecordType(record) cls.PLUGINS_LOADED = True
[ "def", "LoadPlugins", "(", "cls", ")", ":", "if", "cls", ".", "PLUGINS_LOADED", ":", "return", "reg", "=", "ComponentRegistry", "(", ")", "for", "_", ",", "record", "in", "reg", ".", "load_extensions", "(", "'iotile.update_record'", ")", ":", "cls", ".", ...
Load all registered iotile.update_record plugins.
[ "Load", "all", "registered", "iotile", ".", "update_record", "plugins", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/module.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/module.py#L388-L409
def open_handle(self): """ Opens a new handle to the module. The new handle is stored in the L{hFile} property. """ if not self.get_filename(): msg = "Cannot retrieve filename for module at %s" msg = msg % HexDump.address( self.get_base() ) r...
[ "def", "open_handle", "(", "self", ")", ":", "if", "not", "self", ".", "get_filename", "(", ")", ":", "msg", "=", "\"Cannot retrieve filename for module at %s\"", "msg", "=", "msg", "%", "HexDump", ".", "address", "(", "self", ".", "get_base", "(", ")", ")...
Opens a new handle to the module. The new handle is stored in the L{hFile} property.
[ "Opens", "a", "new", "handle", "to", "the", "module", "." ]
python
train
rflamary/POT
ot/stochastic.py
https://github.com/rflamary/POT/blob/c5108efc7b6702e1af3928bef1032e6b37734d1c/ot/stochastic.py#L266-L338
def c_transform_entropic(b, M, reg, beta): ''' The goal is to recover u from the c-transform. The function computes the c_transform of a dual variable from the other dual variable: .. math:: u = v^{c,reg} = -reg \sum_j exp((v - M)/reg) b_j Where : - M is the (ns,nt) metric cost m...
[ "def", "c_transform_entropic", "(", "b", ",", "M", ",", "reg", ",", "beta", ")", ":", "n_source", "=", "np", ".", "shape", "(", "M", ")", "[", "0", "]", "alpha", "=", "np", ".", "zeros", "(", "n_source", ")", "for", "i", "in", "range", "(", "n_...
The goal is to recover u from the c-transform. The function computes the c_transform of a dual variable from the other dual variable: .. math:: u = v^{c,reg} = -reg \sum_j exp((v - M)/reg) b_j Where : - M is the (ns,nt) metric cost matrix - u, v are dual variables in R^IxR^J - re...
[ "The", "goal", "is", "to", "recover", "u", "from", "the", "c", "-", "transform", "." ]
python
train
wglass/lighthouse
lighthouse/haproxy/stanzas/stanza.py
https://github.com/wglass/lighthouse/blob/f4ce6550895acc31e433ede0c05d366718a3ffe5/lighthouse/haproxy/stanzas/stanza.py#L36-L48
def add_line(self, line): """ Adds a given line string to the list of lines, validating the line first. """ if not self.is_valid_line(line): logger.warn( "Invalid line for %s section: '%s'", self.section_name, line ) ...
[ "def", "add_line", "(", "self", ",", "line", ")", ":", "if", "not", "self", ".", "is_valid_line", "(", "line", ")", ":", "logger", ".", "warn", "(", "\"Invalid line for %s section: '%s'\"", ",", "self", ".", "section_name", ",", "line", ")", "return", "sel...
Adds a given line string to the list of lines, validating the line first.
[ "Adds", "a", "given", "line", "string", "to", "the", "list", "of", "lines", "validating", "the", "line", "first", "." ]
python
train
Neurita/boyle
boyle/nifti/sets.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/sets.py#L167-L197
def _load_images_and_labels(self, images, labels=None): """Read the images, load them into self.items and set the labels.""" if not isinstance(images, (list, tuple)): raise ValueError('Expected an iterable (list or tuple) of strings or img-like objects. ' 'Got a ...
[ "def", "_load_images_and_labels", "(", "self", ",", "images", ",", "labels", "=", "None", ")", ":", "if", "not", "isinstance", "(", "images", ",", "(", "list", ",", "tuple", ")", ")", ":", "raise", "ValueError", "(", "'Expected an iterable (list or tuple) of s...
Read the images, load them into self.items and set the labels.
[ "Read", "the", "images", "load", "them", "into", "self", ".", "items", "and", "set", "the", "labels", "." ]
python
valid
pymc-devs/pymc
pymc/Container.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Container.py#L168-L248
def file_items(container, iterable): """ Files away objects into the appropriate attributes of the container. """ # container._value = copy(iterable) container.nodes = set() container.variables = set() container.deterministics = set() container.stochastics = set() container.potenti...
[ "def", "file_items", "(", "container", ",", "iterable", ")", ":", "# container._value = copy(iterable)", "container", ".", "nodes", "=", "set", "(", ")", "container", ".", "variables", "=", "set", "(", ")", "container", ".", "deterministics", "=", "set", "(", ...
Files away objects into the appropriate attributes of the container.
[ "Files", "away", "objects", "into", "the", "appropriate", "attributes", "of", "the", "container", "." ]
python
train
idlesign/django-sitetree
sitetree/sitetreeapp.py
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L472-L493
def current_app_is_admin(self): """Returns boolean whether current application is Admin contrib. :rtype: bool """ is_admin = self._current_app_is_admin if is_admin is None: context = self.current_page_context current_app = getattr( # Try ...
[ "def", "current_app_is_admin", "(", "self", ")", ":", "is_admin", "=", "self", ".", "_current_app_is_admin", "if", "is_admin", "is", "None", ":", "context", "=", "self", ".", "current_page_context", "current_app", "=", "getattr", "(", "# Try from request.resolver_ma...
Returns boolean whether current application is Admin contrib. :rtype: bool
[ "Returns", "boolean", "whether", "current", "application", "is", "Admin", "contrib", "." ]
python
test
davidmogar/cucco
cucco/logging.py
https://github.com/davidmogar/cucco/blob/e2a0ff3342e4a9f25a65c486206a5a2ae1a4dbd4/cucco/logging.py#L5-L23
def initialize_logger(debug): """Set up logger to be used by the library. Args: debug: Wheter to use debug level or not. Returns: A logger ready to be used. """ level = logging.DEBUG if debug else logging.INFO logger = logging.getLogger('cucco') logger.setLevel(level) f...
[ "def", "initialize_logger", "(", "debug", ")", ":", "level", "=", "logging", ".", "DEBUG", "if", "debug", "else", "logging", ".", "INFO", "logger", "=", "logging", ".", "getLogger", "(", "'cucco'", ")", "logger", ".", "setLevel", "(", "level", ")", "form...
Set up logger to be used by the library. Args: debug: Wheter to use debug level or not. Returns: A logger ready to be used.
[ "Set", "up", "logger", "to", "be", "used", "by", "the", "library", "." ]
python
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/termaccess.py
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/termaccess.py#L233-L295
def add_ip_scope(name, description, auth, url, startip=None, endip=None, network_address=None): """ Function takes input of four strings Start Ip, endIp, name, and description to add new Ip Scope to terminal access in the HPE IMC base platform :param name: str Name of the owner of this IP scope ex. 'a...
[ "def", "add_ip_scope", "(", "name", ",", "description", ",", "auth", ",", "url", ",", "startip", "=", "None", ",", "endip", "=", "None", ",", "network_address", "=", "None", ")", ":", "if", "network_address", "is", "not", "None", ":", "nw_address", "=", ...
Function takes input of four strings Start Ip, endIp, name, and description to add new Ip Scope to terminal access in the HPE IMC base platform :param name: str Name of the owner of this IP scope ex. 'admin' :param description: str description of the Ip scope :param auth: requests auth object #usual...
[ "Function", "takes", "input", "of", "four", "strings", "Start", "Ip", "endIp", "name", "and", "description", "to", "add", "new", "Ip", "Scope", "to", "terminal", "access", "in", "the", "HPE", "IMC", "base", "platform" ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/brocade_ras_ext_rpc/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/brocade_ras_ext_rpc/__init__.py#L139-L162
def _set_show_support_save_status(self, v, load=False): """ Setter method for show_support_save_status, mapped from YANG variable /brocade_ras_ext_rpc/show_support_save_status (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_support_save_status is considered as...
[ "def", "_set_show_support_save_status", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v",...
Setter method for show_support_save_status, mapped from YANG variable /brocade_ras_ext_rpc/show_support_save_status (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_support_save_status is considered as a private method. Backends looking to populate this variable sh...
[ "Setter", "method", "for", "show_support_save_status", "mapped", "from", "YANG", "variable", "/", "brocade_ras_ext_rpc", "/", "show_support_save_status", "(", "rpc", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in"...
python
train
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/key_bundle.py
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L786-L842
def key_diff(key_bundle, key_defs): """ Creates a difference dictionary with keys that should added and keys that should be deleted from a Key Bundle to get it updated to a state that mirrors What is in the key_defs specification. :param key_bundle: The original KeyBundle :param key_defs: A set...
[ "def", "key_diff", "(", "key_bundle", ",", "key_defs", ")", ":", "keys", "=", "key_bundle", ".", "get", "(", ")", "diff", "=", "{", "}", "# My own sorted copy", "key_defs", "=", "order_key_defs", "(", "key_defs", ")", "[", ":", "]", "used", "=", "[", "...
Creates a difference dictionary with keys that should added and keys that should be deleted from a Key Bundle to get it updated to a state that mirrors What is in the key_defs specification. :param key_bundle: The original KeyBundle :param key_defs: A set of key definitions :return: A dictionary wi...
[ "Creates", "a", "difference", "dictionary", "with", "keys", "that", "should", "added", "and", "keys", "that", "should", "be", "deleted", "from", "a", "Key", "Bundle", "to", "get", "it", "updated", "to", "a", "state", "that", "mirrors", "What", "is", "in", ...
python
train
ManiacalLabs/BiblioPixel
bibliopixel/util/util.py
https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/util/util.py#L36-L55
def pointOnCircle(cx, cy, radius, angle): """ Calculates the coordinates of a point on a circle given the center point, radius, and angle. """ angle = math.radians(angle) - (math.pi / 2) x = cx + radius * math.cos(angle) if x < cx: x = math.ceil(x) else: x = math.floor(x)...
[ "def", "pointOnCircle", "(", "cx", ",", "cy", ",", "radius", ",", "angle", ")", ":", "angle", "=", "math", ".", "radians", "(", "angle", ")", "-", "(", "math", ".", "pi", "/", "2", ")", "x", "=", "cx", "+", "radius", "*", "math", ".", "cos", ...
Calculates the coordinates of a point on a circle given the center point, radius, and angle.
[ "Calculates", "the", "coordinates", "of", "a", "point", "on", "a", "circle", "given", "the", "center", "point", "radius", "and", "angle", "." ]
python
valid
mottosso/be
be/vendor/requests/packages/urllib3/__init__.py
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/__init__.py#L37-L52
def add_stderr_logger(level=logging.DEBUG): """ Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it. """ # This method needs to be in this __init__.py to get the __name__ correct # even if urllib3 is vendored within another pack...
[ "def", "add_stderr_logger", "(", "level", "=", "logging", ".", "DEBUG", ")", ":", "# This method needs to be in this __init__.py to get the __name__ correct", "# even if urllib3 is vendored within another package.", "logger", "=", "logging", ".", "getLogger", "(", "__name__", "...
Helper for quickly adding a StreamHandler to the logger. Useful for debugging. Returns the handler after adding it.
[ "Helper", "for", "quickly", "adding", "a", "StreamHandler", "to", "the", "logger", ".", "Useful", "for", "debugging", "." ]
python
train
tilde-lab/tilde
tilde/berlinium/cubicspline.py
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/berlinium/cubicspline.py#L23-L77
def uFuncConverter(variableIndex): '''A decorator to convert python functions to numpy universal functions A standard function of 1 variable is extended by a decorator to handle all values in a list, tuple or numpy array :param variableIndex: Specifies index for args to use as variable. This w...
[ "def", "uFuncConverter", "(", "variableIndex", ")", ":", "def", "wrap", "(", "func", ")", ":", "'''Function to wrap around methods and functions\n '''", "def", "npWrapFunc", "(", "*", "args", ")", ":", "'''Function specifying what the wrapping should do\n ''...
A decorator to convert python functions to numpy universal functions A standard function of 1 variable is extended by a decorator to handle all values in a list, tuple or numpy array :param variableIndex: Specifies index for args to use as variable. This way the function can be used in classes as ...
[ "A", "decorator", "to", "convert", "python", "functions", "to", "numpy", "universal", "functions" ]
python
train
yt-project/unyt
unyt/unit_object.py
https://github.com/yt-project/unyt/blob/7a4eafc229f83784f4c63d639aee554f9a6b1ca0/unyt/unit_object.py#L653-L679
def as_coeff_unit(self): """Factor the coefficient multiplying a unit For units that are multiplied by a constant dimensionless coefficient, returns a tuple containing the coefficient and a new unit object for the unmultiplied unit. Example ------- >>> import u...
[ "def", "as_coeff_unit", "(", "self", ")", ":", "coeff", ",", "mul", "=", "self", ".", "expr", ".", "as_coeff_Mul", "(", ")", "coeff", "=", "float", "(", "coeff", ")", "ret", "=", "Unit", "(", "mul", ",", "self", ".", "base_value", "/", "coeff", ","...
Factor the coefficient multiplying a unit For units that are multiplied by a constant dimensionless coefficient, returns a tuple containing the coefficient and a new unit object for the unmultiplied unit. Example ------- >>> import unyt as u >>> unit = (u.m**2/...
[ "Factor", "the", "coefficient", "multiplying", "a", "unit" ]
python
train
BD2KGenomics/protect
src/protect/mutation_calling/somaticsniper.py
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/somaticsniper.py#L168-L243
def filter_somaticsniper(job, tumor_bam, somaticsniper_output, tumor_pileup, univ_options, somaticsniper_options): """ Filter SomaticSniper calls. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param toil.fileStore.FileID somaticsniper_output: SomaticSniper outpu...
[ "def", "filter_somaticsniper", "(", "job", ",", "tumor_bam", ",", "somaticsniper_output", ",", "tumor_pileup", ",", "univ_options", ",", "somaticsniper_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'tumor.bam'", ":...
Filter SomaticSniper calls. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param toil.fileStore.FileID somaticsniper_output: SomaticSniper output vcf :param toil.fileStore.FileID tumor_pileup: Pileup generated for the tumor bam :param dict univ_options: Dict of universal options used by ...
[ "Filter", "SomaticSniper", "calls", "." ]
python
train
rbit/pydtls
dtls/patch.py
https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/patch.py#L100-L123
def _get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): """Retrieve a server certificate Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version'...
[ "def", "_get_server_certificate", "(", "addr", ",", "ssl_version", "=", "PROTOCOL_SSLv23", ",", "ca_certs", "=", "None", ")", ":", "if", "ssl_version", "not", "in", "(", "PROTOCOL_DTLS", ",", "PROTOCOL_DTLSv1", ",", "PROTOCOL_DTLSv1_2", ")", ":", "return", "_ori...
Retrieve a server certificate Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.
[ "Retrieve", "a", "server", "certificate" ]
python
train
nilp0inter/cpe
cpe/comp/cpecomp1_1.py
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L309-L331
def as_wfn(self): r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() ...
[ "def", "as_wfn", "(", "self", ")", ":", "result", "=", "[", "]", "for", "s", "in", "self", ".", "_standard_value", ":", "result", ".", "append", "(", "s", ")", "result", ".", "append", "(", "CPEComponent1_1", ".", "_ESCAPE_SEPARATOR", ")", "return", "\...
r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() 'xp\\!vista'
[ "r", "Returns", "the", "value", "of", "compoment", "encoded", "as", "Well", "-", "Formed", "Name", "(", "WFN", ")", "string", "." ]
python
train
rwl/pylon
pylon/solver.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L260-L277
def _pwl_costs(self, ny, nxyz, ipwl): """ Returns the piece-wise linear components of the objective function. """ any_pwl = int(ny > 0) if any_pwl: y = self.om.get_var("y") # Sum of y vars. Npwl = csr_matrix((ones(ny), (zeros(ny), array(ipwl) + y.i1)))...
[ "def", "_pwl_costs", "(", "self", ",", "ny", ",", "nxyz", ",", "ipwl", ")", ":", "any_pwl", "=", "int", "(", "ny", ">", "0", ")", "if", "any_pwl", ":", "y", "=", "self", ".", "om", ".", "get_var", "(", "\"y\"", ")", "# Sum of y vars.", "Npwl", "=...
Returns the piece-wise linear components of the objective function.
[ "Returns", "the", "piece", "-", "wise", "linear", "components", "of", "the", "objective", "function", "." ]
python
train
brainiak/brainiak
brainiak/funcalign/rsrm.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/funcalign/rsrm.py#L538-L561
def _shrink(v, gamma): """Soft-shrinkage of an array with parameter gamma. Parameters ---------- v : array Array containing the values to be applied to the shrinkage operator gamma : float Shrinkage parameter. Returns ------- v...
[ "def", "_shrink", "(", "v", ",", "gamma", ")", ":", "pos", "=", "v", ">", "gamma", "neg", "=", "v", "<", "-", "gamma", "v", "[", "pos", "]", "-=", "gamma", "v", "[", "neg", "]", "+=", "gamma", "v", "[", "np", ".", "logical_and", "(", "~", "...
Soft-shrinkage of an array with parameter gamma. Parameters ---------- v : array Array containing the values to be applied to the shrinkage operator gamma : float Shrinkage parameter. Returns ------- v : array The same inpu...
[ "Soft", "-", "shrinkage", "of", "an", "array", "with", "parameter", "gamma", "." ]
python
train
portantier/habu
habu/cli/cmd_arp_ping.py
https://github.com/portantier/habu/blob/87091e389dc6332fe1b82830c22b2eefc55816f2/habu/cli/cmd_arp_ping.py#L18-L43
def cmd_arp_ping(ip, iface, verbose): """ Send ARP packets to check if a host it's alive in the local network. Example: \b # habu.arp.ping 192.168.0.1 Ether / ARP is at a4:08:f5:19:17:a4 says 192.168.0.1 / Padding """ if verbose: logging.basicConfig(level=logging.INFO, format=...
[ "def", "cmd_arp_ping", "(", "ip", ",", "iface", ",", "verbose", ")", ":", "if", "verbose", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", "format", "=", "'%(message)s'", ")", "conf", ".", "verb", "=", "False", "if",...
Send ARP packets to check if a host it's alive in the local network. Example: \b # habu.arp.ping 192.168.0.1 Ether / ARP is at a4:08:f5:19:17:a4 says 192.168.0.1 / Padding
[ "Send", "ARP", "packets", "to", "check", "if", "a", "host", "it", "s", "alive", "in", "the", "local", "network", "." ]
python
train
fulfilio/python-magento
magento/catalog.py
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L702-L719
def assign(self, link_type, product, linked_product, data=None, identifierType=None): """ Assign a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linke...
[ "def", "assign", "(", "self", ",", "link_type", ",", "product", ",", "linked_product", ",", "data", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_product_link.assign'", ",", "[", "link...
Assign a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linked_product: ID or SKU of linked product :param data: dictionary of link data, (position, qty, etc.) ...
[ "Assign", "a", "product", "link" ]
python
train
IdentityPython/pyop
src/pyop/provider.py
https://github.com/IdentityPython/pyop/blob/7b1385964f079c39752fce5f2dbcf458b8a92e56/src/pyop/provider.py#L428-L455
def handle_userinfo_request(self, request=None, http_headers=None): # type: (Optional[str], Optional[Mapping[str, str]]) -> oic.oic.message.OpenIDSchema """ Handles a userinfo request. :param request: urlencoded request (either query string or POST body) :param http_headers: http...
[ "def", "handle_userinfo_request", "(", "self", ",", "request", "=", "None", ",", "http_headers", "=", "None", ")", ":", "# type: (Optional[str], Optional[Mapping[str, str]]) -> oic.oic.message.OpenIDSchema", "if", "http_headers", "is", "None", ":", "http_headers", "=", "{...
Handles a userinfo request. :param request: urlencoded request (either query string or POST body) :param http_headers: http headers
[ "Handles", "a", "userinfo", "request", ".", ":", "param", "request", ":", "urlencoded", "request", "(", "either", "query", "string", "or", "POST", "body", ")", ":", "param", "http_headers", ":", "http", "headers" ]
python
train
tk0miya/tk.phpautodoc
src/phply/phpparse.py
https://github.com/tk0miya/tk.phpautodoc/blob/cf789f64abaf76351485cee231a075227e665fb6/src/phply/phpparse.py#L210-L212
def p_statement_switch(p): 'statement : SWITCH LPAREN expr RPAREN switch_case_list' p[0] = ast.Switch(p[3], p[5], lineno=p.lineno(1))
[ "def", "p_statement_switch", "(", "p", ")", ":", "p", "[", "0", "]", "=", "ast", ".", "Switch", "(", "p", "[", "3", "]", ",", "p", "[", "5", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")" ]
statement : SWITCH LPAREN expr RPAREN switch_case_list
[ "statement", ":", "SWITCH", "LPAREN", "expr", "RPAREN", "switch_case_list" ]
python
train
tehmaze/diagram
diagram.py
https://github.com/tehmaze/diagram/blob/1701526a91c14dc8ebc6452c45c8ec9a563a56db/diagram.py#L147-L155
def csi_wrap(self, value, capname, *args): """Return a value wrapped in the selected CSI and does a reset.""" if isinstance(value, str): value = value.encode('utf-8') return b''.join([ self.csi(capname, *args), value, self.csi('sgr0'), ])
[ "def", "csi_wrap", "(", "self", ",", "value", ",", "capname", ",", "*", "args", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "value", ".", "encode", "(", "'utf-8'", ")", "return", "b''", ".", "join", "(", "[", "...
Return a value wrapped in the selected CSI and does a reset.
[ "Return", "a", "value", "wrapped", "in", "the", "selected", "CSI", "and", "does", "a", "reset", "." ]
python
valid
Guake/guake
guake/guake_app.py
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L757-L764
def accel_reset_terminal(self, *args): # TODO KEYBINDINGS ONLY """Callback to reset and clean the terminal""" HidePrevention(self.window).prevent() current_term = self.get_notebook().get_current_terminal() current_term.reset(True, True) HidePrevention(self.window).allow()...
[ "def", "accel_reset_terminal", "(", "self", ",", "*", "args", ")", ":", "# TODO KEYBINDINGS ONLY", "HidePrevention", "(", "self", ".", "window", ")", ".", "prevent", "(", ")", "current_term", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_termin...
Callback to reset and clean the terminal
[ "Callback", "to", "reset", "and", "clean", "the", "terminal" ]
python
train
twisted/twistedchecker
twistedchecker/checkers/comment.py
https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/comment.py#L26-L66
def visit_module(self, node): """ A interface will be called when visiting a module. @param node: node of current module """ if not node.file_stream: # Failed to open the module return isFirstLineOfComment = True isDocString = False ...
[ "def", "visit_module", "(", "self", ",", "node", ")", ":", "if", "not", "node", ".", "file_stream", ":", "# Failed to open the module", "return", "isFirstLineOfComment", "=", "True", "isDocString", "=", "False", "lines", "=", "node", ".", "stream", "(", ")", ...
A interface will be called when visiting a module. @param node: node of current module
[ "A", "interface", "will", "be", "called", "when", "visiting", "a", "module", "." ]
python
train
Clinical-Genomics/scout
scout/server/blueprints/cases/views.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/cases/views.py#L34-L39
def index(): """Display a list of all user institutes.""" institute_objs = user_institutes(store, current_user) institutes_count = ((institute_obj, store.cases(collaborator=institute_obj['_id']).count()) for institute_obj in institute_objs if institute_obj) return dict(institutes...
[ "def", "index", "(", ")", ":", "institute_objs", "=", "user_institutes", "(", "store", ",", "current_user", ")", "institutes_count", "=", "(", "(", "institute_obj", ",", "store", ".", "cases", "(", "collaborator", "=", "institute_obj", "[", "'_id'", "]", ")"...
Display a list of all user institutes.
[ "Display", "a", "list", "of", "all", "user", "institutes", "." ]
python
test
lsst-sqre/lander
lander/ltdclient.py
https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/ltdclient.py#L8-L32
def upload(config): """Upload the build documentation site to LSST the Docs. Parameters ---------- config : `lander.config.Configuration` Site configuration, which includes upload information and credentials. """ token = get_keeper_token(config['keeper_url'], ...
[ "def", "upload", "(", "config", ")", ":", "token", "=", "get_keeper_token", "(", "config", "[", "'keeper_url'", "]", ",", "config", "[", "'keeper_user'", "]", ",", "config", "[", "'keeper_password'", "]", ")", "build_resource", "=", "register_build", "(", "c...
Upload the build documentation site to LSST the Docs. Parameters ---------- config : `lander.config.Configuration` Site configuration, which includes upload information and credentials.
[ "Upload", "the", "build", "documentation", "site", "to", "LSST", "the", "Docs", "." ]
python
train
bykof/billomapy
billomapy/billomapy.py
https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L2174-L2185
def mark_offer_as_win(self, offer_id): """ Mark offer as win :param offer_id: the offer id :return Response """ return self._create_put_request( resource=OFFERS, billomat_id=offer_id, command=WIN, )
[ "def", "mark_offer_as_win", "(", "self", ",", "offer_id", ")", ":", "return", "self", ".", "_create_put_request", "(", "resource", "=", "OFFERS", ",", "billomat_id", "=", "offer_id", ",", "command", "=", "WIN", ",", ")" ]
Mark offer as win :param offer_id: the offer id :return Response
[ "Mark", "offer", "as", "win" ]
python
train
ActiveState/simplealchemy
simplealchemy.py
https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L154-L165
def create_from(cls, another, **kwargs): """Create from another object of different type. Another object must be from a derived class of SimpleObject (which contains FIELDS) """ reused_fields = {} for field, value in another.get_fields(): if field in cls.FIEL...
[ "def", "create_from", "(", "cls", ",", "another", ",", "*", "*", "kwargs", ")", ":", "reused_fields", "=", "{", "}", "for", "field", ",", "value", "in", "another", ".", "get_fields", "(", ")", ":", "if", "field", "in", "cls", ".", "FIELDS", ":", "r...
Create from another object of different type. Another object must be from a derived class of SimpleObject (which contains FIELDS)
[ "Create", "from", "another", "object", "of", "different", "type", "." ]
python
train
joowani/binarytree
binarytree/__init__.py
https://github.com/joowani/binarytree/blob/23cb6f1e60e66b96133259031e97ec03e932ba13/binarytree/__init__.py#L71-L81
def _generate_perfect_bst(height): """Generate a perfect BST (binary search tree) and return its root. :param height: Height of the BST. :type height: int :return: Root node of the BST. :rtype: binarytree.Node """ max_node_count = 2 ** (height + 1) - 1 node_values = list(range(max_node_...
[ "def", "_generate_perfect_bst", "(", "height", ")", ":", "max_node_count", "=", "2", "**", "(", "height", "+", "1", ")", "-", "1", "node_values", "=", "list", "(", "range", "(", "max_node_count", ")", ")", "return", "_build_bst_from_sorted_values", "(", "nod...
Generate a perfect BST (binary search tree) and return its root. :param height: Height of the BST. :type height: int :return: Root node of the BST. :rtype: binarytree.Node
[ "Generate", "a", "perfect", "BST", "(", "binary", "search", "tree", ")", "and", "return", "its", "root", "." ]
python
train
crackinglandia/pype32
pype32/pype32.py
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L449-L456
def _getPaddingToSectionOffset(self): """ Returns the offset to last section header present in the PE file. @rtype: int @return: The offset where the end of the last section header resides in the PE file. """ return len(str(self.dosHeader) + str(self.dosStub) + s...
[ "def", "_getPaddingToSectionOffset", "(", "self", ")", ":", "return", "len", "(", "str", "(", "self", ".", "dosHeader", ")", "+", "str", "(", "self", ".", "dosStub", ")", "+", "str", "(", "self", ".", "ntHeaders", ")", "+", "str", "(", "self", ".", ...
Returns the offset to last section header present in the PE file. @rtype: int @return: The offset where the end of the last section header resides in the PE file.
[ "Returns", "the", "offset", "to", "last", "section", "header", "present", "in", "the", "PE", "file", "." ]
python
train
kytos/python-openflow
pyof/foundation/basic_types.py
https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/basic_types.py#L161-L181
def unpack(self, buff, offset=0): """Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begi...
[ "def", "unpack", "(", "self", ",", "buff", ",", "offset", "=", "0", ")", ":", "begin", "=", "offset", "hexas", "=", "[", "]", "while", "begin", "<", "offset", "+", "8", ":", "number", "=", "struct", ".", "unpack", "(", "\"!B\"", ",", "buff", "[",...
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
[ "Unpack", "a", "binary", "message", "into", "this", "object", "s", "attributes", "." ]
python
train
topic2k/pygcgen
pygcgen/generator.py
https://github.com/topic2k/pygcgen/blob/c41701815df2c8c3a57fd5f7b8babe702127c8a1/pygcgen/generator.py#L249-L267
def generate_sub_section(self, issues, prefix): """ Generate formated list of issues for changelog. :param list issues: Issues to put in sub-section. :param str prefix: Title of sub-section. :rtype: str :return: Generated ready-to-add sub-section. """ lo...
[ "def", "generate_sub_section", "(", "self", ",", "issues", ",", "prefix", ")", ":", "log", "=", "\"\"", "if", "issues", ":", "if", "not", "self", ".", "options", ".", "simple_list", ":", "log", "+=", "u\"{0}\\n\\n\"", ".", "format", "(", "prefix", ")", ...
Generate formated list of issues for changelog. :param list issues: Issues to put in sub-section. :param str prefix: Title of sub-section. :rtype: str :return: Generated ready-to-add sub-section.
[ "Generate", "formated", "list", "of", "issues", "for", "changelog", "." ]
python
valid
Alignak-monitoring/alignak
alignak/objects/schedulingitem.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3437-L3470
def del_act_dependency(self, son_id, parent_id): # pragma: no cover, not yet tested """Remove act_dependency between two hosts or services. TODO: do we really intend to remove dynamically ? :param son_id: uuid of son host/service :type son_id: str :param parent_id: uuid of par...
[ "def", "del_act_dependency", "(", "self", ",", "son_id", ",", "parent_id", ")", ":", "# pragma: no cover, not yet tested", "son", "=", "self", "[", "son_id", "]", "parent", "=", "self", "[", "parent_id", "]", "to_del", "=", "[", "]", "# First we remove in my lis...
Remove act_dependency between two hosts or services. TODO: do we really intend to remove dynamically ? :param son_id: uuid of son host/service :type son_id: str :param parent_id: uuid of parent host/service :type parent_id: str :return: None
[ "Remove", "act_dependency", "between", "two", "hosts", "or", "services", "." ]
python
train
dmlc/xgboost
python-package/xgboost/sklearn.py
https://github.com/dmlc/xgboost/blob/253fdd8a42d5ec6b819788199584d27bf9ea6253/python-package/xgboost/sklearn.py#L217-L226
def get_params(self, deep=False): """Get parameters.""" params = super(XGBModel, self).get_params(deep=deep) if isinstance(self.kwargs, dict): # if kwargs is a dict, update params accordingly params.update(self.kwargs) if params['missing'] is np.nan: params['miss...
[ "def", "get_params", "(", "self", ",", "deep", "=", "False", ")", ":", "params", "=", "super", "(", "XGBModel", ",", "self", ")", ".", "get_params", "(", "deep", "=", "deep", ")", "if", "isinstance", "(", "self", ".", "kwargs", ",", "dict", ")", ":...
Get parameters.
[ "Get", "parameters", "." ]
python
train
clalancette/pycdlib
pycdlib/udf.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L877-L892
def parse(self, data): # type: (bytes) -> None ''' Parse the passed in data into a UDF Entity ID. Parameters: data - The data to parse. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('UDF Enti...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "# type: (bytes) -> None", "if", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'UDF Entity ID already initialized'", ")", "(", "self", ".", "flags", ",", "self"...
Parse the passed in data into a UDF Entity ID. Parameters: data - The data to parse. Returns: Nothing.
[ "Parse", "the", "passed", "in", "data", "into", "a", "UDF", "Entity", "ID", "." ]
python
train
panzarino/mlbgame
mlbgame/data.py
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/data.py#L143-L151
def get_standings(date): """Return the standings file for current standings (given current date).""" try: return urlopen(STANDINGS_URL.format(date.year, date.strftime('%Y/%m/%d'))) except HTTPError: ValueError('Could not find the standings file. ' ...
[ "def", "get_standings", "(", "date", ")", ":", "try", ":", "return", "urlopen", "(", "STANDINGS_URL", ".", "format", "(", "date", ".", "year", ",", "date", ".", "strftime", "(", "'%Y/%m/%d'", ")", ")", ")", "except", "HTTPError", ":", "ValueError", "(", ...
Return the standings file for current standings (given current date).
[ "Return", "the", "standings", "file", "for", "current", "standings", "(", "given", "current", "date", ")", "." ]
python
train
lowandrew/OLCTools
spadespipeline/GeneSeekr.py
https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/GeneSeekr.py#L173-L190
def blastnthreads(self): """Setup and create threads for blastn and xml path""" # Create the threads for the BLAST analysis for i in range(self.cpus): threads = Thread(target=self.runblast, args=()) threads.setDaemon(True) threads.start() # Populate t...
[ "def", "blastnthreads", "(", "self", ")", ":", "# Create the threads for the BLAST analysis", "for", "i", "in", "range", "(", "self", ".", "cpus", ")", ":", "threads", "=", "Thread", "(", "target", "=", "self", ".", "runblast", ",", "args", "=", "(", ")", ...
Setup and create threads for blastn and xml path
[ "Setup", "and", "create", "threads", "for", "blastn", "and", "xml", "path" ]
python
train
iamsteadman/bambu-mail
bambu_mail/views.py
https://github.com/iamsteadman/bambu-mail/blob/5298e6ab861cabc8859c8356ccb2354b1b902cd1/bambu_mail/views.py#L7-L36
def subscribe(request): """ Takes POST data (``email`` and optional ``next`` fields), submitting the ``email`` field to the newsletter provider for subscription to a mailing list, and redirecting the user to the value of ``next`` (this can also be provided in the querystring), or the homepage if no foll...
[ "def", "subscribe", "(", "request", ")", ":", "email", "=", "request", ".", "POST", ".", "get", "(", "'email'", ")", "next", "=", "request", ".", "POST", ".", "get", "(", "'next'", ",", "request", ".", "GET", ".", "get", "(", "'next'", ",", "'/'", ...
Takes POST data (``email`` and optional ``next`` fields), submitting the ``email`` field to the newsletter provider for subscription to a mailing list, and redirecting the user to the value of ``next`` (this can also be provided in the querystring), or the homepage if no follow-on URL is supplied, with a me...
[ "Takes", "POST", "data", "(", "email", "and", "optional", "next", "fields", ")", "submitting", "the", "email", "field", "to", "the", "newsletter", "provider", "for", "subscription", "to", "a", "mailing", "list", "and", "redirecting", "the", "user", "to", "th...
python
train
bolt-project/bolt
bolt/spark/array.py
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L861-L877
def _reshapebasic(self, shape): """ Check if the requested reshape can be broken into independant reshapes on the keys and values. If it can, returns the index in the new shape separating keys from values, otherwise returns -1 """ new = tupleize(shape) old_key_siz...
[ "def", "_reshapebasic", "(", "self", ",", "shape", ")", ":", "new", "=", "tupleize", "(", "shape", ")", "old_key_size", "=", "prod", "(", "self", ".", "keys", ".", "shape", ")", "old_value_size", "=", "prod", "(", "self", ".", "values", ".", "shape", ...
Check if the requested reshape can be broken into independant reshapes on the keys and values. If it can, returns the index in the new shape separating keys from values, otherwise returns -1
[ "Check", "if", "the", "requested", "reshape", "can", "be", "broken", "into", "independant", "reshapes", "on", "the", "keys", "and", "values", ".", "If", "it", "can", "returns", "the", "index", "in", "the", "new", "shape", "separating", "keys", "from", "val...
python
test
CygnusNetworks/pypureomapi
pypureomapi.py
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1332-L1352
def del_host(self, mac): """Delete a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac address could be found @raises socket.error: """ msg = OmapiMessage.open(b"host") msg.obj.append((...
[ "def", "del_host", "(", "self", ",", "mac", ")", ":", "msg", "=", "OmapiMessage", ".", "open", "(", "b\"host\"", ")", "msg", ".", "obj", ".", "append", "(", "(", "b\"hardware-address\"", ",", "pack_mac", "(", "mac", ")", ")", ")", "msg", ".", "obj", ...
Delete a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac address could be found @raises socket.error:
[ "Delete", "a", "host", "object", "with", "with", "given", "mac", "address", "." ]
python
train
pmacosta/peng
peng/functions.py
https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/functions.py#L764-L801
def round_mantissa(arg, decimals=0): """ Round floating point number(s) mantissa to given number of digits. Integers are not altered. The mantissa used is that of the floating point number(s) when expressed in `normalized scientific notation <https://en.wikipedia.org/wiki/Scientific_notation#Normal...
[ "def", "round_mantissa", "(", "arg", ",", "decimals", "=", "0", ")", ":", "if", "arg", "is", "None", ":", "return", "arg", "if", "isinstance", "(", "arg", ",", "np", ".", "ndarray", ")", ":", "foi", "=", "[", "isinstance", "(", "item", ",", "int", ...
Round floating point number(s) mantissa to given number of digits. Integers are not altered. The mantissa used is that of the floating point number(s) when expressed in `normalized scientific notation <https://en.wikipedia.org/wiki/Scientific_notation#Normalized_notation>`_ :param arg: Input data ...
[ "Round", "floating", "point", "number", "(", "s", ")", "mantissa", "to", "given", "number", "of", "digits", "." ]
python
test
wmayner/pyphi
pyphi/examples.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L499-L519
def macro_network(): """A network of micro elements which has greater integrated information after coarse graining to a macro scale. """ tpm = np.array([[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 1.0, 1.0], ...
[ "def", "macro_network", "(", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "0.3", ",", "0.3", ",", "0.3", ",", "0.3", "]", ",", "[", "0.3", ",", "0.3", ",", "0.3", ",", "0.3", "]", ",", "[", "0.3", ",", "0.3", ",", "0.3", ",", ...
A network of micro elements which has greater integrated information after coarse graining to a macro scale.
[ "A", "network", "of", "micro", "elements", "which", "has", "greater", "integrated", "information", "after", "coarse", "graining", "to", "a", "macro", "scale", "." ]
python
train
IceflowRE/unidown
unidown/plugin/link_item.py
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/link_item.py#L37-L49
def from_protobuf(cls, proto: LinkItemProto) -> LinkItem: """ Constructor from protobuf. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto :return: the LinkItem :rtype: ~unidown.plugin.link_item.LinkItem :raises Va...
[ "def", "from_protobuf", "(", "cls", ",", "proto", ":", "LinkItemProto", ")", "->", "LinkItem", ":", "if", "proto", ".", "name", "==", "''", ":", "raise", "ValueError", "(", "\"name of LinkItem does not exist or is empty inside the protobuf.\"", ")", "return", "cls",...
Constructor from protobuf. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto :return: the LinkItem :rtype: ~unidown.plugin.link_item.LinkItem :raises ValueError: name of LinkItem does not exist inside the protobuf or is empty
[ "Constructor", "from", "protobuf", "." ]
python
train
rigetti/rpcq
rpcq/_spec.py
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_spec.py#L86-L100
def get_handler(self, request): """ Get callable from JSON RPC request :param RPCRequest request: JSON RPC request :return: Method :rtype: callable """ try: f = self._json_rpc_methods[request.method] except (AttributeError, KeyError): # prag...
[ "def", "get_handler", "(", "self", ",", "request", ")", ":", "try", ":", "f", "=", "self", ".", "_json_rpc_methods", "[", "request", ".", "method", "]", "except", "(", "AttributeError", ",", "KeyError", ")", ":", "# pragma no coverage", "raise", "RPCMethodEr...
Get callable from JSON RPC request :param RPCRequest request: JSON RPC request :return: Method :rtype: callable
[ "Get", "callable", "from", "JSON", "RPC", "request" ]
python
train
neherlab/treetime
treetime/treeanc.py
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1641-L1724
def optimize_branch_length(self, mode='joint', **kwargs): """ Perform optimization for the branch lengths of the entire tree. This method only does a single path and needs to be iterated. **Note** this method assumes that each node stores information about its sequence as numpy....
[ "def", "optimize_branch_length", "(", "self", ",", "mode", "=", "'joint'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", "(", "\"TreeAnc.optimize_branch_length: running branch length optimization in mode %s...\"", "%", "mode", ",", "1", ")", "if", "(", ...
Perform optimization for the branch lengths of the entire tree. This method only does a single path and needs to be iterated. **Note** this method assumes that each node stores information about its sequence as numpy.array object (node.sequence attribute). Therefore, before calling this...
[ "Perform", "optimization", "for", "the", "branch", "lengths", "of", "the", "entire", "tree", ".", "This", "method", "only", "does", "a", "single", "path", "and", "needs", "to", "be", "iterated", "." ]
python
test
TadLeonard/tfatool
tfatool/util.py
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/util.py#L7-L17
def parse_datetime(datetime_input): """The arrow library is sadly not good enough to parse certain date strings. It even gives unexpected results for partial date strings such as '2015-01' or just '2015', which I think should be seen as 'the first moment of 2014'. This function should overcome those...
[ "def", "parse_datetime", "(", "datetime_input", ")", ":", "date_els", ",", "time_els", "=", "_split_datetime", "(", "datetime_input", ")", "date_vals", "=", "_parse_date", "(", "date_els", ")", "time_vals", "=", "_parse_time", "(", "time_els", ")", "vals", "=", ...
The arrow library is sadly not good enough to parse certain date strings. It even gives unexpected results for partial date strings such as '2015-01' or just '2015', which I think should be seen as 'the first moment of 2014'. This function should overcome those limitations.
[ "The", "arrow", "library", "is", "sadly", "not", "good", "enough", "to", "parse", "certain", "date", "strings", ".", "It", "even", "gives", "unexpected", "results", "for", "partial", "date", "strings", "such", "as", "2015", "-", "01", "or", "just", "2015",...
python
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py#L673-L676
def fw_rule_delete(self, data, fw_name=None): """Top level rule delete function. """ LOG.debug("FW Rule delete %s", data) self._fw_rule_delete(fw_name, data)
[ "def", "fw_rule_delete", "(", "self", ",", "data", ",", "fw_name", "=", "None", ")", ":", "LOG", ".", "debug", "(", "\"FW Rule delete %s\"", ",", "data", ")", "self", ".", "_fw_rule_delete", "(", "fw_name", ",", "data", ")" ]
Top level rule delete function.
[ "Top", "level", "rule", "delete", "function", "." ]
python
train
rhayes777/PyAutoFit
autofit/tools/fit.py
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/fit.py#L59-L63
def signal_to_noise_map(self): """The signal-to-noise_map of the data and noise-map which are fitted.""" signal_to_noise_map = np.divide(self.data, self.noise_map) signal_to_noise_map[signal_to_noise_map < 0] = 0 return signal_to_noise_map
[ "def", "signal_to_noise_map", "(", "self", ")", ":", "signal_to_noise_map", "=", "np", ".", "divide", "(", "self", ".", "data", ",", "self", ".", "noise_map", ")", "signal_to_noise_map", "[", "signal_to_noise_map", "<", "0", "]", "=", "0", "return", "signal_...
The signal-to-noise_map of the data and noise-map which are fitted.
[ "The", "signal", "-", "to", "-", "noise_map", "of", "the", "data", "and", "noise", "-", "map", "which", "are", "fitted", "." ]
python
train
Tinche/django-bower-cache
registry/gitwrapper.py
https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/gitwrapper.py#L45-L54
def clone_from(repo_url, repo_dir): """Clone a remote git repo into a local directory.""" repo_url = _fix_repo_url(repo_url) LOG.info("Cloning %s into %s." % (repo_url, repo_dir)) cmd = GIT_CLONE_CMD.format(repo_url, repo_dir) resp = envoy.run(cmd) if resp.status_code != 0: LOG.error("Cl...
[ "def", "clone_from", "(", "repo_url", ",", "repo_dir", ")", ":", "repo_url", "=", "_fix_repo_url", "(", "repo_url", ")", "LOG", ".", "info", "(", "\"Cloning %s into %s.\"", "%", "(", "repo_url", ",", "repo_dir", ")", ")", "cmd", "=", "GIT_CLONE_CMD", ".", ...
Clone a remote git repo into a local directory.
[ "Clone", "a", "remote", "git", "repo", "into", "a", "local", "directory", "." ]
python
train
grabbles/grabbit
grabbit/core.py
https://github.com/grabbles/grabbit/blob/83ff93df36019eaaee9d4e31f816a518e46cae07/grabbit/core.py#L699-L791
def get(self, return_type='tuple', target=None, extensions=None, domains=None, regex_search=None, **kwargs): """ Retrieve files and/or metadata from the current Layout. Args: return_type (str): Type of result to return. Valid values: 'tuple': returns a li...
[ "def", "get", "(", "self", ",", "return_type", "=", "'tuple'", ",", "target", "=", "None", ",", "extensions", "=", "None", ",", "domains", "=", "None", ",", "regex_search", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "regex_search", "is", "...
Retrieve files and/or metadata from the current Layout. Args: return_type (str): Type of result to return. Valid values: 'tuple': returns a list of namedtuples containing file name as well as attribute/value pairs for all named entities. 'file': r...
[ "Retrieve", "files", "and", "/", "or", "metadata", "from", "the", "current", "Layout", "." ]
python
train
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L175-L186
def get_vnetwork_hosts_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_hosts = ET.Element("get_vnetwork_hosts") config = get_vnetwork_hosts output = ET.SubElement(get_vnetwork_hosts, "output") instance_id =...
[ "def", "get_vnetwork_hosts_output_instance_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_vnetwork_hosts", "=", "ET", ".", "Element", "(", "\"get_vnetwork_hosts\"", ")", "config", "=", "ge...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
wandb/client
wandb/__init__.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/__init__.py#L498-L507
def reset_env(exclude=[]): """Remove environment variables, used in Jupyter notebooks""" if os.getenv(env.INITED): wandb_keys = [key for key in os.environ.keys() if key.startswith( 'WANDB_') and key not in exclude] for key in wandb_keys: del os.environ[key] return...
[ "def", "reset_env", "(", "exclude", "=", "[", "]", ")", ":", "if", "os", ".", "getenv", "(", "env", ".", "INITED", ")", ":", "wandb_keys", "=", "[", "key", "for", "key", "in", "os", ".", "environ", ".", "keys", "(", ")", "if", "key", ".", "star...
Remove environment variables, used in Jupyter notebooks
[ "Remove", "environment", "variables", "used", "in", "Jupyter", "notebooks" ]
python
train
pybel/pybel
src/pybel/manager/cache_manager.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L519-L526
def get_graphs_by_ids(self, network_ids: Iterable[int]) -> List[BELGraph]: """Get a list of networks with the given identifiers and converts to BEL graphs.""" rv = [ self.get_graph_by_id(network_id) for network_id in network_ids ] log.debug('returning graphs for n...
[ "def", "get_graphs_by_ids", "(", "self", ",", "network_ids", ":", "Iterable", "[", "int", "]", ")", "->", "List", "[", "BELGraph", "]", ":", "rv", "=", "[", "self", ".", "get_graph_by_id", "(", "network_id", ")", "for", "network_id", "in", "network_ids", ...
Get a list of networks with the given identifiers and converts to BEL graphs.
[ "Get", "a", "list", "of", "networks", "with", "the", "given", "identifiers", "and", "converts", "to", "BEL", "graphs", "." ]
python
train
litl/rauth
rauth/service.py
https://github.com/litl/rauth/blob/a6d887d7737cf21ec896a8104f25c2754c694011/rauth/service.py#L521-L543
def get_access_token(self, method='POST', decoder=parse_utf8_qsl, key='access_token', **kwargs): ''' Returns an access token. :param method: A string representation of the HTTP method to be used,...
[ "def", "get_access_token", "(", "self", ",", "method", "=", "'POST'", ",", "decoder", "=", "parse_utf8_qsl", ",", "key", "=", "'access_token'", ",", "*", "*", "kwargs", ")", ":", "r", "=", "self", ".", "get_raw_access_token", "(", "method", ",", "*", "*"...
Returns an access token. :param method: A string representation of the HTTP method to be used, defaults to `POST`. :type method: str :param decoder: A function used to parse the Response content. Should return a dictionary. :type decoder: func :param key:...
[ "Returns", "an", "access", "token", "." ]
python
train
pneff/wsgiservice
wsgiservice/resource.py
https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/resource.py#L157-L175
def data(self): """Returns the request data as a dictionary. Merges the path parameters, GET parameters and POST parameters (form-encoded or JSON dictionary). If a key is present in multiple of these, the first one defined is used. """ if self._data: return s...
[ "def", "data", "(", "self", ")", ":", "if", "self", ".", "_data", ":", "return", "self", ".", "_data", "retval", "=", "{", "}", "data", "=", "self", ".", "get_request_data", "(", ")", "for", "subdata", "in", "data", ":", "for", "key", ",", "value",...
Returns the request data as a dictionary. Merges the path parameters, GET parameters and POST parameters (form-encoded or JSON dictionary). If a key is present in multiple of these, the first one defined is used.
[ "Returns", "the", "request", "data", "as", "a", "dictionary", "." ]
python
train
swift-nav/libsbp
generator/sbpg/targets/latex.py
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/latex.py#L168-L253
def handle_fields(definitions, fields, prefix, offset, multiplier): """ Helper for handling naming and sizing of fields. It's terrible. """ items = [] for f in fields: if f.type_id == "array" and f.options['fill'].value in CONSTRUCT_CODE: prefix_name = '.'.join([prefix, f.identifier]) if prefix else...
[ "def", "handle_fields", "(", "definitions", ",", "fields", ",", "prefix", ",", "offset", ",", "multiplier", ")", ":", "items", "=", "[", "]", "for", "f", "in", "fields", ":", "if", "f", ".", "type_id", "==", "\"array\"", "and", "f", ".", "options", "...
Helper for handling naming and sizing of fields. It's terrible.
[ "Helper", "for", "handling", "naming", "and", "sizing", "of", "fields", ".", "It", "s", "terrible", "." ]
python
train
biolink/ontobio
bin/qbiogolr.py
https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/bin/qbiogolr.py#L175-L186
def show_graph(g, nodes, query_ids, args): """ Writes graph """ if args.graph.find('m') > -1: logging.info("SLIMMING") g = get_minimal_subgraph(g, query_ids) w = GraphRenderer.create(args.to) if args.outfile is not None: w.outfile = args.outfile logging.info("Writing ...
[ "def", "show_graph", "(", "g", ",", "nodes", ",", "query_ids", ",", "args", ")", ":", "if", "args", ".", "graph", ".", "find", "(", "'m'", ")", ">", "-", "1", ":", "logging", ".", "info", "(", "\"SLIMMING\"", ")", "g", "=", "get_minimal_subgraph", ...
Writes graph
[ "Writes", "graph" ]
python
train
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1799-L1837
def _prepare_fabric_fw_internal(self, tenant_id, fw_dict, is_fw_virt, result): """Internal routine to prepare the fabric. This creates an entry in FW DB and runs the SM. """ if not self.auto_nwk_create: LOG.info("Auto network creation disa...
[ "def", "_prepare_fabric_fw_internal", "(", "self", ",", "tenant_id", ",", "fw_dict", ",", "is_fw_virt", ",", "result", ")", ":", "if", "not", "self", ".", "auto_nwk_create", ":", "LOG", ".", "info", "(", "\"Auto network creation disabled\"", ")", "return", "Fals...
Internal routine to prepare the fabric. This creates an entry in FW DB and runs the SM.
[ "Internal", "routine", "to", "prepare", "the", "fabric", "." ]
python
train
hermanschaaf/mafan
mafan/text.py
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/text.py#L209-L246
def split_text(text, include_part_of_speech=False, strip_english=False, strip_numbers=False): u""" Split Chinese text at word boundaries. include_pos: also returns the Part Of Speech for each of the words. Some of the different parts of speech are: r: pronoun v: verb ns: proper ...
[ "def", "split_text", "(", "text", ",", "include_part_of_speech", "=", "False", ",", "strip_english", "=", "False", ",", "strip_numbers", "=", "False", ")", ":", "if", "not", "include_part_of_speech", ":", "seg_list", "=", "pseg", ".", "cut", "(", "text", ")"...
u""" Split Chinese text at word boundaries. include_pos: also returns the Part Of Speech for each of the words. Some of the different parts of speech are: r: pronoun v: verb ns: proper noun etc... This all gets returned as a tuple: index 0: the split word ...
[ "u", "Split", "Chinese", "text", "at", "word", "boundaries", "." ]
python
train
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L3046-L3054
def SetPixelColor(self, x: int, y: int, argb: int) -> bool: """ Set color value of a pixel. x: int. y: int. argb: int, color value. Return bool, True if succeed otherwise False. """ return _DllClient.instance().dll.BitmapSetPixel(self._bitmap, x, y, argb)
[ "def", "SetPixelColor", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "argb", ":", "int", ")", "->", "bool", ":", "return", "_DllClient", ".", "instance", "(", ")", ".", "dll", ".", "BitmapSetPixel", "(", "self", ".", "_bitmap", ","...
Set color value of a pixel. x: int. y: int. argb: int, color value. Return bool, True if succeed otherwise False.
[ "Set", "color", "value", "of", "a", "pixel", ".", "x", ":", "int", ".", "y", ":", "int", ".", "argb", ":", "int", "color", "value", ".", "Return", "bool", "True", "if", "succeed", "otherwise", "False", "." ]
python
valid
jleclanche/fireplace
fireplace/card.py
https://github.com/jleclanche/fireplace/blob/d0fc0e97e185c0210de86631be20638659c0609e/fireplace/card.py#L103-L117
def buff(self, target, buff, **kwargs): """ Summon \a buff and apply it to \a target If keyword arguments are given, attempt to set the given values to the buff. Example: player.buff(target, health=random.randint(1, 5)) NOTE: Any Card can buff any other Card. The controller of the Card that buffs the targ...
[ "def", "buff", "(", "self", ",", "target", ",", "buff", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "self", ".", "controller", ".", "card", "(", "buff", ",", "self", ")", "ret", ".", "source", "=", "self", "ret", ".", "apply", "(", "target", ...
Summon \a buff and apply it to \a target If keyword arguments are given, attempt to set the given values to the buff. Example: player.buff(target, health=random.randint(1, 5)) NOTE: Any Card can buff any other Card. The controller of the Card that buffs the target becomes the controller of the buff.
[ "Summon", "\\", "a", "buff", "and", "apply", "it", "to", "\\", "a", "target", "If", "keyword", "arguments", "are", "given", "attempt", "to", "set", "the", "given", "values", "to", "the", "buff", ".", "Example", ":", "player", ".", "buff", "(", "target"...
python
train
rigetti/pyquil
pyquil/api/_base_connection.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/api/_base_connection.py#L152-L180
def prepare_register_list(register_dict: Dict[str, Union[bool, Sequence[int]]]): """ Canonicalize classical addresses for the payload and ready MemoryReference instances for serialization. This function will cast keys that are iterables of int-likes to a list of Python ints. This is to support spec...
[ "def", "prepare_register_list", "(", "register_dict", ":", "Dict", "[", "str", ",", "Union", "[", "bool", ",", "Sequence", "[", "int", "]", "]", "]", ")", ":", "if", "not", "isinstance", "(", "register_dict", ",", "dict", ")", ":", "raise", "TypeError", ...
Canonicalize classical addresses for the payload and ready MemoryReference instances for serialization. This function will cast keys that are iterables of int-likes to a list of Python ints. This is to support specifying the register offsets as ``range()`` or numpy arrays. This mutates ``register_dict`...
[ "Canonicalize", "classical", "addresses", "for", "the", "payload", "and", "ready", "MemoryReference", "instances", "for", "serialization", "." ]
python
train
peterbrittain/asciimatics
samples/maps.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/samples/maps.py#L375-L397
def _draw_tiles(self, x_offset, y_offset, bg): """Render all visible tiles a layer at a time.""" count = 0 for layer_name, c_filters, t_filters in self._get_features(): colour = (self._256_PALETTE[layer_name] if self._screen.colours >= 256 else self._16_PALETTE[...
[ "def", "_draw_tiles", "(", "self", ",", "x_offset", ",", "y_offset", ",", "bg", ")", ":", "count", "=", "0", "for", "layer_name", ",", "c_filters", ",", "t_filters", "in", "self", ".", "_get_features", "(", ")", ":", "colour", "=", "(", "self", ".", ...
Render all visible tiles a layer at a time.
[ "Render", "all", "visible", "tiles", "a", "layer", "at", "a", "time", "." ]
python
train
CI-WATER/gsshapy
gsshapy/orm/prj.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/prj.py#L1068-L1134
def getModelSummaryAsGeoJson(self, session, withStreamNetwork=True, withNodes=False): """ Retrieve a GeoJSON representation of the model. Includes vectorized mask map and stream network. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGI...
[ "def", "getModelSummaryAsGeoJson", "(", "self", ",", "session", ",", "withStreamNetwork", "=", "True", ",", "withNodes", "=", "False", ")", ":", "# Get mask map", "watershedMaskCard", "=", "self", ".", "getCard", "(", "'WATERSHED_MASK'", ")", "maskFilename", "=", ...
Retrieve a GeoJSON representation of the model. Includes vectorized mask map and stream network. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database withStreamNetwork (bool, optional): Include stream network. Defaults to Tru...
[ "Retrieve", "a", "GeoJSON", "representation", "of", "the", "model", ".", "Includes", "vectorized", "mask", "map", "and", "stream", "network", "." ]
python
train
calmjs/calmjs.parse
src/calmjs/parse/utils.py
https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/utils.py#L37-L52
def generate_tab_names(name): """ Return the names to lextab and yacctab modules for the given module name. Typical usage should be like so:: >>> lextab, yacctab = generate_tab_names(__name__) """ package_name, module_name = name.rsplit('.', 1) version = ply_dist.version.replace( ...
[ "def", "generate_tab_names", "(", "name", ")", ":", "package_name", ",", "module_name", "=", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "version", "=", "ply_dist", ".", "version", ".", "replace", "(", "'.'", ",", "'_'", ")", "if", "ply_dist", "i...
Return the names to lextab and yacctab modules for the given module name. Typical usage should be like so:: >>> lextab, yacctab = generate_tab_names(__name__)
[ "Return", "the", "names", "to", "lextab", "and", "yacctab", "modules", "for", "the", "given", "module", "name", ".", "Typical", "usage", "should", "be", "like", "so", "::" ]
python
train
ArchiveTeam/wpull
wpull/document/htmlparse/lxml_.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/document/htmlparse/lxml_.py#L124-L186
def parse_lxml(self, file, encoding=None, target_class=HTMLParserTarget, parser_type='html'): '''Return an iterator of elements found in the document. Args: file: A file object containing the document. encoding (str): The encoding of the document. ...
[ "def", "parse_lxml", "(", "self", ",", "file", ",", "encoding", "=", "None", ",", "target_class", "=", "HTMLParserTarget", ",", "parser_type", "=", "'html'", ")", ":", "if", "encoding", ":", "lxml_encoding", "=", "to_lxml_encoding", "(", "encoding", ")", "or...
Return an iterator of elements found in the document. Args: file: A file object containing the document. encoding (str): The encoding of the document. target_class: A class to be used for target parsing. parser_type (str): The type of parser to use. Accepted valu...
[ "Return", "an", "iterator", "of", "elements", "found", "in", "the", "document", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xtreewidget/xtreewidgetitem.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetitem.py#L242-L290
def initGroupStyle(self, useIcons=True, columnCount=None): """ Initialzes this item with a grouping style option. """ flags = self.flags() if flags & QtCore.Qt.ItemIsSelectable: flags ^= QtCore.Qt.ItemIsSelectable self.setFlags(flags) ...
[ "def", "initGroupStyle", "(", "self", ",", "useIcons", "=", "True", ",", "columnCount", "=", "None", ")", ":", "flags", "=", "self", ".", "flags", "(", ")", "if", "flags", "&", "QtCore", ".", "Qt", ".", "ItemIsSelectable", ":", "flags", "^=", "QtCore",...
Initialzes this item with a grouping style option.
[ "Initialzes", "this", "item", "with", "a", "grouping", "style", "option", "." ]
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/wiki/wiki_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/wiki/wiki_client.py#L338-L370
def get_page_by_id_text(self, project, wiki_identifier, id, recursion_level=None, include_content=None, **kwargs): """GetPageByIdText. [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. :...
[ "def", "get_page_by_id_text", "(", "self", ",", "project", ",", "wiki_identifier", ",", "id", ",", "recursion_level", "=", "None", ",", "include_content", "=", "None", ",", "*", "*", "kwargs", ")", ":", "route_values", "=", "{", "}", "if", "project", "is",...
GetPageByIdText. [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. :param str project: Project ID or project name :param str wiki_identifier: Wiki Id or name. :param int id: Wiki...
[ "GetPageByIdText", ".", "[", "Preview", "API", "]", "Gets", "metadata", "or", "content", "of", "the", "wiki", "page", "for", "the", "provided", "page", "id", ".", "Content", "negotiation", "is", "done", "based", "on", "the", "Accept", "header", "sent", "in...
python
train
DarkEnergySurvey/ugali
ugali/analysis/results.py
https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/results.py#L57-L81
def estimate(self,param,burn=None,clip=10.0,alpha=0.32): """ Estimate parameter value and uncertainties """ # FIXME: Need to add age and metallicity to composite isochrone params (currently properties) if param not in list(self.samples.names) + list(self.source.params) + ['age','metallicity']: ...
[ "def", "estimate", "(", "self", ",", "param", ",", "burn", "=", "None", ",", "clip", "=", "10.0", ",", "alpha", "=", "0.32", ")", ":", "# FIXME: Need to add age and metallicity to composite isochrone params (currently properties)", "if", "param", "not", "in", "list"...
Estimate parameter value and uncertainties
[ "Estimate", "parameter", "value", "and", "uncertainties" ]
python
train
tempodb/tempodb-python
tempodb/client.py
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L433-L489
def aggregate_data(self, start, end, aggregation, keys=[], tags=[], attrs={}, rollup=None, period=None, interpolationf=None, interpolation_period=None, tz=None, limit=1000): """Read data from multiple series according to a filter and apply a function across ...
[ "def", "aggregate_data", "(", "self", ",", "start", ",", "end", ",", "aggregation", ",", "keys", "=", "[", "]", ",", "tags", "=", "[", "]", ",", "attrs", "=", "{", "}", ",", "rollup", "=", "None", ",", "period", "=", "None", ",", "interpolationf", ...
Read data from multiple series according to a filter and apply a function across all the returned series to put the datapoints together into one aggregrate series. See the :meth:`list_series` method for a description of how the filter criteria are applied, and the :meth:`read_data` meth...
[ "Read", "data", "from", "multiple", "series", "according", "to", "a", "filter", "and", "apply", "a", "function", "across", "all", "the", "returned", "series", "to", "put", "the", "datapoints", "together", "into", "one", "aggregrate", "series", "." ]
python
train