repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
bcbio/bcbio-nextgen
bcbio/pipeline/run_info.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L767-L774
def _check_realign(data): """Check for realignment, which is not supported in GATK4 """ if "gatk4" not in data["algorithm"].get("tools_off", []) and not "gatk4" == data["algorithm"].get("tools_off"): if data["algorithm"].get("realign"): raise ValueError("In sample %s, realign specified b...
[ "def", "_check_realign", "(", "data", ")", ":", "if", "\"gatk4\"", "not", "in", "data", "[", "\"algorithm\"", "]", ".", "get", "(", "\"tools_off\"", ",", "[", "]", ")", "and", "not", "\"gatk4\"", "==", "data", "[", "\"algorithm\"", "]", ".", "get", "("...
Check for realignment, which is not supported in GATK4
[ "Check", "for", "realignment", "which", "is", "not", "supported", "in", "GATK4" ]
python
train
62.875
fusionbox/django-argonauts
argonauts/views.py
https://github.com/fusionbox/django-argonauts/blob/0f64f9700199e8c70a1cb9a055b8e31f6843933d/argonauts/views.py#L35-L43
def http_method_not_allowed(self, *args, **kwargs): """ Returns super after setting the Content-Type header to ``application/json`` """ resp = super(JsonResponseMixin, self).http_method_not_allowed(*args, **kwargs) resp['Content-Type'] = 'application/json' return...
[ "def", "http_method_not_allowed", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "super", "(", "JsonResponseMixin", ",", "self", ")", ".", "http_method_not_allowed", "(", "*", "args", ",", "*", "*", "kwargs", ")", "resp", ...
Returns super after setting the Content-Type header to ``application/json``
[ "Returns", "super", "after", "setting", "the", "Content", "-", "Type", "header", "to", "application", "/", "json" ]
python
train
35.222222
array-split/array_split
array_split/split.py
https://github.com/array-split/array_split/blob/e07abe3001209394dde809f7e6f505f9f49a1c26/array_split/split.py#L1162-L1173
def update_tile_extent_bounds(self): """ Updates the :attr:`tile_beg_min` and :attr:`tile_end_max` data members according to :attr:`tile_bounds_policy`. """ if self.tile_bounds_policy == NO_BOUNDS: self.tile_beg_min = self.array_start - self.halo[:, 0] se...
[ "def", "update_tile_extent_bounds", "(", "self", ")", ":", "if", "self", ".", "tile_bounds_policy", "==", "NO_BOUNDS", ":", "self", ".", "tile_beg_min", "=", "self", ".", "array_start", "-", "self", ".", "halo", "[", ":", ",", "0", "]", "self", ".", "til...
Updates the :attr:`tile_beg_min` and :attr:`tile_end_max` data members according to :attr:`tile_bounds_policy`.
[ "Updates", "the", ":", "attr", ":", "tile_beg_min", "and", ":", "attr", ":", "tile_end_max", "data", "members", "according", "to", ":", "attr", ":", "tile_bounds_policy", "." ]
python
train
45.916667
atl/py-smartdc
smartdc/machine.py
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L681-L687
def _save(self, data): """ Take the data from a dict and commit them to appropriate attributes. """ self.state = data.get('state') self.created = dt_time(data.get('created')) self.updated = dt_time(data.get('updated'))
[ "def", "_save", "(", "self", ",", "data", ")", ":", "self", ".", "state", "=", "data", ".", "get", "(", "'state'", ")", "self", ".", "created", "=", "dt_time", "(", "data", ".", "get", "(", "'created'", ")", ")", "self", ".", "updated", "=", "dt_...
Take the data from a dict and commit them to appropriate attributes.
[ "Take", "the", "data", "from", "a", "dict", "and", "commit", "them", "to", "appropriate", "attributes", "." ]
python
train
37.142857
trailofbits/manticore
manticore/core/executor.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/executor.py#L60-L68
def _add_state_callback(self, state_id, state): """ Save summarize(state) on policy shared context before the state is stored """ summary = self.summarize(state) if summary is None: return with self.locked_context('summaries', dict) as ctx: ctx...
[ "def", "_add_state_callback", "(", "self", ",", "state_id", ",", "state", ")", ":", "summary", "=", "self", ".", "summarize", "(", "state", ")", "if", "summary", "is", "None", ":", "return", "with", "self", ".", "locked_context", "(", "'summaries'", ",", ...
Save summarize(state) on policy shared context before the state is stored
[ "Save", "summarize", "(", "state", ")", "on", "policy", "shared", "context", "before", "the", "state", "is", "stored" ]
python
valid
36.888889
trailofbits/manticore
scripts/verify.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/scripts/verify.py#L145-L169
def initialize(state): """ Synchronize the stack and register state (manticore->qemu) """ logger.debug(f"Copying {stack_top - state.cpu.SP} bytes in the stack..") stack_bottom = min(state.cpu.SP, gdb.getR('SP')) for address in range(stack_bottom, stack_top): b = state.cpu.read_int(addres...
[ "def", "initialize", "(", "state", ")", ":", "logger", ".", "debug", "(", "f\"Copying {stack_top - state.cpu.SP} bytes in the stack..\"", ")", "stack_bottom", "=", "min", "(", "state", ".", "cpu", ".", "SP", ",", "gdb", ".", "getR", "(", "'SP'", ")", ")", "f...
Synchronize the stack and register state (manticore->qemu)
[ "Synchronize", "the", "stack", "and", "register", "state", "(", "manticore", "-", ">", "qemu", ")" ]
python
valid
33.36
saltstack/salt
salt/modules/saltsupport.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/saltsupport.py#L195-L219
def format_sync_stats(self, cnt): ''' Format stats of the sync output. :param cnt: :return: ''' stats = salt.utils.odict.OrderedDict() if cnt.get('retcode') == salt.defaults.exitcodes.EX_OK: for line in cnt.get('stdout', '').split(os.linesep): ...
[ "def", "format_sync_stats", "(", "self", ",", "cnt", ")", ":", "stats", "=", "salt", ".", "utils", ".", "odict", ".", "OrderedDict", "(", ")", "if", "cnt", ".", "get", "(", "'retcode'", ")", "==", "salt", ".", "defaults", ".", "exitcodes", ".", "EX_O...
Format stats of the sync output. :param cnt: :return:
[ "Format", "stats", "of", "the", "sync", "output", "." ]
python
train
30.92
auth0/auth0-python
auth0/v3/management/connections.py
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/connections.py#L128-L141
def delete_user_by_email(self, id, email): """Deletes a specified connection user by its email. Args: id (str): The id of the connection (must be a database connection). email (str): The email of the user to delete. See: https://auth0.com/docs/api/management/v2#!/Connect...
[ "def", "delete_user_by_email", "(", "self", ",", "id", ",", "email", ")", ":", "return", "self", ".", "client", ".", "delete", "(", "self", ".", "_url", "(", "id", ")", "+", "'/users'", ",", "params", "=", "{", "'email'", ":", "email", "}", ")" ]
Deletes a specified connection user by its email. Args: id (str): The id of the connection (must be a database connection). email (str): The email of the user to delete. See: https://auth0.com/docs/api/management/v2#!/Connections/delete_users_by_email Returns: ...
[ "Deletes", "a", "specified", "connection", "user", "by", "its", "email", "." ]
python
train
33.928571
callowayproject/django-staff
staff/admin.py
https://github.com/callowayproject/django-staff/blob/248e2b69be36ee9f702ff5ba92cd1fb58597cd41/staff/admin.py#L29-L46
def get_formset(self, request, obj=None, **kwargs): """ Return a form, if the obj has a staffmember object, otherwise return an empty form """ if obj is not None and self.model.objects.filter(user=obj).count(): return super(StaffMemberAdmin, self).get_formset( ...
[ "def", "get_formset", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "obj", "is", "not", "None", "and", "self", ".", "model", ".", "objects", ".", "filter", "(", "user", "=", "obj", ")", ".", "count...
Return a form, if the obj has a staffmember object, otherwise return an empty form
[ "Return", "a", "form", "if", "the", "obj", "has", "a", "staffmember", "object", "otherwise", "return", "an", "empty", "form" ]
python
train
31.722222
SBRG/ssbio
ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py#L207-L228
def _parse_residue(self, residue): """ Extracts Residue Name, Number, Chain, Model, Atoms. I/O: xml object <response> / dictionary """ # Filter Element Nodes childs = [ child for child in residue.childNodes if child.nodeType == child.ELEMENT_NODE ] ...
[ "def", "_parse_residue", "(", "self", ",", "residue", ")", ":", "# Filter Element Nodes", "childs", "=", "[", "child", "for", "child", "in", "residue", ".", "childNodes", "if", "child", ".", "nodeType", "==", "child", ".", "ELEMENT_NODE", "]", "# Parse info ou...
Extracts Residue Name, Number, Chain, Model, Atoms. I/O: xml object <response> / dictionary
[ "Extracts", "Residue", "Name", "Number", "Chain", "Model", "Atoms", ".", "I", "/", "O", ":", "xml", "object", "<response", ">", "/", "dictionary" ]
python
train
35.272727
PredixDev/predixpy
predix/security/uaa.py
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L413-L476
def update_client_grants(self, client_id, scope=[], authorities=[], grant_types=[], redirect_uri=[], replace=False): """ Will extend the client with additional scopes or authorities. Any existing scopes and authorities will be left as is unless asked to replace entirely. ...
[ "def", "update_client_grants", "(", "self", ",", "client_id", ",", "scope", "=", "[", "]", ",", "authorities", "=", "[", "]", ",", "grant_types", "=", "[", "]", ",", "redirect_uri", "=", "[", "]", ",", "replace", "=", "False", ")", ":", "self", ".", ...
Will extend the client with additional scopes or authorities. Any existing scopes and authorities will be left as is unless asked to replace entirely.
[ "Will", "extend", "the", "client", "with", "additional", "scopes", "or", "authorities", ".", "Any", "existing", "scopes", "and", "authorities", "will", "be", "left", "as", "is", "unless", "asked", "to", "replace", "entirely", "." ]
python
train
37.15625
wilzbach/smarkov
smarkov/markov.py
https://github.com/wilzbach/smarkov/blob/c98c08cc432e18c5c87fb9a6e013b1b8eaa54d37/smarkov/markov.py#L56-L76
def _compute_transitions(self, corpus, order=1): """ Computes the transition probabilities of a corpus Args: corpus: the given corpus (a corpus_entry needs to be iterable) order: the maximal Markov chain order """ self.transitions = defaultdict(lambda: defaultdict...
[ "def", "_compute_transitions", "(", "self", ",", "corpus", ",", "order", "=", "1", ")", ":", "self", ".", "transitions", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "int", ")", ")", "for", "corpus_entry", "in", "corpus", ":", "tokens", "=...
Computes the transition probabilities of a corpus Args: corpus: the given corpus (a corpus_entry needs to be iterable) order: the maximal Markov chain order
[ "Computes", "the", "transition", "probabilities", "of", "a", "corpus", "Args", ":", "corpus", ":", "the", "given", "corpus", "(", "a", "corpus_entry", "needs", "to", "be", "iterable", ")", "order", ":", "the", "maximal", "Markov", "chain", "order" ]
python
train
40.428571
d0c-s4vage/pfp
pfp/fuzz/strats.py
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L194-L202
def mutate(self, field): """Mutate the given field, modifying it directly. This is not intended to preserve the value of the field. :field: The pfp.fields.Field instance that will receive the new value """ new_val = self.next_val(field) field._pfp__set_value(new_val) ...
[ "def", "mutate", "(", "self", ",", "field", ")", ":", "new_val", "=", "self", ".", "next_val", "(", "field", ")", "field", ".", "_pfp__set_value", "(", "new_val", ")", "return", "field" ]
Mutate the given field, modifying it directly. This is not intended to preserve the value of the field. :field: The pfp.fields.Field instance that will receive the new value
[ "Mutate", "the", "given", "field", "modifying", "it", "directly", ".", "This", "is", "not", "intended", "to", "preserve", "the", "value", "of", "the", "field", "." ]
python
train
36.555556
ccarocean/python-contours
contours/core.py
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L239-L259
def contour(self, level): """Get contour lines at the given level. Parameters ---------- level : numbers.Number The data level to calculate the contour lines for. Returns ------- : The result of the :attr:`formatter` called on the contour...
[ "def", "contour", "(", "self", ",", "level", ")", ":", "if", "not", "isinstance", "(", "level", ",", "numbers", ".", "Number", ")", ":", "raise", "TypeError", "(", "(", "\"'_level' must be of type 'numbers.Number' but is \"", "\"'{:s}'\"", ")", ".", "format", ...
Get contour lines at the given level. Parameters ---------- level : numbers.Number The data level to calculate the contour lines for. Returns ------- : The result of the :attr:`formatter` called on the contour at the given `level`.
[ "Get", "contour", "lines", "at", "the", "given", "level", "." ]
python
valid
31.190476
annayqho/TheCannon
code/lamost/mass_age/cn/get_colors.py
https://github.com/annayqho/TheCannon/blob/8010a0a5dc9a3f9bb91efa79d7756f79b3c7ba9a/code/lamost/mass_age/cn/get_colors.py#L4-L56
def get_colors(catalog): """ Pull colors from catalog Parameters ---------- catalog: filename """ print("Get Colors") a = pyfits.open(catalog) data = a[1].data a.close() all_ids = data['LAMOST_ID_1'] all_ids = np.array([val.strip() for val in all_ids]) # G magnitude...
[ "def", "get_colors", "(", "catalog", ")", ":", "print", "(", "\"Get Colors\"", ")", "a", "=", "pyfits", ".", "open", "(", "catalog", ")", "data", "=", "a", "[", "1", "]", ".", "data", "a", ".", "close", "(", ")", "all_ids", "=", "data", "[", "'LA...
Pull colors from catalog Parameters ---------- catalog: filename
[ "Pull", "colors", "from", "catalog" ]
python
train
24.622642
cdgriffith/Reusables
reusables/file_operations.py
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/file_operations.py#L259-L287
def save_json(data, json_file, indent=4, **kwargs): """ Takes a dictionary and saves it to a file as JSON .. code:: python my_dict = {"key_1": "val_1", "key_for_dict": {"sub_dict_key": 8}} reusables.save_json(my_dict,"example.json") example.json .. code:: ...
[ "def", "save_json", "(", "data", ",", "json_file", ",", "indent", "=", "4", ",", "*", "*", "kwargs", ")", ":", "with", "open", "(", "json_file", ",", "\"w\"", ")", "as", "f", ":", "json", ".", "dump", "(", "data", ",", "f", ",", "indent", "=", ...
Takes a dictionary and saves it to a file as JSON .. code:: python my_dict = {"key_1": "val_1", "key_for_dict": {"sub_dict_key": 8}} reusables.save_json(my_dict,"example.json") example.json .. code:: { "key_1": "val_1", "key_for_dict":...
[ "Takes", "a", "dictionary", "and", "saves", "it", "to", "a", "file", "as", "JSON" ]
python
train
25.862069
siznax/wptools
wptools/core.py
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L255-L262
def query(self, action=None): """ returns cached query string (without &format=json) for given action, or list of cached actions """ if action in self.cache: return self.cache[action]['query'].replace('&format=json', '') return self.cache.keys() or None
[ "def", "query", "(", "self", ",", "action", "=", "None", ")", ":", "if", "action", "in", "self", ".", "cache", ":", "return", "self", ".", "cache", "[", "action", "]", "[", "'query'", "]", ".", "replace", "(", "'&format=json'", ",", "''", ")", "ret...
returns cached query string (without &format=json) for given action, or list of cached actions
[ "returns", "cached", "query", "string", "(", "without", "&format", "=", "json", ")", "for", "given", "action", "or", "list", "of", "cached", "actions" ]
python
train
38.25
pgjones/quart
quart/app.py
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1007-L1024
def before_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a before request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_request def func(): ... Argum...
[ "def", "before_request", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "before_request_funcs", "[", "name", "]", ...
Add a before request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_request def func(): ... Arguments: func: The before request function itself. name: Optional blueprin...
[ "Add", "a", "before", "request", "function", "." ]
python
train
29.888889
ejeschke/ginga
ginga/rv/plugins/Cuts.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Cuts.py#L1034-L1061
def save_cb(self, mode): """Save image, figure, and plot data arrays.""" # This just defines the basename. # Extension has to be explicitly defined or things can get messy. w = Widgets.SaveDialog(title='Save {0} data'.format(mode)) filename = w.get_path() if filename is...
[ "def", "save_cb", "(", "self", ",", "mode", ")", ":", "# This just defines the basename.", "# Extension has to be explicitly defined or things can get messy.", "w", "=", "Widgets", ".", "SaveDialog", "(", "title", "=", "'Save {0} data'", ".", "format", "(", "mode", ")",...
Save image, figure, and plot data arrays.
[ "Save", "image", "figure", "and", "plot", "data", "arrays", "." ]
python
train
31.607143
ValvePython/steam
steam/client/__init__.py
https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/client/__init__.py#L535-L554
def anonymous_login(self): """Login as anonymous user :return: logon result, see `CMsgClientLogonResponse.eresult <https://github.com/ValvePython/steam/blob/513c68ca081dc9409df932ad86c66100164380a6/protobufs/steammessages_clientserver.proto#L95-L118>`_ :rtype: :class:`.EResult` """ ...
[ "def", "anonymous_login", "(", "self", ")", ":", "self", ".", "_LOG", ".", "debug", "(", "\"Attempting Anonymous login\"", ")", "self", ".", "_pre_login", "(", ")", "self", ".", "username", "=", "None", "self", ".", "login_key", "=", "None", "message", "="...
Login as anonymous user :return: logon result, see `CMsgClientLogonResponse.eresult <https://github.com/ValvePython/steam/blob/513c68ca081dc9409df932ad86c66100164380a6/protobufs/steammessages_clientserver.proto#L95-L118>`_ :rtype: :class:`.EResult`
[ "Login", "as", "anonymous", "user" ]
python
train
38.45
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/__init__.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L175-L179
def colour_for_wp(self, wp_num): '''return a tuple describing the colour a waypoint should appear on the map''' wp = self.module('wp').wploader.wp(wp_num) command = wp.command return self._colour_for_wp_command.get(command, (0,255,0))
[ "def", "colour_for_wp", "(", "self", ",", "wp_num", ")", ":", "wp", "=", "self", ".", "module", "(", "'wp'", ")", ".", "wploader", ".", "wp", "(", "wp_num", ")", "command", "=", "wp", ".", "command", "return", "self", ".", "_colour_for_wp_command", "."...
return a tuple describing the colour a waypoint should appear on the map
[ "return", "a", "tuple", "describing", "the", "colour", "a", "waypoint", "should", "appear", "on", "the", "map" ]
python
train
52.4
numenta/nupic
examples/network/hierarchy_network_demo.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/network/hierarchy_network_demo.py#L105-L128
def createEncoder(): """ Creates and returns a #MultiEncoder including a ScalarEncoder for energy consumption and a DateEncoder for the time of the day. @see nupic/encoders/__init__.py for type to file-name mapping @see nupic/encoders for encoder source files """ encoder = MultiEncoder() encoder.addMul...
[ "def", "createEncoder", "(", ")", ":", "encoder", "=", "MultiEncoder", "(", ")", "encoder", ".", "addMultipleEncoders", "(", "{", "\"consumption\"", ":", "{", "\"fieldname\"", ":", "u\"consumption\"", ",", "\"type\"", ":", "\"ScalarEncoder\"", ",", "\"name\"", "...
Creates and returns a #MultiEncoder including a ScalarEncoder for energy consumption and a DateEncoder for the time of the day. @see nupic/encoders/__init__.py for type to file-name mapping @see nupic/encoders for encoder source files
[ "Creates", "and", "returns", "a", "#MultiEncoder", "including", "a", "ScalarEncoder", "for", "energy", "consumption", "and", "a", "DateEncoder", "for", "the", "time", "of", "the", "day", "." ]
python
valid
36.875
jborean93/requests-credssp
requests_credssp/credssp.py
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L326-L349
def unwrap(self, encrypted_data): """ Decrypts the data send by the server using the TLS channel negotiated between the client and the server. :param encrypted_data: the byte string of the encrypted data :return: a byte string of the decrypted data """ length = s...
[ "def", "unwrap", "(", "self", ",", "encrypted_data", ")", ":", "length", "=", "self", ".", "tls_connection", ".", "bio_write", "(", "encrypted_data", ")", "data", "=", "b''", "counter", "=", "0", "while", "True", ":", "try", ":", "data_chunk", "=", "self...
Decrypts the data send by the server using the TLS channel negotiated between the client and the server. :param encrypted_data: the byte string of the encrypted data :return: a byte string of the decrypted data
[ "Decrypts", "the", "data", "send", "by", "the", "server", "using", "the", "TLS", "channel", "negotiated", "between", "the", "client", "and", "the", "server", "." ]
python
train
29.416667
openstack/networking-arista
networking_arista/ml2/rpc/arista_eapi.py
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/rpc/arista_eapi.py#L142-L150
def get_vlan_assignment_uuid(self): """Returns the UUID for the region's vlan assignment on CVX :returns: string containing the region's vlan assignment UUID """ vlan_uuid_cmd = self.cli_commands['resource-pool'] if vlan_uuid_cmd: return self._run_eos_cmds(commands=v...
[ "def", "get_vlan_assignment_uuid", "(", "self", ")", ":", "vlan_uuid_cmd", "=", "self", ".", "cli_commands", "[", "'resource-pool'", "]", "if", "vlan_uuid_cmd", ":", "return", "self", ".", "_run_eos_cmds", "(", "commands", "=", "vlan_uuid_cmd", ")", "[", "0", ...
Returns the UUID for the region's vlan assignment on CVX :returns: string containing the region's vlan assignment UUID
[ "Returns", "the", "UUID", "for", "the", "region", "s", "vlan", "assignment", "on", "CVX" ]
python
train
38.666667
gem/oq-engine
openquake/hazardlib/gsim/sharma_2009.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sharma_2009.py#L176-L208
def get_fault_type_dummy_variables(self, rup): """ Fault-type classification dummy variable based on rup.rake. "``H`` is 1 for a strike-slip mechanism and 0 for a reverse mechanism" (p. 1201). Note: UserWarning is raised if mechanism is determined to be normal ...
[ "def", "get_fault_type_dummy_variables", "(", "self", ",", "rup", ")", ":", "# normal faulting", "is_normal", "=", "np", ".", "array", "(", "self", ".", "RAKE_THRESH", "<", "-", "rup", ".", "rake", "<", "(", "180.", "-", "self", ".", "RAKE_THRESH", ")", ...
Fault-type classification dummy variable based on rup.rake. "``H`` is 1 for a strike-slip mechanism and 0 for a reverse mechanism" (p. 1201). Note: UserWarning is raised if mechanism is determined to be normal faulting, since as summarized in Table 2 on p. 1197 the data...
[ "Fault", "-", "type", "classification", "dummy", "variable", "based", "on", "rup", ".", "rake", "." ]
python
train
36.606061
jaegertracing/jaeger-client-python
jaeger_client/span.py
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/span.py#L195-L202
def error(self, message, payload=None): """DEPRECATED""" self.set_tag('error', True) if payload: self.log(event=message, payload=payload) else: self.log(event=message) return self
[ "def", "error", "(", "self", ",", "message", ",", "payload", "=", "None", ")", ":", "self", ".", "set_tag", "(", "'error'", ",", "True", ")", "if", "payload", ":", "self", ".", "log", "(", "event", "=", "message", ",", "payload", "=", "payload", ")...
DEPRECATED
[ "DEPRECATED" ]
python
train
29.5
vadimk2016/v-vk-api
v_vk_api/utils.py
https://github.com/vadimk2016/v-vk-api/blob/ef5656e09944b5319a1f573cfb7b022f3d31c0cf/v_vk_api/utils.py#L35-L43
def check_page_for_warnings(html: str) -> None: """ Checks if is any warnings on page if so raises an exception """ soup = BeautifulSoup(html, 'html.parser') warnings = soup.find_all('div', {'class': 'service_msg_warning'}) if warnings: exception_msg = '; '.join((warning.get_text() for w...
[ "def", "check_page_for_warnings", "(", "html", ":", "str", ")", "->", "None", ":", "soup", "=", "BeautifulSoup", "(", "html", ",", "'html.parser'", ")", "warnings", "=", "soup", ".", "find_all", "(", "'div'", ",", "{", "'class'", ":", "'service_msg_warning'"...
Checks if is any warnings on page if so raises an exception
[ "Checks", "if", "is", "any", "warnings", "on", "page", "if", "so", "raises", "an", "exception" ]
python
train
42.777778
ska-sa/katcp-python
katcp/server.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/server.py#L660-L694
def call_from_thread(self, fn): """Allow thread-safe calls to ioloop functions. Uses add_callback if not in the IOLoop thread, otherwise calls directly. Returns an already resolved `tornado.concurrent.Future` if in ioloop, otherwise a `concurrent.Future`. Logs unhandled exceptions. ...
[ "def", "call_from_thread", "(", "self", ",", "fn", ")", ":", "if", "self", ".", "in_ioloop_thread", "(", ")", ":", "f", "=", "tornado_Future", "(", ")", "try", ":", "f", ".", "set_result", "(", "fn", "(", ")", ")", "except", "Exception", ",", "e", ...
Allow thread-safe calls to ioloop functions. Uses add_callback if not in the IOLoop thread, otherwise calls directly. Returns an already resolved `tornado.concurrent.Future` if in ioloop, otherwise a `concurrent.Future`. Logs unhandled exceptions. Resolves with an exception if one occur...
[ "Allow", "thread", "-", "safe", "calls", "to", "ioloop", "functions", "." ]
python
train
35.4
cocaine/cocaine-tools
cocaine/tools/dispatch.py
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1231-L1241
def crashlog_clean(name, timestamp, size, **kwargs): """ For application NAME leave SIZE crashlogs or remove all crashlogs with timestamp > TIMESTAMP. """ ctx = Context(**kwargs) ctx.execute_action('crashlog:clean', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': na...
[ "def", "crashlog_clean", "(", "name", ",", "timestamp", ",", "size", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'crashlog:clean'", ",", "*", "*", "{", "'storage'", ":", ...
For application NAME leave SIZE crashlogs or remove all crashlogs with timestamp > TIMESTAMP.
[ "For", "application", "NAME", "leave", "SIZE", "crashlogs", "or", "remove", "all", "crashlogs", "with", "timestamp", ">", "TIMESTAMP", "." ]
python
train
34
jonaprieto/ponywhoosh
ponywhoosh/index.py
https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L250-L277
def prep_search_string(self, search_string, add_wildcards=False): """Prepares search string as a proper whoosh search string. Args: search_string (str): it prepares the search string and see if the lenght is correct. Optional Args: add_wildcards (bool): It runs a query for inexact quer...
[ "def", "prep_search_string", "(", "self", ",", "search_string", ",", "add_wildcards", "=", "False", ")", ":", "s", "=", "search_string", ".", "strip", "(", ")", "try", ":", "s", "=", "str", "(", "s", ")", "except", ":", "pass", "s", "=", "s", ".", ...
Prepares search string as a proper whoosh search string. Args: search_string (str): it prepares the search string and see if the lenght is correct. Optional Args: add_wildcards (bool): It runs a query for inexact queries. Raises: ValueError: When the search string does not have ...
[ "Prepares", "search", "string", "as", "a", "proper", "whoosh", "search", "string", "." ]
python
train
29.178571
CZ-NIC/yangson
yangson/schemadata.py
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L208-L216
def _check_feature_dependences(self): """Verify feature dependences.""" for mid in self.modules: for fst in self.modules[mid].statement.find_all("feature"): fn, fid = self.resolve_pname(fst.argument, mid) if fn not in self.modules[fid].features: ...
[ "def", "_check_feature_dependences", "(", "self", ")", ":", "for", "mid", "in", "self", ".", "modules", ":", "for", "fst", "in", "self", ".", "modules", "[", "mid", "]", ".", "statement", ".", "find_all", "(", "\"feature\"", ")", ":", "fn", ",", "fid",...
Verify feature dependences.
[ "Verify", "feature", "dependences", "." ]
python
train
48.111111
PyCQA/astroid
astroid/rebuilder.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/rebuilder.py#L907-L912
def visit_yield(self, node, parent): """visit a Yield node by returning a fresh instance of it""" newnode = nodes.Yield(node.lineno, node.col_offset, parent) if node.value is not None: newnode.postinit(self.visit(node.value, newnode)) return newnode
[ "def", "visit_yield", "(", "self", ",", "node", ",", "parent", ")", ":", "newnode", "=", "nodes", ".", "Yield", "(", "node", ".", "lineno", ",", "node", ".", "col_offset", ",", "parent", ")", "if", "node", ".", "value", "is", "not", "None", ":", "n...
visit a Yield node by returning a fresh instance of it
[ "visit", "a", "Yield", "node", "by", "returning", "a", "fresh", "instance", "of", "it" ]
python
train
48
RomelTorres/alpha_vantage
alpha_vantage/techindicators.py
https://github.com/RomelTorres/alpha_vantage/blob/4e0b5057e520e3e3de69cf947301765817290121/alpha_vantage/techindicators.py#L253-L290
def get_stoch(self, symbol, interval='daily', fastkperiod=None, slowkperiod=None, slowdperiod=None, slowkmatype=None, slowdmatype=None): """ Return the stochatic oscillator values in two json objects as data and meta_data. It raises ValueError when problems arise Keywo...
[ "def", "get_stoch", "(", "self", ",", "symbol", ",", "interval", "=", "'daily'", ",", "fastkperiod", "=", "None", ",", "slowkperiod", "=", "None", ",", "slowdperiod", "=", "None", ",", "slowkmatype", "=", "None", ",", "slowdmatype", "=", "None", ")", ":"...
Return the stochatic oscillator values in two json objects as data and meta_data. It raises ValueError when problems arise Keyword Arguments: symbol: the symbol for the equity we want to get its data interval: time interval between two conscutive values, ...
[ "Return", "the", "stochatic", "oscillator", "values", "in", "two", "json", "objects", "as", "data", "and", "meta_data", ".", "It", "raises", "ValueError", "when", "problems", "arise" ]
python
train
55.815789
smdabdoub/phylotoast
bin/core_overlap_plot.py
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/core_overlap_plot.py#L77-L93
def load_core_file(core_fp): """ For core OTU data file, returns Genus-species identifier for each data entry. :type core_fp: str :param core_fp: A file containing core OTU data. :rtype: str :return: Returns genus-species identifier based on identified taxonomical level. """...
[ "def", "load_core_file", "(", "core_fp", ")", ":", "core", "=", "{", "}", "with", "open", "(", "core_fp", ")", "as", "in_f", ":", "for", "line", "in", "in_f", ".", "read", "(", ")", ".", "splitlines", "(", ")", ":", "if", "not", "line", ".", "sta...
For core OTU data file, returns Genus-species identifier for each data entry. :type core_fp: str :param core_fp: A file containing core OTU data. :rtype: str :return: Returns genus-species identifier based on identified taxonomical level.
[ "For", "core", "OTU", "data", "file", "returns", "Genus", "-", "species", "identifier", "for", "each", "data", "entry", ".", ":", "type", "core_fp", ":", "str", ":", "param", "core_fp", ":", "A", "file", "containing", "core", "OTU", "data", ".", ":", "...
python
train
33.294118
fermiPy/fermipy
fermipy/utils.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1111-L1134
def fits_recarray_to_dict(table): """Convert a FITS recarray to a python dictionary.""" cols = {} for icol, col in enumerate(table.columns.names): col_data = table.data[col] if type(col_data[0]) == np.float32: cols[col] = np.array(col_data, dtype=float) elif type(col_da...
[ "def", "fits_recarray_to_dict", "(", "table", ")", ":", "cols", "=", "{", "}", "for", "icol", ",", "col", "in", "enumerate", "(", "table", ".", "columns", ".", "names", ")", ":", "col_data", "=", "table", ".", "data", "[", "col", "]", "if", "type", ...
Convert a FITS recarray to a python dictionary.
[ "Convert", "a", "FITS", "recarray", "to", "a", "python", "dictionary", "." ]
python
train
37.25
cltrudeau/django-flowr
flowr/models.py
https://github.com/cltrudeau/django-flowr/blob/d077b90376ede33721db55ff29e08b8a16ed17ae/flowr/models.py#L111-L128
def find_nodes(self, **kwargs): """Searches the data nodes that are associated with this graph using the key word arguments as a filter and returns a :class:`django.db.models.query.QuerySet`` of the attached :class:`Node` objects. :param kwargs: filter arguments app...
[ "def", "find_nodes", "(", "self", ",", "*", "*", "kwargs", ")", ":", "filter_args", "=", "{", "}", "classname", "=", "self", ".", "data_content_type", ".", "model_class", "(", ")", ".", "__name__", ".", "lower", "(", ")", "for", "key", ",", "value", ...
Searches the data nodes that are associated with this graph using the key word arguments as a filter and returns a :class:`django.db.models.query.QuerySet`` of the attached :class:`Node` objects. :param kwargs: filter arguments applied to searching the :class:`BaseNodeData`...
[ "Searches", "the", "data", "nodes", "that", "are", "associated", "with", "this", "graph", "using", "the", "key", "word", "arguments", "as", "a", "filter", "and", "returns", "a", ":", "class", ":", "django", ".", "db", ".", "models", ".", "query", ".", ...
python
valid
40.555556
dsoprea/PySchedules
pyschedules/xml_callbacks.py
https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L79-L87
def _startStationsNode(self, name, attrs): """Process the start of a node under xtvd/stations""" if name == 'station': self._stationId = attrs.get('id') self._callSign = None self._stationName = None self._affiliate = None self._fccChannelNumb...
[ "def", "_startStationsNode", "(", "self", ",", "name", ",", "attrs", ")", ":", "if", "name", "==", "'station'", ":", "self", ".", "_stationId", "=", "attrs", ".", "get", "(", "'id'", ")", "self", ".", "_callSign", "=", "None", "self", ".", "_stationNam...
Process the start of a node under xtvd/stations
[ "Process", "the", "start", "of", "a", "node", "under", "xtvd", "/", "stations" ]
python
train
35.666667
tBaxter/tango-comments
build/lib/tango_comments/moderation.py
https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L312-L326
def unregister(self, model_or_iterable): """ Remove a model or a list of models from the list of models whose comments will be moderated. Raise ``NotModerated`` if any of the models are not currently registered for moderation. """ if isinstance(model_or_iterable...
[ "def", "unregister", "(", "self", ",", "model_or_iterable", ")", ":", "if", "isinstance", "(", "model_or_iterable", ",", "ModelBase", ")", ":", "model_or_iterable", "=", "[", "model_or_iterable", "]", "for", "model", "in", "model_or_iterable", ":", "if", "model"...
Remove a model or a list of models from the list of models whose comments will be moderated. Raise ``NotModerated`` if any of the models are not currently registered for moderation.
[ "Remove", "a", "model", "or", "a", "list", "of", "models", "from", "the", "list", "of", "models", "whose", "comments", "will", "be", "moderated", "." ]
python
train
40.333333
avelino/bottle-auth
bottle_auth/core/httputil.py
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L191-L233
def parse_multipart_form_data(boundary, data, arguments, files): """Parses a multipart/form-data body. The boundary and data parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body. """ # The standard allows fo...
[ "def", "parse_multipart_form_data", "(", "boundary", ",", "data", ",", "arguments", ",", "files", ")", ":", "# The standard allows for the boundary to be quoted in the header,", "# although it's rare (it happens at least for google app engine", "# xmpp). I think we're also supposed to h...
Parses a multipart/form-data body. The boundary and data parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body.
[ "Parses", "a", "multipart", "/", "form", "-", "data", "body", "." ]
python
test
44.534884
gpoulter/fablib
fablib.py
https://github.com/gpoulter/fablib/blob/5d14c4d998f79dd1aa3207063c3d06e30e3e2bf9/fablib.py#L247-L277
def tagversion(repo, level='patch', special=''): """Increment and return tagged version in git. Increment levels are patch, minor and major. Using semver.org versioning: {major}.{minor}.{patch}{special} Special must start with a-z and consist of _a-zA-Z0-9. """ prepend = 'v' with lcd(repo):...
[ "def", "tagversion", "(", "repo", ",", "level", "=", "'patch'", ",", "special", "=", "''", ")", ":", "prepend", "=", "'v'", "with", "lcd", "(", "repo", ")", ":", "oldversion", "=", "local", "(", "'git describe --abbrev=0 --tags'", ",", "capture", "=", "T...
Increment and return tagged version in git. Increment levels are patch, minor and major. Using semver.org versioning: {major}.{minor}.{patch}{special} Special must start with a-z and consist of _a-zA-Z0-9.
[ "Increment", "and", "return", "tagged", "version", "in", "git", ".", "Increment", "levels", "are", "patch", "minor", "and", "major", "." ]
python
train
40.129032
gawel/irc3
irc3/__init__.py
https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L283-L289
def join(self, target): """join a channel""" password = self.config.passwords.get( target.strip(self.server_config['CHANTYPES'])) if password: target += ' ' + password self.send_line('JOIN %s' % target)
[ "def", "join", "(", "self", ",", "target", ")", ":", "password", "=", "self", ".", "config", ".", "passwords", ".", "get", "(", "target", ".", "strip", "(", "self", ".", "server_config", "[", "'CHANTYPES'", "]", ")", ")", "if", "password", ":", "targ...
join a channel
[ "join", "a", "channel" ]
python
train
36
pyblish/pyblish-qml
pyblish_qml/vendor/mock.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/vendor/mock.py#L1495-L1568
def patch( target, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs ): """ `patch` acts as a function decorator, class decorator or a context manager. Inside the body of the function or with statement, the `target` is patched with a `new...
[ "def", "patch", "(", "target", ",", "new", "=", "DEFAULT", ",", "spec", "=", "None", ",", "create", "=", "False", ",", "spec_set", "=", "None", ",", "autospec", "=", "None", ",", "new_callable", "=", "None", ",", "*", "*", "kwargs", ")", ":", "gett...
`patch` acts as a function decorator, class decorator or a context manager. Inside the body of the function or with statement, the `target` is patched with a `new` object. When the function/with statement exits the patch is undone. If `new` is omitted, then the target is replaced with a `MagicMock`...
[ "patch", "acts", "as", "a", "function", "decorator", "class", "decorator", "or", "a", "context", "manager", ".", "Inside", "the", "body", "of", "the", "function", "or", "with", "statement", "the", "target", "is", "patched", "with", "a", "new", "object", "....
python
train
50.783784
b3j0f/annotation
b3j0f/annotation/core.py
https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/core.py#L328-L338
def on_bind_target(self, target, ctx=None): """Fired after target is bound to self. :param target: newly bound target. :param ctx: target ctx. """ _on_bind_target = getattr(self, Annotation._ON_BIND_TARGET, None) if _on_bind_target is not None: _on_bind_tar...
[ "def", "on_bind_target", "(", "self", ",", "target", ",", "ctx", "=", "None", ")", ":", "_on_bind_target", "=", "getattr", "(", "self", ",", "Annotation", ".", "_ON_BIND_TARGET", ",", "None", ")", "if", "_on_bind_target", "is", "not", "None", ":", "_on_bin...
Fired after target is bound to self. :param target: newly bound target. :param ctx: target ctx.
[ "Fired", "after", "target", "is", "bound", "to", "self", "." ]
python
train
31.181818
darothen/xbpch
xbpch/core.py
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L129-L215
def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts', preprocess=None, lock=None, **kwargs): """ Open multiple bpch files as a single dataset. You must have dask installed for this to work, as this greatly simplifies issues relating to multi-file I/O. Also, ple...
[ "def", "open_mfbpchdataset", "(", "paths", ",", "concat_dim", "=", "'time'", ",", "compat", "=", "'no_conflicts'", ",", "preprocess", "=", "None", ",", "lock", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "xarray", ".", "backends", ".", "api",...
Open multiple bpch files as a single dataset. You must have dask installed for this to work, as this greatly simplifies issues relating to multi-file I/O. Also, please note that this is not a very performant routine. I/O is still limited by the fact that we need to manually scan/read through each bpch...
[ "Open", "multiple", "bpch", "files", "as", "a", "single", "dataset", "." ]
python
train
39.402299
insilichem/pychimera
pychimera/core.py
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/core.py#L100-L104
def patch_sys_version(): """ Remove Continuum copyright statement to avoid parsing errors in IDLE """ if '|' in sys.version: sys_version = sys.version.split('|') sys.version = ' '.join([sys_version[0].strip(), sys_version[-1].strip()])
[ "def", "patch_sys_version", "(", ")", ":", "if", "'|'", "in", "sys", ".", "version", ":", "sys_version", "=", "sys", ".", "version", ".", "split", "(", "'|'", ")", "sys", ".", "version", "=", "' '", ".", "join", "(", "[", "sys_version", "[", "0", "...
Remove Continuum copyright statement to avoid parsing errors in IDLE
[ "Remove", "Continuum", "copyright", "statement", "to", "avoid", "parsing", "errors", "in", "IDLE" ]
python
train
51
CalebBell/thermo
thermo/identifiers.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/identifiers.py#L35-L81
def checkCAS(CASRN): '''Checks if a CAS number is valid. Returns False if the parser cannot parse the given string.. Parameters ---------- CASRN : string A three-piece, dash-separated set of numbers Returns ------- result : bool Boolean value if CASRN was valid. If par...
[ "def", "checkCAS", "(", "CASRN", ")", ":", "try", ":", "check", "=", "CASRN", "[", "-", "1", "]", "CASRN", "=", "CASRN", "[", ":", ":", "-", "1", "]", "[", "1", ":", "]", "productsum", "=", "0", "i", "=", "1", "for", "num", "in", "CASRN", "...
Checks if a CAS number is valid. Returns False if the parser cannot parse the given string.. Parameters ---------- CASRN : string A three-piece, dash-separated set of numbers Returns ------- result : bool Boolean value if CASRN was valid. If parsing fails, return False als...
[ "Checks", "if", "a", "CAS", "number", "is", "valid", ".", "Returns", "False", "if", "the", "parser", "cannot", "parse", "the", "given", "string", ".." ]
python
valid
24.723404
log2timeline/dfvfs
dfvfs/path/path_spec.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/path/path_spec.py#L83-L99
def CopyToDict(self): """Copies the path specification to a dictionary. Returns: dict[str, object]: path specification attributes. """ path_spec_dict = {} for attribute_name, attribute_value in iter(self.__dict__.items()): if attribute_value is None: continue if attribute...
[ "def", "CopyToDict", "(", "self", ")", ":", "path_spec_dict", "=", "{", "}", "for", "attribute_name", ",", "attribute_value", "in", "iter", "(", "self", ".", "__dict__", ".", "items", "(", ")", ")", ":", "if", "attribute_value", "is", "None", ":", "conti...
Copies the path specification to a dictionary. Returns: dict[str, object]: path specification attributes.
[ "Copies", "the", "path", "specification", "to", "a", "dictionary", "." ]
python
train
27.058824
RudolfCardinal/pythonlib
cardinal_pythonlib/source_reformatting.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/source_reformatting.py#L288-L296
def rewrite_file(self) -> None: """ Rewrites the source file. """ if not self.needs_rewriting: return self._info("Rewriting file") with open(self.full_path, "w") as outfile: self._write(outfile)
[ "def", "rewrite_file", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "needs_rewriting", ":", "return", "self", ".", "_info", "(", "\"Rewriting file\"", ")", "with", "open", "(", "self", ".", "full_path", ",", "\"w\"", ")", "as", "outfile...
Rewrites the source file.
[ "Rewrites", "the", "source", "file", "." ]
python
train
28.666667
wiredrive/wtframework
wtframework/wtf/web/webelement.py
https://github.com/wiredrive/wtframework/blob/ef7f86c4d4cf7fb17745fd627b3cc4a41f4c0216/wtframework/wtf/web/webelement.py#L33-L70
def find_element_by_selectors(webdriver, *selectors): """ Utility method makes it easier to find an element using multiple selectors. This is useful for problematic elements what might works with one browser, but fail in another. (Like different page elements being served up for differe...
[ "def", "find_element_by_selectors", "(", "webdriver", ",", "*", "selectors", ")", ":", "# perform initial check to verify selectors are valid by statements.", "for", "selector", "in", "selectors", ":", "(", "by_method", ",", "value", ")", "=", "selector", "if", "not", ...
Utility method makes it easier to find an element using multiple selectors. This is useful for problematic elements what might works with one browser, but fail in another. (Like different page elements being served up for different browsers) Args: selectors - var arg if N number of...
[ "Utility", "method", "makes", "it", "easier", "to", "find", "an", "element", "using", "multiple", "selectors", ".", "This", "is", "useful", "for", "problematic", "elements", "what", "might", "works", "with", "one", "browser", "but", "fail", "in", "another", ...
python
train
45.684211
Arubacloud/pyArubaCloud
ArubaCloud/PyArubaAPI.py
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L54-L67
def login(self, username, password, load=True): """ Set the authentication data in the object, and if load is True (default is True) it also retrieve the ip list and the vm list in order to build the internal objects list. @param (str) username: username of the cloud @par...
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "load", "=", "True", ")", ":", "self", ".", "auth", "=", "Auth", "(", "username", ",", "password", ")", "if", "load", "is", "True", ":", "self", ".", "get_ip", "(", ")", "self", ...
Set the authentication data in the object, and if load is True (default is True) it also retrieve the ip list and the vm list in order to build the internal objects list. @param (str) username: username of the cloud @param (str) password: password of the cloud @param (bool) load:...
[ "Set", "the", "authentication", "data", "in", "the", "object", "and", "if", "load", "is", "True", "(", "default", "is", "True", ")", "it", "also", "retrieve", "the", "ip", "list", "and", "the", "vm", "list", "in", "order", "to", "build", "the", "intern...
python
train
40.642857
m0n5t3r/sentry-zabbix
src/sentry_zabbix/plugin.py
https://github.com/m0n5t3r/sentry-zabbix/blob/3dc6e245b3d67de54e4bd41d2bc9b715fee2dbd2/src/sentry_zabbix/plugin.py#L52-L83
def post_process(self, group, event, is_new, is_sample, **kwargs): """ Process error. """ if not self.is_configured(group.project): return host = self.get_option('server_host', group.project) port = int(self.get_option('server_port', group.project)) p...
[ "def", "post_process", "(", "self", ",", "group", ",", "event", ",", "is_new", ",", "is_sample", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_configured", "(", "group", ".", "project", ")", ":", "return", "host", "=", "self", ".",...
Process error.
[ "Process", "error", "." ]
python
valid
35.375
portfoliome/foil
foil/compose.py
https://github.com/portfoliome/foil/blob/b66d8cf4ab048a387d8c7a033b47e922ed6917d6/foil/compose.py#L5-L13
def create_quantiles(items: Sequence, lower_bound, upper_bound): """Create quantile start and end boundaries.""" interval = (upper_bound - lower_bound) / len(items) quantiles = ((g, (x - interval, x)) for g, x in zip(items, accumulate(repeat(interval, len(items))))) return quantiles
[ "def", "create_quantiles", "(", "items", ":", "Sequence", ",", "lower_bound", ",", "upper_bound", ")", ":", "interval", "=", "(", "upper_bound", "-", "lower_bound", ")", "/", "len", "(", "items", ")", "quantiles", "=", "(", "(", "g", ",", "(", "x", "-"...
Create quantile start and end boundaries.
[ "Create", "quantile", "start", "and", "end", "boundaries", "." ]
python
train
34.555556
happyleavesaoc/aoc-mgz
mgz/enums.py
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L92-L105
def GameTypeEnum(ctx): """Game Type Enumeration.""" return Enum( ctx, RM=0, Regicide=1, DM=2, Scenario=3, Campaign=4, KingOfTheHill=5, WonderRace=6, DefendTheWonder=7, TurboRandom=8 )
[ "def", "GameTypeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "RM", "=", "0", ",", "Regicide", "=", "1", ",", "DM", "=", "2", ",", "Scenario", "=", "3", ",", "Campaign", "=", "4", ",", "KingOfTheHill", "=", "5", ",", "WonderRace...
Game Type Enumeration.
[ "Game", "Type", "Enumeration", "." ]
python
train
18.714286
edx/edx-enterprise
enterprise/admin/views.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/views.py#L699-L723
def get_pending_enrollment_message(cls, pending_users, enrolled_in): """ Create message for the users who were enrolled in a course or program. Args: users: An iterable of PendingEnterpriseCustomerUsers who were successfully linked with a pending enrollment enrolled_in (...
[ "def", "get_pending_enrollment_message", "(", "cls", ",", "pending_users", ",", "enrolled_in", ")", ":", "pending_emails", "=", "[", "pending_user", ".", "user_email", "for", "pending_user", "in", "pending_users", "]", "return", "(", "'warning'", ",", "_", "(", ...
Create message for the users who were enrolled in a course or program. Args: users: An iterable of PendingEnterpriseCustomerUsers who were successfully linked with a pending enrollment enrolled_in (str): A string identifier for the course or program the pending users were linked to ...
[ "Create", "message", "for", "the", "users", "who", "were", "enrolled", "in", "a", "course", "or", "program", "." ]
python
valid
44.36
treycucco/bidon
bidon/json_patch.py
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L193-L202
def resolve_path(root, path): """Resolve a rfc 6901 path, returning the parent and the last path part.""" path = parse_path(path) parent = root for part in path[:-1]: parent = get_child(parent, rfc_6901_replace(part)) return (parent, rfc_6901_replace(path[-1]))
[ "def", "resolve_path", "(", "root", ",", "path", ")", ":", "path", "=", "parse_path", "(", "path", ")", "parent", "=", "root", "for", "part", "in", "path", "[", ":", "-", "1", "]", ":", "parent", "=", "get_child", "(", "parent", ",", "rfc_6901_replac...
Resolve a rfc 6901 path, returning the parent and the last path part.
[ "Resolve", "a", "rfc", "6901", "path", "returning", "the", "parent", "and", "the", "last", "path", "part", "." ]
python
train
26.9
log2timeline/dfvfs
dfvfs/file_io/vhdi_file_io.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/file_io/vhdi_file_io.py#L28-L39
def _Close(self): """Closes the file-like object.""" super(VHDIFile, self)._Close() for vhdi_file in self._parent_vhdi_files: vhdi_file.close() for file_object in self._sub_file_objects: file_object.close() self._parent_vhdi_files = [] self._sub_file_objects = []
[ "def", "_Close", "(", "self", ")", ":", "super", "(", "VHDIFile", ",", "self", ")", ".", "_Close", "(", ")", "for", "vhdi_file", "in", "self", ".", "_parent_vhdi_files", ":", "vhdi_file", ".", "close", "(", ")", "for", "file_object", "in", "self", ".",...
Closes the file-like object.
[ "Closes", "the", "file", "-", "like", "object", "." ]
python
train
24.25
kallimachos/chios
chios/remotecode/__init__.py
https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remotecode/__init__.py#L33-L44
def run(self): """Fetch remote code.""" link = self.content[0] try: r = requests.get(link) r.raise_for_status() self.content = [r.text] return super(RemoteCodeBlock, self).run() except Exception: document = self.state.document ...
[ "def", "run", "(", "self", ")", ":", "link", "=", "self", ".", "content", "[", "0", "]", "try", ":", "r", "=", "requests", ".", "get", "(", "link", ")", "r", ".", "raise_for_status", "(", ")", "self", ".", "content", "=", "[", "r", ".", "text",...
Fetch remote code.
[ "Fetch", "remote", "code", "." ]
python
train
35.666667
slhck/ffmpeg-normalize
ffmpeg_normalize/_ffmpeg_normalize.py
https://github.com/slhck/ffmpeg-normalize/blob/18477a7f2d092777ee238340be40c04ecb45c132/ffmpeg_normalize/_ffmpeg_normalize.py#L163-L178
def run_normalization(self): """ Run the normalization procedures """ for index, media_file in enumerate( tqdm( self.media_files, desc="File", disable=not self.progress, position=0 ...
[ "def", "run_normalization", "(", "self", ")", ":", "for", "index", ",", "media_file", "in", "enumerate", "(", "tqdm", "(", "self", ".", "media_files", ",", "desc", "=", "\"File\"", ",", "disable", "=", "not", "self", ".", "progress", ",", "position", "="...
Run the normalization procedures
[ "Run", "the", "normalization", "procedures" ]
python
train
34.4375
brian-rose/climlab
climlab/process/time_dependent_process.py
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/process/time_dependent_process.py#L307-L342
def step_forward(self): """Updates state variables with computed tendencies. Calls the :func:`compute` method to get current tendencies for all process states. Multiplied with the timestep and added up to the state variables is updating all model states. :Example: ...
[ "def", "step_forward", "(", "self", ")", ":", "tenddict", "=", "self", ".", "compute", "(", ")", "# Total tendency is applied as an explicit forward timestep", "# (already accounting properly for order of operations in compute() )", "for", "varname", ",", "tend", "in", "tend...
Updates state variables with computed tendencies. Calls the :func:`compute` method to get current tendencies for all process states. Multiplied with the timestep and added up to the state variables is updating all model states. :Example: :: >>> import clim...
[ "Updates", "state", "variables", "with", "computed", "tendencies", "." ]
python
train
34.666667
LogicalDash/LiSE
ELiDE/ELiDE/card.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/card.py#L1013-L1032
def on_touch_move(self, touch): """Move the scrollbar to the touch, and update my ``scroll`` accordingly. """ if not self.scrolling or 'bar' not in self.ids: touch.ungrab(self) return touch.push() touch.apply_transform_2d(self.parent.to_local) ...
[ "def", "on_touch_move", "(", "self", ",", "touch", ")", ":", "if", "not", "self", ".", "scrolling", "or", "'bar'", "not", "in", "self", ".", "ids", ":", "touch", ".", "ungrab", "(", "self", ")", "return", "touch", ".", "push", "(", ")", "touch", "....
Move the scrollbar to the touch, and update my ``scroll`` accordingly.
[ "Move", "the", "scrollbar", "to", "the", "touch", "and", "update", "my", "scroll", "accordingly", "." ]
python
train
42.15
samluescher/django-media-tree
media_tree/utils/staticfiles.py
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/staticfiles.py#L83-L102
def find(names, dirs, file_ext): """ Iterating a set of dirs under the static root, this method tries to find a file named like one of the names and file ext passed, and returns the storage path to the first file it encounters. Usage this method makes it possible to over...
[ "def", "find", "(", "names", ",", "dirs", ",", "file_ext", ")", ":", "if", "not", "isinstance", "(", "names", ",", "list", ")", "or", "isinstance", "(", "names", ",", "tuple", ")", ":", "names", "=", "(", "names", ",", ")", "for", "dir_name", "in",...
Iterating a set of dirs under the static root, this method tries to find a file named like one of the names and file ext passed, and returns the storage path to the first file it encounters. Usage this method makes it possible to override static files (such as icon sets) in a s...
[ "Iterating", "a", "set", "of", "dirs", "under", "the", "static", "root", "this", "method", "tries", "to", "find", "a", "file", "named", "like", "one", "of", "the", "names", "and", "file", "ext", "passed", "and", "returns", "the", "storage", "path", "to",...
python
train
46.95
dwavesystems/dimod
dimod/utilities.py
https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/utilities.py#L209-L284
def qubo_to_ising(Q, offset=0.0): """Convert a QUBO problem to an Ising problem. Map a quadratic unconstrained binary optimization (QUBO) problem :math:`x' Q x` defined over binary variables (0 or 1 values), where the linear term is contained along the diagonal of Q, to an Ising model defined on spin...
[ "def", "qubo_to_ising", "(", "Q", ",", "offset", "=", "0.0", ")", ":", "h", "=", "{", "}", "J", "=", "{", "}", "linear_offset", "=", "0.0", "quadratic_offset", "=", "0.0", "for", "(", "u", ",", "v", ")", ",", "bias", "in", "iteritems", "(", "Q", ...
Convert a QUBO problem to an Ising problem. Map a quadratic unconstrained binary optimization (QUBO) problem :math:`x' Q x` defined over binary variables (0 or 1 values), where the linear term is contained along the diagonal of Q, to an Ising model defined on spins (variables with {-1, +1} values). R...
[ "Convert", "a", "QUBO", "problem", "to", "an", "Ising", "problem", "." ]
python
train
30.736842
brunato/lograptor
lograptor/core.py
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L600-L620
def get_config(self): """ Return a formatted text with main configuration parameters. """ # Create a dummy report object if necessary channels = [sect.rsplit('_')[0] for sect in self.config.sections(suffix='_channel')] channels.sort() disabled_apps = [app for app ...
[ "def", "get_config", "(", "self", ")", ":", "# Create a dummy report object if necessary", "channels", "=", "[", "sect", ".", "rsplit", "(", "'_'", ")", "[", "0", "]", "for", "sect", "in", "self", ".", "config", ".", "sections", "(", "suffix", "=", "'_chan...
Return a formatted text with main configuration parameters.
[ "Return", "a", "formatted", "text", "with", "main", "configuration", "parameters", "." ]
python
train
51.857143
tensorflow/cleverhans
examples/nips17_adversarial_competition/dev_toolkit/sample_attacks/fgsm/attack_fgsm.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/nips17_adversarial_competition/dev_toolkit/sample_attacks/fgsm/attack_fgsm.py#L80-L95
def save_images(images, filenames, output_dir): """Saves images to the output directory. Args: images: array with minibatch of images filenames: list of filenames without path If number of file names in this list less than number of images in the minibatch then only first len(filenames) images ...
[ "def", "save_images", "(", "images", ",", "filenames", ",", "output_dir", ")", ":", "for", "i", ",", "filename", "in", "enumerate", "(", "filenames", ")", ":", "# Images for inception classifier are normalized to be in [-1, 1] interval,", "# so rescale them back to [0, 1]."...
Saves images to the output directory. Args: images: array with minibatch of images filenames: list of filenames without path If number of file names in this list less than number of images in the minibatch then only first len(filenames) images will be saved. output_dir: directory where to sav...
[ "Saves", "images", "to", "the", "output", "directory", "." ]
python
train
45.375
Diviyan-Kalainathan/CausalDiscoveryToolbox
cdt/causality/pairwise/RCC.py
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/RCC.py#L97-L114
def fit(self, x, y): """Train the model. Args: x_tr (pd.DataFrame): CEPC format dataframe containing the pairs y_tr (pd.DataFrame or np.ndarray): labels associated to the pairs """ train = np.vstack((np.array([self.featurize_row(row.iloc[0], ...
[ "def", "fit", "(", "self", ",", "x", ",", "y", ")", ":", "train", "=", "np", ".", "vstack", "(", "(", "np", ".", "array", "(", "[", "self", ".", "featurize_row", "(", "row", ".", "iloc", "[", "0", "]", ",", "row", ".", "iloc", "[", "1", "]"...
Train the model. Args: x_tr (pd.DataFrame): CEPC format dataframe containing the pairs y_tr (pd.DataFrame or np.ndarray): labels associated to the pairs
[ "Train", "the", "model", "." ]
python
valid
49.055556
guaix-ucm/numina
numina/array/imsurfit.py
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/imsurfit.py#L40-L49
def _compute_weight(powers, wg): """Return the weight corresponding to given powers.""" # split pow1 = (powers[0], 0) pow2 = (0, powers[1]) cal1 = _compute_value(pow1, wg) cal2 = _compute_value(pow2, wg) return cal1 * cal2
[ "def", "_compute_weight", "(", "powers", ",", "wg", ")", ":", "# split", "pow1", "=", "(", "powers", "[", "0", "]", ",", "0", ")", "pow2", "=", "(", "0", ",", "powers", "[", "1", "]", ")", "cal1", "=", "_compute_value", "(", "pow1", ",", "wg", ...
Return the weight corresponding to given powers.
[ "Return", "the", "weight", "corresponding", "to", "given", "powers", "." ]
python
train
24.3
alpha-xone/xbbg
xbbg/core/utils.py
https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/core/utils.py#L12-L47
def flatten(iterable, maps=None, unique=False) -> list: """ Flatten any array of items to list Args: iterable: any array or value maps: map items to values unique: drop duplicates Returns: list: flattened list References: https://stackoverflow.com/a/4085770...
[ "def", "flatten", "(", "iterable", ",", "maps", "=", "None", ",", "unique", "=", "False", ")", "->", "list", ":", "if", "iterable", "is", "None", ":", "return", "[", "]", "if", "maps", "is", "None", ":", "maps", "=", "dict", "(", ")", "if", "isin...
Flatten any array of items to list Args: iterable: any array or value maps: map items to values unique: drop duplicates Returns: list: flattened list References: https://stackoverflow.com/a/40857703/1332656 Examples: >>> flatten('abc') ['abc'] ...
[ "Flatten", "any", "array", "of", "items", "to", "list" ]
python
valid
24.694444
HttpRunner/HttpRunner
httprunner/report.py
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/report.py#L218-L245
def __expand_meta_datas(meta_datas, meta_datas_expanded): """ expand meta_datas to one level Args: meta_datas (dict/list): maybe in nested format Returns: list: expanded list in one level Examples: >>> meta_datas = [ [ dict1, ...
[ "def", "__expand_meta_datas", "(", "meta_datas", ",", "meta_datas_expanded", ")", ":", "if", "isinstance", "(", "meta_datas", ",", "dict", ")", ":", "meta_datas_expanded", ".", "append", "(", "meta_datas", ")", "elif", "isinstance", "(", "meta_datas", ",", "list...
expand meta_datas to one level Args: meta_datas (dict/list): maybe in nested format Returns: list: expanded list in one level Examples: >>> meta_datas = [ [ dict1, dict2 ], dict3 ] ...
[ "expand", "meta_datas", "to", "one", "level" ]
python
train
27.357143
metachris/RPIO
source/RPIO/_RPIO.py
https://github.com/metachris/RPIO/blob/be1942a69b2592ddacd9dc833d2668a19aafd8d2/source/RPIO/_RPIO.py#L91-L112
def add_tcp_callback(self, port, callback, threaded_callback=False): """ Adds a unix socket server callback, which will be invoked when values arrive from a connected socket client. The callback must accept two parameters, eg. ``def callback(socket, msg)``. """ if not cal...
[ "def", "add_tcp_callback", "(", "self", ",", "port", ",", "callback", ",", "threaded_callback", "=", "False", ")", ":", "if", "not", "callback", ":", "raise", "AttributeError", "(", "\"No callback\"", ")", "serversocket", "=", "socket", ".", "socket", "(", "...
Adds a unix socket server callback, which will be invoked when values arrive from a connected socket client. The callback must accept two parameters, eg. ``def callback(socket, msg)``.
[ "Adds", "a", "unix", "socket", "server", "callback", "which", "will", "be", "invoked", "when", "values", "arrive", "from", "a", "connected", "socket", "client", ".", "The", "callback", "must", "accept", "two", "parameters", "eg", ".", "def", "callback", "(",...
python
train
45.954545
SmokinCaterpillar/pypet
pypet/naturalnaming.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/naturalnaming.py#L856-L868
def _remove_node_or_leaf(self, instance, recursive=False): """Removes a single node from the tree. Only from RAM not from hdf5 file! :param instance: The node to be deleted :param recursive: If group nodes with children should be deleted """ full_name = instance.v_ful...
[ "def", "_remove_node_or_leaf", "(", "self", ",", "instance", ",", "recursive", "=", "False", ")", ":", "full_name", "=", "instance", ".", "v_full_name", "split_name", "=", "deque", "(", "full_name", ".", "split", "(", "'.'", ")", ")", "self", ".", "_remove...
Removes a single node from the tree. Only from RAM not from hdf5 file! :param instance: The node to be deleted :param recursive: If group nodes with children should be deleted
[ "Removes", "a", "single", "node", "from", "the", "tree", "." ]
python
test
33.923077
KrishnaswamyLab/PHATE
Python/phate/vne.py
https://github.com/KrishnaswamyLab/PHATE/blob/346a4597dcfc523f8bef99bce482e677282b6719/Python/phate/vne.py#L11-L49
def compute_von_neumann_entropy(data, t_max=100): """ Determines the Von Neumann entropy of data at varying matrix powers. The user should select a value of t around the "knee" of the entropy curve. Parameters ---------- t_max : int, default: 100 Maximum value of t to test Retu...
[ "def", "compute_von_neumann_entropy", "(", "data", ",", "t_max", "=", "100", ")", ":", "_", ",", "eigenvalues", ",", "_", "=", "svd", "(", "data", ")", "entropy", "=", "[", "]", "eigenvalues_t", "=", "np", ".", "copy", "(", "eigenvalues", ")", "for", ...
Determines the Von Neumann entropy of data at varying matrix powers. The user should select a value of t around the "knee" of the entropy curve. Parameters ---------- t_max : int, default: 100 Maximum value of t to test Returns ------- entropy : array, shape=[t_max] The...
[ "Determines", "the", "Von", "Neumann", "entropy", "of", "data", "at", "varying", "matrix", "powers", ".", "The", "user", "should", "select", "a", "value", "of", "t", "around", "the", "knee", "of", "the", "entropy", "curve", "." ]
python
train
26.230769
bids-standard/pybids
bids/reports/parsing.py
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/parsing.py#L148-L198
def anat_info(suffix, metadata, img, config): """ Generate a paragraph describing T1- and T2-weighted structural scans. Parameters ---------- suffix : :obj:`str` T1 or T2. metadata : :obj:`dict` Data from the json file associated with the scan, in dictionary form. im...
[ "def", "anat_info", "(", "suffix", ",", "metadata", ",", "img", ",", "config", ")", ":", "n_slices", ",", "vs_str", ",", "ms_str", ",", "fov_str", "=", "get_sizestr", "(", "img", ")", "seqs", ",", "variants", "=", "get_seqstr", "(", "config", ",", "met...
Generate a paragraph describing T1- and T2-weighted structural scans. Parameters ---------- suffix : :obj:`str` T1 or T2. metadata : :obj:`dict` Data from the json file associated with the scan, in dictionary form. img : :obj:`nibabel.Nifti1Image` The nifti image of ...
[ "Generate", "a", "paragraph", "describing", "T1", "-", "and", "T2", "-", "weighted", "structural", "scans", "." ]
python
train
33.176471
acutesoftware/virtual-AI-simulator
vais/character.py
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/character.py#L243-L247
def copy(self): """ make an identical copy of the character """ return Character(self.name, self.race,self.ch_class, self.stats, self.skills, self.story, self.inventory)
[ "def", "copy", "(", "self", ")", ":", "return", "Character", "(", "self", ".", "name", ",", "self", ".", "race", ",", "self", ".", "ch_class", ",", "self", ".", "stats", ",", "self", ".", "skills", ",", "self", ".", "story", ",", "self", ".", "in...
make an identical copy of the character
[ "make", "an", "identical", "copy", "of", "the", "character" ]
python
train
39.6
Miserlou/SoundScrape
soundscrape/soundscrape.py
https://github.com/Miserlou/SoundScrape/blob/efc63b99ce7e78b352e2ba22d5e51f83445546d7/soundscrape/soundscrape.py#L127-L297
def process_soundcloud(vargs): """ Main SoundCloud path. """ artist_url = vargs['artist_url'] track_permalink = vargs['track'] keep_previews = vargs['keep'] folders = vargs['folders'] id3_extras = {} one_track = False likes = False client = get_client() if 'soundcloud' ...
[ "def", "process_soundcloud", "(", "vargs", ")", ":", "artist_url", "=", "vargs", "[", "'artist_url'", "]", "track_permalink", "=", "vargs", "[", "'track'", "]", "keep_previews", "=", "vargs", "[", "'keep'", "]", "folders", "=", "vargs", "[", "'folders'", "]"...
Main SoundCloud path.
[ "Main", "SoundCloud", "path", "." ]
python
train
37.292398
tyiannak/pyAudioAnalysis
pyAudioAnalysis/audioFeatureExtraction.py
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L169-L216
def mfccInitFilterBanks(fs, nfft): """ Computes the triangular filterbank for MFCC computation (used in the stFeatureExtraction function before the stMFCC function call) This function is taken from the scikits.talkbox library (MIT Licence): https://pypi.python.org/pypi/scikits.talkbox """ ...
[ "def", "mfccInitFilterBanks", "(", "fs", ",", "nfft", ")", ":", "# filter bank params:", "lowfreq", "=", "133.33", "linsc", "=", "200", "/", "3.", "logsc", "=", "1.0711703", "numLinFiltTotal", "=", "13", "numLogFilt", "=", "27", "if", "fs", "<", "8000", ":...
Computes the triangular filterbank for MFCC computation (used in the stFeatureExtraction function before the stMFCC function call) This function is taken from the scikits.talkbox library (MIT Licence): https://pypi.python.org/pypi/scikits.talkbox
[ "Computes", "the", "triangular", "filterbank", "for", "MFCC", "computation", "(", "used", "in", "the", "stFeatureExtraction", "function", "before", "the", "stMFCC", "function", "call", ")", "This", "function", "is", "taken", "from", "the", "scikits", ".", "talkb...
python
train
36.5
PyGithub/PyGithub
github/MainClass.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/MainClass.py#L629-L639
def get_gitignore_template(self, name): """ :calls: `GET /gitignore/templates/:name <http://developer.github.com/v3/gitignore>`_ :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate` """ assert isinstance(name, (str, unicode)), name headers, attributes = self.__requ...
[ "def", "get_gitignore_template", "(", "self", ",", "name", ")", ":", "assert", "isinstance", "(", "name", ",", "(", "str", ",", "unicode", ")", ")", ",", "name", "headers", ",", "attributes", "=", "self", ".", "__requester", ".", "requestJsonAndCheck", "("...
:calls: `GET /gitignore/templates/:name <http://developer.github.com/v3/gitignore>`_ :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate`
[ ":", "calls", ":", "GET", "/", "gitignore", "/", "templates", "/", ":", "name", "<http", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "gitignore", ">", "_", ":", "rtype", ":", ":", "class", ":", "github", ".", "GitignoreTemplate...
python
train
46.727273
intelsdi-x/snap-plugin-lib-py
snap_plugin/v1/timestamp.py
https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/snap_plugin/v1/timestamp.py#L56-L67
def set(self, time): """Sets time in seconds since Epoch Args: time (:obj:`float`): time in seconds since Epoch (see time.time()) Returns: None """ self._time = time self._pb.sec = int(self._time) self._pb.nsec = int((self._time - self._p...
[ "def", "set", "(", "self", ",", "time", ")", ":", "self", ".", "_time", "=", "time", "self", ".", "_pb", ".", "sec", "=", "int", "(", "self", ".", "_time", ")", "self", ".", "_pb", ".", "nsec", "=", "int", "(", "(", "self", ".", "_time", "-",...
Sets time in seconds since Epoch Args: time (:obj:`float`): time in seconds since Epoch (see time.time()) Returns: None
[ "Sets", "time", "in", "seconds", "since", "Epoch" ]
python
train
27.166667
brunobord/md2ebook
md2ebook/checkers.py
https://github.com/brunobord/md2ebook/blob/31e0d06b77f2d986e6af1115c9e613dfec0591a9/md2ebook/checkers.py#L18-L36
def check_dependencies(): """Check external dependecies Return a tuple with the available generators. """ available = [] try: shell('ebook-convert') available.append('calibre') except OSError: pass try: shell('pandoc --help') available.append('pandoc')...
[ "def", "check_dependencies", "(", ")", ":", "available", "=", "[", "]", "try", ":", "shell", "(", "'ebook-convert'", ")", "available", ".", "append", "(", "'calibre'", ")", "except", "OSError", ":", "pass", "try", ":", "shell", "(", "'pandoc --help'", ")",...
Check external dependecies Return a tuple with the available generators.
[ "Check", "external", "dependecies", "Return", "a", "tuple", "with", "the", "available", "generators", "." ]
python
train
25.421053
ml4ai/delphi
delphi/AnalysisGraph.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/AnalysisGraph.py#L905-L917
def get_subgraph_for_concept_pair( self, source: str, target: str, cutoff: Optional[int] = None ): """ Get subgraph comprised of simple paths between the source and the target. Args: source target cutoff """ paths = nx.all_simple_p...
[ "def", "get_subgraph_for_concept_pair", "(", "self", ",", "source", ":", "str", ",", "target", ":", "str", ",", "cutoff", ":", "Optional", "[", "int", "]", "=", "None", ")", ":", "paths", "=", "nx", ".", "all_simple_paths", "(", "self", ",", "source", ...
Get subgraph comprised of simple paths between the source and the target. Args: source target cutoff
[ "Get", "subgraph", "comprised", "of", "simple", "paths", "between", "the", "source", "and", "the", "target", "." ]
python
train
32.769231
vanheeringen-lab/gimmemotifs
gimmemotifs/denovo.py
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/denovo.py#L395-L466
def best_motif_in_cluster(single_pwm, clus_pwm, clusters, fg_fa, background, stats=None, metrics=("roc_auc", "recall_at_fdr")): """Return the best motif per cluster for a clustering results. The motif can be either the average motif or one of the clustered motifs. Parameters ---------- single_pwm ...
[ "def", "best_motif_in_cluster", "(", "single_pwm", ",", "clus_pwm", ",", "clusters", ",", "fg_fa", ",", "background", ",", "stats", "=", "None", ",", "metrics", "=", "(", "\"roc_auc\"", ",", "\"recall_at_fdr\"", ")", ")", ":", "# combine original and clustered mot...
Return the best motif per cluster for a clustering results. The motif can be either the average motif or one of the clustered motifs. Parameters ---------- single_pwm : str Filename of motifs. clus_pwm : str Filename of motifs. clusters : Motif clustering result. ...
[ "Return", "the", "best", "motif", "per", "cluster", "for", "a", "clustering", "results", "." ]
python
train
30.625
bokeh/bokeh
bokeh/plotting/helpers.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/plotting/helpers.py#L544-L561
def _tool_from_string(name): """ Takes a string and returns a corresponding `Tool` instance. """ known_tools = sorted(_known_tools.keys()) if name in known_tools: tool_fn = _known_tools[name] if isinstance(tool_fn, string_types): tool_fn = _known_tools[tool_fn] return ...
[ "def", "_tool_from_string", "(", "name", ")", ":", "known_tools", "=", "sorted", "(", "_known_tools", ".", "keys", "(", ")", ")", "if", "name", "in", "known_tools", ":", "tool_fn", "=", "_known_tools", "[", "name", "]", "if", "isinstance", "(", "tool_fn", ...
Takes a string and returns a corresponding `Tool` instance.
[ "Takes", "a", "string", "and", "returns", "a", "corresponding", "Tool", "instance", "." ]
python
train
33
subdownloader/subdownloader
subdownloader/provider/SDService.py
https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/provider/SDService.py#L288-L308
def _logout(self): """Logout from current session(token) This functions doesn't return any boolean value, since it can 'fail' for anonymous logins """ self.log.debug("Logging out from session ID: %s" % self._token) try: info = self._xmlrpc_server.LogOut(self._token) ...
[ "def", "_logout", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Logging out from session ID: %s\"", "%", "self", ".", "_token", ")", "try", ":", "info", "=", "self", ".", "_xmlrpc_server", ".", "LogOut", "(", "self", ".", "_token", ")"...
Logout from current session(token) This functions doesn't return any boolean value, since it can 'fail' for anonymous logins
[ "Logout", "from", "current", "session", "(", "token", ")", "This", "functions", "doesn", "t", "return", "any", "boolean", "value", "since", "it", "can", "fail", "for", "anonymous", "logins" ]
python
train
39.809524
hhatto/autopep8
autopep8.py
https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L739-L764
def fix_e251(self, result): """Remove whitespace around parameter '=' sign.""" line_index = result['line'] - 1 target = self.source[line_index] # This is necessary since pycodestyle sometimes reports columns that # goes past the end of the physical line. This happens in cases li...
[ "def", "fix_e251", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "# This is necessary since pycodestyle sometimes reports columns that", "# goes past the...
Remove whitespace around parameter '=' sign.
[ "Remove", "whitespace", "around", "parameter", "=", "sign", "." ]
python
train
36.846154
quantopian/pyfolio
pyfolio/timeseries.py
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/timeseries.py#L843-L867
def calc_distribution_stats(x): """Calculate various summary statistics of data. Parameters ---------- x : numpy.ndarray or pandas.Series Array to compute summary statistics for. Returns ------- pandas.Series Series containing mean, median, std, as well as 5, 25, 75 and ...
[ "def", "calc_distribution_stats", "(", "x", ")", ":", "return", "pd", ".", "Series", "(", "{", "'mean'", ":", "np", ".", "mean", "(", "x", ")", ",", "'median'", ":", "np", ".", "median", "(", "x", ")", ",", "'std'", ":", "np", ".", "std", "(", ...
Calculate various summary statistics of data. Parameters ---------- x : numpy.ndarray or pandas.Series Array to compute summary statistics for. Returns ------- pandas.Series Series containing mean, median, std, as well as 5, 25, 75 and 95 percentiles of passed in values...
[ "Calculate", "various", "summary", "statistics", "of", "data", "." ]
python
valid
32.16
Alignak-monitoring/alignak
alignak/objects/config.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/config.py#L2578-L2596
def show_errors(self): """ Loop over configuration warnings and log them as INFO log Loop over configuration errors and log them as INFO log Note that the warnings and errors are logged on the fly during the configuration parsing. It is not necessary to log as WARNING and ERROR ...
[ "def", "show_errors", "(", "self", ")", ":", "if", "self", ".", "configuration_warnings", ":", "logger", ".", "warning", "(", "\"Configuration warnings:\"", ")", "for", "msg", "in", "self", ".", "configuration_warnings", ":", "logger", ".", "warning", "(", "ms...
Loop over configuration warnings and log them as INFO log Loop over configuration errors and log them as INFO log Note that the warnings and errors are logged on the fly during the configuration parsing. It is not necessary to log as WARNING and ERROR in this function which is used as a sum-up ...
[ "Loop", "over", "configuration", "warnings", "and", "log", "them", "as", "INFO", "log", "Loop", "over", "configuration", "errors", "and", "log", "them", "as", "INFO", "log" ]
python
train
42.894737
six8/corona-cipr
src/cipr/commands/core.py
https://github.com/six8/corona-cipr/blob/a2f45761080c874afa39bf95fd5c4467c8eae272/src/cipr/commands/core.py#L275-L301
def packageipa(env, console): """ Package the built app as an ipa for distribution in iOS App Store """ ipa_path, app_path = _get_ipa(env) output_dir = path.dirname(ipa_path) if path.exists(ipa_path): console.quiet('Removing %s' % ipa_path) os.remove(ipa_path) zf = zipfile....
[ "def", "packageipa", "(", "env", ",", "console", ")", ":", "ipa_path", ",", "app_path", "=", "_get_ipa", "(", "env", ")", "output_dir", "=", "path", ".", "dirname", "(", "ipa_path", ")", "if", "path", ".", "exists", "(", "ipa_path", ")", ":", "console"...
Package the built app as an ipa for distribution in iOS App Store
[ "Package", "the", "built", "app", "as", "an", "ipa", "for", "distribution", "in", "iOS", "App", "Store" ]
python
train
29.851852
Fantomas42/django-blog-zinnia
zinnia/templatetags/zinnia.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/templatetags/zinnia.py#L350-L365
def get_gravatar(email, size=80, rating='g', default=None, protocol=PROTOCOL): """ Return url for a Gravatar. """ gravatar_protocols = {'http': 'http://www', 'https': 'https://secure'} url = '%s.gravatar.com/avatar/%s' % ( gravatar_protocols[protoco...
[ "def", "get_gravatar", "(", "email", ",", "size", "=", "80", ",", "rating", "=", "'g'", ",", "default", "=", "None", ",", "protocol", "=", "PROTOCOL", ")", ":", "gravatar_protocols", "=", "{", "'http'", ":", "'http://www'", ",", "'https'", ":", "'https:/...
Return url for a Gravatar.
[ "Return", "url", "for", "a", "Gravatar", "." ]
python
train
33.875
incf-nidash/nidmresults
nidmresults/objects/inference.py
https://github.com/incf-nidash/nidmresults/blob/438f7cce6abc4a4379b629bd76f4d427891e033f/nidmresults/objects/inference.py#L488-L531
def export(self, version, export_dir): """ Create prov entities and activities. """ atts = [ (PROV['type'], self.type), ] atts += [ (PROV['label'], self.label) ] if self.extent_rsl is not None: atts += [ ...
[ "def", "export", "(", "self", ",", "version", ",", "export_dir", ")", ":", "atts", "=", "[", "(", "PROV", "[", "'type'", "]", ",", "self", ".", "type", ")", ",", "]", "atts", "+=", "[", "(", "PROV", "[", "'label'", "]", ",", "self", ".", "label...
Create prov entities and activities.
[ "Create", "prov", "entities", "and", "activities", "." ]
python
train
27.977273
poppy-project/pypot
pypot/utils/interpolation.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/interpolation.py#L65-L102
def interpolate_motor_positions(self, input_key, nearest_keys): """ Process linear interpolation to estimate actual speed and position of motors Method specific to the :meth:~pypot.primitive.move.Move.position() structure it is a KDTreeDict[timestamp] = {dict[motor]=(position,speed)} ...
[ "def", "interpolate_motor_positions", "(", "self", ",", "input_key", ",", "nearest_keys", ")", ":", "# TODO : to be rewrited with more style (map ?)", "if", "len", "(", "nearest_keys", ")", "==", "1", ":", "return", "self", "[", "nearest_keys", "[", "0", "]", "]",...
Process linear interpolation to estimate actual speed and position of motors Method specific to the :meth:~pypot.primitive.move.Move.position() structure it is a KDTreeDict[timestamp] = {dict[motor]=(position,speed)}
[ "Process", "linear", "interpolation", "to", "estimate", "actual", "speed", "and", "position", "of", "motors", "Method", "specific", "to", "the", ":", "meth", ":", "~pypot", ".", "primitive", ".", "move", ".", "Move", ".", "position", "()", "structure", "it",...
python
train
48.894737
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L91-L130
def analyse(self, name): """ reads the specified file. :param name: the name. :return: the analysis as frequency/Pxx. """ if name in self._cache: target = self._cache[name] if target['type'] == 'wav': signal = self._uploadController...
[ "def", "analyse", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_cache", ":", "target", "=", "self", ".", "_cache", "[", "name", "]", "if", "target", "[", "'type'", "]", "==", "'wav'", ":", "signal", "=", "self", ".", "_up...
reads the specified file. :param name: the name. :return: the analysis as frequency/Pxx.
[ "reads", "the", "specified", "file", ".", ":", "param", "name", ":", "the", "name", ".", ":", "return", ":", "the", "analysis", "as", "frequency", "/", "Pxx", "." ]
python
train
45.275
Parsl/parsl
parsl/executors/extreme_scale/mpi_worker_pool.py
https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/executors/extreme_scale/mpi_worker_pool.py#L125-L136
def recv_task_request_from_workers(self): """ Receives 1 task request from MPI comm Returns: -------- worker_rank: worker_rank id """ info = MPI.Status() comm.recv(source=MPI.ANY_SOURCE, tag=TASK_REQUEST_TAG, status=info) worker_rank = info.Get_source...
[ "def", "recv_task_request_from_workers", "(", "self", ")", ":", "info", "=", "MPI", ".", "Status", "(", ")", "comm", ".", "recv", "(", "source", "=", "MPI", ".", "ANY_SOURCE", ",", "tag", "=", "TASK_REQUEST_TAG", ",", "status", "=", "info", ")", "worker_...
Receives 1 task request from MPI comm Returns: -------- worker_rank: worker_rank id
[ "Receives", "1", "task", "request", "from", "MPI", "comm" ]
python
valid
34.833333
hotdoc/hotdoc
hotdoc/extensions/c/clang/cindex.py
https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/c/clang/cindex.py#L2845-L2856
def get_tokens(self, locations=None, extent=None): """Obtain tokens in this translation unit. This is a generator for Token instances. The caller specifies a range of source code to obtain tokens for. The range can be specified as a 2-tuple of SourceLocation or as a SourceRange. If both...
[ "def", "get_tokens", "(", "self", ",", "locations", "=", "None", ",", "extent", "=", "None", ")", ":", "if", "locations", "is", "not", "None", ":", "extent", "=", "SourceRange", "(", "start", "=", "locations", "[", "0", "]", ",", "end", "=", "locatio...
Obtain tokens in this translation unit. This is a generator for Token instances. The caller specifies a range of source code to obtain tokens for. The range can be specified as a 2-tuple of SourceLocation or as a SourceRange. If both are defined, behavior is undefined.
[ "Obtain", "tokens", "in", "this", "translation", "unit", "." ]
python
train
43.5
philgyford/django-spectator
spectator/reading/templatetags/spectator_reading.py
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/reading/templatetags/spectator_reading.py#L100-L110
def day_publications_card(date): """ Displays Publications that were being read on `date`. `date` is a date tobject. """ d = date.strftime(app_settings.DATE_FORMAT) card_title = 'Reading on {}'.format(d) return { 'card_title': card_title, 'publication_list': day_publi...
[ "def", "day_publications_card", "(", "date", ")", ":", "d", "=", "date", ".", "strftime", "(", "app_settings", ".", "DATE_FORMAT", ")", "card_title", "=", "'Reading on {}'", ".", "format", "(", "d", ")", "return", "{", "'card_title'", ":", "card_title", ",",...
Displays Publications that were being read on `date`. `date` is a date tobject.
[ "Displays", "Publications", "that", "were", "being", "read", "on", "date", ".", "date", "is", "a", "date", "tobject", "." ]
python
train
31.181818
openstack/networking-arista
networking_arista/l3Plugin/l3_arista.py
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L106-L125
def synchronize(self): """Synchronizes Router DB from Neturon DB with EOS. Walks through the Neturon Db and ensures that all the routers created in Netuton DB match with EOS. After creating appropriate routers, it ensures to add interfaces as well. Uses idempotent properties of ...
[ "def", "synchronize", "(", "self", ")", ":", "LOG", ".", "info", "(", "_LI", "(", "'Syncing Neutron Router DB <-> EOS'", ")", ")", "routers", ",", "router_interfaces", "=", "self", ".", "get_routers_and_interfaces", "(", ")", "expected_vrfs", "=", "set", "(", ...
Synchronizes Router DB from Neturon DB with EOS. Walks through the Neturon Db and ensures that all the routers created in Netuton DB match with EOS. After creating appropriate routers, it ensures to add interfaces as well. Uses idempotent properties of EOS configuration, which means ...
[ "Synchronizes", "Router", "DB", "from", "Neturon", "DB", "with", "EOS", "." ]
python
train
47.15
quantopian/zipline
zipline/sources/benchmark_source.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/sources/benchmark_source.py#L196-L312
def _initialize_precalculated_series(self, asset, trading_calendar, trading_days, data_portal): """ Internal method that pre-calculates the ...
[ "def", "_initialize_precalculated_series", "(", "self", ",", "asset", ",", "trading_calendar", ",", "trading_days", ",", "data_portal", ")", ":", "if", "self", ".", "emission_rate", "==", "\"minute\"", ":", "minutes", "=", "trading_calendar", ".", "minutes_for_sessi...
Internal method that pre-calculates the benchmark return series for use in the simulation. Parameters ---------- asset: Asset to use trading_calendar: TradingCalendar trading_days: pd.DateTimeIndex data_portal: DataPortal Notes ----- ...
[ "Internal", "method", "that", "pre", "-", "calculates", "the", "benchmark", "return", "series", "for", "use", "in", "the", "simulation", "." ]
python
train
35.162393
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/attributes_manager.py
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/attributes_manager.py#L165-L182
def persistent_attributes(self): # type: () -> Dict[str, object] """Attributes stored at the Persistence level of the skill lifecycle. :return: persistent_attributes retrieved from persistence adapter :rtype: Dict[str, object] :raises: :py:class:`ask_sdk_core.exceptions.Attribut...
[ "def", "persistent_attributes", "(", "self", ")", ":", "# type: () -> Dict[str, object]", "if", "not", "self", ".", "_persistence_adapter", ":", "raise", "AttributesManagerException", "(", "\"Cannot get PersistentAttributes without Persistence adapter\"", ")", "if", "not", "s...
Attributes stored at the Persistence level of the skill lifecycle. :return: persistent_attributes retrieved from persistence adapter :rtype: Dict[str, object] :raises: :py:class:`ask_sdk_core.exceptions.AttributesManagerException` if trying to get persistent attributes without persi...
[ "Attributes", "stored", "at", "the", "Persistence", "level", "of", "the", "skill", "lifecycle", "." ]
python
train
49.333333
uber-common/opentracing-python-instrumentation
opentracing_instrumentation/client_hooks/_singleton.py
https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/client_hooks/_singleton.py#L30-L55
def singleton(func): """ This decorator allows you to make sure that a function is called once and only once. Note that recursive functions will still work. WARNING: Not thread-safe!!! """ @functools.wraps(func) def wrapper(*args, **kwargs): if wrapper.__call_state__ == CALLED: ...
[ "def", "singleton", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "wrapper", ".", "__call_state__", "==", "CALLED", ":", "return", "ret", "=", "...
This decorator allows you to make sure that a function is called once and only once. Note that recursive functions will still work. WARNING: Not thread-safe!!!
[ "This", "decorator", "allows", "you", "to", "make", "sure", "that", "a", "function", "is", "called", "once", "and", "only", "once", ".", "Note", "that", "recursive", "functions", "will", "still", "work", "." ]
python
train
25.192308
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L606-L615
def find_source_lines(self): """Mark all executable source lines in fn as executed 0 times.""" strs = trace.find_strings(self.filename) lines = trace.find_lines_from_code(self.fn.__code__, strs) self.firstcodelineno = sys.maxint for lineno in lines: self.firstcodeline...
[ "def", "find_source_lines", "(", "self", ")", ":", "strs", "=", "trace", ".", "find_strings", "(", "self", ".", "filename", ")", "lines", "=", "trace", ".", "find_lines_from_code", "(", "self", ".", "fn", ".", "__code__", ",", "strs", ")", "self", ".", ...
Mark all executable source lines in fn as executed 0 times.
[ "Mark", "all", "executable", "source", "lines", "in", "fn", "as", "executed", "0", "times", "." ]
python
train
49.9
cltk/cltk
cltk/utils/matrix_corpus_fun.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/utils/matrix_corpus_fun.py#L375-L387
def distinct_letters(string_matrix: List[List[str]]) -> Set[str]: """ Diagnostic function :param string_matrix: a data matrix: a list wrapping a list of strings, with each sublist being a sentence. :return: >>> dl = distinct_letters([['the', 'quick', 'brown'],['how', 'now', 'cow']]) >>> sorted(d...
[ "def", "distinct_letters", "(", "string_matrix", ":", "List", "[", "List", "[", "str", "]", "]", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "[", "letter", "for", "sentence", "in", "string_matrix", "for", "word", "in", "sentence", "fo...
Diagnostic function :param string_matrix: a data matrix: a list wrapping a list of strings, with each sublist being a sentence. :return: >>> dl = distinct_letters([['the', 'quick', 'brown'],['how', 'now', 'cow']]) >>> sorted(dl) ['b', 'c', 'e', 'h', 'i', 'k', 'n', 'o', 'q', 'r', 't', 'u', 'w']
[ "Diagnostic", "function", ":", "param", "string_matrix", ":", "a", "data", "matrix", ":", "a", "list", "wrapping", "a", "list", "of", "strings", "with", "each", "sublist", "being", "a", "sentence", ".", ":", "return", ":", ">>>", "dl", "=", "distinct_lette...
python
train
40.846154
square/pylink
pylink/jlink.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L3342-L3365
def step(self, thumb=False): """Executes a single step. Steps even if there is a breakpoint. Args: self (JLink): the ``JLink`` instance thumb (bool): boolean indicating if to step in thumb mode Returns: ``None`` Raises: JLinkException: ...
[ "def", "step", "(", "self", ",", "thumb", "=", "False", ")", ":", "method", "=", "self", ".", "_dll", ".", "JLINKARM_Step", "if", "thumb", ":", "method", "=", "self", ".", "_dll", ".", "JLINKARM_StepComposite", "res", "=", "method", "(", ")", "if", "...
Executes a single step. Steps even if there is a breakpoint. Args: self (JLink): the ``JLink`` instance thumb (bool): boolean indicating if to step in thumb mode Returns: ``None`` Raises: JLinkException: on error
[ "Executes", "a", "single", "step", "." ]
python
train
23.833333