repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
PythonCharmers/python-future
src/future/backports/xmlrpc/server.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/xmlrpc/server.py#L243-L278
def _marshaled_dispatch(self, data, dispatch_method = None, path = None): """Dispatches an XML-RPC method from marshalled (XML) data. XML-RPC methods are dispatched from the marshalled (XML) data using the _dispatch method and the result is returned as marshalled data. For backwards com...
[ "def", "_marshaled_dispatch", "(", "self", ",", "data", ",", "dispatch_method", "=", "None", ",", "path", "=", "None", ")", ":", "try", ":", "params", ",", "method", "=", "loads", "(", "data", ",", "use_builtin_types", "=", "self", ".", "use_builtin_types"...
Dispatches an XML-RPC method from marshalled (XML) data. XML-RPC methods are dispatched from the marshalled (XML) data using the _dispatch method and the result is returned as marshalled data. For backwards compatibility, a dispatch function can be provided as an argument (see comment i...
[ "Dispatches", "an", "XML", "-", "RPC", "method", "from", "marshalled", "(", "XML", ")", "data", "." ]
python
train
opennode/waldur-core
waldur_core/core/schemas.py
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L250-L258
def create_view(self, callback, method, request=None): """ Given a callback, return an actual view instance. """ view = super(WaldurSchemaGenerator, self).create_view(callback, method, request) if is_disabled_action(view): view.exclude_from_schema = True retu...
[ "def", "create_view", "(", "self", ",", "callback", ",", "method", ",", "request", "=", "None", ")", ":", "view", "=", "super", "(", "WaldurSchemaGenerator", ",", "self", ")", ".", "create_view", "(", "callback", ",", "method", ",", "request", ")", "if",...
Given a callback, return an actual view instance.
[ "Given", "a", "callback", "return", "an", "actual", "view", "instance", "." ]
python
train
pyhys/minimalmodbus
dummy_serial.py
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L118-L127
def open(self): """Open a (previously initialized) port on dummy_serial.""" if VERBOSE: _print_out('\nDummy_serial: Opening port\n') if self._isOpen: raise IOError('Dummy_serial: The port is already open') self._isOpen = True self.port = self...
[ "def", "open", "(", "self", ")", ":", "if", "VERBOSE", ":", "_print_out", "(", "'\\nDummy_serial: Opening port\\n'", ")", "if", "self", ".", "_isOpen", ":", "raise", "IOError", "(", "'Dummy_serial: The port is already open'", ")", "self", ".", "_isOpen", "=", "T...
Open a (previously initialized) port on dummy_serial.
[ "Open", "a", "(", "previously", "initialized", ")", "port", "on", "dummy_serial", "." ]
python
train
googleapis/google-cloud-python
bigtable/google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py#L1447-L1548
def update_app_profile( self, app_profile, update_mask, ignore_warnings=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Updates an app profile within an instance. ...
[ "def", "update_app_profile", "(", "self", ",", "app_profile", ",", "update_mask", ",", "ignore_warnings", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core...
Updates an app profile within an instance. Example: >>> from google.cloud import bigtable_admin_v2 >>> >>> client = bigtable_admin_v2.BigtableInstanceAdminClient() >>> >>> # TODO: Initialize `app_profile`: >>> app_profile = {} ...
[ "Updates", "an", "app", "profile", "within", "an", "instance", "." ]
python
train
numberoverzero/bloop
bloop/stream/shard.py
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/stream/shard.py#L206-L250
def load_children(self): """If the Shard doesn't have any children, tries to find some from DescribeStream. If the Shard is open this won't find any children, so an empty response doesn't mean the Shard will **never** have children. """ # Child count is fixed the first time any ...
[ "def", "load_children", "(", "self", ")", ":", "# Child count is fixed the first time any of the following happen:", "# 0 :: stream closed or throughput decreased", "# 1 :: shard was open for ~4 hours", "# 2 :: throughput increased", "if", "self", ".", "children", ":", "return", "sel...
If the Shard doesn't have any children, tries to find some from DescribeStream. If the Shard is open this won't find any children, so an empty response doesn't mean the Shard will **never** have children.
[ "If", "the", "Shard", "doesn", "t", "have", "any", "children", "tries", "to", "find", "some", "from", "DescribeStream", "." ]
python
train
django-leonardo/django-leonardo
leonardo/module/media/admin/folder/admin.py
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/folder/admin.py#L113-L136
def response_change(self, request, obj): """ Overrides the default to be able to forward to the directory listing instead of the default change_list_view """ r = super(FolderAdmin, self).response_change(request, obj) # Code borrowed from django ModelAdmin to determine cha...
[ "def", "response_change", "(", "self", ",", "request", ",", "obj", ")", ":", "r", "=", "super", "(", "FolderAdmin", ",", "self", ")", ".", "response_change", "(", "request", ",", "obj", ")", "# Code borrowed from django ModelAdmin to determine changelist on the", ...
Overrides the default to be able to forward to the directory listing instead of the default change_list_view
[ "Overrides", "the", "default", "to", "be", "able", "to", "forward", "to", "the", "directory", "listing", "instead", "of", "the", "default", "change_list_view" ]
python
train
aiogram/aiogram
aiogram/contrib/fsm_storage/redis.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/fsm_storage/redis.py#L77-L94
async def get_record(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None) -> typing.Dict: """ Get record from storage :param chat: :param user: :return: """ chat, user = s...
[ "async", "def", "get_record", "(", "self", ",", "*", ",", "chat", ":", "typing", ".", "Union", "[", "str", ",", "int", ",", "None", "]", "=", "None", ",", "user", ":", "typing", ".", "Union", "[", "str", ",", "int", ",", "None", "]", "=", "None...
Get record from storage :param chat: :param user: :return:
[ "Get", "record", "from", "storage" ]
python
train
adafruit/Adafruit_Python_LED_Backpack
Adafruit_LED_Backpack/BicolorMatrix8x8.py
https://github.com/adafruit/Adafruit_Python_LED_Backpack/blob/7356b4dd8b4bb162d60987878c2cb752fdd017d5/Adafruit_LED_Backpack/BicolorMatrix8x8.py#L41-L51
def set_pixel(self, x, y, value): """Set pixel at position x, y to the given value. X and Y should be values of 0 to 8. Value should be OFF, GREEN, RED, or YELLOW. """ if x < 0 or x > 7 or y < 0 or y > 7: # Ignore out of bounds pixels. return # Set green...
[ "def", "set_pixel", "(", "self", ",", "x", ",", "y", ",", "value", ")", ":", "if", "x", "<", "0", "or", "x", ">", "7", "or", "y", "<", "0", "or", "y", ">", "7", ":", "# Ignore out of bounds pixels.", "return", "# Set green LED based on 1st bit in value."...
Set pixel at position x, y to the given value. X and Y should be values of 0 to 8. Value should be OFF, GREEN, RED, or YELLOW.
[ "Set", "pixel", "at", "position", "x", "y", "to", "the", "given", "value", ".", "X", "and", "Y", "should", "be", "values", "of", "0", "to", "8", ".", "Value", "should", "be", "OFF", "GREEN", "RED", "or", "YELLOW", "." ]
python
train
saltstack/salt
salt/runners/queue.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/queue.py#L280-L304
def process_runner(quantity=1, queue=None, backend=None): ''' Process queued runners quantity number of runners to process queue queue to insert the runner reference into backend backend that to use for the queue CLI Example: .. code-block:: bash salt-ru...
[ "def", "process_runner", "(", "quantity", "=", "1", ",", "queue", "=", "None", ",", "backend", "=", "None", ")", ":", "queue_kwargs", "=", "__get_queue_opts", "(", "queue", "=", "queue", ",", "backend", "=", "backend", ")", "data", "=", "process_queue", ...
Process queued runners quantity number of runners to process queue queue to insert the runner reference into backend backend that to use for the queue CLI Example: .. code-block:: bash salt-run queue.process_runner salt-run queue.process_runner 5
[ "Process", "queued", "runners" ]
python
train
frejanordsiek/GeminiMotorDrive
GeminiMotorDrive/utilities.py
https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/utilities.py#L79-L99
def to_motor_distance(self, distance): """ Convert distance/s to motor units. Converts distance/s to units of motor encoder counts, which is what the drive requires when given move instructions. Parameters ---------- distance : int, float, or iterable of ints and floats...
[ "def", "to_motor_distance", "(", "self", ",", "distance", ")", ":", "if", "isinstance", "(", "distance", ",", "collections", ".", "Iterable", ")", ":", "return", "[", "(", "x", "*", "self", ".", "_distance_to_motor", ")", "for", "x", "in", "distance", "]...
Convert distance/s to motor units. Converts distance/s to units of motor encoder counts, which is what the drive requires when given move instructions. Parameters ---------- distance : int, float, or iterable of ints and floats The distance/s to convert. Re...
[ "Convert", "distance", "/", "s", "to", "motor", "units", "." ]
python
train
ibis-project/ibis
ibis/expr/api.py
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/api.py#L3402-L3502
def projection(table, exprs): """ Compute new table expression with the indicated column expressions from this table. Parameters ---------- exprs : column expression, or string, or list of column expressions and strings. If strings passed, must be columns in the table already Returns...
[ "def", "projection", "(", "table", ",", "exprs", ")", ":", "import", "ibis", ".", "expr", ".", "analysis", "as", "L", "if", "isinstance", "(", "exprs", ",", "(", "Expr", ",", "str", ")", ")", ":", "exprs", "=", "[", "exprs", "]", "projector", "=", ...
Compute new table expression with the indicated column expressions from this table. Parameters ---------- exprs : column expression, or string, or list of column expressions and strings. If strings passed, must be columns in the table already Returns ------- projection : TableExpr ...
[ "Compute", "new", "table", "expression", "with", "the", "indicated", "column", "expressions", "from", "this", "table", "." ]
python
train
sveetch/djangocodemirror
djangocodemirror/templatetags/djangocodemirror_tags.py
https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L285-L328
def codemirror_instance(config_name, varname, element_id, assets=True): """ Return HTML to init a CodeMirror instance for an element. This will output the whole HTML needed to initialize a CodeMirror instance with needed assets loading. Assets can be omitted with the ``assets`` option. Example...
[ "def", "codemirror_instance", "(", "config_name", ",", "varname", ",", "element_id", ",", "assets", "=", "True", ")", ":", "output", "=", "io", ".", "StringIO", "(", ")", "manifesto", "=", "CodemirrorAssetTagRender", "(", ")", "manifesto", ".", "register", "...
Return HTML to init a CodeMirror instance for an element. This will output the whole HTML needed to initialize a CodeMirror instance with needed assets loading. Assets can be omitted with the ``assets`` option. Example: :: {% load djangocodemirror_tags %} {% codemirror...
[ "Return", "HTML", "to", "init", "a", "CodeMirror", "instance", "for", "an", "element", "." ]
python
train
Parsl/parsl
parsl/dataflow/flow_control.py
https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/dataflow/flow_control.py#L131-L140
def make_callback(self, kind=None): """Makes the callback and resets the timer. KWargs: - kind (str): Default=None, used to pass information on what triggered the callback """ self._wake_up_time = time.time() + self.interval self.callback(tasks=se...
[ "def", "make_callback", "(", "self", ",", "kind", "=", "None", ")", ":", "self", ".", "_wake_up_time", "=", "time", ".", "time", "(", ")", "+", "self", ".", "interval", "self", ".", "callback", "(", "tasks", "=", "self", ".", "_event_buffer", ",", "k...
Makes the callback and resets the timer. KWargs: - kind (str): Default=None, used to pass information on what triggered the callback
[ "Makes", "the", "callback", "and", "resets", "the", "timer", "." ]
python
valid
DLR-RM/RAFCON
source/rafcon/gui/mygaphas/utils/gap_draw_helper.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/utils/gap_draw_helper.py#L33-L48
def limit_value_string_length(value): """This method limits the string representation of the value to MAX_VALUE_LABEL_TEXT_LENGTH + 3 characters. :param value: Value to limit string representation :return: String holding the value with a maximum length of MAX_VALUE_LABEL_TEXT_LENGTH + 3 """ if isin...
[ "def", "limit_value_string_length", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", "and", "len", "(", "value", ")", ">", "constants", ".", "MAX_VALUE_LABEL_TEXT_LENGTH", ":", "value", "=", "value", "[", ":", "constants", ...
This method limits the string representation of the value to MAX_VALUE_LABEL_TEXT_LENGTH + 3 characters. :param value: Value to limit string representation :return: String holding the value with a maximum length of MAX_VALUE_LABEL_TEXT_LENGTH + 3
[ "This", "method", "limits", "the", "string", "representation", "of", "the", "value", "to", "MAX_VALUE_LABEL_TEXT_LENGTH", "+", "3", "characters", "." ]
python
train
googleapis/google-cloud-python
logging/google/cloud/logging_v2/gapic/logging_service_v2_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging_v2/gapic/logging_service_v2_client.py#L416-L544
def list_log_entries( self, resource_names, project_ids=None, filter_=None, order_by=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lis...
[ "def", "list_log_entries", "(", "self", ",", "resource_names", ",", "project_ids", "=", "None", ",", "filter_", "=", "None", ",", "order_by", "=", "None", ",", "page_size", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", ...
Lists log entries. Use this method to retrieve log entries from Logging. For ways to export log entries, see `Exporting Logs <https://cloud.google.com/logging/docs/export>`__. Example: >>> from google.cloud import logging_v2 >>> >>> client = logging_v2.Loggin...
[ "Lists", "log", "entries", ".", "Use", "this", "method", "to", "retrieve", "log", "entries", "from", "Logging", ".", "For", "ways", "to", "export", "log", "entries", "see", "Exporting", "Logs", "<https", ":", "//", "cloud", ".", "google", ".", "com", "/"...
python
train
openstack/python-scciclient
scciclient/irmc/ipmi.py
https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L129-L170
def get_pci_device(d_info, pci_device_ids): """Get quantity of PCI devices. Get quantity of PCI devices of the node. :param d_info: the list of ipmitool parameters for accessing a node. :param pci_device_ids: the list contains pairs of <vendorID>/<deviceID> for PCI devices. :returns: the numbe...
[ "def", "get_pci_device", "(", "d_info", ",", "pci_device_ids", ")", ":", "# note:", "# Get quantity of PCI devices:", "# ipmi cmd '0xF1'", "#", "# $ ipmitool raw 0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00", "#", "# Raw response:", "# 80 28 00 00 00 05 data1 data2 34 17 76 11 00 04", "# ...
Get quantity of PCI devices. Get quantity of PCI devices of the node. :param d_info: the list of ipmitool parameters for accessing a node. :param pci_device_ids: the list contains pairs of <vendorID>/<deviceID> for PCI devices. :returns: the number of PCI devices.
[ "Get", "quantity", "of", "PCI", "devices", "." ]
python
train
peerplays-network/python-peerplays
peerplays/cli/bookie.py
https://github.com/peerplays-network/python-peerplays/blob/188f04238e7e21d5f73e9b01099eea44289ef6b7/peerplays/cli/bookie.py#L49-L55
def events(ctx, eventgroup): """ [bookie] List events for an event group :param str eventgroup: Event Group id """ eg = EventGroup(eventgroup, peerplays_instance=ctx.peerplays) click.echo(pretty_print(eg.events, ctx=ctx))
[ "def", "events", "(", "ctx", ",", "eventgroup", ")", ":", "eg", "=", "EventGroup", "(", "eventgroup", ",", "peerplays_instance", "=", "ctx", ".", "peerplays", ")", "click", ".", "echo", "(", "pretty_print", "(", "eg", ".", "events", ",", "ctx", "=", "c...
[bookie] List events for an event group :param str eventgroup: Event Group id
[ "[", "bookie", "]", "List", "events", "for", "an", "event", "group" ]
python
train
Holzhaus/python-cmuclmtk
cmuclmtk/__init__.py
https://github.com/Holzhaus/python-cmuclmtk/blob/67a5c6713c497ca644ea1c697a70e8d930c9d4b4/cmuclmtk/__init__.py#L448-L475
def binlm2arpa(input_file, output_file, verbosity=2): """ Converts a binary format language model, as generated by idngram2lm, into an an ARPA format language model. """ cmd = ['binlm2arpa', '-binary', input_file, '-arpa'. output_file] if verbosity: cmd.exte...
[ "def", "binlm2arpa", "(", "input_file", ",", "output_file", ",", "verbosity", "=", "2", ")", ":", "cmd", "=", "[", "'binlm2arpa'", ",", "'-binary'", ",", "input_file", ",", "'-arpa'", ".", "output_file", "]", "if", "verbosity", ":", "cmd", ".", "extend", ...
Converts a binary format language model, as generated by idngram2lm, into an an ARPA format language model.
[ "Converts", "a", "binary", "format", "language", "model", "as", "generated", "by", "idngram2lm", "into", "an", "an", "ARPA", "format", "language", "model", "." ]
python
train
shonenada/flask-rbac
flask_rbac/__init__.py
https://github.com/shonenada/flask-rbac/blob/e085121ff11825114e2d6f8419f0b6de6f9ba476/flask_rbac/__init__.py#L91-L98
def is_allowed(self, role, method, resource): """Check whether role is allowed to access resource :param role: Role to be checked. :param method: Method to be checked. :param resource: View function to be checked. """ return (role, method, resource) in self._allowed
[ "def", "is_allowed", "(", "self", ",", "role", ",", "method", ",", "resource", ")", ":", "return", "(", "role", ",", "method", ",", "resource", ")", "in", "self", ".", "_allowed" ]
Check whether role is allowed to access resource :param role: Role to be checked. :param method: Method to be checked. :param resource: View function to be checked.
[ "Check", "whether", "role", "is", "allowed", "to", "access", "resource" ]
python
valid
HPAC/matchpy
matchpy/expressions/expressions.py
https://github.com/HPAC/matchpy/blob/06b2ec50ee0efdf3dd183768c0ffdb51b7efc393/matchpy/expressions/expressions.py#L755-L770
def optional(name, default) -> 'Wildcard': """Create a `Wildcard` that matches a single argument with a default value. If the wildcard does not match, the substitution will contain the default value instead. Args: name: The name for the wildcard. ...
[ "def", "optional", "(", "name", ",", "default", ")", "->", "'Wildcard'", ":", "return", "Wildcard", "(", "min_count", "=", "1", ",", "fixed_size", "=", "True", ",", "variable_name", "=", "name", ",", "optional", "=", "default", ")" ]
Create a `Wildcard` that matches a single argument with a default value. If the wildcard does not match, the substitution will contain the default value instead. Args: name: The name for the wildcard. default: The default value of the wil...
[ "Create", "a", "Wildcard", "that", "matches", "a", "single", "argument", "with", "a", "default", "value", "." ]
python
train
wrobstory/vincent
vincent/visualization.py
https://github.com/wrobstory/vincent/blob/c5a06e50179015fbb788a7a42e4570ff4467a9e9/vincent/visualization.py#L77-L91
def viewport(value): """2-element list of ints : Dimensions of the viewport The viewport is a bounding box containing the visualization. If the dimensions of the visualization are larger than the viewport, then the visualization will be scrollable. If undefined, then the full v...
[ "def", "viewport", "(", "value", ")", ":", "if", "len", "(", "value", ")", "!=", "2", ":", "raise", "ValueError", "(", "'viewport must have 2 dimensions'", ")", "for", "v", "in", "value", ":", "_assert_is_type", "(", "'viewport dimension'", ",", "v", ",", ...
2-element list of ints : Dimensions of the viewport The viewport is a bounding box containing the visualization. If the dimensions of the visualization are larger than the viewport, then the visualization will be scrollable. If undefined, then the full visualization is shown.
[ "2", "-", "element", "list", "of", "ints", ":", "Dimensions", "of", "the", "viewport" ]
python
train
openai/universe
universe/wrappers/recording.py
https://github.com/openai/universe/blob/cc9ce6ec241821bfb0f3b85dd455bd36e4ee7a8c/universe/wrappers/recording.py#L77-L88
def _get_writer(self, i): """ Returns a tuple of (log_fn, log_f, bin_fn, bin_f) to be written to by vectorized env channel i Or all Nones if recording is inactive on that channel """ if self._recording_dir is None: return None if self._log_n is None: ...
[ "def", "_get_writer", "(", "self", ",", "i", ")", ":", "if", "self", ".", "_recording_dir", "is", "None", ":", "return", "None", "if", "self", ".", "_log_n", "is", "None", ":", "self", ".", "_log_n", "=", "[", "None", "]", "*", "self", ".", "n", ...
Returns a tuple of (log_fn, log_f, bin_fn, bin_f) to be written to by vectorized env channel i Or all Nones if recording is inactive on that channel
[ "Returns", "a", "tuple", "of", "(", "log_fn", "log_f", "bin_fn", "bin_f", ")", "to", "be", "written", "to", "by", "vectorized", "env", "channel", "i", "Or", "all", "Nones", "if", "recording", "is", "inactive", "on", "that", "channel" ]
python
train
bhmm/bhmm
bhmm/util/statistics.py
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/util/statistics.py#L108-L151
def confidence_interval_arr(data, conf=0.95): r""" Computes element-wise confidence intervals from a sample of ndarrays Given a sample of arbitrarily shaped ndarrays, computes element-wise confidence intervals Parameters ---------- data : ndarray (K, (shape)) ndarray of ndarrays, the first...
[ "def", "confidence_interval_arr", "(", "data", ",", "conf", "=", "0.95", ")", ":", "if", "conf", "<", "0", "or", "conf", ">", "1", ":", "raise", "ValueError", "(", "'Not a meaningful confidence level: '", "+", "str", "(", "conf", ")", ")", "# list or 1D-arra...
r""" Computes element-wise confidence intervals from a sample of ndarrays Given a sample of arbitrarily shaped ndarrays, computes element-wise confidence intervals Parameters ---------- data : ndarray (K, (shape)) ndarray of ndarrays, the first index is a sample index, the remaining indexes ar...
[ "r", "Computes", "element", "-", "wise", "confidence", "intervals", "from", "a", "sample", "of", "ndarrays" ]
python
train
djgagne/hagelslag
hagelslag/processing/ObjectMatcher.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/ObjectMatcher.py#L190-L224
def match(self, set_a, set_b): """ For each step in each track from set_a, identify all steps in all tracks from set_b that meet all cost function criteria Args: set_a: List of STObjects set_b: List of STObjects Returns: track_pairing...
[ "def", "match", "(", "self", ",", "set_a", ",", "set_b", ")", ":", "track_step_matches", "=", "[", "[", "]", "*", "len", "(", "set_a", ")", "]", "costs", "=", "self", ".", "cost_matrix", "(", "set_a", ",", "set_b", ")", "valid_costs", "=", "np", "....
For each step in each track from set_a, identify all steps in all tracks from set_b that meet all cost function criteria Args: set_a: List of STObjects set_b: List of STObjects Returns: track_pairings: pandas.DataFrame
[ "For", "each", "step", "in", "each", "track", "from", "set_a", "identify", "all", "steps", "in", "all", "tracks", "from", "set_b", "that", "meet", "all", "cost", "function", "criteria", "Args", ":", "set_a", ":", "List", "of", "STObjects", "set_b", ":", ...
python
train
Spinmob/spinmob
_data.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L1171-L1200
def trim(self, *conditions): """ Removes data points not satisfying the supplied conditions. Conditions can be truth arrays (having the same length as the columns!) or scripted strings. Example Workflow ---------------- d1 = spinmob.data.load() d2 = d1.tr...
[ "def", "trim", "(", "self", ",", "*", "conditions", ")", ":", "conditions", "=", "list", "(", "conditions", ")", "# if necessary, evaluate string scripts", "for", "n", "in", "range", "(", "len", "(", "conditions", ")", ")", ":", "if", "type", "(", "conditi...
Removes data points not satisfying the supplied conditions. Conditions can be truth arrays (having the same length as the columns!) or scripted strings. Example Workflow ---------------- d1 = spinmob.data.load() d2 = d1.trim( (2<d1[0]) & (d1[0]<10) | (d1[3]==22), 'sin(d[...
[ "Removes", "data", "points", "not", "satisfying", "the", "supplied", "conditions", ".", "Conditions", "can", "be", "truth", "arrays", "(", "having", "the", "same", "length", "as", "the", "columns!", ")", "or", "scripted", "strings", "." ]
python
train
fastavro/fastavro
fastavro/_write_py.py
https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L70-L75
def prepare_date(data, schema): """Converts datetime.date to int timestamp""" if isinstance(data, datetime.date): return data.toordinal() - DAYS_SHIFT else: return data
[ "def", "prepare_date", "(", "data", ",", "schema", ")", ":", "if", "isinstance", "(", "data", ",", "datetime", ".", "date", ")", ":", "return", "data", ".", "toordinal", "(", ")", "-", "DAYS_SHIFT", "else", ":", "return", "data" ]
Converts datetime.date to int timestamp
[ "Converts", "datetime", ".", "date", "to", "int", "timestamp" ]
python
train
odlgroup/odl
odl/tomo/analytic/filtered_back_projection.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/tomo/analytic/filtered_back_projection.py#L49-L101
def _fbp_filter(norm_freq, filter_type, frequency_scaling): """Create a smoothing filter for FBP. Parameters ---------- norm_freq : `array-like` Frequencies normalized to lie in the interval [0, 1]. filter_type : {'Ram-Lak', 'Shepp-Logan', 'Cosine', 'Hamming', 'Hann', cal...
[ "def", "_fbp_filter", "(", "norm_freq", ",", "filter_type", ",", "frequency_scaling", ")", ":", "filter_type", ",", "filter_type_in", "=", "str", "(", "filter_type", ")", ".", "lower", "(", ")", ",", "filter_type", "if", "callable", "(", "filter_type", ")", ...
Create a smoothing filter for FBP. Parameters ---------- norm_freq : `array-like` Frequencies normalized to lie in the interval [0, 1]. filter_type : {'Ram-Lak', 'Shepp-Logan', 'Cosine', 'Hamming', 'Hann', callable} The type of filter to be used. If a string i...
[ "Create", "a", "smoothing", "filter", "for", "FBP", "." ]
python
train
alimanfoo/vcfnp
vcfnp/array.py
https://github.com/alimanfoo/vcfnp/blob/c3f63fb11ada56d4a88076c61c81f99b8ee78b8f/vcfnp/array.py#L34-L138
def variants(vcf_fn, region=None, fields=None, exclude_fields=None, dtypes=None, arities=None, fills=None, transformers=None, vcf_types=None, count=None, progress=0, logstream=None, condition=None, slice_args=None, flatten_filter=False, verbose=True, cache=False, cach...
[ "def", "variants", "(", "vcf_fn", ",", "region", "=", "None", ",", "fields", "=", "None", ",", "exclude_fields", "=", "None", ",", "dtypes", "=", "None", ",", "arities", "=", "None", ",", "fills", "=", "None", ",", "transformers", "=", "None", ",", "...
Load an numpy structured array with data from the fixed fields of a VCF file (including INFO). Parameters ---------- vcf_fn: string or list Name of the VCF file or list of file names. region: string, optional Region to extract, e.g., 'chr1' or 'chr1:0-100000'. fields: list or a...
[ "Load", "an", "numpy", "structured", "array", "with", "data", "from", "the", "fixed", "fields", "of", "a", "VCF", "file", "(", "including", "INFO", ")", "." ]
python
train
iotile/coretools
transport_plugins/websocket/iotile_transport_websocket/device_adapter.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/device_adapter.py#L178-L188
async def _on_report_notification(self, event): """Callback function called when a report event is received. Args: event (dict): The report_event """ conn_string = event.get('connection_string') report = self._report_parser.deserialize_report(event.get('serialized_r...
[ "async", "def", "_on_report_notification", "(", "self", ",", "event", ")", ":", "conn_string", "=", "event", ".", "get", "(", "'connection_string'", ")", "report", "=", "self", ".", "_report_parser", ".", "deserialize_report", "(", "event", ".", "get", "(", ...
Callback function called when a report event is received. Args: event (dict): The report_event
[ "Callback", "function", "called", "when", "a", "report", "event", "is", "received", "." ]
python
train
googleapis/google-cloud-python
datastore/google/cloud/datastore/query.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/query.py#L262-L271
def projection(self, projection): """Set the fields returned the query. :type projection: str or sequence of strings :param projection: Each value is a string giving the name of a property to be included in the projection query. """ if isinstance(proje...
[ "def", "projection", "(", "self", ",", "projection", ")", ":", "if", "isinstance", "(", "projection", ",", "str", ")", ":", "projection", "=", "[", "projection", "]", "self", ".", "_projection", "[", ":", "]", "=", "projection" ]
Set the fields returned the query. :type projection: str or sequence of strings :param projection: Each value is a string giving the name of a property to be included in the projection query.
[ "Set", "the", "fields", "returned", "the", "query", "." ]
python
train
unt-libraries/pyuntl
pyuntl/highwire_structure.py
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L77-L84
def get_publisher_name(self, **kwargs): """Get the publisher name.""" children = kwargs.get('children', []) # Find the creator type in children. for child in children: if child.tag == 'name': return child.content return None
[ "def", "get_publisher_name", "(", "self", ",", "*", "*", "kwargs", ")", ":", "children", "=", "kwargs", ".", "get", "(", "'children'", ",", "[", "]", ")", "# Find the creator type in children.", "for", "child", "in", "children", ":", "if", "child", ".", "t...
Get the publisher name.
[ "Get", "the", "publisher", "name", "." ]
python
train
fossasia/knittingpattern
knittingpattern/convert/AYABPNGBuilder.py
https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/convert/AYABPNGBuilder.py#L75-L80
def _set_pixel_and_convert_color(self, x, y, color): """set the pixel but convert the color before.""" if color is None: return color = self._convert_color_to_rrggbb(color) self._set_pixel(x, y, color)
[ "def", "_set_pixel_and_convert_color", "(", "self", ",", "x", ",", "y", ",", "color", ")", ":", "if", "color", "is", "None", ":", "return", "color", "=", "self", ".", "_convert_color_to_rrggbb", "(", "color", ")", "self", ".", "_set_pixel", "(", "x", ","...
set the pixel but convert the color before.
[ "set", "the", "pixel", "but", "convert", "the", "color", "before", "." ]
python
valid
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/external/mathjax.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/external/mathjax.py#L32-L79
def install_mathjax(tag='v1.1', replace=False): """Download and install MathJax for offline use. This will install mathjax to the 'static' dir in the IPython notebook package, so it will fail if the caller does not have write access to that location. MathJax is a ~15MB download, and ~150MB...
[ "def", "install_mathjax", "(", "tag", "=", "'v1.1'", ",", "replace", "=", "False", ")", ":", "mathjax_url", "=", "\"https://github.com/mathjax/MathJax/tarball/%s\"", "%", "tag", "nbdir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "a...
Download and install MathJax for offline use. This will install mathjax to the 'static' dir in the IPython notebook package, so it will fail if the caller does not have write access to that location. MathJax is a ~15MB download, and ~150MB installed. Parameters ---------- ...
[ "Download", "and", "install", "MathJax", "for", "offline", "use", ".", "This", "will", "install", "mathjax", "to", "the", "static", "dir", "in", "the", "IPython", "notebook", "package", "so", "it", "will", "fail", "if", "the", "caller", "does", "not", "hav...
python
test
gesellkammer/sndfileio
sndfileio/dsp.py
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/dsp.py#L32-L60
def lowpass_cheby2_coeffs(freq, sr, maxorder=12): # type: (float, int, int) -> Tuple[np.ndarray, np.ndarray, float] """ freq : The frequency above which signals are attenuated with 95 dB sr : Sampling rate in Hz. maxorder: Maximal order of the designed cheby2 filter Return...
[ "def", "lowpass_cheby2_coeffs", "(", "freq", ",", "sr", ",", "maxorder", "=", "12", ")", ":", "# type: (float, int, int) -> Tuple[np.ndarray, np.ndarray, float]", "nyquist", "=", "sr", "*", "0.5", "# rp - maximum ripple of passband, rs - attenuation of stopband", "rp", ",", ...
freq : The frequency above which signals are attenuated with 95 dB sr : Sampling rate in Hz. maxorder: Maximal order of the designed cheby2 filter Returns --> (b coeffs, a coeffs, freq_passband)
[ "freq", ":", "The", "frequency", "above", "which", "signals", "are", "attenuated", "with", "95", "dB", "sr", ":", "Sampling", "rate", "in", "Hz", ".", "maxorder", ":", "Maximal", "order", "of", "the", "designed", "cheby2", "filter" ]
python
train
biocore/burrito-fillings
bfillings/seqprep.py
https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/seqprep.py#L145-L153
def _discarded_reads1_out_file_name(self): """Checks if file name is set for discarded reads1 output. Returns absolute path.""" if self.Parameters['-3'].isOn(): discarded_reads1 = self._absolute(str(self.Parameters['-3'].Value)) else: raise ValueError( ...
[ "def", "_discarded_reads1_out_file_name", "(", "self", ")", ":", "if", "self", ".", "Parameters", "[", "'-3'", "]", ".", "isOn", "(", ")", ":", "discarded_reads1", "=", "self", ".", "_absolute", "(", "str", "(", "self", ".", "Parameters", "[", "'-3'", "]...
Checks if file name is set for discarded reads1 output. Returns absolute path.
[ "Checks", "if", "file", "name", "is", "set", "for", "discarded", "reads1", "output", ".", "Returns", "absolute", "path", "." ]
python
train
CivicSpleen/ambry
ambry/bundle/bundle.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/bundle.py#L1419-L1440
def sync_in(self, force=False): """Synchronize from files to records, and records to objects""" self.log('---- Sync In ----') self.dstate = self.STATES.BUILDING for path_name in self.source_fs.listdir(): f = self.build_source_files.instance_from_name(path_name) ...
[ "def", "sync_in", "(", "self", ",", "force", "=", "False", ")", ":", "self", ".", "log", "(", "'---- Sync In ----'", ")", "self", ".", "dstate", "=", "self", ".", "STATES", ".", "BUILDING", "for", "path_name", "in", "self", ".", "source_fs", ".", "list...
Synchronize from files to records, and records to objects
[ "Synchronize", "from", "files", "to", "records", "and", "records", "to", "objects" ]
python
train
SheffieldML/GPy
GPy/kern/src/stationary.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/kern/src/stationary.py#L118-L123
def dK_dr_via_X(self, X, X2): """ compute the derivative of K wrt X going through X """ #a convenience function, so we can cache dK_dr return self.dK_dr(self._scaled_dist(X, X2))
[ "def", "dK_dr_via_X", "(", "self", ",", "X", ",", "X2", ")", ":", "#a convenience function, so we can cache dK_dr", "return", "self", ".", "dK_dr", "(", "self", ".", "_scaled_dist", "(", "X", ",", "X2", ")", ")" ]
compute the derivative of K wrt X going through X
[ "compute", "the", "derivative", "of", "K", "wrt", "X", "going", "through", "X" ]
python
train
dropbox/stone
stone/backends/python_types.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/python_types.py#L660-L713
def _generate_custom_annotation_processors(self, ns, data_type, extra_annotations=()): """ Generates code that will run a custom function 'processor' on every field with a custom annotation, no matter how deep (recursively) it might be located in data_type (incl. in elements of lists or ...
[ "def", "_generate_custom_annotation_processors", "(", "self", ",", "ns", ",", "data_type", ",", "extra_annotations", "=", "(", ")", ")", ":", "# annotations applied to members of this type", "dt", ",", "_", ",", "_", "=", "unwrap", "(", "data_type", ")", "if", "...
Generates code that will run a custom function 'processor' on every field with a custom annotation, no matter how deep (recursively) it might be located in data_type (incl. in elements of lists or maps). If extra_annotations is passed, it's assumed to be a list of custom annotation appli...
[ "Generates", "code", "that", "will", "run", "a", "custom", "function", "processor", "on", "every", "field", "with", "a", "custom", "annotation", "no", "matter", "how", "deep", "(", "recursively", ")", "it", "might", "be", "located", "in", "data_type", "(", ...
python
train
tanghaibao/goatools
goatools/gosubdag/rpt/wr_xlsx.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/rpt/wr_xlsx.py#L51-L55
def get_nts_sections(self, sections, sortby=None): """Given a list of sections containing GO IDs, get a list of sections w/GO nts.""" goids = self.get_goids_sections(sections) gosubdag = GoSubDag(goids, self.go2obj) return [(sec, gosubdag.get_nts(gos, sortby)) for sec, gos in sections]
[ "def", "get_nts_sections", "(", "self", ",", "sections", ",", "sortby", "=", "None", ")", ":", "goids", "=", "self", ".", "get_goids_sections", "(", "sections", ")", "gosubdag", "=", "GoSubDag", "(", "goids", ",", "self", ".", "go2obj", ")", "return", "[...
Given a list of sections containing GO IDs, get a list of sections w/GO nts.
[ "Given", "a", "list", "of", "sections", "containing", "GO", "IDs", "get", "a", "list", "of", "sections", "w", "/", "GO", "nts", "." ]
python
train
saltstack/salt
salt/states/memcached.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/memcached.py#L34-L101
def managed(name, value=None, host=DEFAULT_HOST, port=DEFAULT_PORT, time=DEFAULT_TIME, min_compress_len=DEFAULT_MIN_COMPRESS_LEN): ''' Manage a memcached key. name The key to manage value The value to set for that key hos...
[ "def", "managed", "(", "name", ",", "value", "=", "None", ",", "host", "=", "DEFAULT_HOST", ",", "port", "=", "DEFAULT_PORT", ",", "time", "=", "DEFAULT_TIME", ",", "min_compress_len", "=", "DEFAULT_MIN_COMPRESS_LEN", ")", ":", "ret", "=", "{", "'name'", "...
Manage a memcached key. name The key to manage value The value to set for that key host The memcached server IP address port The memcached server port .. code-block:: yaml foo: memcached.managed: - value: bar
[ "Manage", "a", "memcached", "key", "." ]
python
train
keon/algorithms
algorithms/bit/subsets.py
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/bit/subsets.py#L21-L34
def subsets(nums): """ :param nums: List[int] :return: Set[tuple] """ n = len(nums) total = 1 << n res = set() for i in range(total): subset = tuple(num for j, num in enumerate(nums) if i & 1 << j) res.add(subset) return res
[ "def", "subsets", "(", "nums", ")", ":", "n", "=", "len", "(", "nums", ")", "total", "=", "1", "<<", "n", "res", "=", "set", "(", ")", "for", "i", "in", "range", "(", "total", ")", ":", "subset", "=", "tuple", "(", "num", "for", "j", ",", "...
:param nums: List[int] :return: Set[tuple]
[ ":", "param", "nums", ":", "List", "[", "int", "]", ":", "return", ":", "Set", "[", "tuple", "]" ]
python
train
Bogdanp/dramatiq
dramatiq/worker.py
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L102-L106
def resume(self): """Resumes all the worker threads. """ for child in chain(self.consumers.values(), self.workers): child.resume()
[ "def", "resume", "(", "self", ")", ":", "for", "child", "in", "chain", "(", "self", ".", "consumers", ".", "values", "(", ")", ",", "self", ".", "workers", ")", ":", "child", ".", "resume", "(", ")" ]
Resumes all the worker threads.
[ "Resumes", "all", "the", "worker", "threads", "." ]
python
train
pauleveritt/kaybee
kaybee/plugins/resources/base_resource.py
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/resources/base_resource.py#L76-L102
def acquire(self, resources, prop_name): """ Starting with self, walk until you find prop or None """ # Instance custom_prop = getattr(self.props, prop_name, None) if custom_prop: return custom_prop # Parents...can't use acquire as have to keep going on acquireds ...
[ "def", "acquire", "(", "self", ",", "resources", ",", "prop_name", ")", ":", "# Instance", "custom_prop", "=", "getattr", "(", "self", ".", "props", ",", "prop_name", ",", "None", ")", "if", "custom_prop", ":", "return", "custom_prop", "# Parents...can't use a...
Starting with self, walk until you find prop or None
[ "Starting", "with", "self", "walk", "until", "you", "find", "prop", "or", "None" ]
python
train
10gen/mongo-orchestration
mongo_orchestration/apps/links.py
https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/apps/links.py#L112-L127
def all_base_links(rel_to=None): """Get a list of all links to be included to base (/) API requests.""" links = [ base_link('get-releases'), base_link('service'), server_link('get-servers'), server_link('add-server'), replica_set_link('add-replica-set'), replica_s...
[ "def", "all_base_links", "(", "rel_to", "=", "None", ")", ":", "links", "=", "[", "base_link", "(", "'get-releases'", ")", ",", "base_link", "(", "'service'", ")", ",", "server_link", "(", "'get-servers'", ")", ",", "server_link", "(", "'add-server'", ")", ...
Get a list of all links to be included to base (/) API requests.
[ "Get", "a", "list", "of", "all", "links", "to", "be", "included", "to", "base", "(", "/", ")", "API", "requests", "." ]
python
train
tcalmant/python-javaobj
javaobj/core.py
https://github.com/tcalmant/python-javaobj/blob/e042c2cbf1ce9de659b6cb9290b5ccd5442514d1/javaobj/core.py#L941-L952
def do_string(self, parent=None, ident=0): """ Handles a TC_STRING opcode :param parent: :param ident: Log indentation level :return: A string """ log_debug("[string]", ident) ba = JavaString(self._readString()) self._add_reference(ba, ident) ...
[ "def", "do_string", "(", "self", ",", "parent", "=", "None", ",", "ident", "=", "0", ")", ":", "log_debug", "(", "\"[string]\"", ",", "ident", ")", "ba", "=", "JavaString", "(", "self", ".", "_readString", "(", ")", ")", "self", ".", "_add_reference", ...
Handles a TC_STRING opcode :param parent: :param ident: Log indentation level :return: A string
[ "Handles", "a", "TC_STRING", "opcode" ]
python
train
decryptus/httpdis
httpdis/httpdis.py
https://github.com/decryptus/httpdis/blob/5d198cdc5558f416634602689b3df2c8aeb34984/httpdis/httpdis.py#L489-L523
def send_error_explain(self, code, message=None, headers=None, content_type=None): "do not use directly" if headers is None: headers = {} if code in self.responses: if message is None: message = self.responses[code][0] explain = self.response...
[ "def", "send_error_explain", "(", "self", ",", "code", ",", "message", "=", "None", ",", "headers", "=", "None", ",", "content_type", "=", "None", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "{", "}", "if", "code", "in", "self", "."...
do not use directly
[ "do", "not", "use", "directly" ]
python
train
kisom/pypcapfile
pcapfile/protocols/linklayer/ethernet.py
https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/ethernet.py#L31-L47
def load_network(self, layers=1): """ Given an Ethernet frame, determine the appropriate sub-protocol; If layers is greater than zerol determine the type of the payload and load the appropriate type of network packet. It is expected that the payload be a hexified string. The laye...
[ "def", "load_network", "(", "self", ",", "layers", "=", "1", ")", ":", "if", "layers", ":", "ctor", "=", "payload_type", "(", "self", ".", "type", ")", "[", "0", "]", "if", "ctor", ":", "ctor", "=", "ctor", "payload", "=", "self", ".", "payload", ...
Given an Ethernet frame, determine the appropriate sub-protocol; If layers is greater than zerol determine the type of the payload and load the appropriate type of network packet. It is expected that the payload be a hexified string. The layers argument determines how many layers to desc...
[ "Given", "an", "Ethernet", "frame", "determine", "the", "appropriate", "sub", "-", "protocol", ";", "If", "layers", "is", "greater", "than", "zerol", "determine", "the", "type", "of", "the", "payload", "and", "load", "the", "appropriate", "type", "of", "netw...
python
valid
rigetti/pyquil
pyquil/reference_simulator.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/reference_simulator.py#L120-L130
def expectation(self, operator: Union[PauliTerm, PauliSum]): """ Compute the expectation of an operator. :param operator: The operator :return: The operator's expectation value """ if not isinstance(operator, PauliSum): operator = PauliSum([operator]) ...
[ "def", "expectation", "(", "self", ",", "operator", ":", "Union", "[", "PauliTerm", ",", "PauliSum", "]", ")", ":", "if", "not", "isinstance", "(", "operator", ",", "PauliSum", ")", ":", "operator", "=", "PauliSum", "(", "[", "operator", "]", ")", "ret...
Compute the expectation of an operator. :param operator: The operator :return: The operator's expectation value
[ "Compute", "the", "expectation", "of", "an", "operator", "." ]
python
train
WoLpH/mailjet
mailjet/contrib/django_mailjet/forms.py
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L54-L68
def list_id(self): """ Get or create the list id. """ list_id = getattr(self, '_list_id', None) if list_id is None: for l in self.api.lists.all()['lists']: if l['name'] == self.list_name: self._list_id = l['id'] if not getattr(self, '...
[ "def", "list_id", "(", "self", ")", ":", "list_id", "=", "getattr", "(", "self", ",", "'_list_id'", ",", "None", ")", "if", "list_id", "is", "None", ":", "for", "l", "in", "self", ".", "api", ".", "lists", ".", "all", "(", ")", "[", "'lists'", "]...
Get or create the list id.
[ "Get", "or", "create", "the", "list", "id", "." ]
python
train
portfors-lab/sparkle
sparkle/gui/dialogs/saving_dlg.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/saving_dlg.py#L43-L59
def getfile(self): """Gets the full file path of the entered/selected file :returns: str -- the name of the data file to open/create """ current_file = str(self.selectedFiles()[0]) if os.path.isfile(current_file): print 'current_file', current_file if cur...
[ "def", "getfile", "(", "self", ")", ":", "current_file", "=", "str", "(", "self", ".", "selectedFiles", "(", ")", "[", "0", "]", ")", "if", "os", ".", "path", ".", "isfile", "(", "current_file", ")", ":", "print", "'current_file'", ",", "current_file",...
Gets the full file path of the entered/selected file :returns: str -- the name of the data file to open/create
[ "Gets", "the", "full", "file", "path", "of", "the", "entered", "/", "selected", "file" ]
python
train
cokelaer/spectrum
src/spectrum/mtm.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/mtm.py#L359-L418
def _other_dpss_method(N, NW, Kmax): """Returns the Discrete Prolate Spheroidal Sequences of orders [0,Kmax-1] for a given frequency-spacing multiple NW and sequence length N. See dpss function that is the official version. This version is indepedant of the C code and relies on Scipy function. However,...
[ "def", "_other_dpss_method", "(", "N", ",", "NW", ",", "Kmax", ")", ":", "# here we want to set up an optimization problem to find a sequence", "# whose energy is maximally concentrated within band [-W,W].", "# Thus, the measure lambda(T,W) is the ratio between the energy within", "# that ...
Returns the Discrete Prolate Spheroidal Sequences of orders [0,Kmax-1] for a given frequency-spacing multiple NW and sequence length N. See dpss function that is the official version. This version is indepedant of the C code and relies on Scipy function. However, it is slower by a factor 3 Tridiagonal...
[ "Returns", "the", "Discrete", "Prolate", "Spheroidal", "Sequences", "of", "orders", "[", "0", "Kmax", "-", "1", "]", "for", "a", "given", "frequency", "-", "spacing", "multiple", "NW", "and", "sequence", "length", "N", "." ]
python
valid
vtkiorg/vtki
vtki/utilities.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L263-L283
def is_inside_bounds(point, bounds): """ Checks if a point is inside a set of bounds. This is implemented through recursion so that this is N-dimensional. """ if isinstance(point, (int, float)): point = [point] if isinstance(point, collections.Iterable) and not isinstance(point, collections....
[ "def", "is_inside_bounds", "(", "point", ",", "bounds", ")", ":", "if", "isinstance", "(", "point", ",", "(", "int", ",", "float", ")", ")", ":", "point", "=", "[", "point", "]", "if", "isinstance", "(", "point", ",", "collections", ".", "Iterable", ...
Checks if a point is inside a set of bounds. This is implemented through recursion so that this is N-dimensional.
[ "Checks", "if", "a", "point", "is", "inside", "a", "set", "of", "bounds", ".", "This", "is", "implemented", "through", "recursion", "so", "that", "this", "is", "N", "-", "dimensional", "." ]
python
train
saltstack/salt
salt/proxy/fx2.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L351-L368
def ping(): ''' Is the chassis responding? :return: Returns False if the chassis didn't respond, True otherwise. ''' r = __salt__['dracr.system_info'](host=DETAILS['host'], admin_username=DETAILS['admin_username'], admin_p...
[ "def", "ping", "(", ")", ":", "r", "=", "__salt__", "[", "'dracr.system_info'", "]", "(", "host", "=", "DETAILS", "[", "'host'", "]", ",", "admin_username", "=", "DETAILS", "[", "'admin_username'", "]", ",", "admin_password", "=", "DETAILS", "[", "'admin_p...
Is the chassis responding? :return: Returns False if the chassis didn't respond, True otherwise.
[ "Is", "the", "chassis", "responding?" ]
python
train
matthiask/django-cte-forest
cte_forest/models.py
https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/models.py#L335-L346
def branches(self): """ Returns a :class:`QuerySet` of all branch nodes (nodes with at least one child). :return: A :class:`QuerySet` of all leaf nodes (nodes with at least one child). """ # We need to read the _cte_node_children attribute, so ensure it e...
[ "def", "branches", "(", "self", ")", ":", "# We need to read the _cte_node_children attribute, so ensure it exists.", "self", ".", "_ensure_parameters", "(", ")", "return", "self", ".", "filter", "(", "*", "*", "{", "\"%s__id__in\"", "%", "self", ".", "model", ".", ...
Returns a :class:`QuerySet` of all branch nodes (nodes with at least one child). :return: A :class:`QuerySet` of all leaf nodes (nodes with at least one child).
[ "Returns", "a", ":", "class", ":", "QuerySet", "of", "all", "branch", "nodes", "(", "nodes", "with", "at", "least", "one", "child", ")", "." ]
python
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L181-L195
def split_header(fp): """ Read file pointer and return pair of lines lists: first - header, second - the rest. """ body_start, header_ended = 0, False lines = [] for line in fp: if line.startswith('#') and not header_ended: # Header tex...
[ "def", "split_header", "(", "fp", ")", ":", "body_start", ",", "header_ended", "=", "0", ",", "False", "lines", "=", "[", "]", "for", "line", "in", "fp", ":", "if", "line", ".", "startswith", "(", "'#'", ")", "and", "not", "header_ended", ":", "# Hea...
Read file pointer and return pair of lines lists: first - header, second - the rest.
[ "Read", "file", "pointer", "and", "return", "pair", "of", "lines", "lists", ":", "first", "-", "header", "second", "-", "the", "rest", "." ]
python
train
PyCQA/pylint
pylint/checkers/typecheck.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/typecheck.py#L1434-L1439
def visit_unaryop(self, node): """Detect TypeErrors for unary operands.""" for error in node.type_errors(): # Let the error customize its output. self.add_message("invalid-unary-operand-type", args=str(error), node=node)
[ "def", "visit_unaryop", "(", "self", ",", "node", ")", ":", "for", "error", "in", "node", ".", "type_errors", "(", ")", ":", "# Let the error customize its output.", "self", ".", "add_message", "(", "\"invalid-unary-operand-type\"", ",", "args", "=", "str", "(",...
Detect TypeErrors for unary operands.
[ "Detect", "TypeErrors", "for", "unary", "operands", "." ]
python
test
littlemo/moear-spider-zhihudaily
moear_spider_zhihudaily/spiders/zhihu_daily.py
https://github.com/littlemo/moear-spider-zhihudaily/blob/1e4e60b547afe3e2fbb3bbcb7d07a75dca608149/moear_spider_zhihudaily/spiders/zhihu_daily.py#L126-L166
def parse_post(self, response): ''' 根据 :meth:`.ZhihuDailySpider.parse` 中生成的具体文章地址,获取到文章内容, 并对其进行格式化处理,结果填充到对象属性 ``item_list`` 中 :param Response response: 由 ``Scrapy`` 调用并传入的请求响应对象 ''' content = json.loads(response.body.decode(), encoding='UTF-8') post = response....
[ "def", "parse_post", "(", "self", ",", "response", ")", ":", "content", "=", "json", ".", "loads", "(", "response", ".", "body", ".", "decode", "(", ")", ",", "encoding", "=", "'UTF-8'", ")", "post", "=", "response", ".", "meta", "[", "'post'", "]", ...
根据 :meth:`.ZhihuDailySpider.parse` 中生成的具体文章地址,获取到文章内容, 并对其进行格式化处理,结果填充到对象属性 ``item_list`` 中 :param Response response: 由 ``Scrapy`` 调用并传入的请求响应对象
[ "根据", ":", "meth", ":", ".", "ZhihuDailySpider", ".", "parse", "中生成的具体文章地址,获取到文章内容,", "并对其进行格式化处理,结果填充到对象属性", "item_list", "中" ]
python
train
SoCo/SoCo
soco/services.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L373-L424
def build_command(self, action, args=None): """Build a SOAP request. Args: action (str): the name of an action (a string as specified in the service description XML file) to be sent. args (list, optional): Relevant arguments as a list of (name, va...
[ "def", "build_command", "(", "self", ",", "action", ",", "args", "=", "None", ")", ":", "# A complete request should look something like this:", "# POST path of control URL HTTP/1.1", "# HOST: host of control URL:port of control URL", "# CONTENT-LENGTH: bytes in body", "# CONTENT-TYP...
Build a SOAP request. Args: action (str): the name of an action (a string as specified in the service description XML file) to be sent. args (list, optional): Relevant arguments as a list of (name, value) tuples. Returns: tuple: a tup...
[ "Build", "a", "SOAP", "request", "." ]
python
train
spacetelescope/drizzlepac
drizzlepac/imageObject.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/imageObject.py#L1151-L1168
def compute_wcslin(self,undistort=True): """ Compute the undistorted WCS based solely on the known distortion model information associated with the WCS. """ for chip in range(1,self._numchips+1,1): sci_chip = self._image[self.scienceExt,chip] chip_wcs = sci_ch...
[ "def", "compute_wcslin", "(", "self", ",", "undistort", "=", "True", ")", ":", "for", "chip", "in", "range", "(", "1", ",", "self", ".", "_numchips", "+", "1", ",", "1", ")", ":", "sci_chip", "=", "self", ".", "_image", "[", "self", ".", "scienceEx...
Compute the undistorted WCS based solely on the known distortion model information associated with the WCS.
[ "Compute", "the", "undistorted", "WCS", "based", "solely", "on", "the", "known", "distortion", "model", "information", "associated", "with", "the", "WCS", "." ]
python
train
biocore/mustached-octo-ironman
moi/job.py
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/job.py#L57-L80
def _status_change(id, new_status): """Update the status of a job The status associated with the id is updated, an update command is issued to the job's pubsub, and and the old status is returned. Parameters ---------- id : str The job ID new_status : str The status change ...
[ "def", "_status_change", "(", "id", ",", "new_status", ")", ":", "job_info", "=", "json", ".", "loads", "(", "r_client", ".", "get", "(", "id", ")", ")", "old_status", "=", "job_info", "[", "'status'", "]", "job_info", "[", "'status'", "]", "=", "new_s...
Update the status of a job The status associated with the id is updated, an update command is issued to the job's pubsub, and and the old status is returned. Parameters ---------- id : str The job ID new_status : str The status change Returns ------- str Th...
[ "Update", "the", "status", "of", "a", "job" ]
python
train
Jajcus/pyxmpp2
pyxmpp2/ext/disco.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/disco.py#L687-L697
def add_feature(self,var): """Add a feature to `self`. :Parameters: - `var`: the feature name. :Types: - `var`: `unicode`""" if self.has_feature(var): return n=self.xmlnode.newChild(None, "feature", None) n.setProp("var", to_utf8(var))
[ "def", "add_feature", "(", "self", ",", "var", ")", ":", "if", "self", ".", "has_feature", "(", "var", ")", ":", "return", "n", "=", "self", ".", "xmlnode", ".", "newChild", "(", "None", ",", "\"feature\"", ",", "None", ")", "n", ".", "setProp", "(...
Add a feature to `self`. :Parameters: - `var`: the feature name. :Types: - `var`: `unicode`
[ "Add", "a", "feature", "to", "self", "." ]
python
valid
inveniosoftware/invenio-search
invenio_search/utils.py
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/utils.py#L39-L60
def schema_to_index(schema, index_names=None): """Get index/doc_type given a schema URL. :param schema: The schema name :param index_names: A list of index name. :returns: A tuple containing (index, doc_type). """ parts = schema.split('/') doc_type = os.path.splitext(parts[-1]) if doc_...
[ "def", "schema_to_index", "(", "schema", ",", "index_names", "=", "None", ")", ":", "parts", "=", "schema", ".", "split", "(", "'/'", ")", "doc_type", "=", "os", ".", "path", ".", "splitext", "(", "parts", "[", "-", "1", "]", ")", "if", "doc_type", ...
Get index/doc_type given a schema URL. :param schema: The schema name :param index_names: A list of index name. :returns: A tuple containing (index, doc_type).
[ "Get", "index", "/", "doc_type", "given", "a", "schema", "URL", "." ]
python
train
santoshphilip/eppy
eppy/modeleditor.py
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L636-L652
def initreadtxt(self, idftxt): """ Use the current IDD and read an IDF from text data. If the IDD has not yet been initialised then this is done first. Parameters ---------- idftxt : str Text representing an IDF file. """ iddfhandle = StringI...
[ "def", "initreadtxt", "(", "self", ",", "idftxt", ")", ":", "iddfhandle", "=", "StringIO", "(", "iddcurrent", ".", "iddtxt", ")", "if", "self", ".", "getiddname", "(", ")", "==", "None", ":", "self", ".", "setiddname", "(", "iddfhandle", ")", "idfhandle"...
Use the current IDD and read an IDF from text data. If the IDD has not yet been initialised then this is done first. Parameters ---------- idftxt : str Text representing an IDF file.
[ "Use", "the", "current", "IDD", "and", "read", "an", "IDF", "from", "text", "data", ".", "If", "the", "IDD", "has", "not", "yet", "been", "initialised", "then", "this", "is", "done", "first", "." ]
python
train
hydpy-dev/hydpy
hydpy/models/hland/hland_model.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/hland/hland_model.py#L437-L523
def calc_tf_ic_v1(self): """Calculate throughfall and update the interception storage accordingly. Required control parameters: |NmbZones| |ZoneType| |IcMax| Required flux sequences: |PC| Calculated fluxes sequences: |TF| Updated state sequence: |Ic| ...
[ "def", "calc_tf_ic_v1", "(", "self", ")", ":", "con", "=", "self", ".", "parameters", ".", "control", ".", "fastaccess", "flu", "=", "self", ".", "sequences", ".", "fluxes", ".", "fastaccess", "sta", "=", "self", ".", "sequences", ".", "states", ".", "...
Calculate throughfall and update the interception storage accordingly. Required control parameters: |NmbZones| |ZoneType| |IcMax| Required flux sequences: |PC| Calculated fluxes sequences: |TF| Updated state sequence: |Ic| Basic equation: :math:`TF ...
[ "Calculate", "throughfall", "and", "update", "the", "interception", "storage", "accordingly", "." ]
python
train
msmbuilder/msmbuilder
msmbuilder/cluster/__init__.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/cluster/__init__.py#L37-L60
def _replace_labels(doc): """Really hacky find-and-replace method that modifies one of the sklearn docstrings to change the semantics of labels_ for the subclasses""" lines = doc.splitlines() labelstart, labelend = None, None foundattributes = False for i, line in enumerate(lines): strip...
[ "def", "_replace_labels", "(", "doc", ")", ":", "lines", "=", "doc", ".", "splitlines", "(", ")", "labelstart", ",", "labelend", "=", "None", ",", "None", "foundattributes", "=", "False", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", "...
Really hacky find-and-replace method that modifies one of the sklearn docstrings to change the semantics of labels_ for the subclasses
[ "Really", "hacky", "find", "-", "and", "-", "replace", "method", "that", "modifies", "one", "of", "the", "sklearn", "docstrings", "to", "change", "the", "semantics", "of", "labels_", "for", "the", "subclasses" ]
python
train
davidfokkema/artist
artist/multi_plot.py
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/multi_plot.py#L491-L521
def render(self, template=None): """Render the plot using a template. Once the plot is complete, it needs to be rendered. Artist uses the Jinja2 templating engine. The default template results in a LaTeX file which can be included in your document. :param template: a user-sup...
[ "def", "render", "(", "self", ",", "template", "=", "None", ")", ":", "if", "not", "template", ":", "template", "=", "self", ".", "template", "for", "subplot", "in", "self", ".", "subplots", ":", "subplot", ".", "_prepare_data", "(", ")", "response", "...
Render the plot using a template. Once the plot is complete, it needs to be rendered. Artist uses the Jinja2 templating engine. The default template results in a LaTeX file which can be included in your document. :param template: a user-supplied template or None. :type templa...
[ "Render", "the", "plot", "using", "a", "template", "." ]
python
train
samgiles/slumber
slumber/utils.py
https://github.com/samgiles/slumber/blob/af0f9ef7bd8df8bde6b47088630786c737869bce/slumber/utils.py#L9-L16
def url_join(base, *args): """ Helper function to join an arbitrary number of url segments together. """ scheme, netloc, path, query, fragment = urlsplit(base) path = path if len(path) else "/" path = posixpath.join(path, *[('%s' % x) for x in args]) return urlunsplit([scheme, netloc, path, ...
[ "def", "url_join", "(", "base", ",", "*", "args", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlsplit", "(", "base", ")", "path", "=", "path", "if", "len", "(", "path", ")", "else", "\"/\"", "path", "=", ...
Helper function to join an arbitrary number of url segments together.
[ "Helper", "function", "to", "join", "an", "arbitrary", "number", "of", "url", "segments", "together", "." ]
python
train
saltstack/salt
salt/modules/nxos_api.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_api.py#L257-L314
def show(commands, raw_text=True, **kwargs): ''' Execute one or more show (non-configuration) commands. commands The commands to be executed. raw_text: ``True`` Whether to return raw text or structured data. transport: ``https`` Specifies the type of conn...
[ "def", "show", "(", "commands", ",", "raw_text", "=", "True", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "[", "]", "if", "raw_text", ":", "method", "=", "'cli_ascii'", "key", "=", "'msg'", "else", ":", "method", "=", "'cli'", "key", "=", "'body...
Execute one or more show (non-configuration) commands. commands The commands to be executed. raw_text: ``True`` Whether to return raw text or structured data. transport: ``https`` Specifies the type of connection transport to use. Valid values for the connection are ``http...
[ "Execute", "one", "or", "more", "show", "(", "non", "-", "configuration", ")", "commands", "." ]
python
train
wakatime/wakatime
wakatime/packages/pygments/lexers/__init__.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/lexers/__init__.py#L209-L222
def get_lexer_for_mimetype(_mime, **options): """Get a lexer for a mimetype. Raises ClassNotFound if not found. """ for modname, name, _, _, mimetypes in itervalues(LEXERS): if _mime in mimetypes: if name not in _lexer_cache: _load_lexers(modname) return ...
[ "def", "get_lexer_for_mimetype", "(", "_mime", ",", "*", "*", "options", ")", ":", "for", "modname", ",", "name", ",", "_", ",", "_", ",", "mimetypes", "in", "itervalues", "(", "LEXERS", ")", ":", "if", "_mime", "in", "mimetypes", ":", "if", "name", ...
Get a lexer for a mimetype. Raises ClassNotFound if not found.
[ "Get", "a", "lexer", "for", "a", "mimetype", "." ]
python
train
msmbuilder/msmbuilder
msmbuilder/utils/progressbar/widgets.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/utils/progressbar/widgets.py#L147-L163
def update(self, pbar): """Updates the widget to show the ETA or total time when finished.""" if pbar.currval == 0: return 'ETA: --:--:--' elif pbar.finished: return 'Time: %s' % self.format_time(pbar.seconds_elapsed) else: elapsed = pbar.seconds_elap...
[ "def", "update", "(", "self", ",", "pbar", ")", ":", "if", "pbar", ".", "currval", "==", "0", ":", "return", "'ETA: --:--:--'", "elif", "pbar", ".", "finished", ":", "return", "'Time: %s'", "%", "self", ".", "format_time", "(", "pbar", ".", "seconds_ela...
Updates the widget to show the ETA or total time when finished.
[ "Updates", "the", "widget", "to", "show", "the", "ETA", "or", "total", "time", "when", "finished", "." ]
python
train
gofed/gofedlib
gofedlib/distribution/distributionsnapshot.py
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/distributionsnapshot.py#L42-L45
def setRpms(self, package, build, build_ts, rpms): """Add/Update package rpm """ self._builds[package] = {"build": build, "build_ts": build_ts, "rpms": rpms}
[ "def", "setRpms", "(", "self", ",", "package", ",", "build", ",", "build_ts", ",", "rpms", ")", ":", "self", ".", "_builds", "[", "package", "]", "=", "{", "\"build\"", ":", "build", ",", "\"build_ts\"", ":", "build_ts", ",", "\"rpms\"", ":", "rpms", ...
Add/Update package rpm
[ "Add", "/", "Update", "package", "rpm" ]
python
train
rigetti/grove
grove/deutsch_jozsa/deutsch_jozsa.py
https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/deutsch_jozsa/deutsch_jozsa.py#L71-L89
def _init_attr(self, bitstring_map: Dict[str, str]): """ Acts instead of __init__ method to instantiate the necessary Deutsch-Jozsa state. :param Dict[String, String] bitstring_map: truth-table of the input bitstring map in dictionary format, used to construct the oracle in the Deutsch-...
[ "def", "_init_attr", "(", "self", ",", "bitstring_map", ":", "Dict", "[", "str", ",", "str", "]", ")", ":", "self", ".", "bit_map", "=", "bitstring_map", "self", ".", "n_qubits", "=", "len", "(", "list", "(", "bitstring_map", ".", "keys", "(", ")", "...
Acts instead of __init__ method to instantiate the necessary Deutsch-Jozsa state. :param Dict[String, String] bitstring_map: truth-table of the input bitstring map in dictionary format, used to construct the oracle in the Deutsch-Jozsa algorithm. :return: None :rtype: NoneType
[ "Acts", "instead", "of", "__init__", "method", "to", "instantiate", "the", "necessary", "Deutsch", "-", "Jozsa", "state", "." ]
python
train
python-wink/python-wink
src/pywink/devices/cloud_clock.py
https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/cloud_clock.py#L183-L187
def update_state(self): """ Update state with latest info from Wink API. """ response = self.api_interface.get_device_state(self, id_override=self.parent_id(), type_override=self.parent_object_type()) self._update_state_from_response(res...
[ "def", "update_state", "(", "self", ")", ":", "response", "=", "self", ".", "api_interface", ".", "get_device_state", "(", "self", ",", "id_override", "=", "self", ".", "parent_id", "(", ")", ",", "type_override", "=", "self", ".", "parent_object_type", "(",...
Update state with latest info from Wink API.
[ "Update", "state", "with", "latest", "info", "from", "Wink", "API", "." ]
python
train
kxgames/glooey
glooey/drawing/grid.py
https://github.com/kxgames/glooey/blob/f0125c1f218b05cfb2efb52a88d80f54eae007a0/glooey/drawing/grid.py#L531-L551
def make_grid(rect, cells={}, num_rows=0, num_cols=0, padding=None, inner_padding=None, outer_padding=None, row_heights={}, col_widths={}, default_row_height='expand', default_col_width='expand'): """ Return rectangles for each cell in the specified grid. The rectangles are returned in a ...
[ "def", "make_grid", "(", "rect", ",", "cells", "=", "{", "}", ",", "num_rows", "=", "0", ",", "num_cols", "=", "0", ",", "padding", "=", "None", ",", "inner_padding", "=", "None", ",", "outer_padding", "=", "None", ",", "row_heights", "=", "{", "}", ...
Return rectangles for each cell in the specified grid. The rectangles are returned in a dictionary where the keys are (row, col) tuples.
[ "Return", "rectangles", "for", "each", "cell", "in", "the", "specified", "grid", ".", "The", "rectangles", "are", "returned", "in", "a", "dictionary", "where", "the", "keys", "are", "(", "row", "col", ")", "tuples", "." ]
python
train
gitpython-developers/GitPython
git/index/fun.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/index/fun.py#L171-L177
def entry_key(*entry): """:return: Key suitable to be used for the index.entries dictionary :param entry: One instance of type BaseIndexEntry or the path and the stage""" if len(entry) == 1: return (entry[0].path, entry[0].stage) else: return tuple(entry)
[ "def", "entry_key", "(", "*", "entry", ")", ":", "if", "len", "(", "entry", ")", "==", "1", ":", "return", "(", "entry", "[", "0", "]", ".", "path", ",", "entry", "[", "0", "]", ".", "stage", ")", "else", ":", "return", "tuple", "(", "entry", ...
:return: Key suitable to be used for the index.entries dictionary :param entry: One instance of type BaseIndexEntry or the path and the stage
[ ":", "return", ":", "Key", "suitable", "to", "be", "used", "for", "the", "index", ".", "entries", "dictionary", ":", "param", "entry", ":", "One", "instance", "of", "type", "BaseIndexEntry", "or", "the", "path", "and", "the", "stage" ]
python
train
abilian/abilian-core
abilian/cli/base.py
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/cli/base.py#L41-L66
def createuser(email, password, role=None, name=None, first_name=None): """Create new user.""" if User.query.filter(User.email == email).count() > 0: print(f"A user with email '{email}' already exists, aborting.") return # if password is None: # password = prompt_pass("Password") ...
[ "def", "createuser", "(", "email", ",", "password", ",", "role", "=", "None", ",", "name", "=", "None", ",", "first_name", "=", "None", ")", ":", "if", "User", ".", "query", ".", "filter", "(", "User", ".", "email", "==", "email", ")", ".", "count"...
Create new user.
[ "Create", "new", "user", "." ]
python
train
pzs741/TEDT
TEDT/candidate_title.py
https://github.com/pzs741/TEDT/blob/6b6663227b755005fe1a1e3e807a05bdb521e066/TEDT/candidate_title.py#L93-L135
def vote(self): """选举新闻标题 Return: title -- 新闻标题,str类型 """ # 初始化 weight_queue = [] sameKV = 0 count = 0 # 相似度计算 for unit in self._queue: unit_set = convert_to_set(unit) for i in unit_set: ...
[ "def", "vote", "(", "self", ")", ":", "# 初始化", "weight_queue", "=", "[", "]", "sameKV", "=", "0", "count", "=", "0", "# 相似度计算", "for", "unit", "in", "self", ".", "_queue", ":", "unit_set", "=", "convert_to_set", "(", "unit", ")", "for", "i", "in", ...
选举新闻标题 Return: title -- 新闻标题,str类型
[ "选举新闻标题" ]
python
train
scanny/python-pptx
pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/chart/chart.py#L177-L193
def iter_xCharts(self): """ Generate each xChart child element in document. """ plot_tags = ( qn('c:area3DChart'), qn('c:areaChart'), qn('c:bar3DChart'), qn('c:barChart'), qn('c:bubbleChart'), qn('c:doughnutChart'), qn('c:line3DChart'), qn('c:lineChart...
[ "def", "iter_xCharts", "(", "self", ")", ":", "plot_tags", "=", "(", "qn", "(", "'c:area3DChart'", ")", ",", "qn", "(", "'c:areaChart'", ")", ",", "qn", "(", "'c:bar3DChart'", ")", ",", "qn", "(", "'c:barChart'", ")", ",", "qn", "(", "'c:bubbleChart'", ...
Generate each xChart child element in document.
[ "Generate", "each", "xChart", "child", "element", "in", "document", "." ]
python
train
yfpeng/bioc
bioc/biocxml/decoder.py
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocxml/decoder.py#L39-L55
def decode(self, fp: TextIO) -> BioCCollection: """ Deserialize ``fp`` to a BioC collection object. Args: fp: a ``.read()``-supporting file-like object containing a BioC collection Returns: an object of BioCollection """ # utf8_parser = etree.XML...
[ "def", "decode", "(", "self", ",", "fp", ":", "TextIO", ")", "->", "BioCCollection", ":", "# utf8_parser = etree.XMLParser(encoding='utf-8')", "tree", "=", "etree", ".", "parse", "(", "fp", ")", "collection", "=", "self", ".", "__parse_collection", "(", "tree", ...
Deserialize ``fp`` to a BioC collection object. Args: fp: a ``.read()``-supporting file-like object containing a BioC collection Returns: an object of BioCollection
[ "Deserialize", "fp", "to", "a", "BioC", "collection", "object", "." ]
python
train
jalanb/pysyte
pysyte/paths.py
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L103-L116
def dirpaths(self): """Split the dirname into individual directory names An absolute path starts with an empty string, a relative path does not >>> p = DotPath(u'/path/to/x.py') >>> p.paths == p.dirpaths() True """ parts = self.parts() result = [DotPath(...
[ "def", "dirpaths", "(", "self", ")", ":", "parts", "=", "self", ".", "parts", "(", ")", "result", "=", "[", "DotPath", "(", "parts", "[", "0", "]", "or", "'/'", ")", "]", "for", "name", "in", "parts", "[", "1", ":", "]", ":", "result", ".", "...
Split the dirname into individual directory names An absolute path starts with an empty string, a relative path does not >>> p = DotPath(u'/path/to/x.py') >>> p.paths == p.dirpaths() True
[ "Split", "the", "dirname", "into", "individual", "directory", "names" ]
python
train
apple/turicreate
src/unity/python/turicreate/toolkits/image_classifier/image_classifier.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/image_classifier/image_classifier.py#L546-L609
def predict_topk(self, dataset, output_type="probability", k=3, batch_size=64): """ Return top-k predictions for the ``dataset``, using the trained model. Predictions are returned as an SFrame with three columns: `id`, `class`, and `probability`, `margin`, or `rank`, depending on the ``...
[ "def", "predict_topk", "(", "self", ",", "dataset", ",", "output_type", "=", "\"probability\"", ",", "k", "=", "3", ",", "batch_size", "=", "64", ")", ":", "if", "not", "isinstance", "(", "dataset", ",", "(", "_tc", ".", "SFrame", ",", "_tc", ".", "S...
Return top-k predictions for the ``dataset``, using the trained model. Predictions are returned as an SFrame with three columns: `id`, `class`, and `probability`, `margin`, or `rank`, depending on the ``output_type`` parameter. Input dataset size must be the same as for training of the model. ...
[ "Return", "top", "-", "k", "predictions", "for", "the", "dataset", "using", "the", "trained", "model", ".", "Predictions", "are", "returned", "as", "an", "SFrame", "with", "three", "columns", ":", "id", "class", "and", "probability", "margin", "or", "rank", ...
python
train
aktaylor08/RosbagPandas
scripts/bag2csv.py
https://github.com/aktaylor08/RosbagPandas/blob/c2af9f22537102696dffdf2e61790362726a8403/scripts/bag2csv.py#L11-L32
def buildParser(): ''' Builds the parser for reading the command line arguments''' parser = argparse.ArgumentParser( description='Script to parse bagfile to csv file') parser.add_argument('bag', help='Bag file to read', type=str) parser.add_argument('-i', '--include', ...
[ "def", "buildParser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Script to parse bagfile to csv file'", ")", "parser", ".", "add_argument", "(", "'bag'", ",", "help", "=", "'Bag file to read'", ",", "type", "=", "...
Builds the parser for reading the command line arguments
[ "Builds", "the", "parser", "for", "reading", "the", "command", "line", "arguments" ]
python
train
tensorlayer/tensorlayer
tensorlayer/layers/core.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/core.py#L191-L197
def print_layers(self): """Print all info of layers in the network.""" for i, layer in enumerate(self.all_layers): # logging.info(" layer %d: %s" % (i, str(layer))) logging.info( " layer {:3}: {:20} {:15} {}".format(i, layer.name, str(layer.get_shape()), laye...
[ "def", "print_layers", "(", "self", ")", ":", "for", "i", ",", "layer", "in", "enumerate", "(", "self", ".", "all_layers", ")", ":", "# logging.info(\" layer %d: %s\" % (i, str(layer)))", "logging", ".", "info", "(", "\" layer {:3}: {:20} {:15} {}\"", ".", "for...
Print all info of layers in the network.
[ "Print", "all", "info", "of", "layers", "in", "the", "network", "." ]
python
valid
sentinel-hub/sentinelhub-py
sentinelhub/download.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L159-L167
def is_downloaded(self): """ Checks if data for this request has already been downloaded and is saved to disk. :return: returns ``True`` if data for this request has already been downloaded and is saved to disk. :rtype: bool """ if self.file_path is None: return Fals...
[ "def", "is_downloaded", "(", "self", ")", ":", "if", "self", ".", "file_path", "is", "None", ":", "return", "False", "return", "os", ".", "path", ".", "exists", "(", "self", ".", "file_path", ")" ]
Checks if data for this request has already been downloaded and is saved to disk. :return: returns ``True`` if data for this request has already been downloaded and is saved to disk. :rtype: bool
[ "Checks", "if", "data", "for", "this", "request", "has", "already", "been", "downloaded", "and", "is", "saved", "to", "disk", "." ]
python
train
googleapis/google-cloud-python
core/google/cloud/operation.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/operation.py#L233-L250
def _update_state(self, operation_pb): """Update the state of the current object based on operation. :type operation_pb: :class:`~google.longrunning.operations_pb2.Operation` :param operation_pb: Protobuf to be parsed. """ if operation_pb.done: self._comp...
[ "def", "_update_state", "(", "self", ",", "operation_pb", ")", ":", "if", "operation_pb", ".", "done", ":", "self", ".", "_complete", "=", "True", "if", "operation_pb", ".", "HasField", "(", "\"metadata\"", ")", ":", "self", ".", "metadata", "=", "_from_an...
Update the state of the current object based on operation. :type operation_pb: :class:`~google.longrunning.operations_pb2.Operation` :param operation_pb: Protobuf to be parsed.
[ "Update", "the", "state", "of", "the", "current", "object", "based", "on", "operation", "." ]
python
train
treycucco/bidon
bidon/util/__init__.py
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/__init__.py#L123-L138
def get_value(obj, name, fallback=None): """Calls through to has_value. If has_value[0] is True, return has_value[1] otherwise returns fallback() if fallback is callable, else just fallback. :obj: the object to pull values from :name: the name to use when getting the value :fallback: the value to return when...
[ "def", "get_value", "(", "obj", ",", "name", ",", "fallback", "=", "None", ")", ":", "present", ",", "value", "=", "has_value", "(", "obj", ",", "name", ")", "if", "present", ":", "return", "value", "else", ":", "if", "callable", "(", "fallback", ")"...
Calls through to has_value. If has_value[0] is True, return has_value[1] otherwise returns fallback() if fallback is callable, else just fallback. :obj: the object to pull values from :name: the name to use when getting the value :fallback: the value to return when has_value(:obj:, :name:) returns False
[ "Calls", "through", "to", "has_value", ".", "If", "has_value", "[", "0", "]", "is", "True", "return", "has_value", "[", "1", "]", "otherwise", "returns", "fallback", "()", "if", "fallback", "is", "callable", "else", "just", "fallback", "." ]
python
train
pytroll/satpy
satpy/readers/viirs_edr_active_fires.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/viirs_edr_active_fires.py#L35-L52
def get_dataset(self, dsid, dsinfo): """Get dataset function Args: dsid: Dataset ID param2: Dataset Information Returns: Dask DataArray: Data """ data = self[dsinfo.get('file_key', dsid.name)] data.attrs.update(dsinfo) data....
[ "def", "get_dataset", "(", "self", ",", "dsid", ",", "dsinfo", ")", ":", "data", "=", "self", "[", "dsinfo", ".", "get", "(", "'file_key'", ",", "dsid", ".", "name", ")", "]", "data", ".", "attrs", ".", "update", "(", "dsinfo", ")", "data", ".", ...
Get dataset function Args: dsid: Dataset ID param2: Dataset Information Returns: Dask DataArray: Data
[ "Get", "dataset", "function" ]
python
train
elsampsa/valkka-live
valkka/live/container/video.py
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/live/container/video.py#L234-L261
def setDevice(self, device): """Sets the video stream :param device: A rather generic device class. In this case DataModel.RTSPCameraDevice. """ print(self.pre, "setDevice :", device) if (not device and not self.device): # None can be passed as an argumen...
[ "def", "setDevice", "(", "self", ",", "device", ")", ":", "print", "(", "self", ".", "pre", ",", "\"setDevice :\"", ",", "device", ")", "if", "(", "not", "device", "and", "not", "self", ".", "device", ")", ":", "# None can be passed as an argument when the d...
Sets the video stream :param device: A rather generic device class. In this case DataModel.RTSPCameraDevice.
[ "Sets", "the", "video", "stream", ":", "param", "device", ":", "A", "rather", "generic", "device", "class", ".", "In", "this", "case", "DataModel", ".", "RTSPCameraDevice", "." ]
python
train
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L650-L683
def delete(self, pid, record, **kwargs): """Delete a record. Permissions: ``delete_permission_factory`` Procedure description: #. The record is resolved reading the pid value from the url. #. The ETag is checked. #. The record is deleted. #. All PIDs are mar...
[ "def", "delete", "(", "self", ",", "pid", ",", "record", ",", "*", "*", "kwargs", ")", ":", "self", ".", "check_etag", "(", "str", "(", "record", ".", "model", ".", "version_id", ")", ")", "record", ".", "delete", "(", ")", "# mark all PIDs as DELETED"...
Delete a record. Permissions: ``delete_permission_factory`` Procedure description: #. The record is resolved reading the pid value from the url. #. The ETag is checked. #. The record is deleted. #. All PIDs are marked as DELETED. :param pid: Persistent iden...
[ "Delete", "a", "record", "." ]
python
train
PyCQA/pylint
pylint/checkers/strings.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/strings.py#L744-L747
def register(linter): """required method to auto register this checker """ linter.register_checker(StringFormatChecker(linter)) linter.register_checker(StringConstantChecker(linter))
[ "def", "register", "(", "linter", ")", ":", "linter", ".", "register_checker", "(", "StringFormatChecker", "(", "linter", ")", ")", "linter", ".", "register_checker", "(", "StringConstantChecker", "(", "linter", ")", ")" ]
required method to auto register this checker
[ "required", "method", "to", "auto", "register", "this", "checker" ]
python
test
EpistasisLab/scikit-rebate
skrebate/surf.py
https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/surf.py#L71-L87
def _find_neighbors(self, inst, avg_dist): """ Identify nearest hits and misses within radius defined by average distance over whole distance array. This works the same regardless of endpoint type. """ NN = [] min_indicies = [] for i in range(self._datalen): if inst ...
[ "def", "_find_neighbors", "(", "self", ",", "inst", ",", "avg_dist", ")", ":", "NN", "=", "[", "]", "min_indicies", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "_datalen", ")", ":", "if", "inst", "!=", "i", ":", "locator", "=", "[...
Identify nearest hits and misses within radius defined by average distance over whole distance array. This works the same regardless of endpoint type.
[ "Identify", "nearest", "hits", "and", "misses", "within", "radius", "defined", "by", "average", "distance", "over", "whole", "distance", "array", ".", "This", "works", "the", "same", "regardless", "of", "endpoint", "type", "." ]
python
train
mbr/latex
latex/jinja2.py
https://github.com/mbr/latex/blob/f96cb9125b4f570fc2ffc5ae628e2f4069b2f3cf/latex/jinja2.py#L41-L60
def make_env(*args, **kwargs): """Creates an :py:class:`~jinja2.Environment` with different defaults. Per default, ``autoescape`` will be disabled and ``trim_blocks`` enabled. All start/end/prefix strings will be changed for a more LaTeX-friendly version (see the docs for details). Any arguments w...
[ "def", "make_env", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ka", "=", "ENV_ARGS", ".", "copy", "(", ")", "ka", ".", "update", "(", "kwargs", ")", "env", "=", "Environment", "(", "*", "args", ",", "*", "*", "ka", ")", "env", ".", ...
Creates an :py:class:`~jinja2.Environment` with different defaults. Per default, ``autoescape`` will be disabled and ``trim_blocks`` enabled. All start/end/prefix strings will be changed for a more LaTeX-friendly version (see the docs for details). Any arguments will be passed on to the :py:class:`~ji...
[ "Creates", "an", ":", "py", ":", "class", ":", "~jinja2", ".", "Environment", "with", "different", "defaults", "." ]
python
train
Nic30/hwt
hwt/interfaces/agents/rdSynced.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/interfaces/agents/rdSynced.py#L47-L49
def doWrite(self, sim, data): """write data to interface""" sim.write(data, self.intf.data)
[ "def", "doWrite", "(", "self", ",", "sim", ",", "data", ")", ":", "sim", ".", "write", "(", "data", ",", "self", ".", "intf", ".", "data", ")" ]
write data to interface
[ "write", "data", "to", "interface" ]
python
test
wheerd/multiset
multiset.py
https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L365-L405
def symmetric_difference(self, other): r"""Return a new set with elements in either the set or other but not both. >>> ms = Multiset('aab') >>> sorted(ms.symmetric_difference('abc')) ['a', 'c'] You can also use the ``^`` operator for the same effect. However, the operator versi...
[ "def", "symmetric_difference", "(", "self", ",", "other", ")", ":", "other", "=", "self", ".", "_as_multiset", "(", "other", ")", "result", "=", "self", ".", "__class__", "(", ")", "_total", "=", "0", "_elements", "=", "result", ".", "_elements", "self_e...
r"""Return a new set with elements in either the set or other but not both. >>> ms = Multiset('aab') >>> sorted(ms.symmetric_difference('abc')) ['a', 'c'] You can also use the ``^`` operator for the same effect. However, the operator version will only accept a set as other oper...
[ "r", "Return", "a", "new", "set", "with", "elements", "in", "either", "the", "set", "or", "other", "but", "not", "both", "." ]
python
train
pneff/wsgiservice
wsgiservice/status.py
https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L208-L220
def raise_402(instance, msg=None): """Abort the current request with a 402 (Payment Required) response code. If the message is given it's output as an error message in the response body (correctly converted to the requested MIME type). :param instance: Resource instance (used to access the response) ...
[ "def", "raise_402", "(", "instance", ",", "msg", "=", "None", ")", ":", "instance", ".", "response", ".", "status", "=", "402", "if", "msg", ":", "instance", ".", "response", ".", "body_raw", "=", "{", "'error'", ":", "msg", "}", "raise", "ResponseExce...
Abort the current request with a 402 (Payment Required) response code. If the message is given it's output as an error message in the response body (correctly converted to the requested MIME type). :param instance: Resource instance (used to access the response) :type instance: :class:`webob.resource.R...
[ "Abort", "the", "current", "request", "with", "a", "402", "(", "Payment", "Required", ")", "response", "code", ".", "If", "the", "message", "is", "given", "it", "s", "output", "as", "an", "error", "message", "in", "the", "response", "body", "(", "correct...
python
train
rocky/python-uncompyle6
uncompyle6/semantics/pysource.py
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1033-L1172
def comprehension_walk_newer(self, node, iter_index, code_index=-5): """Non-closure-based comprehensions the way they are done in Python3 and some Python 2.7. Note: there are also other set comprehensions. """ p = self.prec self.prec = 27 code = node[code_index].attr ...
[ "def", "comprehension_walk_newer", "(", "self", ",", "node", ",", "iter_index", ",", "code_index", "=", "-", "5", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "code", "=", "node", "[", "code_index", "]", ".", "attr", "asse...
Non-closure-based comprehensions the way they are done in Python3 and some Python 2.7. Note: there are also other set comprehensions.
[ "Non", "-", "closure", "-", "based", "comprehensions", "the", "way", "they", "are", "done", "in", "Python3", "and", "some", "Python", "2", ".", "7", ".", "Note", ":", "there", "are", "also", "other", "set", "comprehensions", "." ]
python
train
ThreatConnect-Inc/tcex
tcex/tcex_bin_validate.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_validate.py#L273-L353
def check_layout_params(self): """Check that the layout.json is consistent with install.json. The layout.json files references the params.name from the install.json file. The method will validate that no reference appear for inputs in install.json that don't exist. """ ij_inpu...
[ "def", "check_layout_params", "(", "self", ")", ":", "ij_input_names", "=", "[", "]", "ij_output_names", "=", "[", "]", "if", "os", ".", "path", ".", "isfile", "(", "'install.json'", ")", ":", "try", ":", "with", "open", "(", "'install.json'", ")", "as",...
Check that the layout.json is consistent with install.json. The layout.json files references the params.name from the install.json file. The method will validate that no reference appear for inputs in install.json that don't exist.
[ "Check", "that", "the", "layout", ".", "json", "is", "consistent", "with", "install", ".", "json", "." ]
python
train
mwshinn/paranoidscientist
paranoid/decorators.py
https://github.com/mwshinn/paranoidscientist/blob/a5e9198bc40b0a985174ad643cc5d6d0c46efdcd/paranoid/decorators.py#L288-L351
def ensures(condition): """A function decorator to specify exit conditions for the function. Exit conditions should be a string, which will be evaluated as Python code. Arguments of the function may be accessed by their name. The return value of the function may be accessed using the special vari...
[ "def", "ensures", "(", "condition", ")", ":", "def", "_decorator", "(", "func", ",", "condition", "=", "condition", ")", ":", "# @ensures decorator", "if", "U", ".", "has_fun_prop", "(", "func", ",", "\"ensures\"", ")", ":", "if", "not", "isinstance", "(",...
A function decorator to specify exit conditions for the function. Exit conditions should be a string, which will be evaluated as Python code. Arguments of the function may be accessed by their name. The return value of the function may be accessed using the special variable name "return". The sp...
[ "A", "function", "decorator", "to", "specify", "exit", "conditions", "for", "the", "function", "." ]
python
train
mottosso/be
be/vendor/requests/sessions.py
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/sessions.py#L538-L615
def send(self, request, **kwargs): """Send a given PreparedRequest.""" # Set defaults that the hooks can utilize to ensure they always have # the correct parameters to reproduce the previous request. kwargs.setdefault('stream', self.stream) kwargs.setdefault('verify', self.verify...
[ "def", "send", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# Set defaults that the hooks can utilize to ensure they always have", "# the correct parameters to reproduce the previous request.", "kwargs", ".", "setdefault", "(", "'stream'", ",", "self", "...
Send a given PreparedRequest.
[ "Send", "a", "given", "PreparedRequest", "." ]
python
train
bashu/django-easy-maps
easy_maps/geocode.py
https://github.com/bashu/django-easy-maps/blob/32f4f3274443219e8828d93d09a406bf2a126982/easy_maps/geocode.py#L15-L30
def google_v3(address): """ Given an address, return ``(computed_address, (latitude, longitude))`` tuple using Google Geocoding API v3. """ try: g = geocoders.GoogleV3(api_key=settings.EASY_MAPS_GOOGLE_KEY or settings.EASY_MAPS_GOOGLE_MAPS_API_KEY) results = g.geocode(smart_str(add...
[ "def", "google_v3", "(", "address", ")", ":", "try", ":", "g", "=", "geocoders", ".", "GoogleV3", "(", "api_key", "=", "settings", ".", "EASY_MAPS_GOOGLE_KEY", "or", "settings", ".", "EASY_MAPS_GOOGLE_MAPS_API_KEY", ")", "results", "=", "g", ".", "geocode", ...
Given an address, return ``(computed_address, (latitude, longitude))`` tuple using Google Geocoding API v3.
[ "Given", "an", "address", "return", "(", "computed_address", "(", "latitude", "longitude", "))", "tuple", "using", "Google", "Geocoding", "API", "v3", "." ]
python
train