repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
Staffjoy/client_python
staffjoy/resource.py
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L180-L204
def create(cls, parent=None, **kwargs): """Create an object and return it""" if parent is None: raise Exception("Parent class is required") route = copy(parent.route) if cls.ID_NAME is not None: route[cls.ID_NAME] = "" obj = cls(key=parent.key, route=ro...
[ "def", "create", "(", "cls", ",", "parent", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "parent", "is", "None", ":", "raise", "Exception", "(", "\"Parent class is required\"", ")", "route", "=", "copy", "(", "parent", ".", "route", ")", "if",...
Create an object and return it
[ "Create", "an", "object", "and", "return", "it" ]
python
train
31.04
insilichem/ommprotocol
ommprotocol/io.py
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L582-L613
def from_csv(cls, path): """ Get box vectors from comma-separated values in file `path`. The csv file must containt only one line, which in turn can contain three values (orthogonal vectors) or nine values (triclinic box). The values should be in nanometers. Parameters...
[ "def", "from_csv", "(", "cls", ",", "path", ")", ":", "with", "open", "(", "path", ")", "as", "f", ":", "fields", "=", "map", "(", "float", ",", "next", "(", "f", ")", ".", "split", "(", "','", ")", ")", "if", "len", "(", "fields", ")", "==",...
Get box vectors from comma-separated values in file `path`. The csv file must containt only one line, which in turn can contain three values (orthogonal vectors) or nine values (triclinic box). The values should be in nanometers. Parameters ---------- path : str ...
[ "Get", "box", "vectors", "from", "comma", "-", "separated", "values", "in", "file", "path", "." ]
python
train
36.15625
Locu/chronology
pykronos/pykronos/utils/cache.py
https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/pykronos/pykronos/utils/cache.py#L132-L149
def _bucket_events(self, event_iterable): """ Convert an iterable of events into an iterable of lists of events per bucket. """ current_bucket_time = None current_bucket_events = None for event in event_iterable: event_bucket_time = self._bucket_time(event[TIMESTAMP_FIELD]) if c...
[ "def", "_bucket_events", "(", "self", ",", "event_iterable", ")", ":", "current_bucket_time", "=", "None", "current_bucket_events", "=", "None", "for", "event", "in", "event_iterable", ":", "event_bucket_time", "=", "self", ".", "_bucket_time", "(", "event", "[", ...
Convert an iterable of events into an iterable of lists of events per bucket.
[ "Convert", "an", "iterable", "of", "events", "into", "an", "iterable", "of", "lists", "of", "events", "per", "bucket", "." ]
python
train
38.333333
davidmiller/letter
letter/__init__.py
https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L228-L244
def deliver(self, message, to): """ Deliver our message Arguments: - `message`: MIMEMultipart Return: None Exceptions: None """ # Send the message via local SMTP server. s = smtplib.SMTP(self.host, self.port) # sendmail function takes 3 a...
[ "def", "deliver", "(", "self", ",", "message", ",", "to", ")", ":", "# Send the message via local SMTP server.", "s", "=", "smtplib", ".", "SMTP", "(", "self", ".", "host", ",", "self", ".", "port", ")", "# sendmail function takes 3 arguments: sender's address, reci...
Deliver our message Arguments: - `message`: MIMEMultipart Return: None Exceptions: None
[ "Deliver", "our", "message" ]
python
train
29.823529
Microsoft/LightGBM
python-package/lightgbm/basic.py
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L95-L100
def cfloat64_array_to_numpy(cptr, length): """Convert a ctypes double pointer array to a numpy array.""" if isinstance(cptr, ctypes.POINTER(ctypes.c_double)): return np.fromiter(cptr, dtype=np.float64, count=length) else: raise RuntimeError('Expected double pointer')
[ "def", "cfloat64_array_to_numpy", "(", "cptr", ",", "length", ")", ":", "if", "isinstance", "(", "cptr", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_double", ")", ")", ":", "return", "np", ".", "fromiter", "(", "cptr", ",", "dtype", "=", "np"...
Convert a ctypes double pointer array to a numpy array.
[ "Convert", "a", "ctypes", "double", "pointer", "array", "to", "a", "numpy", "array", "." ]
python
train
48.333333
lionheart/django-pyodbc
django_pyodbc/compiler.py
https://github.com/lionheart/django-pyodbc/blob/46adda7b0bfabfa2640f72592c6f6f407f78b363/django_pyodbc/compiler.py#L346-L393
def _fix_slicing_order(self, outer_fields, inner_select, order, inner_table_name): """ Apply any necessary fixes to the outer_fields, inner_select, and order strings due to slicing. """ # Using ROW_NUMBER requires an ordering if order is None: meta = self.quer...
[ "def", "_fix_slicing_order", "(", "self", ",", "outer_fields", ",", "inner_select", ",", "order", ",", "inner_table_name", ")", ":", "# Using ROW_NUMBER requires an ordering", "if", "order", "is", "None", ":", "meta", "=", "self", ".", "query", ".", "get_meta", ...
Apply any necessary fixes to the outer_fields, inner_select, and order strings due to slicing.
[ "Apply", "any", "necessary", "fixes", "to", "the", "outer_fields", "inner_select", "and", "order", "strings", "due", "to", "slicing", "." ]
python
train
50.145833
GuyAllard/markov_clustering
markov_clustering/modularity.py
https://github.com/GuyAllard/markov_clustering/blob/28787cf64ef06bf024ff915246008c767ea830cf/markov_clustering/modularity.py#L25-L42
def convert_to_adjacency_matrix(matrix): """ Converts transition matrix into adjacency matrix :param matrix: The matrix to be converted :returns: adjacency matrix """ for i in range(matrix.shape[0]): if isspmatrix(matrix): col = find(matrix[:,i])[2] else: ...
[ "def", "convert_to_adjacency_matrix", "(", "matrix", ")", ":", "for", "i", "in", "range", "(", "matrix", ".", "shape", "[", "0", "]", ")", ":", "if", "isspmatrix", "(", "matrix", ")", ":", "col", "=", "find", "(", "matrix", "[", ":", ",", "i", "]",...
Converts transition matrix into adjacency matrix :param matrix: The matrix to be converted :returns: adjacency matrix
[ "Converts", "transition", "matrix", "into", "adjacency", "matrix" ]
python
train
26.277778
tanghaibao/jcvi
jcvi/utils/orderedcollections.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/utils/orderedcollections.py#L184-L197
def parse_qs(qs, keep_blank_values=0, strict_parsing=0, keep_attr_order=True): """ Kind of like urlparse.parse_qs, except returns an ordered dict. Also avoids replicating that function's bad habit of overriding the built-in 'dict' type. Taken from below with modification: <https://bitbucket.org...
[ "def", "parse_qs", "(", "qs", ",", "keep_blank_values", "=", "0", ",", "strict_parsing", "=", "0", ",", "keep_attr_order", "=", "True", ")", ":", "od", "=", "DefaultOrderedDict", "(", "list", ")", "if", "keep_attr_order", "else", "defaultdict", "(", "list", ...
Kind of like urlparse.parse_qs, except returns an ordered dict. Also avoids replicating that function's bad habit of overriding the built-in 'dict' type. Taken from below with modification: <https://bitbucket.org/btubbs/thumpy/raw/8cdece404f15/thumpy.py>
[ "Kind", "of", "like", "urlparse", ".", "parse_qs", "except", "returns", "an", "ordered", "dict", ".", "Also", "avoids", "replicating", "that", "function", "s", "bad", "habit", "of", "overriding", "the", "built", "-", "in", "dict", "type", "." ]
python
train
39.428571
SKA-ScienceDataProcessor/integration-prototype
sip/examples/flask_processing_controller/app/old.db/client.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L95-L108
def get_processing_block_ids(self): """Get list of processing block ids using the processing block id""" # Initialise empty list _processing_block_ids = [] # Pattern used to search processing block ids pattern = '*:processing_block:*' block_ids = self._db.get_ids(patter...
[ "def", "get_processing_block_ids", "(", "self", ")", ":", "# Initialise empty list", "_processing_block_ids", "=", "[", "]", "# Pattern used to search processing block ids", "pattern", "=", "'*:processing_block:*'", "block_ids", "=", "self", ".", "_db", ".", "get_ids", "(...
Get list of processing block ids using the processing block id
[ "Get", "list", "of", "processing", "block", "ids", "using", "the", "processing", "block", "id" ]
python
train
34.857143
oceanprotocol/osmosis-azure-driver
osmosis_azure_driver/computing_plugin.py
https://github.com/oceanprotocol/osmosis-azure-driver/blob/36bcfa96547fb6117346b02b0ac6a74345c59695/osmosis_azure_driver/computing_plugin.py#L135-L184
def exec_container(self, asset_url, algorithm_url, resource_group_name, account_name, account_key, location, share_name_input='compute', ...
[ "def", "exec_container", "(", "self", ",", "asset_url", ",", "algorithm_url", ",", "resource_group_name", ",", "account_name", ",", "account_key", ",", "location", ",", "share_name_input", "=", "'compute'", ",", "share_name_output", "=", "'output'", ",", "docker_ima...
Prepare a docker image that will run in the cloud, mounting the asset and executing the algorithm. :param asset_url :param algorithm_url :param resource_group_name: :param account_name: :param account_key: :param share_name_input: :param share_name_output: ...
[ "Prepare", "a", "docker", "image", "that", "will", "run", "in", "the", "cloud", "mounting", "the", "asset", "and", "executing", "the", "algorithm", ".", ":", "param", "asset_url", ":", "param", "algorithm_url", ":", "param", "resource_group_name", ":", ":", ...
python
train
54.88
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L328-L367
def _custom_dtype_getter(self, getter, name, shape=None, dtype=DEFAULT_DTYPE, *args, **kwargs): """Creates variables in fp32, then casts to fp16 if necessary. This function is a custom getter. A custom getter is a function with the same signature as tf.get_variable, except it has...
[ "def", "_custom_dtype_getter", "(", "self", ",", "getter", ",", "name", ",", "shape", "=", "None", ",", "dtype", "=", "DEFAULT_DTYPE", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "dtype", "in", "CASTABLE_TYPES", ":", "var", "=", "getter"...
Creates variables in fp32, then casts to fp16 if necessary. This function is a custom getter. A custom getter is a function with the same signature as tf.get_variable, except it has an additional getter parameter. Custom getters can be passed as the `custom_getter` parameter of tf.variable_scope. Then,...
[ "Creates", "variables", "in", "fp32", "then", "casts", "to", "fp16", "if", "necessary", "." ]
python
train
50.375
SoCo/SoCo
soco/events.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/events.py#L234-L270
def do_NOTIFY(self): # pylint: disable=invalid-name """Serve a ``NOTIFY`` request. A ``NOTIFY`` request will be sent by a Sonos device when a state variable changes. See the `UPnP Spec §4.3 [pdf] <http://upnp.org/specs/arch/UPnP-arch -DeviceArchitecture-v1.1.pdf>`_ for details...
[ "def", "do_NOTIFY", "(", "self", ")", ":", "# pylint: disable=invalid-name", "timestamp", "=", "time", ".", "time", "(", ")", "headers", "=", "requests", ".", "structures", ".", "CaseInsensitiveDict", "(", "self", ".", "headers", ")", "seq", "=", "headers", ...
Serve a ``NOTIFY`` request. A ``NOTIFY`` request will be sent by a Sonos device when a state variable changes. See the `UPnP Spec §4.3 [pdf] <http://upnp.org/specs/arch/UPnP-arch -DeviceArchitecture-v1.1.pdf>`_ for details.
[ "Serve", "a", "NOTIFY", "request", "." ]
python
train
45.324324
saltstack/salt
salt/client/ssh/wrapper/state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/wrapper/state.py#L108-L118
def _check_pillar(kwargs, pillar=None): ''' Check the pillar for errors, refuse to run the state if there are errors in the pillar and return the pillar errors ''' if kwargs.get('force'): return True pillar_dict = pillar if pillar is not None else __pillar__ if '_errors' in pillar_di...
[ "def", "_check_pillar", "(", "kwargs", ",", "pillar", "=", "None", ")", ":", "if", "kwargs", ".", "get", "(", "'force'", ")", ":", "return", "True", "pillar_dict", "=", "pillar", "if", "pillar", "is", "not", "None", "else", "__pillar__", "if", "'_errors'...
Check the pillar for errors, refuse to run the state if there are errors in the pillar and return the pillar errors
[ "Check", "the", "pillar", "for", "errors", "refuse", "to", "run", "the", "state", "if", "there", "are", "errors", "in", "the", "pillar", "and", "return", "the", "pillar", "errors" ]
python
train
31.818182
closeio/quotequail
quotequail/_html.py
https://github.com/closeio/quotequail/blob/8a3960c033d595b25a8bbc2c340be898e3065b5f/quotequail/_html.py#L281-L372
def tree_line_generator(el, max_lines=None): """ Internal generator that iterates through an LXML tree and yields a tuple per line. In this context, lines are blocks of text separated by <br> tags or by block elements. The tuples contain the following elements: - A tuple with the element reference ...
[ "def", "tree_line_generator", "(", "el", ",", "max_lines", "=", "None", ")", ":", "def", "_trim_spaces", "(", "text", ")", ":", "return", "MULTIPLE_WHITESPACE_RE", ".", "sub", "(", "' '", ",", "text", ")", ".", "strip", "(", ")", "counter", "=", "1", "...
Internal generator that iterates through an LXML tree and yields a tuple per line. In this context, lines are blocks of text separated by <br> tags or by block elements. The tuples contain the following elements: - A tuple with the element reference (element, position) for the start of the line. The ...
[ "Internal", "generator", "that", "iterates", "through", "an", "LXML", "tree", "and", "yields", "a", "tuple", "per", "line", ".", "In", "this", "context", "lines", "are", "blocks", "of", "text", "separated", "by", "<br", ">", "tags", "or", "by", "block", ...
python
train
34.73913
ValvePython/steam
steam/webauth.py
https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/webauth.py#L155-L232
def login(self, password='', captcha='', email_code='', twofactor_code='', language='english'): """Attempts web login and returns on a session with cookies set :param password: password, if it wasn't provided on instance init :type password: :class:`str` :param captcha: text reponse fo...
[ "def", "login", "(", "self", ",", "password", "=", "''", ",", "captcha", "=", "''", ",", "email_code", "=", "''", ",", "twofactor_code", "=", "''", ",", "language", "=", "'english'", ")", ":", "if", "self", ".", "logged_on", ":", "return", "self", "....
Attempts web login and returns on a session with cookies set :param password: password, if it wasn't provided on instance init :type password: :class:`str` :param captcha: text reponse for captcha challenge :type captcha: :class:`str` :param email_code: email code for steam gu...
[ "Attempts", "web", "login", "and", "returns", "on", "a", "session", "with", "cookies", "set" ]
python
train
43.910256
lambdamusic/Ontospy
ontospy/core/utils.py
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L195-L219
def pprint2columns(llist, max_length=60): """ llist = a list of strings max_length = if a word is longer than that, for single col display > prints a list in two columns, taking care of alignment too """ if len(llist) == 0: return None col_width = max(len(word) for word in llist) +...
[ "def", "pprint2columns", "(", "llist", ",", "max_length", "=", "60", ")", ":", "if", "len", "(", "llist", ")", "==", "0", ":", "return", "None", "col_width", "=", "max", "(", "len", "(", "word", ")", "for", "word", "in", "llist", ")", "+", "2", "...
llist = a list of strings max_length = if a word is longer than that, for single col display > prints a list in two columns, taking care of alignment too
[ "llist", "=", "a", "list", "of", "strings", "max_length", "=", "if", "a", "word", "is", "longer", "than", "that", "for", "single", "col", "display" ]
python
train
30.64
apache/airflow
airflow/contrib/operators/gcp_container_operator.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/gcp_container_operator.py#L310-L322
def _get_field(self, extras, field, default=None): """ Fetches a field from extras, and returns it. This is some Airflow magic. The google_cloud_platform hook type adds custom UI elements to the hook page, which allow admins to specify service_account, key_path, etc. They get for...
[ "def", "_get_field", "(", "self", ",", "extras", ",", "field", ",", "default", "=", "None", ")", ":", "long_f", "=", "'extra__google_cloud_platform__{}'", ".", "format", "(", "field", ")", "if", "long_f", "in", "extras", ":", "return", "extras", "[", "long...
Fetches a field from extras, and returns it. This is some Airflow magic. The google_cloud_platform hook type adds custom UI elements to the hook page, which allow admins to specify service_account, key_path, etc. They get formatted as shown below.
[ "Fetches", "a", "field", "from", "extras", "and", "returns", "it", ".", "This", "is", "some", "Airflow", "magic", ".", "The", "google_cloud_platform", "hook", "type", "adds", "custom", "UI", "elements", "to", "the", "hook", "page", "which", "allow", "admins"...
python
test
44.461538
Clinical-Genomics/scout
scout/adapter/mongo/variant_loader.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/variant_loader.py#L198-L288
def update_case_compounds(self, case_obj, build='37'): """Update the compounds for a case Loop over all coding intervals to get coordinates for all potential compound positions. Update all variants within a gene with a bulk operation. """ case_id = case_obj['_id'] # Pos...
[ "def", "update_case_compounds", "(", "self", ",", "case_obj", ",", "build", "=", "'37'", ")", ":", "case_id", "=", "case_obj", "[", "'_id'", "]", "# Possible categories 'snv', 'sv', 'str', 'cancer':", "categories", "=", "set", "(", ")", "# Possible variant types 'clin...
Update the compounds for a case Loop over all coding intervals to get coordinates for all potential compound positions. Update all variants within a gene with a bulk operation.
[ "Update", "the", "compounds", "for", "a", "case" ]
python
test
40.868132
gorakhargosh/pepe
pepe/content_types.py
https://github.com/gorakhargosh/pepe/blob/1e40853378d515c99f03b3f59efa9b943d26eb62/pepe/content_types.py#L97-L151
def get_comment_group_for_path(self, pathname, default_content_type=None): """ Obtains the comment group for a specified pathname. :param pathname: The path for which the comment group will be obtained. :return: Returns the comment group for the specified pathnam...
[ "def", "get_comment_group_for_path", "(", "self", ",", "pathname", ",", "default_content_type", "=", "None", ")", ":", "content_type", "=", "self", ".", "guess_content_type", "(", "pathname", ")", "if", "not", "content_type", ":", "# Content type is not found.", "if...
Obtains the comment group for a specified pathname. :param pathname: The path for which the comment group will be obtained. :return: Returns the comment group for the specified pathname or raises a ``ValueError`` if a content type is not found or raises a...
[ "Obtains", "the", "comment", "group", "for", "a", "specified", "pathname", "." ]
python
train
41.036364
IBM/pyxcli
pyxcli/response.py
https://github.com/IBM/pyxcli/blob/7d8ece1dcc16f50246740a447aa81b94a0dbced4/pyxcli/response.py#L75-L87
def as_single_element(self): """ Processes the response as a single-element response, like config_get or system_counters_get. If there is more then one element in the response or no elements this raises a ResponseError """ if self.as_return_etree is None: ...
[ "def", "as_single_element", "(", "self", ")", ":", "if", "self", ".", "as_return_etree", "is", "None", ":", "return", "None", "if", "len", "(", "self", ".", "as_return_etree", ".", "getchildren", "(", ")", ")", "==", "1", ":", "return", "_populate_bunch_wi...
Processes the response as a single-element response, like config_get or system_counters_get. If there is more then one element in the response or no elements this raises a ResponseError
[ "Processes", "the", "response", "as", "a", "single", "-", "element", "response", "like", "config_get", "or", "system_counters_get", ".", "If", "there", "is", "more", "then", "one", "element", "in", "the", "response", "or", "no", "elements", "this", "raises", ...
python
train
44.769231
rosenbrockc/fortpy
fortpy/isense/evaluator.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/isense/evaluator.py#L435-L474
def _complete_values(self, symbol = ""): """Compiles a list of possible symbols that can hold a value in place. These consist of local vars, global vars, and functions.""" result = {} #Also add the subroutines from the module and its dependencies. moddict = self._generic_filter_e...
[ "def", "_complete_values", "(", "self", ",", "symbol", "=", "\"\"", ")", ":", "result", "=", "{", "}", "#Also add the subroutines from the module and its dependencies.", "moddict", "=", "self", ".", "_generic_filter_execs", "(", "self", ".", "context", ".", "module"...
Compiles a list of possible symbols that can hold a value in place. These consist of local vars, global vars, and functions.
[ "Compiles", "a", "list", "of", "possible", "symbols", "that", "can", "hold", "a", "value", "in", "place", ".", "These", "consist", "of", "local", "vars", "global", "vars", "and", "functions", "." ]
python
train
56.975
pandas-dev/pandas
pandas/core/generic.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/generic.py#L274-L278
def _construct_axes_dict(self, axes=None, **kwargs): """Return an axes dictionary for myself.""" d = {a: self._get_axis(a) for a in (axes or self._AXIS_ORDERS)} d.update(kwargs) return d
[ "def", "_construct_axes_dict", "(", "self", ",", "axes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "d", "=", "{", "a", ":", "self", ".", "_get_axis", "(", "a", ")", "for", "a", "in", "(", "axes", "or", "self", ".", "_AXIS_ORDERS", ")", "}",...
Return an axes dictionary for myself.
[ "Return", "an", "axes", "dictionary", "for", "myself", "." ]
python
train
42.8
CivicSpleen/ambry
ambry/orm/partition.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/partition.py#L1022-L1040
def shapes(self, simplify=None, predicate=None): """ Return geodata as a list of Shapely shapes :param simplify: Integer or None. Simplify the geometry to a tolerance, in the units of the geometry. :param predicate: A single-argument function to select which records to include in the ou...
[ "def", "shapes", "(", "self", ",", "simplify", "=", "None", ",", "predicate", "=", "None", ")", ":", "from", "shapely", ".", "wkt", "import", "loads", "if", "not", "predicate", ":", "predicate", "=", "lambda", "row", ":", "True", "if", "simplify", ":",...
Return geodata as a list of Shapely shapes :param simplify: Integer or None. Simplify the geometry to a tolerance, in the units of the geometry. :param predicate: A single-argument function to select which records to include in the output. :return: A list of Shapely objects
[ "Return", "geodata", "as", "a", "list", "of", "Shapely", "shapes" ]
python
train
35.526316
rigetti/pyquil
pyquil/gates.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/gates.py#L379-L398
def CSWAP(control, target_1, target_2): """Produces a controlled-SWAP gate. This gate conditionally swaps the state of two qubits:: CSWAP = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], ...
[ "def", "CSWAP", "(", "control", ",", "target_1", ",", "target_2", ")", ":", "qubits", "=", "[", "unpack_qubit", "(", "q", ")", "for", "q", "in", "(", "control", ",", "target_1", ",", "target_2", ")", "]", "return", "Gate", "(", "name", "=", "\"CSWAP\...
Produces a controlled-SWAP gate. This gate conditionally swaps the state of two qubits:: CSWAP = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], ...
[ "Produces", "a", "controlled", "-", "SWAP", "gate", ".", "This", "gate", "conditionally", "swaps", "the", "state", "of", "two", "qubits", "::" ]
python
train
40.45
neuropsychology/NeuroKit.py
neurokit/eeg/eeg_complexity.py
https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/neurokit/eeg/eeg_complexity.py#L20-L92
def eeg_complexity(eeg, sampling_rate, times=None, index=None, include="all", exclude=None, hemisphere="both", central=True, verbose=True, shannon=True, sampen=True, multiscale=True, spectral=True, svd=True, correlation=True, higushi=True, petrosian=True, fisher=True, hurst=True, dfa=True, lyap_r=False, lyap_e=False, n...
[ "def", "eeg_complexity", "(", "eeg", ",", "sampling_rate", ",", "times", "=", "None", ",", "index", "=", "None", ",", "include", "=", "\"all\"", ",", "exclude", "=", "None", ",", "hemisphere", "=", "\"both\"", ",", "central", "=", "True", ",", "verbose",...
Compute complexity indices of epochs or raw object. DOCS INCOMPLETE :(
[ "Compute", "complexity", "indices", "of", "epochs", "or", "raw", "object", "." ]
python
train
42.917808
zeroSteiner/AdvancedHTTPServer
advancedhttpserver.py
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L972-L983
def respond_redirect(self, location='/'): """ Respond to the client with a 301 message and redirect them with a Location header. :param str location: The new location to redirect the client to. """ self.send_response(301) self.send_header('Content-Length', 0) self.send_header('Location', location) se...
[ "def", "respond_redirect", "(", "self", ",", "location", "=", "'/'", ")", ":", "self", ".", "send_response", "(", "301", ")", "self", ".", "send_header", "(", "'Content-Length'", ",", "0", ")", "self", ".", "send_header", "(", "'Location'", ",", "location"...
Respond to the client with a 301 message and redirect them with a Location header. :param str location: The new location to redirect the client to.
[ "Respond", "to", "the", "client", "with", "a", "301", "message", "and", "redirect", "them", "with", "a", "Location", "header", "." ]
python
train
27.833333
Duke-GCB/DukeDSClient
ddsc/sdk/client.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/sdk/client.py#L102-L111
def create_project(self, name, description): """ Create a new project with the specified name and description :param name: str: name of the project to create :param description: str: description of the project to create :return: Project """ return self._create_ite...
[ "def", "create_project", "(", "self", ",", "name", ",", "description", ")", ":", "return", "self", ".", "_create_item_response", "(", "self", ".", "data_service", ".", "create_project", "(", "name", ",", "description", ")", ",", "Project", ")" ]
Create a new project with the specified name and description :param name: str: name of the project to create :param description: str: description of the project to create :return: Project
[ "Create", "a", "new", "project", "with", "the", "specified", "name", "and", "description", ":", "param", "name", ":", "str", ":", "name", "of", "the", "project", "to", "create", ":", "param", "description", ":", "str", ":", "description", "of", "the", "p...
python
train
40.8
jeremymcrae/denovonear
scripts/run_batch.py
https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/scripts/run_batch.py#L96-L112
def get_random_string(): """ make a random string, which we can use for bsub job IDs, so that different jobs do not have the same job IDs. """ # set up a random string to associate with the run hash_string = "%8x" % random.getrandbits(32) hash_string = hash_string.strip() # done't ...
[ "def", "get_random_string", "(", ")", ":", "# set up a random string to associate with the run", "hash_string", "=", "\"%8x\"", "%", "random", ".", "getrandbits", "(", "32", ")", "hash_string", "=", "hash_string", ".", "strip", "(", ")", "# done't allow the random strin...
make a random string, which we can use for bsub job IDs, so that different jobs do not have the same job IDs.
[ "make", "a", "random", "string", "which", "we", "can", "use", "for", "bsub", "job", "IDs", "so", "that", "different", "jobs", "do", "not", "have", "the", "same", "job", "IDs", "." ]
python
train
35.823529
gem/oq-engine
openquake/server/db/upgrade_manager.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L291-L299
def extract_upgrade_scripts(self): """ Extract the OpenQuake upgrade scripts from the links in the GitHub page """ link_pattern = '>\s*{0}\s*<'.format(self.pattern[1:-1]) page = urllib.request.urlopen(self.upgrades_url).read() for mo in re.finditer(link_pattern, page): ...
[ "def", "extract_upgrade_scripts", "(", "self", ")", ":", "link_pattern", "=", "'>\\s*{0}\\s*<'", ".", "format", "(", "self", ".", "pattern", "[", "1", ":", "-", "1", "]", ")", "page", "=", "urllib", ".", "request", ".", "urlopen", "(", "self", ".", "up...
Extract the OpenQuake upgrade scripts from the links in the GitHub page
[ "Extract", "the", "OpenQuake", "upgrade", "scripts", "from", "the", "links", "in", "the", "GitHub", "page" ]
python
train
45.888889
playpauseandstop/rororo
rororo/timedelta.py
https://github.com/playpauseandstop/rororo/blob/28a04e8028c29647941e727116335e9d6fd64c27/rororo/timedelta.py#L181-L188
def timedelta_seconds(value: datetime.timedelta) -> int: """Return full number of seconds from timedelta. By default, Python returns only one day seconds, not all timedelta seconds. :param value: Timedelta instance. """ return SECONDS_PER_DAY * value.days + value.seconds
[ "def", "timedelta_seconds", "(", "value", ":", "datetime", ".", "timedelta", ")", "->", "int", ":", "return", "SECONDS_PER_DAY", "*", "value", ".", "days", "+", "value", ".", "seconds" ]
Return full number of seconds from timedelta. By default, Python returns only one day seconds, not all timedelta seconds. :param value: Timedelta instance.
[ "Return", "full", "number", "of", "seconds", "from", "timedelta", "." ]
python
train
35.75
mitsei/dlkit
dlkit/primordium/locale/types/heading.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/primordium/locale/types/heading.py#L15-L34
def get_type_data(name): """Return dictionary representation of type. Can be used to initialize primordium.type.primitives.Type """ name = name.upper() try: return { 'authority': 'okapia.net', 'namespace': 'heading', 'identifier': name, 'doma...
[ "def", "get_type_data", "(", "name", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "try", ":", "return", "{", "'authority'", ":", "'okapia.net'", ",", "'namespace'", ":", "'heading'", ",", "'identifier'", ":", "name", ",", "'domain'", ":", "'Hea...
Return dictionary representation of type. Can be used to initialize primordium.type.primitives.Type
[ "Return", "dictionary", "representation", "of", "type", "." ]
python
train
31.65
fastai/fastai
fastai/script.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/script.py#L25-L33
def anno_parser(func): "Look at params (annotated with `Param`) in func and return an `ArgumentParser`" p = ArgumentParser(description=func.__doc__) for k,v in inspect.signature(func).parameters.items(): param = func.__annotations__.get(k, Param()) kwargs = param.kwargs if v.default ...
[ "def", "anno_parser", "(", "func", ")", ":", "p", "=", "ArgumentParser", "(", "description", "=", "func", ".", "__doc__", ")", "for", "k", ",", "v", "in", "inspect", ".", "signature", "(", "func", ")", ".", "parameters", ".", "items", "(", ")", ":", ...
Look at params (annotated with `Param`) in func and return an `ArgumentParser`
[ "Look", "at", "params", "(", "annotated", "with", "Param", ")", "in", "func", "and", "return", "an", "ArgumentParser" ]
python
train
48.222222
EventTeam/beliefs
src/beliefs/beliefstate.py
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L96-L101
def set_environment_variable(self, key, val): """ Sets a variable if that variable is not already set """ if self.get_environment_variable(key) in [None, val]: self.__dict__['environment_variables'][key] = val else: raise Contradiction("Could not set environment variable ...
[ "def", "set_environment_variable", "(", "self", ",", "key", ",", "val", ")", ":", "if", "self", ".", "get_environment_variable", "(", "key", ")", "in", "[", "None", ",", "val", "]", ":", "self", ".", "__dict__", "[", "'environment_variables'", "]", "[", ...
Sets a variable if that variable is not already set
[ "Sets", "a", "variable", "if", "that", "variable", "is", "not", "already", "set" ]
python
train
54.5
junzis/pyModeS
pyModeS/decoder/bds/__init__.py
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/__init__.py#L30-L89
def is50or60(msg, spd_ref, trk_ref, alt_ref): """Use reference ground speed and trk to determine BDS50 and DBS60. Args: msg (String): 28 bytes hexadecimal message string spd_ref (float): reference speed (ADS-B ground speed), kts trk_ref (float): reference track (ADS-B track angle), deg ...
[ "def", "is50or60", "(", "msg", ",", "spd_ref", ",", "trk_ref", ",", "alt_ref", ")", ":", "def", "vxy", "(", "v", ",", "angle", ")", ":", "vx", "=", "v", "*", "np", ".", "sin", "(", "np", ".", "radians", "(", "angle", ")", ")", "vy", "=", "v",...
Use reference ground speed and trk to determine BDS50 and DBS60. Args: msg (String): 28 bytes hexadecimal message string spd_ref (float): reference speed (ADS-B ground speed), kts trk_ref (float): reference track (ADS-B track angle), deg alt_ref (float): reference altitude (ADS-B al...
[ "Use", "reference", "ground", "speed", "and", "trk", "to", "determine", "BDS50", "and", "DBS60", "." ]
python
train
29
urbn/Caesium
caesium/handler.py
https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L294-L317
def get(self, id): """ Get an by object by unique identifier :id string id: the bson id of an object :rtype: JSON """ try: if self.request.headers.get("Id"): object_ = yield self.client.find_one({self.request.headers.get("Id"): id}) ...
[ "def", "get", "(", "self", ",", "id", ")", ":", "try", ":", "if", "self", ".", "request", ".", "headers", ".", "get", "(", "\"Id\"", ")", ":", "object_", "=", "yield", "self", ".", "client", ".", "find_one", "(", "{", "self", ".", "request", ".",...
Get an by object by unique identifier :id string id: the bson id of an object :rtype: JSON
[ "Get", "an", "by", "object", "by", "unique", "identifier" ]
python
train
30.625
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2512-L2516
def organization_field_show(self, id, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/organization_fields#show-organization-field" api_path = "/api/v2/organization_fields/{id}.json" api_path = api_path.format(id=id) return self.call(api_path, **kwargs)
[ "def", "organization_field_show", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/organization_fields/{id}.json\"", "api_path", "=", "api_path", ".", "format", "(", "id", "=", "id", ")", "return", "self", ".", "call", "...
https://developer.zendesk.com/rest_api/docs/core/organization_fields#show-organization-field
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "organization_fields#show", "-", "organization", "-", "field" ]
python
train
58.6
LordDarkula/chess_py
chess_py/core/algebraic/location.py
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L201-L210
def shift_right(self, times=1): """ Finds Location shifted right by 1 :rtype: Location """ try: return Location(self._rank, self._file + times) except IndexError as e: raise IndexError(e)
[ "def", "shift_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
Finds Location shifted right by 1 :rtype: Location
[ "Finds", "Location", "shifted", "right", "by", "1" ]
python
train
25.1
CivicSpleen/ambry
ambry/util/sortedcollection.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L193-L198
def find_le_index(self, k): 'Return last item with a key <= k. Raise ValueError if not found.' i = bisect_right(self._keys, k) if i: return i - 1 raise ValueError('No item found with key at or below: %r' % (k,))
[ "def", "find_le_index", "(", "self", ",", "k", ")", ":", "i", "=", "bisect_right", "(", "self", ".", "_keys", ",", "k", ")", "if", "i", ":", "return", "i", "-", "1", "raise", "ValueError", "(", "'No item found with key at or below: %r'", "%", "(", "k", ...
Return last item with a key <= k. Raise ValueError if not found.
[ "Return", "last", "item", "with", "a", "key", "<", "=", "k", ".", "Raise", "ValueError", "if", "not", "found", "." ]
python
train
41.833333
gagneurlab/concise
concise/data/encode.py
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/data/encode.py#L14-L31
def get_metadata(): """Get pandas.DataFrame with metadata about the PWM's. Columns: - PWM_id (id of the PWM - pass to get_pwm_list() for getting the pwm - info1 - additional information about the motifs - info2 - consensus: PWM consensus sequence """ motifs = _load_motifs() motif_names...
[ "def", "get_metadata", "(", ")", ":", "motifs", "=", "_load_motifs", "(", ")", "motif_names", "=", "sorted", "(", "list", "(", "motifs", ".", "keys", "(", ")", ")", ")", "df", "=", "pd", ".", "Series", "(", "motif_names", ")", ".", "str", ".", "spl...
Get pandas.DataFrame with metadata about the PWM's. Columns: - PWM_id (id of the PWM - pass to get_pwm_list() for getting the pwm - info1 - additional information about the motifs - info2 - consensus: PWM consensus sequence
[ "Get", "pandas", ".", "DataFrame", "with", "metadata", "about", "the", "PWM", "s", ".", "Columns", ":" ]
python
train
34.388889
alex-kostirin/pyatomac
atomac/Clipboard.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/Clipboard.py#L133-L144
def clearContents(cls): """Clear contents of general pasteboard. Future enhancement can include specifying which clipboard to clear Returns: True on success; caller should expect to catch exceptions, probably from AppKit (ValueError) """ log_msg = 'Request to cl...
[ "def", "clearContents", "(", "cls", ")", ":", "log_msg", "=", "'Request to clear contents of pasteboard: general'", "logging", ".", "debug", "(", "log_msg", ")", "pb", "=", "AppKit", ".", "NSPasteboard", ".", "generalPasteboard", "(", ")", "pb", ".", "clearContent...
Clear contents of general pasteboard. Future enhancement can include specifying which clipboard to clear Returns: True on success; caller should expect to catch exceptions, probably from AppKit (ValueError)
[ "Clear", "contents", "of", "general", "pasteboard", "." ]
python
valid
39.666667
TkTech/Jawa
jawa/attribute.py
https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attribute.py#L67-L82
def unpack(self, source: IO): """ Read the ConstantPool from the file-like object `source`. .. note:: Advanced usage only. You will typically never need to call this method as it will be called for you when loading a ClassFile. :param source: Any file-like obje...
[ "def", "unpack", "(", "self", ",", "source", ":", "IO", ")", ":", "count", "=", "unpack", "(", "'>H'", ",", "source", ".", "read", "(", "2", ")", ")", "[", "0", "]", "for", "_", "in", "repeat", "(", "None", ",", "count", ")", ":", "name_index",...
Read the ConstantPool from the file-like object `source`. .. note:: Advanced usage only. You will typically never need to call this method as it will be called for you when loading a ClassFile. :param source: Any file-like object providing `read()`
[ "Read", "the", "ConstantPool", "from", "the", "file", "-", "like", "object", "source", "." ]
python
train
36.6875
tylerbutler/engineer
engineer/devtools/theme_tools.py
https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/devtools/theme_tools.py#L20-L42
def compile_theme(theme_id=None): """Compiles a theme.""" from engineer.processors import convert_less from engineer.themes import ThemeManager if theme_id is None: themes = ThemeManager.themes().values() else: themes = [ThemeManager.theme(theme_id)] with(indent(2)): pu...
[ "def", "compile_theme", "(", "theme_id", "=", "None", ")", ":", "from", "engineer", ".", "processors", "import", "convert_less", "from", "engineer", ".", "themes", "import", "ThemeManager", "if", "theme_id", "is", "None", ":", "themes", "=", "ThemeManager", "....
Compiles a theme.
[ "Compiles", "a", "theme", "." ]
python
train
38.391304
PyCQA/astroid
astroid/rebuilder.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/rebuilder.py#L353-L386
def visit_call(self, node, parent): """visit a CallFunc node by returning a fresh instance of it""" newnode = nodes.Call(node.lineno, node.col_offset, parent) starargs = _visit_or_none(node, "starargs", self, newnode) kwargs = _visit_or_none(node, "kwargs", self, newnode) args = ...
[ "def", "visit_call", "(", "self", ",", "node", ",", "parent", ")", ":", "newnode", "=", "nodes", ".", "Call", "(", "node", ".", "lineno", ",", "node", ".", "col_offset", ",", "parent", ")", "starargs", "=", "_visit_or_none", "(", "node", ",", "\"starar...
visit a CallFunc node by returning a fresh instance of it
[ "visit", "a", "CallFunc", "node", "by", "returning", "a", "fresh", "instance", "of", "it" ]
python
train
37.352941
PaulHancock/Aegean
AegeanTools/fits_image.py
https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L63-L102
def get_beam(header): """ Create a :class:`AegeanTools.fits_image.Beam` object from a fits header. BPA may be missing but will be assumed to be zero. if BMAJ or BMIN are missing then return None instead of a beam object. Parameters ---------- header : HDUHeader The fits header. ...
[ "def", "get_beam", "(", "header", ")", ":", "if", "\"BPA\"", "not", "in", "header", ":", "log", ".", "warning", "(", "\"BPA not present in fits header, using 0\"", ")", "bpa", "=", "0", "else", ":", "bpa", "=", "header", "[", "\"BPA\"", "]", "if", "\"BMAJ\...
Create a :class:`AegeanTools.fits_image.Beam` object from a fits header. BPA may be missing but will be assumed to be zero. if BMAJ or BMIN are missing then return None instead of a beam object. Parameters ---------- header : HDUHeader The fits header. Returns ------- beam : ...
[ "Create", "a", ":", "class", ":", "AegeanTools", ".", "fits_image", ".", "Beam", "object", "from", "a", "fits", "header", "." ]
python
train
23.775
dstufft/storages
storages/utils.py
https://github.com/dstufft/storages/blob/0d893afc1db32cd83eaf8e2ad4ed51b37933d5f0/storages/utils.py#L48-L70
def safe_join(base, *paths): """ Joins one or more path components to the base path component intelligently. Returns a normalized, absolute version of the final path. The final path must be located inside of the base path component (otherwise a ValueError is raised). """ base = base pat...
[ "def", "safe_join", "(", "base", ",", "*", "paths", ")", ":", "base", "=", "base", "paths", "=", "[", "p", "for", "p", "in", "paths", "]", "final_path", "=", "abspath", "(", "os", ".", "path", ".", "join", "(", "base", ",", "*", "paths", ")", "...
Joins one or more path components to the base path component intelligently. Returns a normalized, absolute version of the final path. The final path must be located inside of the base path component (otherwise a ValueError is raised).
[ "Joins", "one", "or", "more", "path", "components", "to", "the", "base", "path", "component", "intelligently", ".", "Returns", "a", "normalized", "absolute", "version", "of", "the", "final", "path", "." ]
python
train
46.521739
frawau/aiolifx
aiolifx/aiolifx.py
https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L687-L697
def device_characteristics_str(self, indent): """Convenience to string method. """ s = "{}\n".format(self.label) s += indent + "MAC Address: {}\n".format(self.mac_addr) s += indent + "IP Address: {}\n".format(self.ip_addr) s += indent + "Port: {}\n".format(self.port) ...
[ "def", "device_characteristics_str", "(", "self", ",", "indent", ")", ":", "s", "=", "\"{}\\n\"", ".", "format", "(", "self", ".", "label", ")", "s", "+=", "indent", "+", "\"MAC Address: {}\\n\"", ".", "format", "(", "self", ".", "mac_addr", ")", "s", "+...
Convenience to string method.
[ "Convenience", "to", "string", "method", "." ]
python
train
46.181818
crs4/hl7apy
hl7apy/core.py
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/core.py#L285-L329
def set(self, name, value, index=-1): """ Assign the ``value`` to the child having the given ``name`` at the ``index`` position :type name: ``str`` :param name: the child name (e.g. PID) :type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance ...
[ "def", "set", "(", "self", ",", "name", ",", "value", ",", "index", "=", "-", "1", ")", ":", "# just copy the first element of the ElementProxy (e.g. message.pid = message2.pid)", "if", "isinstance", "(", "value", ",", "ElementProxy", ")", ":", "value", "=", "valu...
Assign the ``value`` to the child having the given ``name`` at the ``index`` position :type name: ``str`` :param name: the child name (e.g. PID) :type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance of :class:`ElementProxy <hl7apy.core.ElementPr...
[ "Assign", "the", "value", "to", "the", "child", "having", "the", "given", "name", "at", "the", "index", "position" ]
python
train
40.777778
msmbuilder/msmbuilder
msmbuilder/msm/validation/transmat_errorbar.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/msm/validation/transmat_errorbar.py#L4-L34
def create_perturb_params(countsmat, transmat=None): ''' Computes transition probabilities and standard errors of the transition probabilities due to finite sampling using the MSM counts matrix. First, the transition probabilities are computed by dividing the each element c_ij by the row-sumemd counts...
[ "def", "create_perturb_params", "(", "countsmat", ",", "transmat", "=", "None", ")", ":", "norm", "=", "np", ".", "sum", "(", "countsmat", ",", "axis", "=", "1", ")", "if", "not", "transmat", ":", "transmat", "=", "(", "countsmat", ".", "transpose", "(...
Computes transition probabilities and standard errors of the transition probabilities due to finite sampling using the MSM counts matrix. First, the transition probabilities are computed by dividing the each element c_ij by the row-sumemd counts of row i. THe standard errors are then computed by first com...
[ "Computes", "transition", "probabilities", "and", "standard", "errors", "of", "the", "transition", "probabilities", "due", "to", "finite", "sampling", "using", "the", "MSM", "counts", "matrix", ".", "First", "the", "transition", "probabilities", "are", "computed", ...
python
train
49.935484
tensorflow/probability
tensorflow_probability/python/distributions/joint_distribution_sequential.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/joint_distribution_sequential.py#L276-L326
def _resolve_graph(self, distribution_names=None, leaf_name='x'): """Creates a `tuple` of `tuple`s of dependencies. This function is **experimental**. That said, we encourage its use and ask that you report problems to `tfprobability@tensorflow.org`. Args: distribution_names: `list` of `str` or ...
[ "def", "_resolve_graph", "(", "self", ",", "distribution_names", "=", "None", ",", "leaf_name", "=", "'x'", ")", ":", "# This function additionally depends on:", "# self._dist_fn_args", "# self._dist_fn_wrapped", "# TODO(b/129008220): Robustify this procedure. Eg, handle collis...
Creates a `tuple` of `tuple`s of dependencies. This function is **experimental**. That said, we encourage its use and ask that you report problems to `tfprobability@tensorflow.org`. Args: distribution_names: `list` of `str` or `None` names corresponding to each of `model` elements. (`None`s ...
[ "Creates", "a", "tuple", "of", "tuple", "s", "of", "dependencies", "." ]
python
test
38.254902
RiotGames/cloud-inquisitor
plugins/public/cinq-auditor-required-tags/cinq_auditor_required_tags/__init__.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-auditor-required-tags/cinq_auditor_required_tags/__init__.py#L351-L427
def process_actions(self, actions): """Process the actions we want to take Args: actions (`list`): List of actions we want to take Returns: `list` of notifications """ notices = {} notification_contacts = {} for action in actions: ...
[ "def", "process_actions", "(", "self", ",", "actions", ")", ":", "notices", "=", "{", "}", "notification_contacts", "=", "{", "}", "for", "action", "in", "actions", ":", "resource", "=", "action", "[", "'resource'", "]", "action_status", "=", "ActionStatus",...
Process the actions we want to take Args: actions (`list`): List of actions we want to take Returns: `list` of notifications
[ "Process", "the", "actions", "we", "want", "to", "take" ]
python
train
40.753247
T-002/pycast
pycast/methods/regression.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L130-L151
def predict(self, timeseriesX, n, m): """ Calculates the dependent timeseries Y for the given parameters and independent timeseries. (y=m*x + n) :param TimeSeries timeseriesX: the independent Timeseries. :param float n: The interception with the x access that has be...
[ "def", "predict", "(", "self", ",", "timeseriesX", ",", "n", ",", "m", ")", ":", "new_entries", "=", "[", "]", "for", "entry", "in", "timeseriesX", ":", "predicted_value", "=", "m", "*", "entry", "[", "1", "]", "+", "n", "new_entries", ".", "append",...
Calculates the dependent timeseries Y for the given parameters and independent timeseries. (y=m*x + n) :param TimeSeries timeseriesX: the independent Timeseries. :param float n: The interception with the x access that has been calculated during regression :param float m: T...
[ "Calculates", "the", "dependent", "timeseries", "Y", "for", "the", "given", "parameters", "and", "independent", "timeseries", ".", "(", "y", "=", "m", "*", "x", "+", "n", ")" ]
python
train
38.409091
ARMmbed/icetea
icetea_lib/tools/tools.py
https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/tools.py#L147-L161
def _is_pid_running_on_windows(pid): """ Check if PID is running for Windows systems """ import ctypes.wintypes kernel32 = ctypes.windll.kernel32 handle = kernel32.OpenProcess(1, 0, pid) if handle == 0: return False exit_code = ctypes.wintypes.DWORD() ret = kernel32.GetExitC...
[ "def", "_is_pid_running_on_windows", "(", "pid", ")", ":", "import", "ctypes", ".", "wintypes", "kernel32", "=", "ctypes", ".", "windll", ".", "kernel32", "handle", "=", "kernel32", ".", "OpenProcess", "(", "1", ",", "0", ",", "pid", ")", "if", "handle", ...
Check if PID is running for Windows systems
[ "Check", "if", "PID", "is", "running", "for", "Windows", "systems" ]
python
train
33.4
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py#L1192-L1204
def router_fabric_virtual_gateway_address_family_ipv6_gateway_mac_address(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") router = ET.SubElement(config, "router", xmlns="urn:brocade.com:mgmt:brocade-common-def") fabric_virtual_gateway = ET.SubElement(rou...
[ "def", "router_fabric_virtual_gateway_address_family_ipv6_gateway_mac_address", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "router", "=", "ET", ".", "SubElement", "(", "config", ",", "\"router\"", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
58.384615
dlintott/gns3-converter
gns3converter/topology.py
https://github.com/dlintott/gns3-converter/blob/acbc55da51de86388dc5b5f6da55809b3c86b7ca/gns3converter/topology.py#L469-L498
def get_topology(self): """ Get the converted topology ready for JSON encoding :return: converted topology assembled into a single dict :rtype: dict """ topology = {'name': self._name, 'resources_type': 'local', 'topology': {}, ...
[ "def", "get_topology", "(", "self", ")", ":", "topology", "=", "{", "'name'", ":", "self", ".", "_name", ",", "'resources_type'", ":", "'local'", ",", "'topology'", ":", "{", "}", ",", "'type'", ":", "'topology'", ",", "'version'", ":", "'1.0'", "}", "...
Get the converted topology ready for JSON encoding :return: converted topology assembled into a single dict :rtype: dict
[ "Get", "the", "converted", "topology", "ready", "for", "JSON", "encoding" ]
python
train
34.6
ThreatConnect-Inc/tcex
tcex/tcex.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L404-L419
def datastore(self, domain, data_type, mapping=None): """Get instance of the DataStore module. Args: domain (str): The domain can be either "system", "organization", or "local". When using "organization" the data store can be accessed by any Application in the entire org, ...
[ "def", "datastore", "(", "self", ",", "domain", ",", "data_type", ",", "mapping", "=", "None", ")", ":", "from", ".", "tcex_datastore", "import", "TcExDataStore", "return", "TcExDataStore", "(", "self", ",", "domain", ",", "data_type", ",", "mapping", ")" ]
Get instance of the DataStore module. Args: domain (str): The domain can be either "system", "organization", or "local". When using "organization" the data store can be accessed by any Application in the entire org, while "local" access is restricted to the App writi...
[ "Get", "instance", "of", "the", "DataStore", "module", "." ]
python
train
46
XuShaohua/bcloud
bcloud/App.py
https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/App.py#L313-L331
def update_avatar(self): '''更新用户头像''' def do_update_avatar(info, error=None): if error or not info: logger.error('Failed to get user avatar: %s, %s' % (info, error)) else: uk, uname, img_path = info self...
[ "def", "update_avatar", "(", "self", ")", ":", "def", "do_update_avatar", "(", "info", ",", "error", "=", "None", ")", ":", "if", "error", "or", "not", "info", ":", "logger", ".", "error", "(", "'Failed to get user avatar: %s, %s'", "%", "(", "info", ",", ...
更新用户头像
[ "更新用户头像" ]
python
train
42.789474
NoneGG/aredis
aredis/utils.py
https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/utils.py#L151-L176
def clusterdown_wrapper(func): """ Wrapper for CLUSTERDOWN error handling. If the cluster reports it is down it is assumed that: - connection_pool was disconnected - connection_pool was reseted - refereh_table_asap set to True It will try 3 times to rerun the command and raises ClusterD...
[ "def", "clusterdown_wrapper", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "async", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "_", "in", "range", "(", "0", ",", "3", ")", ":", "try", ":", "return", "a...
Wrapper for CLUSTERDOWN error handling. If the cluster reports it is down it is assumed that: - connection_pool was disconnected - connection_pool was reseted - refereh_table_asap set to True It will try 3 times to rerun the command and raises ClusterDownException if it continues to fail.
[ "Wrapper", "for", "CLUSTERDOWN", "error", "handling", "." ]
python
train
31.884615
scopus-api/scopus
scopus/deprecated_/scopus_author.py
https://github.com/scopus-api/scopus/blob/27ce02dd3095bfdab9d3e8475543d7c17767d1ab/scopus/deprecated_/scopus_author.py#L267-L271
def get_journal_abstracts(self, refresh=True): """Return a list of ScopusAbstract objects using ScopusSearch, but only if belonging to a Journal.""" return [abstract for abstract in self.get_abstracts(refresh=refresh) if abstract.aggregationType == 'Journal']
[ "def", "get_journal_abstracts", "(", "self", ",", "refresh", "=", "True", ")", ":", "return", "[", "abstract", "for", "abstract", "in", "self", ".", "get_abstracts", "(", "refresh", "=", "refresh", ")", "if", "abstract", ".", "aggregationType", "==", "'Journ...
Return a list of ScopusAbstract objects using ScopusSearch, but only if belonging to a Journal.
[ "Return", "a", "list", "of", "ScopusAbstract", "objects", "using", "ScopusSearch", "but", "only", "if", "belonging", "to", "a", "Journal", "." ]
python
train
59.6
SiLab-Bonn/pixel_clusterizer
pixel_clusterizer/cluster_functions.py
https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L137-L143
def _is_in_max_difference(value_1, value_2, max_difference): ''' Helper function to determine the difference of two values that can be np.uints. Works in python and numba mode. Circumvents numba bug #1653 ''' if value_1 <= value_2: return value_2 - value_1 <= max_difference return value_1 - ...
[ "def", "_is_in_max_difference", "(", "value_1", ",", "value_2", ",", "max_difference", ")", ":", "if", "value_1", "<=", "value_2", ":", "return", "value_2", "-", "value_1", "<=", "max_difference", "return", "value_1", "-", "value_2", "<=", "max_difference" ]
Helper function to determine the difference of two values that can be np.uints. Works in python and numba mode. Circumvents numba bug #1653
[ "Helper", "function", "to", "determine", "the", "difference", "of", "two", "values", "that", "can", "be", "np", ".", "uints", ".", "Works", "in", "python", "and", "numba", "mode", ".", "Circumvents", "numba", "bug", "#1653" ]
python
test
48.428571
apache/incubator-heron
heron/instance/src/python/network/heron_client.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/instance/src/python/network/heron_client.py#L186-L197
def start_connect(self): """Tries to connect to the Heron Server ``loop()`` method needs to be called after this. """ Log.debug("In start_connect() of %s" % self._get_classname()) # TODO: specify buffer size, exception handling self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # when ...
[ "def", "start_connect", "(", "self", ")", ":", "Log", ".", "debug", "(", "\"In start_connect() of %s\"", "%", "self", ".", "_get_classname", "(", ")", ")", "# TODO: specify buffer size, exception handling", "self", ".", "create_socket", "(", "socket", ".", "AF_INET"...
Tries to connect to the Heron Server ``loop()`` method needs to be called after this.
[ "Tries", "to", "connect", "to", "the", "Heron", "Server" ]
python
valid
33.333333
AdvancedClimateSystems/uModbus
umodbus/functions.py
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/functions.py#L99-L113
def pdu_to_function_code_or_raise_error(resp_pdu): """ Parse response PDU and return of :class:`ModbusFunction` or raise error. :param resp_pdu: PDU of response. :return: Subclass of :class:`ModbusFunction` matching the response. :raises ModbusError: When response contains error code. """ f...
[ "def", "pdu_to_function_code_or_raise_error", "(", "resp_pdu", ")", ":", "function_code", "=", "struct", ".", "unpack", "(", "'>B'", ",", "resp_pdu", "[", "0", ":", "1", "]", ")", "[", "0", "]", "if", "function_code", "not", "in", "function_code_to_function_ma...
Parse response PDU and return of :class:`ModbusFunction` or raise error. :param resp_pdu: PDU of response. :return: Subclass of :class:`ModbusFunction` matching the response. :raises ModbusError: When response contains error code.
[ "Parse", "response", "PDU", "and", "return", "of", ":", "class", ":", "ModbusFunction", "or", "raise", "error", "." ]
python
train
37.6
neurosynth/neurosynth
neurosynth/analysis/classify.py
https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L291-L306
def fit(self, X, y, cv=None, class_weight='auto'): """ Fits X to outcomes y, using clf """ # Incorporate error checking such as : # if isinstance(self.classifier, ScikitClassifier): # do one thingNone # otherwiseNone. self.X = X self.y = y self.set_...
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "cv", "=", "None", ",", "class_weight", "=", "'auto'", ")", ":", "# Incorporate error checking such as :", "# if isinstance(self.classifier, ScikitClassifier):", "# do one thingNone", "# otherwiseNone.", "self", "....
Fits X to outcomes y, using clf
[ "Fits", "X", "to", "outcomes", "y", "using", "clf" ]
python
test
25.8125
danielfrg/datasciencebox
datasciencebox/core/cloud/instance.py
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/cloud/instance.py#L36-L50
def new(cls, settings, *args, **kwargs): """ Create a new Cloud instance based on the Settings """ logger.debug('Initializing new "%s" Instance object' % settings['CLOUD']) cloud = settings['CLOUD'] if cloud == 'bare': self = BareInstance(settings=settings, *a...
[ "def", "new", "(", "cls", ",", "settings", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Initializing new \"%s\" Instance object'", "%", "settings", "[", "'CLOUD'", "]", ")", "cloud", "=", "settings", "[", "'CLOUD'", ...
Create a new Cloud instance based on the Settings
[ "Create", "a", "new", "Cloud", "instance", "based", "on", "the", "Settings" ]
python
train
40.866667
happyleavesaoc/python-limitlessled
limitlessled/group/commands/legacy.py
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/commands/legacy.py#L72-L84
def _build_command(self, cmd_1, cmd_2=None, select=False, select_command=None): """ Constructs the complete command. :param cmd_1: Light command 1. :param cmd_2: Light command 2. :param select: If command requires selection. :param select_command: S...
[ "def", "_build_command", "(", "self", ",", "cmd_1", ",", "cmd_2", "=", "None", ",", "select", "=", "False", ",", "select_command", "=", "None", ")", ":", "return", "CommandLegacy", "(", "cmd_1", ",", "cmd_2", ",", "self", ".", "_group_number", ",", "sele...
Constructs the complete command. :param cmd_1: Light command 1. :param cmd_2: Light command 2. :param select: If command requires selection. :param select_command: Selection command bytes. :return: The complete command.
[ "Constructs", "the", "complete", "command", ".", ":", "param", "cmd_1", ":", "Light", "command", "1", ".", ":", "param", "cmd_2", ":", "Light", "command", "2", ".", ":", "param", "select", ":", "If", "command", "requires", "selection", ".", ":", "param",...
python
train
38.384615
KimiNewt/pyshark
src/pyshark/tshark/tshark.py
https://github.com/KimiNewt/pyshark/blob/089ea6208c4321f03bc548f491e00a053285918f/src/pyshark/tshark/tshark.py#L96-L105
def get_tshark_interfaces(tshark_path=None): """ Returns a list of interface numbers from the output tshark -D. Used internally to capture on multiple interfaces. """ parameters = [get_process_path(tshark_path), '-D'] with open(os.devnull, 'w') as null: tshark_interfaces = subprocess.che...
[ "def", "get_tshark_interfaces", "(", "tshark_path", "=", "None", ")", ":", "parameters", "=", "[", "get_process_path", "(", "tshark_path", ")", ",", "'-D'", "]", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "null", ":", "tshark_interfa...
Returns a list of interface numbers from the output tshark -D. Used internally to capture on multiple interfaces.
[ "Returns", "a", "list", "of", "interface", "numbers", "from", "the", "output", "tshark", "-", "D", ".", "Used", "internally", "to", "capture", "on", "multiple", "interfaces", "." ]
python
train
43.7
zsimic/runez
src/runez/base.py
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L187-L197
def remove_threadlocal(self, name): """ Args: name (str | unicode): Remove entry with `name` from current thread's context """ with self._lock: if self._tpayload is not None: if name in self._tpayload.context: del self._tpayload...
[ "def", "remove_threadlocal", "(", "self", ",", "name", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_tpayload", "is", "not", "None", ":", "if", "name", "in", "self", ".", "_tpayload", ".", "context", ":", "del", "self", ".", "_tpa...
Args: name (str | unicode): Remove entry with `name` from current thread's context
[ "Args", ":", "name", "(", "str", "|", "unicode", ")", ":", "Remove", "entry", "with", "name", "from", "current", "thread", "s", "context" ]
python
train
37.545455
O365/python-o365
O365/utils/attachment.py
https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/utils/attachment.py#L315-L320
def _update_parent_attachments(self): """ Tries to update the parent property 'has_attachments' """ try: self._parent.has_attachments = bool(len(self.__attachments)) except AttributeError: pass
[ "def", "_update_parent_attachments", "(", "self", ")", ":", "try", ":", "self", ".", "_parent", ".", "has_attachments", "=", "bool", "(", "len", "(", "self", ".", "__attachments", ")", ")", "except", "AttributeError", ":", "pass" ]
Tries to update the parent property 'has_attachments'
[ "Tries", "to", "update", "the", "parent", "property", "has_attachments" ]
python
train
39.333333
mlperf/training
reinforcement/tensorflow/minigo/rl_loop/update_resign_threshold.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/rl_loop/update_resign_threshold.py#L56-L79
def update_flagfile(flags_path, new_threshold): """Updates the flagfile at `flags_path`, changing the value for `resign_threshold` to `new_threshold` """ if abs(new_threshold) > 1: raise ValueError("Invalid new percentile for resign threshold") with tf.gfile.GFile(flags_path) as f: l...
[ "def", "update_flagfile", "(", "flags_path", ",", "new_threshold", ")", ":", "if", "abs", "(", "new_threshold", ")", ">", "1", ":", "raise", "ValueError", "(", "\"Invalid new percentile for resign threshold\"", ")", "with", "tf", ".", "gfile", ".", "GFile", "(",...
Updates the flagfile at `flags_path`, changing the value for `resign_threshold` to `new_threshold`
[ "Updates", "the", "flagfile", "at", "flags_path", "changing", "the", "value", "for", "resign_threshold", "to", "new_threshold" ]
python
train
45.041667
jldantas/libmft
libmft/attribute.py
https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1599-L1630
def _from_binary_reparse(cls, binary_stream): """See base class.""" ''' Reparse type flags - 4 Reparse tag - 4 bits Reserved - 12 bits Reparse type - 2 bits Reparse data length - 2 Padding - 2 ''' #content = cls._REPR.unpack(binary_view[:cls._REPR.size...
[ "def", "_from_binary_reparse", "(", "cls", ",", "binary_stream", ")", ":", "''' Reparse type flags - 4\n Reparse tag - 4 bits\n Reserved - 12 bits\n Reparse type - 2 bits\n Reparse data length - 2\n Padding - 2\n '''", "#content = cls._REPR.unpack(...
See base class.
[ "See", "base", "class", "." ]
python
train
43.25
nyrkovalex/httpsrv
httpsrv/httpsrv.py
https://github.com/nyrkovalex/httpsrv/blob/0acc3298be56856f73bda1ed10c9ab5153894b01/httpsrv/httpsrv.py#L263-L270
def stop(self): ''' Shuts the server down and waits for server thread to join ''' self._server.shutdown() self._server.server_close() self._thread.join() self.running = False
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_server", ".", "shutdown", "(", ")", "self", ".", "_server", ".", "server_close", "(", ")", "self", ".", "_thread", ".", "join", "(", ")", "self", ".", "running", "=", "False" ]
Shuts the server down and waits for server thread to join
[ "Shuts", "the", "server", "down", "and", "waits", "for", "server", "thread", "to", "join" ]
python
train
27.875
ConsenSys/mythril-classic
mythril/analysis/report.py
https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/analysis/report.py#L97-L106
def _set_internal_compiler_error(self): """ Adds the false positive to description and changes severity to low """ self.severity = "Low" self.description_tail += ( " This issue is reported for internal compiler generated code." ) self.description = "%s...
[ "def", "_set_internal_compiler_error", "(", "self", ")", ":", "self", ".", "severity", "=", "\"Low\"", "self", ".", "description_tail", "+=", "(", "\" This issue is reported for internal compiler generated code.\"", ")", "self", ".", "description", "=", "\"%s\\n%s\"", "...
Adds the false positive to description and changes severity to low
[ "Adds", "the", "false", "positive", "to", "description", "and", "changes", "severity", "to", "low" ]
python
train
38.8
agile4you/bottle-neck
bottle_neck/response.py
https://github.com/agile4you/bottle-neck/blob/ebc670a4b178255473d68e9b4122ba04e38f4810/bottle_neck/response.py#L198-L211
def unauthorized(cls, errors=None): """Shortcut API for HTTP 401 `Unauthorized` response. Args: errors (list): Response key/value data. Returns: WSResponse Instance. """ if cls.expose_status: # pragma: no cover cls.response.content_type = 'a...
[ "def", "unauthorized", "(", "cls", ",", "errors", "=", "None", ")", ":", "if", "cls", ".", "expose_status", ":", "# pragma: no cover", "cls", ".", "response", ".", "content_type", "=", "'application/json'", "cls", ".", "response", ".", "_status_line", "=", "...
Shortcut API for HTTP 401 `Unauthorized` response. Args: errors (list): Response key/value data. Returns: WSResponse Instance.
[ "Shortcut", "API", "for", "HTTP", "401", "Unauthorized", "response", "." ]
python
train
30.714286
tensorflow/tensorboard
tensorboard/plugins/interactive_inference/interactive_inference_plugin.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/interactive_inference/interactive_inference_plugin.py#L190-L208
def _duplicate_example(self, request): """Duplicates the specified example. Args: request: A request that should contain 'index'. Returns: An empty response. """ index = int(request.args.get('index')) if index >= len(self.examples): return http_util.Respond(request, {'error':...
[ "def", "_duplicate_example", "(", "self", ",", "request", ")", ":", "index", "=", "int", "(", "request", ".", "args", ".", "get", "(", "'index'", ")", ")", "if", "index", ">=", "len", "(", "self", ".", "examples", ")", ":", "return", "http_util", "."...
Duplicates the specified example. Args: request: A request that should contain 'index'. Returns: An empty response.
[ "Duplicates", "the", "specified", "example", "." ]
python
train
37.473684
fermiPy/fermipy
fermipy/jobs/file_archive.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/file_archive.py#L766-L775
def write_table_file(self, table_file=None): """Write the table to self._table_file""" if self._table is None: raise RuntimeError("No table to write") if table_file is not None: self._table_file = table_file if self._table_file is None: raise RuntimeEr...
[ "def", "write_table_file", "(", "self", ",", "table_file", "=", "None", ")", ":", "if", "self", ".", "_table", "is", "None", ":", "raise", "RuntimeError", "(", "\"No table to write\"", ")", "if", "table_file", "is", "not", "None", ":", "self", ".", "_table...
Write the table to self._table_file
[ "Write", "the", "table", "to", "self", ".", "_table_file" ]
python
train
48.4
bpannier/simpletr64
simpletr64/actions/wan.py
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wan.py#L187-L200
def getConnectionInfo(self, wanInterfaceId=1, timeout=1): """Execute GetInfo action to get WAN connection information's. :param int wanInterfaceId: the id of the WAN device :param float timeout: the timeout to wait for the action to be executed :return: WAN connection information's. ...
[ "def", "getConnectionInfo", "(", "self", ",", "wanInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wan", ".", "getServiceType", "(", "\"getConnectionInfo\"", ")", "+", "str", "(", "wanInterfaceId", ")", "uri", "=", "self", "."...
Execute GetInfo action to get WAN connection information's. :param int wanInterfaceId: the id of the WAN device :param float timeout: the timeout to wait for the action to be executed :return: WAN connection information's. :rtype: ConnectionInfo
[ "Execute", "GetInfo", "action", "to", "get", "WAN", "connection", "information", "s", "." ]
python
train
42
Chilipp/psyplot
psyplot/config/rcsetup.py
https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/config/rcsetup.py#L350-L355
def validate(self): """Dictionary with validation methods as values""" depr = self._all_deprecated return dict((key, val[1]) for key, val in six.iteritems(self.defaultParams) if key not in depr)
[ "def", "validate", "(", "self", ")", ":", "depr", "=", "self", ".", "_all_deprecated", "return", "dict", "(", "(", "key", ",", "val", "[", "1", "]", ")", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "self", ".", "defaultParams", ")...
Dictionary with validation methods as values
[ "Dictionary", "with", "validation", "methods", "as", "values" ]
python
train
42.166667
mitsei/dlkit
dlkit/aws_adapter/osid/queries.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/aws_adapter/osid/queries.py#L68-L77
def _get_string_match_value(self, string, string_match_type): """Gets the match value""" if string_match_type == Type(**get_type_data('EXACT')): return string elif string_match_type == Type(**get_type_data('IGNORECASE')): return re.compile('^' + string, re.I) elif...
[ "def", "_get_string_match_value", "(", "self", ",", "string", ",", "string_match_type", ")", ":", "if", "string_match_type", "==", "Type", "(", "*", "*", "get_type_data", "(", "'EXACT'", ")", ")", ":", "return", "string", "elif", "string_match_type", "==", "Ty...
Gets the match value
[ "Gets", "the", "match", "value" ]
python
train
54.8
klavinslab/coral
coral/design/_oligo_synthesis/oligo_assembly.py
https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/design/_oligo_synthesis/oligo_assembly.py#L215-L347
def _grow_overlaps(dna, melting_temp, require_even, length_max, overlap_min, min_exception): '''Grows equidistant overlaps until they meet specified constraints. :param dna: Input sequence. :type dna: coral.DNA :param melting_temp: Ideal Tm of the overlaps, in degrees C. :type me...
[ "def", "_grow_overlaps", "(", "dna", ",", "melting_temp", ",", "require_even", ",", "length_max", ",", "overlap_min", ",", "min_exception", ")", ":", "# TODO: prevent growing overlaps from bumping into each other -", "# should halt when it happens, give warning, let user decide if ...
Grows equidistant overlaps until they meet specified constraints. :param dna: Input sequence. :type dna: coral.DNA :param melting_temp: Ideal Tm of the overlaps, in degrees C. :type melting_temp: float :param require_even: Require that the number of oligonucleotides is even. :type require_even:...
[ "Grows", "equidistant", "overlaps", "until", "they", "meet", "specified", "constraints", "." ]
python
train
43.503759
datosgobar/pydatajson
pydatajson/core.py
https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L902-L945
def _extract_datasets_to_harvest(cls, report): """Extrae de un reporte los datos necesarios para reconocer qué datasets marcar para cosecha en cualquier generador. Args: report (str o list): Reporte (lista de dicts) o path a uno. Returns: list: Lista de tuplas c...
[ "def", "_extract_datasets_to_harvest", "(", "cls", ",", "report", ")", ":", "assert", "isinstance", "(", "report", ",", "string_types", "+", "(", "list", ",", ")", ")", "# Si `report` es una lista de tuplas con longitud 2, asumimos que es un", "# reporte procesado para extr...
Extrae de un reporte los datos necesarios para reconocer qué datasets marcar para cosecha en cualquier generador. Args: report (str o list): Reporte (lista de dicts) o path a uno. Returns: list: Lista de tuplas con los títulos de catálogo y dataset de cada r...
[ "Extrae", "de", "un", "reporte", "los", "datos", "necesarios", "para", "reconocer", "qué", "datasets", "marcar", "para", "cosecha", "en", "cualquier", "generador", "." ]
python
train
39.681818
ace0/pyrelic
pyrelic/ec.py
https://github.com/ace0/pyrelic/blob/f23d4e6586674675f72304d5938548267d6413bf/pyrelic/ec.py#L231-L242
def _getCachedValue(obj, relicFunc, resultType): """ Retrieves a value from obj.cached (if not None) or calls @relicFunc and caches the result (of @resultType) int obj.cached. This is a common implementation for orderG1/G2/Gt and generatotG1/G2/Gt """ # If the value has not been previously cac...
[ "def", "_getCachedValue", "(", "obj", ",", "relicFunc", ",", "resultType", ")", ":", "# If the value has not been previously cached, fetch ", "if", "not", "obj", ".", "cached", ":", "obj", ".", "cached", "=", "resultType", "(", ")", "relicFunc", "(", "byref", "(...
Retrieves a value from obj.cached (if not None) or calls @relicFunc and caches the result (of @resultType) int obj.cached. This is a common implementation for orderG1/G2/Gt and generatotG1/G2/Gt
[ "Retrieves", "a", "value", "from", "obj", ".", "cached", "(", "if", "not", "None", ")", "or", "calls", "@relicFunc", "and", "caches", "the", "result", "(", "of", "@resultType", ")", "int", "obj", ".", "cached", "." ]
python
train
36.333333
pandas-dev/pandas
pandas/core/groupby/groupby.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1224-L1236
def sem(self, ddof=1): """ Compute standard error of the mean of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom """ return s...
[ "def", "sem", "(", "self", ",", "ddof", "=", "1", ")", ":", "return", "self", ".", "std", "(", "ddof", "=", "ddof", ")", "/", "np", ".", "sqrt", "(", "self", ".", "count", "(", ")", ")" ]
Compute standard error of the mean of groups, excluding missing values. For multiple groupings, the result index will be a MultiIndex. Parameters ---------- ddof : integer, default 1 degrees of freedom
[ "Compute", "standard", "error", "of", "the", "mean", "of", "groups", "excluding", "missing", "values", "." ]
python
train
26.923077
CityOfZion/neo-python
neo/Core/State/UnspentCoinState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/UnspentCoinState.py#L55-L65
def IsAllSpent(self): """ Flag indicating if all balance is spend. Returns: bool: """ for item in self.Items: if item == CoinState.Confirmed: return False return True
[ "def", "IsAllSpent", "(", "self", ")", ":", "for", "item", "in", "self", ".", "Items", ":", "if", "item", "==", "CoinState", ".", "Confirmed", ":", "return", "False", "return", "True" ]
Flag indicating if all balance is spend. Returns: bool:
[ "Flag", "indicating", "if", "all", "balance", "is", "spend", "." ]
python
train
22.272727
ultrabug/py3status
py3status/docstrings.py
https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/docstrings.py#L257-L289
def _from_docstring_rst(doc): """ format from docstring to ReStructured Text """ def format_fn(line, status): """ format function """ if re_from_data.match(line): line = re_from_data.sub(r"**\1** ", line) status["add_line"] = True line = re_from_defaults...
[ "def", "_from_docstring_rst", "(", "doc", ")", ":", "def", "format_fn", "(", "line", ",", "status", ")", ":", "\"\"\" format function \"\"\"", "if", "re_from_data", ".", "match", "(", "line", ")", ":", "line", "=", "re_from_data", ".", "sub", "(", "r\"**\\1*...
format from docstring to ReStructured Text
[ "format", "from", "docstring", "to", "ReStructured", "Text" ]
python
train
35.606061
IdentityPython/SATOSA
src/satosa/util.py
https://github.com/IdentityPython/SATOSA/blob/49da5d4c0ac1a5ebf1a71b4f7aaf04f0e52d8fdb/src/satosa/util.py#L15-L32
def hash_data(salt, value, hash_alg=None): """ Hashes a value together with a salt with the given hash algorithm. :type salt: str :type hash_alg: str :type value: str :param salt: hash salt :param hash_alg: the hash algorithm to use (default: SHA512) :param value: value to hash together...
[ "def", "hash_data", "(", "salt", ",", "value", ",", "hash_alg", "=", "None", ")", ":", "hash_alg", "=", "hash_alg", "or", "'sha512'", "hasher", "=", "hashlib", ".", "new", "(", "hash_alg", ")", "hasher", ".", "update", "(", "value", ".", "encode", "(",...
Hashes a value together with a salt with the given hash algorithm. :type salt: str :type hash_alg: str :type value: str :param salt: hash salt :param hash_alg: the hash algorithm to use (default: SHA512) :param value: value to hash together with the salt :return: hashed value
[ "Hashes", "a", "value", "together", "with", "a", "salt", "with", "the", "given", "hash", "algorithm", "." ]
python
train
31.388889
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1206-L1238
def listTheExtras(self, deleteAlso): """ Use ConfigObj's get_extra_values() call to find any extra/unknown parameters we may have loaded. Return a string similar to findTheLost. If deleteAlso is True, this will also delete any extra/unknown items. """ # get list of extras ...
[ "def", "listTheExtras", "(", "self", ",", "deleteAlso", ")", ":", "# get list of extras", "extras", "=", "configobj", ".", "get_extra_values", "(", "self", ")", "# extras is in format: [(sections, key), (sections, key), ]", "# but we need: [(sections, key, result), ...] - set all...
Use ConfigObj's get_extra_values() call to find any extra/unknown parameters we may have loaded. Return a string similar to findTheLost. If deleteAlso is True, this will also delete any extra/unknown items.
[ "Use", "ConfigObj", "s", "get_extra_values", "()", "call", "to", "find", "any", "extra", "/", "unknown", "parameters", "we", "may", "have", "loaded", ".", "Return", "a", "string", "similar", "to", "findTheLost", ".", "If", "deleteAlso", "is", "True", "this",...
python
train
47.969697
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L342-L375
def get_resampled_top_edge(self, angle_var=0.1): """ This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle. :param float angle_var: Number represe...
[ "def", "get_resampled_top_edge", "(", "self", ",", "angle_var", "=", "0.1", ")", ":", "mesh", "=", "self", ".", "mesh", "top_edge", "=", "[", "Point", "(", "mesh", ".", "lons", "[", "0", "]", "[", "0", "]", ",", "mesh", ".", "lats", "[", "0", "]"...
This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle. :param float angle_var: Number representing the maximum deviation (in degrees) admitted without...
[ "This", "methods", "computes", "a", "simplified", "representation", "of", "a", "fault", "top", "edge", "by", "removing", "the", "points", "that", "are", "not", "describing", "a", "change", "of", "direction", "provided", "a", "certain", "tolerance", "angle", "....
python
train
40.911765
7sDream/zhihu-py3
zhihu/answer.py
https://github.com/7sDream/zhihu-py3/blob/bcb4aa8325f8b54d3b44bd0bdc959edd9761fcfc/zhihu/answer.py#L169-L181
def collect_num(self): """获取答案收藏数 :return: 答案收藏数量 :rtype: int """ element = self.soup.find("a", { "data-za-a": "click_answer_collected_count" }) if element is None: return 0 else: return int(element.get_text())
[ "def", "collect_num", "(", "self", ")", ":", "element", "=", "self", ".", "soup", ".", "find", "(", "\"a\"", ",", "{", "\"data-za-a\"", ":", "\"click_answer_collected_count\"", "}", ")", "if", "element", "is", "None", ":", "return", "0", "else", ":", "re...
获取答案收藏数 :return: 答案收藏数量 :rtype: int
[ "获取答案收藏数" ]
python
train
23.076923
saltstack/salt
salt/modules/mysql.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1710-L1732
def db_optimize(name, table=None, **connection_args): ''' Optimizes the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_optimize dbname ''' ret = [] if table is None: # we need to optimize all tables ...
[ "def", "db_optimize", "(", "name", ",", "table", "=", "None", ",", "*", "*", "connection_args", ")", ":", "ret", "=", "[", "]", "if", "table", "is", "None", ":", "# we need to optimize all tables", "tables", "=", "db_tables", "(", "name", ",", "*", "*", ...
Optimizes the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_optimize dbname
[ "Optimizes", "the", "full", "database", "or", "just", "a", "given", "table" ]
python
train
29.652174
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/utils/ipstruct.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/ipstruct.py#L219-L231
def __dict_invert(self, data): """Helper function for merge. Takes a dictionary whose values are lists and returns a dict with the elements of each list as keys and the original keys as values. """ outdict = {} for k,lst in data.items(): if isinstance(lst, st...
[ "def", "__dict_invert", "(", "self", ",", "data", ")", ":", "outdict", "=", "{", "}", "for", "k", ",", "lst", "in", "data", ".", "items", "(", ")", ":", "if", "isinstance", "(", "lst", ",", "str", ")", ":", "lst", "=", "lst", ".", "split", "(",...
Helper function for merge. Takes a dictionary whose values are lists and returns a dict with the elements of each list as keys and the original keys as values.
[ "Helper", "function", "for", "merge", "." ]
python
test
33.307692
sosy-lab/benchexec
benchexec/cgroups.py
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/cgroups.py#L119-L130
def _find_own_cgroups(): """ For all subsystems, return the information in which (sub-)cgroup this process is in. (Each process is in exactly cgroup in each hierarchy.) @return a generator of tuples (subsystem, cgroup) """ try: with open('/proc/self/cgroup', 'rt') as ownCgroupsFile: ...
[ "def", "_find_own_cgroups", "(", ")", ":", "try", ":", "with", "open", "(", "'/proc/self/cgroup'", ",", "'rt'", ")", "as", "ownCgroupsFile", ":", "for", "cgroup", "in", "_parse_proc_pid_cgroup", "(", "ownCgroupsFile", ")", ":", "yield", "cgroup", "except", "IO...
For all subsystems, return the information in which (sub-)cgroup this process is in. (Each process is in exactly cgroup in each hierarchy.) @return a generator of tuples (subsystem, cgroup)
[ "For", "all", "subsystems", "return", "the", "information", "in", "which", "(", "sub", "-", ")", "cgroup", "this", "process", "is", "in", ".", "(", "Each", "process", "is", "in", "exactly", "cgroup", "in", "each", "hierarchy", ".", ")" ]
python
train
39.833333
ooici/elasticpy
elasticpy/sort.py
https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/sort.py#L16-L32
def missing(self, field, last=True): ''' Numeric fields support specific handling for missing fields in a doc. The missing value can be _last, _first, or a custom value (that will be used for missing docs as the sort value). missing('price') > {"price" : {"missing": "_la...
[ "def", "missing", "(", "self", ",", "field", ",", "last", "=", "True", ")", ":", "if", "last", ":", "self", ".", "append", "(", "{", "field", ":", "{", "'missing'", ":", "'_last'", "}", "}", ")", "else", ":", "self", ".", "append", "(", "{", "f...
Numeric fields support specific handling for missing fields in a doc. The missing value can be _last, _first, or a custom value (that will be used for missing docs as the sort value). missing('price') > {"price" : {"missing": "_last" } } missing('price',False) > {"price"...
[ "Numeric", "fields", "support", "specific", "handling", "for", "missing", "fields", "in", "a", "doc", ".", "The", "missing", "value", "can", "be", "_last", "_first", "or", "a", "custom", "value", "(", "that", "will", "be", "used", "for", "missing", "docs",...
python
train
33.058824
ForensicArtifacts/artifacts
utils/dependencies.py
https://github.com/ForensicArtifacts/artifacts/blob/044a63bfb4448af33d085c69066c80f9505ae7ca/utils/dependencies.py#L88-L108
def Read(self, file_object): """Reads dependency definitions. Args: file_object (file): file-like object to read from. Yields: DependencyDefinition: dependency definition. """ config_parser = configparser.RawConfigParser() # pylint: disable=deprecated-method # TODO: replace rea...
[ "def", "Read", "(", "self", ",", "file_object", ")", ":", "config_parser", "=", "configparser", ".", "RawConfigParser", "(", ")", "# pylint: disable=deprecated-method", "# TODO: replace readfp by read_file, check if Python 2 compatible", "config_parser", ".", "readfp", "(", ...
Reads dependency definitions. Args: file_object (file): file-like object to read from. Yields: DependencyDefinition: dependency definition.
[ "Reads", "dependency", "definitions", "." ]
python
train
34
briandilley/ebs-deploy
ebs_deploy/__init__.py
https://github.com/briandilley/ebs-deploy/blob/4178c9c1282a9025fb987dab3470bea28c202e10/ebs_deploy/__init__.py#L309-L324
def create_environment(self, env_name, version_label=None, solution_stack_name=None, cname_prefix=None, description=None, option_settings=None, tier_name='WebServer', tier_type='Standard', tier_version='1.1'): """ Creates a new environment ""...
[ "def", "create_environment", "(", "self", ",", "env_name", ",", "version_label", "=", "None", ",", "solution_stack_name", "=", "None", ",", "cname_prefix", "=", "None", ",", "description", "=", "None", ",", "option_settings", "=", "None", ",", "tier_name", "="...
Creates a new environment
[ "Creates", "a", "new", "environment" ]
python
valid
62.5625
spyder-ide/spyder
spyder/plugins/editor/extensions/closequotes.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/extensions/closequotes.py#L61-L113
def _autoinsert_quotes(self, key): """Control how to automatically insert quotes in various situations.""" char = {Qt.Key_QuoteDbl: '"', Qt.Key_Apostrophe: '\''}[key] line_text = self.editor.get_text('sol', 'eol') line_to_cursor = self.editor.get_text('sol', 'cursor') cursor = s...
[ "def", "_autoinsert_quotes", "(", "self", ",", "key", ")", ":", "char", "=", "{", "Qt", ".", "Key_QuoteDbl", ":", "'\"'", ",", "Qt", ".", "Key_Apostrophe", ":", "'\\''", "}", "[", "key", "]", "line_text", "=", "self", ".", "editor", ".", "get_text", ...
Control how to automatically insert quotes in various situations.
[ "Control", "how", "to", "automatically", "insert", "quotes", "in", "various", "situations", "." ]
python
train
49.283019
saltstack/salt
salt/modules/boto_kms.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L180-L200
def key_exists(key_id, region=None, key=None, keyid=None, profile=None): ''' Check for the existence of a key. CLI example:: salt myminion boto_kms.key_exists 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: key = conn.de...
[ "def", "key_exists", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid",...
Check for the existence of a key. CLI example:: salt myminion boto_kms.key_exists 'alias/mykey'
[ "Check", "for", "the", "existence", "of", "a", "key", "." ]
python
train
29.190476
dereneaton/ipyrad
ipyrad/analysis/tree.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/tree.py#L176-L199
def _collapse_outgroup(tree, taxdicts): """ collapse outgroup in ete Tree for easier viewing """ ## check that all tests have the same outgroup outg = taxdicts[0]["p4"] if not all([i["p4"] == outg for i in taxdicts]): raise Exception("no good") ## prune tree, keep only one sample from ou...
[ "def", "_collapse_outgroup", "(", "tree", ",", "taxdicts", ")", ":", "## check that all tests have the same outgroup", "outg", "=", "taxdicts", "[", "0", "]", "[", "\"p4\"", "]", "if", "not", "all", "(", "[", "i", "[", "\"p4\"", "]", "==", "outg", "for", "...
collapse outgroup in ete Tree for easier viewing
[ "collapse", "outgroup", "in", "ete", "Tree", "for", "easier", "viewing" ]
python
valid
33.75
pre-commit/pre-commit
pre_commit/languages/helpers.py
https://github.com/pre-commit/pre-commit/blob/72f98d26e690da11dc2e41861d14c58eb21930cb/pre_commit/languages/helpers.py#L73-L83
def _shuffled(seq): """Deterministically shuffle identically under both py2 + py3.""" fixed_random = random.Random() if six.PY2: # pragma: no cover (py2) fixed_random.seed(FIXED_RANDOM_SEED) else: # pragma: no cover (py3) fixed_random.seed(FIXED_RANDOM_SEED, version=1) seq = list(...
[ "def", "_shuffled", "(", "seq", ")", ":", "fixed_random", "=", "random", ".", "Random", "(", ")", "if", "six", ".", "PY2", ":", "# pragma: no cover (py2)", "fixed_random", ".", "seed", "(", "FIXED_RANDOM_SEED", ")", "else", ":", "# pragma: no cover (py3)", "fi...
Deterministically shuffle identically under both py2 + py3.
[ "Deterministically", "shuffle", "identically", "under", "both", "py2", "+", "py3", "." ]
python
train
34.636364
dbrattli/OSlash
oslash/cont.py
https://github.com/dbrattli/OSlash/blob/ffdc714c5d454f7519f740254de89f70850929eb/oslash/cont.py#L45-L50
def bind(self, fn: Callable[[Any], 'Cont']) -> 'Cont': r"""Chain continuation passing functions. Haskell: m >>= k = Cont $ \c -> runCont m $ \a -> runCont (k a) c """ return Cont(lambda c: self.run(lambda a: fn(a).run(c)))
[ "def", "bind", "(", "self", ",", "fn", ":", "Callable", "[", "[", "Any", "]", ",", "'Cont'", "]", ")", "->", "'Cont'", ":", "return", "Cont", "(", "lambda", "c", ":", "self", ".", "run", "(", "lambda", "a", ":", "fn", "(", "a", ")", ".", "run...
r"""Chain continuation passing functions. Haskell: m >>= k = Cont $ \c -> runCont m $ \a -> runCont (k a) c
[ "r", "Chain", "continuation", "passing", "functions", "." ]
python
train
41.666667
locationlabs/mockredis
mockredis/client.py
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L782-L790
def brpoplpush(self, source, destination, timeout=0): """Emulate brpoplpush""" transfer_item = self.brpop(source, timeout) if transfer_item is None: return None key, val = transfer_item self.lpush(destination, val) return val
[ "def", "brpoplpush", "(", "self", ",", "source", ",", "destination", ",", "timeout", "=", "0", ")", ":", "transfer_item", "=", "self", ".", "brpop", "(", "source", ",", "timeout", ")", "if", "transfer_item", "is", "None", ":", "return", "None", "key", ...
Emulate brpoplpush
[ "Emulate", "brpoplpush" ]
python
train
30.888889
atlassian-api/atlassian-python-api
atlassian/jira.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L1131-L1138
def get_agile_board(self, board_id): """ Get agile board info by id :param board_id: :return: """ url = 'rest/agile/1.0/board/{}'.format(str(board_id)) return self.get(url)
[ "def", "get_agile_board", "(", "self", ",", "board_id", ")", ":", "url", "=", "'rest/agile/1.0/board/{}'", ".", "format", "(", "str", "(", "board_id", ")", ")", "return", "self", ".", "get", "(", "url", ")" ]
Get agile board info by id :param board_id: :return:
[ "Get", "agile", "board", "info", "by", "id", ":", "param", "board_id", ":", ":", "return", ":" ]
python
train
27.625