Unnamed: 0
int64
0
10k
repository_name
stringlengths
7
54
func_path_in_repository
stringlengths
5
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
100
30.3k
language
stringclasses
1 value
func_code_string
stringlengths
100
30.3k
func_code_tokens
stringlengths
138
33.2k
func_documentation_string
stringlengths
1
15k
func_documentation_tokens
stringlengths
5
5.14k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
9,500
StanfordVL/robosuite
robosuite/utils/transform_utils.py
random_quat
def random_quat(rand=None): """Return uniform random unit quaternion. rand: array like or None Three independent random variables that are uniformly distributed between 0 and 1. >>> q = random_quat() >>> np.allclose(1.0, vector_norm(q)) True >>> q = random_quat(np.random.random(3...
python
def random_quat(rand=None): """Return uniform random unit quaternion. rand: array like or None Three independent random variables that are uniformly distributed between 0 and 1. >>> q = random_quat() >>> np.allclose(1.0, vector_norm(q)) True >>> q = random_quat(np.random.random(3...
['def', 'random_quat', '(', 'rand', '=', 'None', ')', ':', 'if', 'rand', 'is', 'None', ':', 'rand', '=', 'np', '.', 'random', '.', 'rand', '(', '3', ')', 'else', ':', 'assert', 'len', '(', 'rand', ')', '==', '3', 'r1', '=', 'np', '.', 'sqrt', '(', '1.0', '-', 'rand', '[', '0', ']', ')', 'r2', '=', 'np', '.', 'sqrt', '(...
Return uniform random unit quaternion. rand: array like or None Three independent random variables that are uniformly distributed between 0 and 1. >>> q = random_quat() >>> np.allclose(1.0, vector_norm(q)) True >>> q = random_quat(np.random.random(3)) >>> q.shape (4,)
['Return', 'uniform', 'random', 'unit', 'quaternion', '.', 'rand', ':', 'array', 'like', 'or', 'None', 'Three', 'independent', 'random', 'variables', 'that', 'are', 'uniformly', 'distributed', 'between', '0', 'and', '1', '.', '>>>', 'q', '=', 'random_quat', '()', '>>>', 'np', '.', 'allclose', '(', '1', '.', '0', 'vecto...
train
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/utils/transform_utils.py#L147-L171
9,501
saltstack/salt
salt/client/__init__.py
LocalClient.get_cli_event_returns
def get_cli_event_returns( self, jid, minions, timeout=None, tgt='*', tgt_type='glob', verbose=False, progress=False, show_timeout=False, show_jid=False, **kwargs): ''' Get...
python
def get_cli_event_returns( self, jid, minions, timeout=None, tgt='*', tgt_type='glob', verbose=False, progress=False, show_timeout=False, show_jid=False, **kwargs): ''' Get...
['def', 'get_cli_event_returns', '(', 'self', ',', 'jid', ',', 'minions', ',', 'timeout', '=', 'None', ',', 'tgt', '=', "'*'", ',', 'tgt_type', '=', "'glob'", ',', 'verbose', '=', 'False', ',', 'progress', '=', 'False', ',', 'show_timeout', '=', 'False', ',', 'show_jid', '=', 'False', ',', '*', '*', 'kwargs', ')', ':',...
Get the returns for the command line interface via the event system
['Get', 'the', 'returns', 'for', 'the', 'command', 'line', 'interface', 'via', 'the', 'event', 'system']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/__init__.py#L1514-L1594
9,502
michael-lazar/rtv
rtv/page.py
Page.prompt_and_select_link
def prompt_and_select_link(self): """ Prompt the user to select a link from a list to open. Return the link that was selected, or ``None`` if no link was selected. """ data = self.get_selected_item() url_full = data.get('url_full') permalink = data.get('permalink...
python
def prompt_and_select_link(self): """ Prompt the user to select a link from a list to open. Return the link that was selected, or ``None`` if no link was selected. """ data = self.get_selected_item() url_full = data.get('url_full') permalink = data.get('permalink...
['def', 'prompt_and_select_link', '(', 'self', ')', ':', 'data', '=', 'self', '.', 'get_selected_item', '(', ')', 'url_full', '=', 'data', '.', 'get', '(', "'url_full'", ')', 'permalink', '=', 'data', '.', 'get', '(', "'permalink'", ')', 'if', 'url_full', 'and', 'url_full', '!=', 'permalink', ':', "# The item is a link...
Prompt the user to select a link from a list to open. Return the link that was selected, or ``None`` if no link was selected.
['Prompt', 'the', 'user', 'to', 'select', 'a', 'link', 'from', 'a', 'list', 'to', 'open', '.']
train
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/page.py#L481-L512
9,503
JensAstrup/pyOutlook
pyOutlook/internal/utils.py
check_response
def check_response(response): """ Checks that a response is successful, raising the appropriate Exceptions otherwise. """ status_code = response.status_code if 100 < status_code < 299: return True elif status_code == 401 or status_code == 403: message = get_response_data(response) ...
python
def check_response(response): """ Checks that a response is successful, raising the appropriate Exceptions otherwise. """ status_code = response.status_code if 100 < status_code < 299: return True elif status_code == 401 or status_code == 403: message = get_response_data(response) ...
['def', 'check_response', '(', 'response', ')', ':', 'status_code', '=', 'response', '.', 'status_code', 'if', '100', '<', 'status_code', '<', '299', ':', 'return', 'True', 'elif', 'status_code', '==', '401', 'or', 'status_code', '==', '403', ':', 'message', '=', 'get_response_data', '(', 'response', ')', 'raise', 'Aut...
Checks that a response is successful, raising the appropriate Exceptions otherwise.
['Checks', 'that', 'a', 'response', 'is', 'successful', 'raising', 'the', 'appropriate', 'Exceptions', 'otherwise', '.']
train
https://github.com/JensAstrup/pyOutlook/blob/f4ca9d4a8629c0a41f78102ce84fab702a841167/pyOutlook/internal/utils.py#L30-L48
9,504
ioos/cc-plugin-ncei
cc_plugin_ncei/util.py
get_z_variable
def get_z_variable(nc): ''' Returns the name of the variable that defines the Z axis or height/depth :param netCDF4.Dataset nc: netCDF dataset ''' axis_z = nc.get_variables_by_attributes(axis='Z') if axis_z: return axis_z[0].name valid_standard_names = ('depth', 'height', 'altitude'...
python
def get_z_variable(nc): ''' Returns the name of the variable that defines the Z axis or height/depth :param netCDF4.Dataset nc: netCDF dataset ''' axis_z = nc.get_variables_by_attributes(axis='Z') if axis_z: return axis_z[0].name valid_standard_names = ('depth', 'height', 'altitude'...
['def', 'get_z_variable', '(', 'nc', ')', ':', 'axis_z', '=', 'nc', '.', 'get_variables_by_attributes', '(', 'axis', '=', "'Z'", ')', 'if', 'axis_z', ':', 'return', 'axis_z', '[', '0', ']', '.', 'name', 'valid_standard_names', '=', '(', "'depth'", ',', "'height'", ',', "'altitude'", ')', 'z', '=', 'nc', '.', 'get_varia...
Returns the name of the variable that defines the Z axis or height/depth :param netCDF4.Dataset nc: netCDF dataset
['Returns', 'the', 'name', 'of', 'the', 'variable', 'that', 'defines', 'the', 'Z', 'axis', 'or', 'height', '/', 'depth']
train
https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/util.py#L95-L108
9,505
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.setGroups
def setGroups(self, groups, kerningGroupConversionRenameMaps=None): """ Copy the groups into our font. """ skipping = [] for name, members in groups.items(): checked = [] for m in members: if m in self.font: checked.append(m) ...
python
def setGroups(self, groups, kerningGroupConversionRenameMaps=None): """ Copy the groups into our font. """ skipping = [] for name, members in groups.items(): checked = [] for m in members: if m in self.font: checked.append(m) ...
['def', 'setGroups', '(', 'self', ',', 'groups', ',', 'kerningGroupConversionRenameMaps', '=', 'None', ')', ':', 'skipping', '=', '[', ']', 'for', 'name', ',', 'members', 'in', 'groups', '.', 'items', '(', ')', ':', 'checked', '=', '[', ']', 'for', 'm', 'in', 'members', ':', 'if', 'm', 'in', 'self', '.', 'font', ':', '...
Copy the groups into our font.
['Copy', 'the', 'groups', 'into', 'our', 'font', '.']
train
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L80-L100
9,506
rsmuc/health_monitoring_plugins
health_monitoring_plugins/check_snmp_eaton_ups/check_snmp_eaton_ups.py
check_ups_output_current
def check_ups_output_current(the_session, the_helper, the_snmp_value): """ OID .1.3.6.1.2.1.33.1.4.4.1.3.1 MIB excerpt The present output current. """ a_current = calc_output_current_from_snmpvalue(the_snmp_value) the_helper.add_metric( label=the_helper.options.type, val...
python
def check_ups_output_current(the_session, the_helper, the_snmp_value): """ OID .1.3.6.1.2.1.33.1.4.4.1.3.1 MIB excerpt The present output current. """ a_current = calc_output_current_from_snmpvalue(the_snmp_value) the_helper.add_metric( label=the_helper.options.type, val...
['def', 'check_ups_output_current', '(', 'the_session', ',', 'the_helper', ',', 'the_snmp_value', ')', ':', 'a_current', '=', 'calc_output_current_from_snmpvalue', '(', 'the_snmp_value', ')', 'the_helper', '.', 'add_metric', '(', 'label', '=', 'the_helper', '.', 'options', '.', 'type', ',', 'value', '=', 'a_current', '...
OID .1.3.6.1.2.1.33.1.4.4.1.3.1 MIB excerpt The present output current.
['OID', '.', '1', '.', '3', '.', '6', '.', '1', '.', '2', '.', '1', '.', '33', '.', '1', '.', '4', '.', '4', '.', '1', '.', '3', '.', '1', 'MIB', 'excerpt', 'The', 'present', 'output', 'current', '.']
train
https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/check_snmp_eaton_ups/check_snmp_eaton_ups.py#L121-L134
9,507
pytroll/satpy
satpy/readers/grib.py
GRIBFileHandler.get_dataset
def get_dataset(self, dataset_id, ds_info): """Read a GRIB message into an xarray DataArray.""" msg = self._get_message(ds_info) ds_info = self.get_metadata(msg, ds_info) fill = msg['missingValue'] data = msg.values.astype(np.float32) if msg.valid_key('jScansPositively') ...
python
def get_dataset(self, dataset_id, ds_info): """Read a GRIB message into an xarray DataArray.""" msg = self._get_message(ds_info) ds_info = self.get_metadata(msg, ds_info) fill = msg['missingValue'] data = msg.values.astype(np.float32) if msg.valid_key('jScansPositively') ...
['def', 'get_dataset', '(', 'self', ',', 'dataset_id', ',', 'ds_info', ')', ':', 'msg', '=', 'self', '.', '_get_message', '(', 'ds_info', ')', 'ds_info', '=', 'self', '.', 'get_metadata', '(', 'msg', ',', 'ds_info', ')', 'fill', '=', 'msg', '[', "'missingValue'", ']', 'data', '=', 'msg', '.', 'values', '.', 'astype', '...
Read a GRIB message into an xarray DataArray.
['Read', 'a', 'GRIB', 'message', 'into', 'an', 'xarray', 'DataArray', '.']
train
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/grib.py#L250-L266
9,508
rmax/scrapy-redis
src/scrapy_redis/spiders.py
RedisMixin.schedule_next_requests
def schedule_next_requests(self): """Schedules a request if available""" # TODO: While there is capacity, schedule a batch of redis requests. for req in self.next_requests(): self.crawler.engine.crawl(req, spider=self)
python
def schedule_next_requests(self): """Schedules a request if available""" # TODO: While there is capacity, schedule a batch of redis requests. for req in self.next_requests(): self.crawler.engine.crawl(req, spider=self)
['def', 'schedule_next_requests', '(', 'self', ')', ':', '# TODO: While there is capacity, schedule a batch of redis requests.', 'for', 'req', 'in', 'self', '.', 'next_requests', '(', ')', ':', 'self', '.', 'crawler', '.', 'engine', '.', 'crawl', '(', 'req', ',', 'spider', '=', 'self', ')']
Schedules a request if available
['Schedules', 'a', 'request', 'if', 'available']
train
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/spiders.py#L112-L116
9,509
beerfactory/hbmqtt
hbmqtt/adapters.py
WebSocketsWriter.drain
def drain(self): """ Let the write buffer of the underlying transport a chance to be flushed. """ data = self._stream.getvalue() if len(data): yield from self._protocol.send(data) self._stream = io.BytesIO(b'')
python
def drain(self): """ Let the write buffer of the underlying transport a chance to be flushed. """ data = self._stream.getvalue() if len(data): yield from self._protocol.send(data) self._stream = io.BytesIO(b'')
['def', 'drain', '(', 'self', ')', ':', 'data', '=', 'self', '.', '_stream', '.', 'getvalue', '(', ')', 'if', 'len', '(', 'data', ')', ':', 'yield', 'from', 'self', '.', '_protocol', '.', 'send', '(', 'data', ')', 'self', '.', '_stream', '=', 'io', '.', 'BytesIO', '(', "b''", ')']
Let the write buffer of the underlying transport a chance to be flushed.
['Let', 'the', 'write', 'buffer', 'of', 'the', 'underlying', 'transport', 'a', 'chance', 'to', 'be', 'flushed', '.']
train
https://github.com/beerfactory/hbmqtt/blob/4aa6fe982141abc3c54e9f4d7b981ab3eba0a13c/hbmqtt/adapters.py#L114-L121
9,510
manns/pyspread
pyspread/src/actions/_grid_actions.py
SelectionActions.delete
def delete(self): """Deletes a selection if any else deletes the cursor cell Refreshes grid after deletion """ if self.grid.IsSelection(): # Delete selection self.grid.actions.delete_selection() else: # Delete cell at cursor cur...
python
def delete(self): """Deletes a selection if any else deletes the cursor cell Refreshes grid after deletion """ if self.grid.IsSelection(): # Delete selection self.grid.actions.delete_selection() else: # Delete cell at cursor cur...
['def', 'delete', '(', 'self', ')', ':', 'if', 'self', '.', 'grid', '.', 'IsSelection', '(', ')', ':', '# Delete selection', 'self', '.', 'grid', '.', 'actions', '.', 'delete_selection', '(', ')', 'else', ':', '# Delete cell at cursor', 'cursor', '=', 'self', '.', 'grid', '.', 'actions', '.', 'cursor', 'self', '.', 'gr...
Deletes a selection if any else deletes the cursor cell Refreshes grid after deletion
['Deletes', 'a', 'selection', 'if', 'any', 'else', 'deletes', 'the', 'cursor', 'cell']
train
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1553-L1570
9,511
osrg/ryu
ryu/lib/ofctl_string.py
ofp_instruction_from_str
def ofp_instruction_from_str(ofproto, action_str): """ Parse an ovs-ofctl style action string and return a list of jsondict representations of OFPInstructionActions, which can then be passed to ofproto_parser.ofp_instruction_from_jsondict. Please note that this is for making transition from ovs-ofc...
python
def ofp_instruction_from_str(ofproto, action_str): """ Parse an ovs-ofctl style action string and return a list of jsondict representations of OFPInstructionActions, which can then be passed to ofproto_parser.ofp_instruction_from_jsondict. Please note that this is for making transition from ovs-ofc...
['def', 'ofp_instruction_from_str', '(', 'ofproto', ',', 'action_str', ')', ':', 'action_re', '=', 're', '.', 'compile', '(', 'r"([a-z_]+)(\\([^)]*\\)|[^a-z_,()][^,()]*)*"', ')', 'result', '=', '[', ']', 'while', 'len', '(', 'action_str', ')', ':', 'm', '=', 'action_re', '.', 'match', '(', 'action_str', ')', 'if', 'not...
Parse an ovs-ofctl style action string and return a list of jsondict representations of OFPInstructionActions, which can then be passed to ofproto_parser.ofp_instruction_from_jsondict. Please note that this is for making transition from ovs-ofctl easier. Please consider using OFPAction constructors whe...
['Parse', 'an', 'ovs', '-', 'ofctl', 'style', 'action', 'string', 'and', 'return', 'a', 'list', 'of', 'jsondict', 'representations', 'of', 'OFPInstructionActions', 'which', 'can', 'then', 'be', 'passed', 'to', 'ofproto_parser', '.', 'ofp_instruction_from_jsondict', '.']
train
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/ofctl_string.py#L23-L73
9,512
numan/py-analytics
analytics/backends/redis.py
Redis._get_closest_week
def _get_closest_week(self, metric_date): """ Gets the closest monday to the date provided. """ #find the offset to the closest monday days_after_monday = metric_date.isoweekday() - 1 return metric_date - datetime.timedelta(days=days_after_monday)
python
def _get_closest_week(self, metric_date): """ Gets the closest monday to the date provided. """ #find the offset to the closest monday days_after_monday = metric_date.isoweekday() - 1 return metric_date - datetime.timedelta(days=days_after_monday)
['def', '_get_closest_week', '(', 'self', ',', 'metric_date', ')', ':', '#find the offset to the closest monday', 'days_after_monday', '=', 'metric_date', '.', 'isoweekday', '(', ')', '-', '1', 'return', 'metric_date', '-', 'datetime', '.', 'timedelta', '(', 'days', '=', 'days_after_monday', ')']
Gets the closest monday to the date provided.
['Gets', 'the', 'closest', 'monday', 'to', 'the', 'date', 'provided', '.']
train
https://github.com/numan/py-analytics/blob/abbc814925c6cc200b3329c7de9f1868e1cb8c01/analytics/backends/redis.py#L58-L65
9,513
MostAwesomeDude/gentleman
gentleman/base.py
AddNodeTags
def AddNodeTags(r, node, tags, dry_run=False): """ Adds tags to a node. @type node: str @param node: node to add tags to @type tags: list of str @param tags: tags to add to the node @type dry_run: bool @param dry_run: whether to perform a dry run @rtype: int @return: job id ...
python
def AddNodeTags(r, node, tags, dry_run=False): """ Adds tags to a node. @type node: str @param node: node to add tags to @type tags: list of str @param tags: tags to add to the node @type dry_run: bool @param dry_run: whether to perform a dry run @rtype: int @return: job id ...
['def', 'AddNodeTags', '(', 'r', ',', 'node', ',', 'tags', ',', 'dry_run', '=', 'False', ')', ':', 'query', '=', '{', '"tag"', ':', 'tags', ',', '"dry-run"', ':', 'dry_run', ',', '}', 'return', 'r', '.', 'request', '(', '"put"', ',', '"/2/nodes/%s/tags"', '%', 'node', ',', 'query', '=', 'query', ',', 'content', '=', 't...
Adds tags to a node. @type node: str @param node: node to add tags to @type tags: list of str @param tags: tags to add to the node @type dry_run: bool @param dry_run: whether to perform a dry run @rtype: int @return: job id
['Adds', 'tags', 'to', 'a', 'node', '.']
train
https://github.com/MostAwesomeDude/gentleman/blob/17fb8ffb922aa4af9d8bcab85e452c9311d41805/gentleman/base.py#L1114-L1135
9,514
secdev/scapy
scapy/automaton.py
SelectableSelector._exit_door
def _exit_door(self, _input): """This function is passed to each SelectableObject as a callback The SelectableObjects have to call it once there are ready""" self.results.append(_input) if self._ended: return self._ended = True self._release_all()
python
def _exit_door(self, _input): """This function is passed to each SelectableObject as a callback The SelectableObjects have to call it once there are ready""" self.results.append(_input) if self._ended: return self._ended = True self._release_all()
['def', '_exit_door', '(', 'self', ',', '_input', ')', ':', 'self', '.', 'results', '.', 'append', '(', '_input', ')', 'if', 'self', '.', '_ended', ':', 'return', 'self', '.', '_ended', '=', 'True', 'self', '.', '_release_all', '(', ')']
This function is passed to each SelectableObject as a callback The SelectableObjects have to call it once there are ready
['This', 'function', 'is', 'passed', 'to', 'each', 'SelectableObject', 'as', 'a', 'callback', 'The', 'SelectableObjects', 'have', 'to', 'call', 'it', 'once', 'there', 'are', 'ready']
train
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L136-L143
9,515
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.parse
def parse(self, filePath, skipLines=0, separator = ',', stringSeparator = '"', lineSeparator = '\n') : """Loads a CSV file""" self.filename = filePath f = open(filePath) if lineSeparator == '\n' : lines = f.readlines() else : lines = f.read().split(lineSeparator) f.flush() f.close() lines = ...
python
def parse(self, filePath, skipLines=0, separator = ',', stringSeparator = '"', lineSeparator = '\n') : """Loads a CSV file""" self.filename = filePath f = open(filePath) if lineSeparator == '\n' : lines = f.readlines() else : lines = f.read().split(lineSeparator) f.flush() f.close() lines = ...
['def', 'parse', '(', 'self', ',', 'filePath', ',', 'skipLines', '=', '0', ',', 'separator', '=', "','", ',', 'stringSeparator', '=', '\'"\'', ',', 'lineSeparator', '=', "'\\n'", ')', ':', 'self', '.', 'filename', '=', 'filePath', 'f', '=', 'open', '(', 'filePath', ')', 'if', 'lineSeparator', '==', "'\\n'", ':', 'lines...
Loads a CSV file
['Loads', 'a', 'CSV', 'file']
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L231-L266
9,516
theonion/django-bulbs
bulbs/content/models.py
Content.first_image
def first_image(self): """Ready-only attribute that provides the value of the first non-none image that's not the thumbnail override field. """ # loop through image fields and grab the first non-none one for model_field in self._meta.fields: if isinstance(model_field,...
python
def first_image(self): """Ready-only attribute that provides the value of the first non-none image that's not the thumbnail override field. """ # loop through image fields and grab the first non-none one for model_field in self._meta.fields: if isinstance(model_field,...
['def', 'first_image', '(', 'self', ')', ':', '# loop through image fields and grab the first non-none one', 'for', 'model_field', 'in', 'self', '.', '_meta', '.', 'fields', ':', 'if', 'isinstance', '(', 'model_field', ',', 'ImageField', ')', ':', 'if', 'model_field', '.', 'name', 'is', 'not', "'thumbnail_override'", '...
Ready-only attribute that provides the value of the first non-none image that's not the thumbnail override field.
['Ready', '-', 'only', 'attribute', 'that', 'provides', 'the', 'value', 'of', 'the', 'first', 'non', '-', 'none', 'image', 'that', 's', 'not', 'the', 'thumbnail', 'override', 'field', '.']
train
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/content/models.py#L278-L291
9,517
spyder-ide/spyder
spyder/preferences/shortcuts.py
ShortcutsConfigPage.reset_to_default
def reset_to_default(self): """Reset to default values of the shortcuts making a confirmation.""" reset = QMessageBox.warning(self, _("Shortcuts reset"), _("Do you want to reset " "to default values?"), ...
python
def reset_to_default(self): """Reset to default values of the shortcuts making a confirmation.""" reset = QMessageBox.warning(self, _("Shortcuts reset"), _("Do you want to reset " "to default values?"), ...
['def', 'reset_to_default', '(', 'self', ')', ':', 'reset', '=', 'QMessageBox', '.', 'warning', '(', 'self', ',', '_', '(', '"Shortcuts reset"', ')', ',', '_', '(', '"Do you want to reset "', '"to default values?"', ')', ',', 'QMessageBox', '.', 'Yes', '|', 'QMessageBox', '.', 'No', ')', 'if', 'reset', '==', 'QMessageB...
Reset to default values of the shortcuts making a confirmation.
['Reset', 'to', 'default', 'values', 'of', 'the', 'shortcuts', 'making', 'a', 'confirmation', '.']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/shortcuts.py#L895-L907
9,518
ProjetPP/PPP-Core
ppp_core/config.py
Module.should_send
def should_send(self, request): """Returns whether or not the request should be sent to the modules, based on the filters.""" if self.filters.get('whitelist', None): return request.tree.type in self.filters['whitelist'] elif self.filters.get('blacklist', None): re...
python
def should_send(self, request): """Returns whether or not the request should be sent to the modules, based on the filters.""" if self.filters.get('whitelist', None): return request.tree.type in self.filters['whitelist'] elif self.filters.get('blacklist', None): re...
['def', 'should_send', '(', 'self', ',', 'request', ')', ':', 'if', 'self', '.', 'filters', '.', 'get', '(', "'whitelist'", ',', 'None', ')', ':', 'return', 'request', '.', 'tree', '.', 'type', 'in', 'self', '.', 'filters', '[', "'whitelist'", ']', 'elif', 'self', '.', 'filters', '.', 'get', '(', "'blacklist'", ',', 'N...
Returns whether or not the request should be sent to the modules, based on the filters.
['Returns', 'whether', 'or', 'not', 'the', 'request', 'should', 'be', 'sent', 'to', 'the', 'modules', 'based', 'on', 'the', 'filters', '.']
train
https://github.com/ProjetPP/PPP-Core/blob/49ee5b16325aa7134e2e423cf75e7b2609df96a0/ppp_core/config.py#L28-L36
9,519
HewlettPackard/python-hpOneView
hpOneView/oneview_client.py
OneViewClient.storage_volume_attachments
def storage_volume_attachments(self): """ Gets the StorageVolumeAttachments API client. Returns: StorageVolumeAttachments: """ if not self.__storage_volume_attachments: self.__storage_volume_attachments = StorageVolumeAttachments(self.__connection) ...
python
def storage_volume_attachments(self): """ Gets the StorageVolumeAttachments API client. Returns: StorageVolumeAttachments: """ if not self.__storage_volume_attachments: self.__storage_volume_attachments = StorageVolumeAttachments(self.__connection) ...
['def', 'storage_volume_attachments', '(', 'self', ')', ':', 'if', 'not', 'self', '.', '__storage_volume_attachments', ':', 'self', '.', '__storage_volume_attachments', '=', 'StorageVolumeAttachments', '(', 'self', '.', '__connection', ')', 'return', 'self', '.', '__storage_volume_attachments']
Gets the StorageVolumeAttachments API client. Returns: StorageVolumeAttachments:
['Gets', 'the', 'StorageVolumeAttachments', 'API', 'client', '.']
train
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L869-L878
9,520
mk-fg/graphite-metrics
graphite_metrics/collectors/cron_log.py
file_follow_durable
def file_follow_durable( path, min_dump_interval=10, xattr_name='user.collectd.logtail.pos', xattr_update=True, **follow_kwz ): '''Records log position into xattrs after reading line every min_dump_interval seconds. Checksum of the last line at the position is also recorded (so line itself don't have to ...
python
def file_follow_durable( path, min_dump_interval=10, xattr_name='user.collectd.logtail.pos', xattr_update=True, **follow_kwz ): '''Records log position into xattrs after reading line every min_dump_interval seconds. Checksum of the last line at the position is also recorded (so line itself don't have to ...
['def', 'file_follow_durable', '(', 'path', ',', 'min_dump_interval', '=', '10', ',', 'xattr_name', '=', "'user.collectd.logtail.pos'", ',', 'xattr_update', '=', 'True', ',', '*', '*', 'follow_kwz', ')', ':', 'from', 'xattr', 'import', 'xattr', 'from', 'io', 'import', 'open', 'from', 'hashlib', 'import', 'sha1', 'from'...
Records log position into xattrs after reading line every min_dump_interval seconds. Checksum of the last line at the position is also recorded (so line itself don't have to fit into xattr) to make sure file wasn't truncated between last xattr dump and re-open.
['Records', 'log', 'position', 'into', 'xattrs', 'after', 'reading', 'line', 'every', 'min_dump_interval', 'seconds', '.', 'Checksum', 'of', 'the', 'last', 'line', 'at', 'the', 'position', 'is', 'also', 'recorded', '(', 'so', 'line', 'itself', 'don', 't', 'have', 'to', 'fit', 'into', 'xattr', ')', 'to', 'make', 'sure',...
train
https://github.com/mk-fg/graphite-metrics/blob/f0ba28d1ed000b2316d3c403206eba78dd7b4c50/graphite_metrics/collectors/cron_log.py#L78-L135
9,521
secdev/scapy
scapy/layers/tls/record_tls13.py
TLS13._tls_auth_decrypt
def _tls_auth_decrypt(self, s): """ Provided with the record header and AEAD-ciphered data, return the sliced and clear tuple (TLSInnerPlaintext, tag). Note that we still return the slicing of the original input in case of decryption failure. Also, if the integrity check fails, a...
python
def _tls_auth_decrypt(self, s): """ Provided with the record header and AEAD-ciphered data, return the sliced and clear tuple (TLSInnerPlaintext, tag). Note that we still return the slicing of the original input in case of decryption failure. Also, if the integrity check fails, a...
['def', '_tls_auth_decrypt', '(', 'self', ',', 's', ')', ':', 'rcs', '=', 'self', '.', 'tls_session', '.', 'rcs', 'read_seq_num', '=', 'struct', '.', 'pack', '(', '"!Q"', ',', 'rcs', '.', 'seq_num', ')', 'rcs', '.', 'seq_num', '+=', '1', 'try', ':', 'return', 'rcs', '.', 'cipher', '.', 'auth_decrypt', '(', 'b""', ',', ...
Provided with the record header and AEAD-ciphered data, return the sliced and clear tuple (TLSInnerPlaintext, tag). Note that we still return the slicing of the original input in case of decryption failure. Also, if the integrity check fails, a warning will be issued, but we still return...
['Provided', 'with', 'the', 'record', 'header', 'and', 'AEAD', '-', 'ciphered', 'data', 'return', 'the', 'sliced', 'and', 'clear', 'tuple', '(', 'TLSInnerPlaintext', 'tag', ')', '.', 'Note', 'that', 'we', 'still', 'return', 'the', 'slicing', 'of', 'the', 'original', 'input', 'in', 'case', 'of', 'decryption', 'failure',...
train
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record_tls13.py#L104-L122
9,522
gamechanger/schemer
schemer/validators.py
gte
def gte(min_value): """ Validates that a field value is greater than or equal to the value given to this validator. """ def validate(value): if value < min_value: return e("{} is not greater than or equal to {}", value, min_value) return validate
python
def gte(min_value): """ Validates that a field value is greater than or equal to the value given to this validator. """ def validate(value): if value < min_value: return e("{} is not greater than or equal to {}", value, min_value) return validate
['def', 'gte', '(', 'min_value', ')', ':', 'def', 'validate', '(', 'value', ')', ':', 'if', 'value', '<', 'min_value', ':', 'return', 'e', '(', '"{} is not greater than or equal to {}"', ',', 'value', ',', 'min_value', ')', 'return', 'validate']
Validates that a field value is greater than or equal to the value given to this validator.
['Validates', 'that', 'a', 'field', 'value', 'is', 'greater', 'than', 'or', 'equal', 'to', 'the', 'value', 'given', 'to', 'this', 'validator', '.']
train
https://github.com/gamechanger/schemer/blob/1d1dd7da433d3b84ce5a80ded5a84ab4a65825ee/schemer/validators.py#L24-L32
9,523
iskandr/fancyimpute
fancyimpute/dictionary_helpers.py
nested_key_indices
def nested_key_indices(nested_dict): """ Give an ordering to the outer and inner keys used in a dictionary that maps to dictionaries. """ outer_keys, inner_keys = collect_nested_keys(nested_dict) outer_key_indices = {k: i for (i, k) in enumerate(outer_keys)} inner_key_indices = {k: i for (i,...
python
def nested_key_indices(nested_dict): """ Give an ordering to the outer and inner keys used in a dictionary that maps to dictionaries. """ outer_keys, inner_keys = collect_nested_keys(nested_dict) outer_key_indices = {k: i for (i, k) in enumerate(outer_keys)} inner_key_indices = {k: i for (i,...
['def', 'nested_key_indices', '(', 'nested_dict', ')', ':', 'outer_keys', ',', 'inner_keys', '=', 'collect_nested_keys', '(', 'nested_dict', ')', 'outer_key_indices', '=', '{', 'k', ':', 'i', 'for', '(', 'i', ',', 'k', ')', 'in', 'enumerate', '(', 'outer_keys', ')', '}', 'inner_key_indices', '=', '{', 'k', ':', 'i', 'f...
Give an ordering to the outer and inner keys used in a dictionary that maps to dictionaries.
['Give', 'an', 'ordering', 'to', 'the', 'outer', 'and', 'inner', 'keys', 'used', 'in', 'a', 'dictionary', 'that', 'maps', 'to', 'dictionaries', '.']
train
https://github.com/iskandr/fancyimpute/blob/9f0837d387c7303d5c8c925a9989ca77a1a96e3e/fancyimpute/dictionary_helpers.py#L39-L47
9,524
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.read_PIA0_A_control
def read_PIA0_A_control(self, cpu_cycles, op_address, address): """ read from 0xff01 -> PIA 0 A side control register """ value = 0xb3 log.error( "%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\t|%s", op_address, address, value, byte2bi...
python
def read_PIA0_A_control(self, cpu_cycles, op_address, address): """ read from 0xff01 -> PIA 0 A side control register """ value = 0xb3 log.error( "%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\t|%s", op_address, address, value, byte2bi...
['def', 'read_PIA0_A_control', '(', 'self', ',', 'cpu_cycles', ',', 'op_address', ',', 'address', ')', ':', 'value', '=', '0xb3', 'log', '.', 'error', '(', '"%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\\t|%s"', ',', 'op_address', ',', 'address', ',', 'value', ',', 'byte2bit_string', '(', 'value',...
read from 0xff01 -> PIA 0 A side control register
['read', 'from', '0xff01', '-', '>', 'PIA', '0', 'A', 'side', 'control', 'register']
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L309-L319
9,525
ev3dev/ev3dev-lang-python
ev3dev2/motor.py
Motor.driver_name
def driver_name(self): """ Returns the name of the driver that provides this tacho motor device. """ (self._driver_name, value) = self.get_cached_attr_string(self._driver_name, 'driver_name') return value
python
def driver_name(self): """ Returns the name of the driver that provides this tacho motor device. """ (self._driver_name, value) = self.get_cached_attr_string(self._driver_name, 'driver_name') return value
['def', 'driver_name', '(', 'self', ')', ':', '(', 'self', '.', '_driver_name', ',', 'value', ')', '=', 'self', '.', 'get_cached_attr_string', '(', 'self', '.', '_driver_name', ',', "'driver_name'", ')', 'return', 'value']
Returns the name of the driver that provides this tacho motor device.
['Returns', 'the', 'name', 'of', 'the', 'driver', 'that', 'provides', 'this', 'tacho', 'motor', 'device', '.']
train
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L469-L474
9,526
bitesofcode/projexui
projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py
XMenuTemplateWidget.renameMenu
def renameMenu( self ): """ Prompts the user to supply a new name for the menu. """ item = self.uiMenuTREE.currentItem() name, accepted = QInputDialog.getText( self, 'Rename Menu', ...
python
def renameMenu( self ): """ Prompts the user to supply a new name for the menu. """ item = self.uiMenuTREE.currentItem() name, accepted = QInputDialog.getText( self, 'Rename Menu', ...
['def', 'renameMenu', '(', 'self', ')', ':', 'item', '=', 'self', '.', 'uiMenuTREE', '.', 'currentItem', '(', ')', 'name', ',', 'accepted', '=', 'QInputDialog', '.', 'getText', '(', 'self', ',', "'Rename Menu'", ',', "'Name:'", ',', 'QLineEdit', '.', 'Normal', ',', 'item', '.', 'text', '(', '0', ')', ')', 'if', '(', 'a...
Prompts the user to supply a new name for the menu.
['Prompts', 'the', 'user', 'to', 'supply', 'a', 'new', 'name', 'for', 'the', 'menu', '.']
train
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py#L271-L283
9,527
secdev/scapy
scapy/contrib/pnio_rpc.py
IODWriteReq.get_response
def get_response(self): """Generate the response block of this request. Careful: it only sets the fields which can be set from the request """ res = IODWriteRes() for field in ["seqNum", "ARUUID", "API", "slotNumber", "subslotNumber", "index"]: r...
python
def get_response(self): """Generate the response block of this request. Careful: it only sets the fields which can be set from the request """ res = IODWriteRes() for field in ["seqNum", "ARUUID", "API", "slotNumber", "subslotNumber", "index"]: r...
['def', 'get_response', '(', 'self', ')', ':', 'res', '=', 'IODWriteRes', '(', ')', 'for', 'field', 'in', '[', '"seqNum"', ',', '"ARUUID"', ',', '"API"', ',', '"slotNumber"', ',', '"subslotNumber"', ',', '"index"', ']', ':', 'res', '.', 'setfieldval', '(', 'field', ',', 'self', '.', 'getfieldval', '(', 'field', ')', ')...
Generate the response block of this request. Careful: it only sets the fields which can be set from the request
['Generate', 'the', 'response', 'block', 'of', 'this', 'request', '.', 'Careful', ':', 'it', 'only', 'sets', 'the', 'fields', 'which', 'can', 'be', 'set', 'from', 'the', 'request']
train
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio_rpc.py#L445-L453
9,528
zeromake/aiko
aiko/response.py
Response.handel_default
def handel_default(self) -> None: """ 处理设置到body上的数据默认 headers """ raw_body = self._body body = cast(Optional[bytes], None) default_type = 2 charset = self._charset or self._default_charset if raw_body is None: pass elif isinstance(raw_b...
python
def handel_default(self) -> None: """ 处理设置到body上的数据默认 headers """ raw_body = self._body body = cast(Optional[bytes], None) default_type = 2 charset = self._charset or self._default_charset if raw_body is None: pass elif isinstance(raw_b...
['def', 'handel_default', '(', 'self', ')', '->', 'None', ':', 'raw_body', '=', 'self', '.', '_body', 'body', '=', 'cast', '(', 'Optional', '[', 'bytes', ']', ',', 'None', ')', 'default_type', '=', '2', 'charset', '=', 'self', '.', '_charset', 'or', 'self', '.', '_default_charset', 'if', 'raw_body', 'is', 'None', ':', ...
处理设置到body上的数据默认 headers
['处理设置到body上的数据默认', 'headers']
train
https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/response.py#L261-L312
9,529
jasonrbriggs/stomp.py
stomp/protocol.py
Protocol10.begin
def begin(self, transaction=None, headers=None, **keyword_headers): """ Begin a transaction. :param str transaction: the identifier for the transaction (optional - if not specified a unique transaction id will be generated) :param dict headers: a map of any additional header...
python
def begin(self, transaction=None, headers=None, **keyword_headers): """ Begin a transaction. :param str transaction: the identifier for the transaction (optional - if not specified a unique transaction id will be generated) :param dict headers: a map of any additional header...
['def', 'begin', '(', 'self', ',', 'transaction', '=', 'None', ',', 'headers', '=', 'None', ',', '*', '*', 'keyword_headers', ')', ':', 'headers', '=', 'utils', '.', 'merge_headers', '(', '[', 'headers', ',', 'keyword_headers', ']', ')', 'if', 'not', 'transaction', ':', 'transaction', '=', 'utils', '.', 'get_uuid', '('...
Begin a transaction. :param str transaction: the identifier for the transaction (optional - if not specified a unique transaction id will be generated) :param dict headers: a map of any additional headers the broker requires :param keyword_headers: any additional headers the broker ...
['Begin', 'a', 'transaction', '.']
train
https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/protocol.py#L68-L85
9,530
johnwheeler/flask-ask
flask_ask/core.py
Ask._parse_timestamp
def _parse_timestamp(timestamp): """ Parse a given timestamp value, raising ValueError if None or Flasey """ if timestamp: try: return aniso8601.parse_datetime(timestamp) except AttributeError: # raised by aniso8601 if raw_timestamp...
python
def _parse_timestamp(timestamp): """ Parse a given timestamp value, raising ValueError if None or Flasey """ if timestamp: try: return aniso8601.parse_datetime(timestamp) except AttributeError: # raised by aniso8601 if raw_timestamp...
['def', '_parse_timestamp', '(', 'timestamp', ')', ':', 'if', 'timestamp', ':', 'try', ':', 'return', 'aniso8601', '.', 'parse_datetime', '(', 'timestamp', ')', 'except', 'AttributeError', ':', '# raised by aniso8601 if raw_timestamp is not valid string', '# in ISO8601 format', 'try', ':', 'return', 'datetime', '.', 'u...
Parse a given timestamp value, raising ValueError if None or Flasey
['Parse', 'a', 'given', 'timestamp', 'value', 'raising', 'ValueError', 'if', 'None', 'or', 'Flasey']
train
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L724-L740
9,531
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/handlers.py
KickOffJobHandler._get_input_readers
def _get_input_readers(self, state): """Get input readers. Args: state: a MapreduceState model. Returns: A tuple: (a list of input readers, a model._HugeTaskPayload entity). The payload entity contains the json serialized input readers. (None, None) when input reader inplitting returne...
python
def _get_input_readers(self, state): """Get input readers. Args: state: a MapreduceState model. Returns: A tuple: (a list of input readers, a model._HugeTaskPayload entity). The payload entity contains the json serialized input readers. (None, None) when input reader inplitting returne...
['def', '_get_input_readers', '(', 'self', ',', 'state', ')', ':', 'serialized_input_readers_key', '=', '(', 'self', '.', '_SERIALIZED_INPUT_READERS_KEY', '%', 'state', '.', 'key', '(', ')', '.', 'id_or_name', '(', ')', ')', 'serialized_input_readers', '=', 'model', '.', '_HugeTaskPayload', '.', 'get_by_key_name', '(',...
Get input readers. Args: state: a MapreduceState model. Returns: A tuple: (a list of input readers, a model._HugeTaskPayload entity). The payload entity contains the json serialized input readers. (None, None) when input reader inplitting returned no data to process.
['Get', 'input', 'readers', '.']
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/handlers.py#L1435-L1480
9,532
bitesofcode/projexui
projexui/widgets/xsplitter.py
XSplitterHandle.toggleCollapseAfter
def toggleCollapseAfter( self ): """ Collapses the splitter after this handle. """ if ( self.isCollapsed() ): self.uncollapse() else: self.collapse( XSplitterHandle.CollapseDirection.After )
python
def toggleCollapseAfter( self ): """ Collapses the splitter after this handle. """ if ( self.isCollapsed() ): self.uncollapse() else: self.collapse( XSplitterHandle.CollapseDirection.After )
['def', 'toggleCollapseAfter', '(', 'self', ')', ':', 'if', '(', 'self', '.', 'isCollapsed', '(', ')', ')', ':', 'self', '.', 'uncollapse', '(', ')', 'else', ':', 'self', '.', 'collapse', '(', 'XSplitterHandle', '.', 'CollapseDirection', '.', 'After', ')']
Collapses the splitter after this handle.
['Collapses', 'the', 'splitter', 'after', 'this', 'handle', '.']
train
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsplitter.py#L287-L294
9,533
dpmcmlxxvi/pixelscan
pixelscan/pixelscan.py
scale.next
def next(self): """Next point in iteration """ x, y = next(self.scan) xr = self.sx * x yr = self.sy * y return xr, yr
python
def next(self): """Next point in iteration """ x, y = next(self.scan) xr = self.sx * x yr = self.sy * y return xr, yr
['def', 'next', '(', 'self', ')', ':', 'x', ',', 'y', '=', 'next', '(', 'self', '.', 'scan', ')', 'xr', '=', 'self', '.', 'sx', '*', 'x', 'yr', '=', 'self', '.', 'sy', '*', 'y', 'return', 'xr', ',', 'yr']
Next point in iteration
['Next', 'point', 'in', 'iteration']
train
https://github.com/dpmcmlxxvi/pixelscan/blob/d641207b13a8fc5bf7ac9964b982971652bb0a7e/pixelscan/pixelscan.py#L274-L280
9,534
eternnoir/pyTelegramBotAPI
telebot/__init__.py
TeleBot.send_video_note
def send_video_note(self, chat_id, data, duration=None, length=None, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None): """ Use this method to send video files, Telegram clients support mp4 videos. :param chat_id: Integer : Unique ident...
python
def send_video_note(self, chat_id, data, duration=None, length=None, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None): """ Use this method to send video files, Telegram clients support mp4 videos. :param chat_id: Integer : Unique ident...
['def', 'send_video_note', '(', 'self', ',', 'chat_id', ',', 'data', ',', 'duration', '=', 'None', ',', 'length', '=', 'None', ',', 'reply_to_message_id', '=', 'None', ',', 'reply_markup', '=', 'None', ',', 'disable_notification', '=', 'None', ',', 'timeout', '=', 'None', ')', ':', 'return', 'types', '.', 'Message', '....
Use this method to send video files, Telegram clients support mp4 videos. :param chat_id: Integer : Unique identifier for the message recipient — User or GroupChat id :param data: InputFile or String : Video note to send. You can either pass a file_id as String to resend a video that is already on the T...
['Use', 'this', 'method', 'to', 'send', 'video', 'files', 'Telegram', 'clients', 'support', 'mp4', 'videos', '.', ':', 'param', 'chat_id', ':', 'Integer', ':', 'Unique', 'identifier', 'for', 'the', 'message', 'recipient', '—', 'User', 'or', 'GroupChat', 'id', ':', 'param', 'data', ':', 'InputFile', 'or', 'String', ':',...
train
https://github.com/eternnoir/pyTelegramBotAPI/blob/47b53b88123097f1b9562a6cd5d4e080b86185d1/telebot/__init__.py#L722-L736
9,535
googledatalab/pydatalab
solutionbox/structured_data/mltoolbox/_structured_data/_package.py
analyze
def analyze(output_dir, dataset, cloud=False, project_id=None): """Blocking version of analyze_async. See documentation of analyze_async.""" job = analyze_async( output_dir=output_dir, dataset=dataset, cloud=cloud, project_id=project_id) job.wait() print('Analyze: ' + str(job.state))
python
def analyze(output_dir, dataset, cloud=False, project_id=None): """Blocking version of analyze_async. See documentation of analyze_async.""" job = analyze_async( output_dir=output_dir, dataset=dataset, cloud=cloud, project_id=project_id) job.wait() print('Analyze: ' + str(job.state))
['def', 'analyze', '(', 'output_dir', ',', 'dataset', ',', 'cloud', '=', 'False', ',', 'project_id', '=', 'None', ')', ':', 'job', '=', 'analyze_async', '(', 'output_dir', '=', 'output_dir', ',', 'dataset', '=', 'dataset', ',', 'cloud', '=', 'cloud', ',', 'project_id', '=', 'project_id', ')', 'job', '.', 'wait', '(', '...
Blocking version of analyze_async. See documentation of analyze_async.
['Blocking', 'version', 'of', 'analyze_async', '.', 'See', 'documentation', 'of', 'analyze_async', '.']
train
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/_package.py#L136-L144
9,536
aestrivex/bctpy
bct/algorithms/similarity.py
corr_flat_dir
def corr_flat_dir(a1, a2): ''' Returns the correlation coefficient between two flattened adjacency matrices. Similarity metric for weighted matrices. Parameters ---------- A1 : NxN np.ndarray directed matrix 1 A2 : NxN np.ndarray directed matrix 2 Returns ------- ...
python
def corr_flat_dir(a1, a2): ''' Returns the correlation coefficient between two flattened adjacency matrices. Similarity metric for weighted matrices. Parameters ---------- A1 : NxN np.ndarray directed matrix 1 A2 : NxN np.ndarray directed matrix 2 Returns ------- ...
['def', 'corr_flat_dir', '(', 'a1', ',', 'a2', ')', ':', 'n', '=', 'len', '(', 'a1', ')', 'if', 'len', '(', 'a2', ')', '!=', 'n', ':', 'raise', 'BCTParamError', '(', '"Cannot calculate flattened correlation on "', '"matrices of different size"', ')', 'ix', '=', 'np', '.', 'logical_not', '(', 'np', '.', 'eye', '(', 'n',...
Returns the correlation coefficient between two flattened adjacency matrices. Similarity metric for weighted matrices. Parameters ---------- A1 : NxN np.ndarray directed matrix 1 A2 : NxN np.ndarray directed matrix 2 Returns ------- r : float Correlation coeffi...
['Returns', 'the', 'correlation', 'coefficient', 'between', 'two', 'flattened', 'adjacency', 'matrices', '.', 'Similarity', 'metric', 'for', 'weighted', 'matrices', '.']
train
https://github.com/aestrivex/bctpy/blob/4cb0e759eb4a038750b07e23bd29958c400684b8/bct/algorithms/similarity.py#L355-L377
9,537
chibisov/drf-extensions
docs/backdoc.py
Markdown._do_smart_punctuation
def _do_smart_punctuation(self, text): """Fancifies 'single quotes', "double quotes", and apostrophes. Converts --, ---, and ... into en dashes, em dashes, and ellipses. Inspiration is: <http://daringfireball.net/projects/smartypants/> See "test/tm-cases/smarty_pants.text" for a full di...
python
def _do_smart_punctuation(self, text): """Fancifies 'single quotes', "double quotes", and apostrophes. Converts --, ---, and ... into en dashes, em dashes, and ellipses. Inspiration is: <http://daringfireball.net/projects/smartypants/> See "test/tm-cases/smarty_pants.text" for a full di...
['def', '_do_smart_punctuation', '(', 'self', ',', 'text', ')', ':', 'if', '"\'"', 'in', 'text', ':', '# guard for perf', 'text', '=', 'self', '.', '_do_smart_contractions', '(', 'text', ')', 'text', '=', 'self', '.', '_opening_single_quote_re', '.', 'sub', '(', '"&#8216;"', ',', 'text', ')', 'text', '=', 'self', '.', ...
Fancifies 'single quotes', "double quotes", and apostrophes. Converts --, ---, and ... into en dashes, em dashes, and ellipses. Inspiration is: <http://daringfireball.net/projects/smartypants/> See "test/tm-cases/smarty_pants.text" for a full discussion of the support here and <...
['Fancifies', 'single', 'quotes', 'double', 'quotes', 'and', 'apostrophes', '.', 'Converts', '--', '---', 'and', '...', 'into', 'en', 'dashes', 'em', 'dashes', 'and', 'ellipses', '.']
train
https://github.com/chibisov/drf-extensions/blob/1d28a4b28890eab5cd19e93e042f8590c8c2fb8b/docs/backdoc.py#L1653-L1677
9,538
watson-developer-cloud/python-sdk
ibm_watson/compare_comply_v1.py
UnalignedElement._to_dict
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'document_label') and self.document_label is not None: _dict['document_label'] = self.document_label if hasattr(self, 'location') and self.location is not None: ...
python
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'document_label') and self.document_label is not None: _dict['document_label'] = self.document_label if hasattr(self, 'location') and self.location is not None: ...
['def', '_to_dict', '(', 'self', ')', ':', '_dict', '=', '{', '}', 'if', 'hasattr', '(', 'self', ',', "'document_label'", ')', 'and', 'self', '.', 'document_label', 'is', 'not', 'None', ':', '_dict', '[', "'document_label'", ']', '=', 'self', '.', 'document_label', 'if', 'hasattr', '(', 'self', ',', "'location'", ')', ...
Return a json dictionary representing this model.
['Return', 'a', 'json', 'dictionary', 'representing', 'this', 'model', '.']
train
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/compare_comply_v1.py#L4999-L5014
9,539
hatemile/hatemile-for-python
hatemile/implementation/assoc.py
AccessibleAssociationImplementation._get_model_table
def _get_model_table(self, part): """ Returns a list that represents the table. :param part: The table header, table footer or table body. :type part: hatemile.util.html.htmldomelement.HTMLDOMElement :return: The list that represents the table. :rtype: list(list(hatemile...
python
def _get_model_table(self, part): """ Returns a list that represents the table. :param part: The table header, table footer or table body. :type part: hatemile.util.html.htmldomelement.HTMLDOMElement :return: The list that represents the table. :rtype: list(list(hatemile...
['def', '_get_model_table', '(', 'self', ',', 'part', ')', ':', 'rows', '=', 'self', '.', 'parser', '.', 'find', '(', 'part', ')', '.', 'find_children', '(', "'tr'", ')', '.', 'list_results', '(', ')', 'table', '=', '[', ']', 'for', 'row', 'in', 'rows', ':', 'table', '.', 'append', '(', 'self', '.', '_get_model_row', '...
Returns a list that represents the table. :param part: The table header, table footer or table body. :type part: hatemile.util.html.htmldomelement.HTMLDOMElement :return: The list that represents the table. :rtype: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
['Returns', 'a', 'list', 'that', 'represents', 'the', 'table', '.']
train
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L46-L62
9,540
dhermes/bezier
src/bezier/surface.py
Surface._get_degree
def _get_degree(num_nodes): """Get the degree of the current surface. Args: num_nodes (int): The number of control points for a B |eacute| zier surface. Returns: int: The degree :math:`d` such that :math:`(d + 1)(d + 2)/2` equals ``num_nodes`...
python
def _get_degree(num_nodes): """Get the degree of the current surface. Args: num_nodes (int): The number of control points for a B |eacute| zier surface. Returns: int: The degree :math:`d` such that :math:`(d + 1)(d + 2)/2` equals ``num_nodes`...
['def', '_get_degree', '(', 'num_nodes', ')', ':', '# 8 * num_nodes = 4(d + 1)(d + 2)', '# = 4d^2 + 12d + 8', '# = (2d + 3)^2 - 1', 'd_float', '=', '0.5', '*', '(', 'np', '.', 'sqrt', '(', '8.0', '*', 'num_nodes', '+', '1.0', ')', '-', '3.0', ')', 'd_int', '=', 'int', '(', 'np', '.', 'round'...
Get the degree of the current surface. Args: num_nodes (int): The number of control points for a B |eacute| zier surface. Returns: int: The degree :math:`d` such that :math:`(d + 1)(d + 2)/2` equals ``num_nodes``. Raises: ValueEr...
['Get', 'the', 'degree', 'of', 'the', 'current', 'surface', '.']
train
https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/surface.py#L214-L237
9,541
materialsproject/pymatgen
pymatgen/core/bonds.py
get_bond_length
def get_bond_length(sp1, sp2, bond_order=1): """ Get the bond length between two species. Args: sp1 (Specie): First specie. sp2 (Specie): Second specie. bond_order: For species with different possible bond orders, this allows one to obtain the bond length for a particula...
python
def get_bond_length(sp1, sp2, bond_order=1): """ Get the bond length between two species. Args: sp1 (Specie): First specie. sp2 (Specie): Second specie. bond_order: For species with different possible bond orders, this allows one to obtain the bond length for a particula...
['def', 'get_bond_length', '(', 'sp1', ',', 'sp2', ',', 'bond_order', '=', '1', ')', ':', 'sp1', '=', 'Element', '(', 'sp1', ')', 'if', 'isinstance', '(', 'sp1', ',', 'str', ')', 'else', 'sp1', 'sp2', '=', 'Element', '(', 'sp2', ')', 'if', 'isinstance', '(', 'sp2', ',', 'str', ')', 'else', 'sp2', 'try', ':', 'all_lengt...
Get the bond length between two species. Args: sp1 (Specie): First specie. sp2 (Specie): Second specie. bond_order: For species with different possible bond orders, this allows one to obtain the bond length for a particular bond order. For example, to get the C=C bon...
['Get', 'the', 'bond', 'length', 'between', 'two', 'species', '.']
train
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L199-L229
9,542
bfontaine/p7magma
magma/courses.py
CoursesList._populate
def _populate(self, soup): """ Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object. """ tables = soup.select('table[rules=all]') if not tables: return trs = tables[0].select('tr')[1:] if len(trs[0]) == 5: # M1 se...
python
def _populate(self, soup): """ Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object. """ tables = soup.select('table[rules=all]') if not tables: return trs = tables[0].select('tr')[1:] if len(trs[0]) == 5: # M1 se...
['def', '_populate', '(', 'self', ',', 'soup', ')', ':', 'tables', '=', 'soup', '.', 'select', '(', "'table[rules=all]'", ')', 'if', 'not', 'tables', ':', 'return', 'trs', '=', 'tables', '[', '0', ']', '.', 'select', '(', "'tr'", ')', '[', '1', ':', ']', 'if', 'len', '(', 'trs', '[', '0', ']', ')', '==', '5', ':', '# M...
Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object.
['Populate', 'the', 'list', 'assuming', 'soup', 'is', 'a', 'BeautifulSoup', 'object', '.']
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L70-L84
9,543
lacava/few
few/population.py
PopMixin.stacks_2_eqns
def stacks_2_eqns(self,stacks): """returns equation strings from stacks""" if stacks: return list(map(lambda p: self.stack_2_eqn(p), stacks)) else: return []
python
def stacks_2_eqns(self,stacks): """returns equation strings from stacks""" if stacks: return list(map(lambda p: self.stack_2_eqn(p), stacks)) else: return []
['def', 'stacks_2_eqns', '(', 'self', ',', 'stacks', ')', ':', 'if', 'stacks', ':', 'return', 'list', '(', 'map', '(', 'lambda', 'p', ':', 'self', '.', 'stack_2_eqn', '(', 'p', ')', ',', 'stacks', ')', ')', 'else', ':', 'return', '[', ']']
returns equation strings from stacks
['returns', 'equation', 'strings', 'from', 'stacks']
train
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/population.py#L199-L204
9,544
Azure/azure-cli-extensions
src/interactive/azext_interactive/azclishell/app.py
space_toolbar
def space_toolbar(settings_items, empty_space): """ formats the toolbar """ counter = 0 for part in settings_items: counter += len(part) if len(settings_items) == 1: spacing = '' else: spacing = empty_space[ :int(math.floor((len(empty_space) - counter) / (len(set...
python
def space_toolbar(settings_items, empty_space): """ formats the toolbar """ counter = 0 for part in settings_items: counter += len(part) if len(settings_items) == 1: spacing = '' else: spacing = empty_space[ :int(math.floor((len(empty_space) - counter) / (len(set...
['def', 'space_toolbar', '(', 'settings_items', ',', 'empty_space', ')', ':', 'counter', '=', '0', 'for', 'part', 'in', 'settings_items', ':', 'counter', '+=', 'len', '(', 'part', ')', 'if', 'len', '(', 'settings_items', ')', '==', '1', ':', 'spacing', '=', "''", 'else', ':', 'spacing', '=', 'empty_space', '[', ':', 'i...
formats the toolbar
['formats', 'the', 'toolbar']
train
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/interactive/azext_interactive/azclishell/app.py#L62-L77
9,545
boriel/zxbasic
arch/zx48k/optimizer.py
MemCell.destroys
def destroys(self): """ Returns which single registers (including f, flag) this instruction changes. Registers are: a, b, c, d, e, i, h, l, ixh, ixl, iyh, iyl, r LD a, X => Destroys a LD a, a => Destroys nothing INC a => Destroys a, f POP af => Destroys a, f, s...
python
def destroys(self): """ Returns which single registers (including f, flag) this instruction changes. Registers are: a, b, c, d, e, i, h, l, ixh, ixl, iyh, iyl, r LD a, X => Destroys a LD a, a => Destroys nothing INC a => Destroys a, f POP af => Destroys a, f, s...
['def', 'destroys', '(', 'self', ')', ':', 'if', 'self', '.', 'asm', 'in', 'arch', '.', 'zx48k', '.', 'backend', '.', 'ASMS', ':', 'return', 'ALL_REGS', 'res', '=', 'set', '(', '[', ']', ')', 'i', '=', 'self', '.', 'inst', 'o', '=', 'self', '.', 'opers', 'if', 'i', 'in', '{', "'push'", ',', "'ret'", ',', "'call'", ',',...
Returns which single registers (including f, flag) this instruction changes. Registers are: a, b, c, d, e, i, h, l, ixh, ixl, iyh, iyl, r LD a, X => Destroys a LD a, a => Destroys nothing INC a => Destroys a, f POP af => Destroys a, f, sp PUSH af => Destroys sp...
['Returns', 'which', 'single', 'registers', '(', 'including', 'f', 'flag', ')', 'this', 'instruction', 'changes', '.']
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L966-L1027
9,546
MacHu-GWU/loggerFactory-project
loggerFactory/logger.py
BaseLogger.recover_all_handler
def recover_all_handler(self): """ Relink the file handler association you just removed. """ for handler in self._handler_cache: self.logger.addHandler(handler) self._handler_cache = list()
python
def recover_all_handler(self): """ Relink the file handler association you just removed. """ for handler in self._handler_cache: self.logger.addHandler(handler) self._handler_cache = list()
['def', 'recover_all_handler', '(', 'self', ')', ':', 'for', 'handler', 'in', 'self', '.', '_handler_cache', ':', 'self', '.', 'logger', '.', 'addHandler', '(', 'handler', ')', 'self', '.', '_handler_cache', '=', 'list', '(', ')']
Relink the file handler association you just removed.
['Relink', 'the', 'file', 'handler', 'association', 'you', 'just', 'removed', '.']
train
https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L119-L125
9,547
MonashBI/arcana
arcana/study/base.py
Study.data
def data(self, name, subject_ids=None, visit_ids=None, session_ids=None, **kwargs): """ Returns the Fileset(s) or Field(s) associated with the provided spec name(s), generating derived filesets as required. Multiple names in a list can be provided, to allow their workflows t...
python
def data(self, name, subject_ids=None, visit_ids=None, session_ids=None, **kwargs): """ Returns the Fileset(s) or Field(s) associated with the provided spec name(s), generating derived filesets as required. Multiple names in a list can be provided, to allow their workflows t...
['def', 'data', '(', 'self', ',', 'name', ',', 'subject_ids', '=', 'None', ',', 'visit_ids', '=', 'None', ',', 'session_ids', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'if', 'isinstance', '(', 'name', ',', 'basestring', ')', ':', 'single_name', '=', 'True', 'names', '=', '[', 'name', ']', 'else', ':', 'names', '=...
Returns the Fileset(s) or Field(s) associated with the provided spec name(s), generating derived filesets as required. Multiple names in a list can be provided, to allow their workflows to be combined into a single workflow. Parameters ---------- name : str | List[str] ...
['Returns', 'the', 'Fileset', '(', 's', ')', 'or', 'Field', '(', 's', ')', 'associated', 'with', 'the', 'provided', 'spec', 'name', '(', 's', ')', 'generating', 'derived', 'filesets', 'as', 'required', '.', 'Multiple', 'names', 'in', 'a', 'list', 'can', 'be', 'provided', 'to', 'allow', 'their', 'workflows', 'to', 'be',...
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L244-L376
9,548
elifesciences/elife-tools
elifetools/parseJATS.py
pub_date
def pub_date(soup): """ Return the publishing date in struct format pub_date_date, pub_date_day, pub_date_month, pub_date_year, pub_date_timestamp Default date_type is pub """ pub_date = first(raw_parser.pub_date(soup, date_type="pub")) if pub_date is None: pub_date = first(raw_parse...
python
def pub_date(soup): """ Return the publishing date in struct format pub_date_date, pub_date_day, pub_date_month, pub_date_year, pub_date_timestamp Default date_type is pub """ pub_date = first(raw_parser.pub_date(soup, date_type="pub")) if pub_date is None: pub_date = first(raw_parse...
['def', 'pub_date', '(', 'soup', ')', ':', 'pub_date', '=', 'first', '(', 'raw_parser', '.', 'pub_date', '(', 'soup', ',', 'date_type', '=', '"pub"', ')', ')', 'if', 'pub_date', 'is', 'None', ':', 'pub_date', '=', 'first', '(', 'raw_parser', '.', 'pub_date', '(', 'soup', ',', 'date_type', '=', '"publication"', ')', ')'...
Return the publishing date in struct format pub_date_date, pub_date_day, pub_date_month, pub_date_year, pub_date_timestamp Default date_type is pub
['Return', 'the', 'publishing', 'date', 'in', 'struct', 'format', 'pub_date_date', 'pub_date_day', 'pub_date_month', 'pub_date_year', 'pub_date_timestamp', 'Default', 'date_type', 'is', 'pub']
train
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L354-L366
9,549
daboth/pagan
pagan/generator.py
generate_by_hash
def generate_by_hash(hashcode): """Generates an PIL image avatar based on the given hash String. Acts as the main accessor to pagan.""" img = Image.new(IMAGE_MODE, IMAGE_SIZE, BACKGROUND_COLOR) if len(hashcode) < 32: print ("hashcode must have lenght >= 32, %s" % hashcode) raise FalseHas...
python
def generate_by_hash(hashcode): """Generates an PIL image avatar based on the given hash String. Acts as the main accessor to pagan.""" img = Image.new(IMAGE_MODE, IMAGE_SIZE, BACKGROUND_COLOR) if len(hashcode) < 32: print ("hashcode must have lenght >= 32, %s" % hashcode) raise FalseHas...
['def', 'generate_by_hash', '(', 'hashcode', ')', ':', 'img', '=', 'Image', '.', 'new', '(', 'IMAGE_MODE', ',', 'IMAGE_SIZE', ',', 'BACKGROUND_COLOR', ')', 'if', 'len', '(', 'hashcode', ')', '<', '32', ':', 'print', '(', '"hashcode must have lenght >= 32, %s"', '%', 'hashcode', ')', 'raise', 'FalseHashError', 'allowed'...
Generates an PIL image avatar based on the given hash String. Acts as the main accessor to pagan.
['Generates', 'an', 'PIL', 'image', 'avatar', 'based', 'on', 'the', 'given', 'hash', 'String', '.', 'Acts', 'as', 'the', 'main', 'accessor', 'to', 'pagan', '.']
train
https://github.com/daboth/pagan/blob/1e6d31f78e312d242751e70566ca9a6278784915/pagan/generator.py#L282-L298
9,550
stephanepechard/projy
projy/cmdline.py
run_info
def run_info(template): """ Print information about a specific template. """ template.project_name = 'TowelStuff' # fake project name, always the same name = template_name_from_class_name(template.__class__.__name__) term = TerminalView() term.print_info("Content of template {} with an example proje...
python
def run_info(template): """ Print information about a specific template. """ template.project_name = 'TowelStuff' # fake project name, always the same name = template_name_from_class_name(template.__class__.__name__) term = TerminalView() term.print_info("Content of template {} with an example proje...
['def', 'run_info', '(', 'template', ')', ':', 'template', '.', 'project_name', '=', "'TowelStuff'", '# fake project name, always the same', 'name', '=', 'template_name_from_class_name', '(', 'template', '.', '__class__', '.', '__name__', ')', 'term', '=', 'TerminalView', '(', ')', 'term', '.', 'print_info', '(', '"Con...
Print information about a specific template.
['Print', 'information', 'about', 'a', 'specific', 'template', '.']
train
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/cmdline.py#L54-L91
9,551
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.get_custom_implementations
def get_custom_implementations(self): """Retrieve a list of cutom implementations. Yields: (str, str, ImplementationProperty) tuples: The name of the attribute an implementation lives at, the name of the related transition, and the related implementation. ...
python
def get_custom_implementations(self): """Retrieve a list of cutom implementations. Yields: (str, str, ImplementationProperty) tuples: The name of the attribute an implementation lives at, the name of the related transition, and the related implementation. ...
['def', 'get_custom_implementations', '(', 'self', ')', ':', 'for', 'trname', 'in', 'self', '.', 'custom_implems', ':', 'attr', '=', 'self', '.', 'transitions_at', '[', 'trname', ']', 'implem', '=', 'self', '.', 'implementations', '[', 'trname', ']', 'yield', '(', 'trname', ',', 'attr', ',', 'implem', ')']
Retrieve a list of cutom implementations. Yields: (str, str, ImplementationProperty) tuples: The name of the attribute an implementation lives at, the name of the related transition, and the related implementation.
['Retrieve', 'a', 'list', 'of', 'cutom', 'implementations', '.']
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L734-L745
9,552
mediawiki-utilities/python-mwxml
mwxml/iteration/dump.py
Dump.from_file
def from_file(cls, f): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process """ element = ElementIterator.from_file(f) assert element.tag == "me...
python
def from_file(cls, f): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process """ element = ElementIterator.from_file(f) assert element.tag == "me...
['def', 'from_file', '(', 'cls', ',', 'f', ')', ':', 'element', '=', 'ElementIterator', '.', 'from_file', '(', 'f', ')', 'assert', 'element', '.', 'tag', '==', '"mediawiki"', 'return', 'cls', '.', 'from_element', '(', 'element', ')']
Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process
['Constructs', 'a', ':', 'class', ':', '~mwxml', '.', 'iteration', '.', 'dump', '.', 'Dump', 'from', 'a', 'file', 'pointer', '.']
train
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L136-L146
9,553
saltstack/salt
salt/modules/cmdmod.py
_check_avail
def _check_avail(cmd): ''' Check to see if the given command can be run ''' if isinstance(cmd, list): cmd = ' '.join([six.text_type(x) if not isinstance(x, six.string_types) else x for x in cmd]) bret = True wret = False if __salt__['config.get']('cmd_blacklis...
python
def _check_avail(cmd): ''' Check to see if the given command can be run ''' if isinstance(cmd, list): cmd = ' '.join([six.text_type(x) if not isinstance(x, six.string_types) else x for x in cmd]) bret = True wret = False if __salt__['config.get']('cmd_blacklis...
['def', '_check_avail', '(', 'cmd', ')', ':', 'if', 'isinstance', '(', 'cmd', ',', 'list', ')', ':', 'cmd', '=', "' '", '.', 'join', '(', '[', 'six', '.', 'text_type', '(', 'x', ')', 'if', 'not', 'isinstance', '(', 'x', ',', 'six', '.', 'string_types', ')', 'else', 'x', 'for', 'x', 'in', 'cmd', ']', ')', 'bret', '=', '...
Check to see if the given command can be run
['Check', 'to', 'see', 'if', 'the', 'given', 'command', 'can', 'be', 'run']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cmdmod.py#L222-L247
9,554
tanghaibao/goatools
goatools/nt_utils.py
wr_py_nts
def wr_py_nts(fout_py, nts, docstring=None, varname="nts"): """Save namedtuples into a Python module.""" if nts: with open(fout_py, 'w') as prt: prt.write('"""{DOCSTRING}"""\n\n'.format(DOCSTRING=docstring)) prt.write("# Created: {DATE}\n".format(DATE=str(datetime.date.today())))...
python
def wr_py_nts(fout_py, nts, docstring=None, varname="nts"): """Save namedtuples into a Python module.""" if nts: with open(fout_py, 'w') as prt: prt.write('"""{DOCSTRING}"""\n\n'.format(DOCSTRING=docstring)) prt.write("# Created: {DATE}\n".format(DATE=str(datetime.date.today())))...
['def', 'wr_py_nts', '(', 'fout_py', ',', 'nts', ',', 'docstring', '=', 'None', ',', 'varname', '=', '"nts"', ')', ':', 'if', 'nts', ':', 'with', 'open', '(', 'fout_py', ',', "'w'", ')', 'as', 'prt', ':', 'prt', '.', 'write', '(', '\'"""{DOCSTRING}"""\\n\\n\'', '.', 'format', '(', 'DOCSTRING', '=', 'docstring', ')', ')...
Save namedtuples into a Python module.
['Save', 'namedtuples', 'into', 'a', 'Python', 'module', '.']
train
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L54-L61
9,555
dhocker/udmx-pyusb
example.py
main
def main(): """ How to control a DMX light through an Anyma USB controller """ # Channel value list for channels 1-512 cv = [0 for v in range(0, 512)] # Create an instance of the DMX controller and open it print("Opening DMX controller...") dev = pyudmx.uDMXDevice() # This will...
python
def main(): """ How to control a DMX light through an Anyma USB controller """ # Channel value list for channels 1-512 cv = [0 for v in range(0, 512)] # Create an instance of the DMX controller and open it print("Opening DMX controller...") dev = pyudmx.uDMXDevice() # This will...
['def', 'main', '(', ')', ':', '# Channel value list for channels 1-512', 'cv', '=', '[', '0', 'for', 'v', 'in', 'range', '(', '0', ',', '512', ')', ']', '# Create an instance of the DMX controller and open it ', 'print', '(', '"Opening DMX controller..."', ')', 'dev', '=', 'pyudmx', '.', 'uDMXDevice', '(', ')', '# ...
How to control a DMX light through an Anyma USB controller
['How', 'to', 'control', 'a', 'DMX', 'light', 'through', 'an', 'Anyma', 'USB', 'controller']
train
https://github.com/dhocker/udmx-pyusb/blob/ee7d10604ecd83857154ed6739793de3b7bd5fc1/example.py#L39-L96
9,556
DomainTools/python_api
domaintools/api.py
API.reverse_ip_whois
def reverse_ip_whois(self, query=None, ip=None, country=None, server=None, include_total_count=False, page=1, **kwargs): """Pass in an IP address or a list of free text query terms.""" if (ip and query) or not (ip or query): raise ValueError('Query or IP Address (but...
python
def reverse_ip_whois(self, query=None, ip=None, country=None, server=None, include_total_count=False, page=1, **kwargs): """Pass in an IP address or a list of free text query terms.""" if (ip and query) or not (ip or query): raise ValueError('Query or IP Address (but...
['def', 'reverse_ip_whois', '(', 'self', ',', 'query', '=', 'None', ',', 'ip', '=', 'None', ',', 'country', '=', 'None', ',', 'server', '=', 'None', ',', 'include_total_count', '=', 'False', ',', 'page', '=', '1', ',', '*', '*', 'kwargs', ')', ':', 'if', '(', 'ip', 'and', 'query', ')', 'or', 'not', '(', 'ip', 'or', 'qu...
Pass in an IP address or a list of free text query terms.
['Pass', 'in', 'an', 'IP', 'address', 'or', 'a', 'list', 'of', 'free', 'text', 'query', 'terms', '.']
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L148-L156
9,557
rlisagor/pynetlinux
pynetlinux/ifconfig.py
Interface.get_mac
def get_mac(self): ''' Obtain the device's mac address. ''' ifreq = struct.pack('16sH14s', self.name, AF_UNIX, b'\x00'*14) res = fcntl.ioctl(sockfd, SIOCGIFHWADDR, ifreq) address = struct.unpack('16sH14s', res)[2] mac = struct.unpack('6B8x', address) return ":".join(['%0...
python
def get_mac(self): ''' Obtain the device's mac address. ''' ifreq = struct.pack('16sH14s', self.name, AF_UNIX, b'\x00'*14) res = fcntl.ioctl(sockfd, SIOCGIFHWADDR, ifreq) address = struct.unpack('16sH14s', res)[2] mac = struct.unpack('6B8x', address) return ":".join(['%0...
['def', 'get_mac', '(', 'self', ')', ':', 'ifreq', '=', 'struct', '.', 'pack', '(', "'16sH14s'", ',', 'self', '.', 'name', ',', 'AF_UNIX', ',', "b'\\x00'", '*', '14', ')', 'res', '=', 'fcntl', '.', 'ioctl', '(', 'sockfd', ',', 'SIOCGIFHWADDR', ',', 'ifreq', ')', 'address', '=', 'struct', '.', 'unpack', '(', "'16sH14s'"...
Obtain the device's mac address.
['Obtain', 'the', 'device', 's', 'mac', 'address', '.']
train
https://github.com/rlisagor/pynetlinux/blob/e3f16978855c6649685f0c43d4c3fcf768427ae5/pynetlinux/ifconfig.py#L179-L186
9,558
hsolbrig/PyShEx
pyshex/utils/url_utils.py
generate_base
def generate_base(path: str) -> str: """ Convert path, which can be a URL or a file path into a base URI :param path: file location or url :return: file location or url sans actual name """ if ':' in path: parts = urlparse(path) parts_dict = parts._asdict() parts_dict['path'...
python
def generate_base(path: str) -> str: """ Convert path, which can be a URL or a file path into a base URI :param path: file location or url :return: file location or url sans actual name """ if ':' in path: parts = urlparse(path) parts_dict = parts._asdict() parts_dict['path'...
['def', 'generate_base', '(', 'path', ':', 'str', ')', '->', 'str', ':', 'if', "':'", 'in', 'path', ':', 'parts', '=', 'urlparse', '(', 'path', ')', 'parts_dict', '=', 'parts', '.', '_asdict', '(', ')', 'parts_dict', '[', "'path'", ']', '=', 'os', '.', 'path', '.', 'split', '(', 'parts', '.', 'path', ')', '[', '0', ']'...
Convert path, which can be a URL or a file path into a base URI :param path: file location or url :return: file location or url sans actual name
['Convert', 'path', 'which', 'can', 'be', 'a', 'URL', 'or', 'a', 'file', 'path', 'into', 'a', 'base', 'URI']
train
https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/url_utils.py#L6-L18
9,559
google/prettytensor
prettytensor/pretty_tensor_class.py
_conversion_function
def _conversion_function(pt_wrapper, dtype=None, name=None, as_ref=False): """Allows PrettyTensors and Loss to work as a tensor.""" # Ignore as_ref to not create backward compatibility issues. _ = name, as_ref t = pt_wrapper.tensor if dtype and not dtype.is_compatible_with(t.dtype): raise ValueError( ...
python
def _conversion_function(pt_wrapper, dtype=None, name=None, as_ref=False): """Allows PrettyTensors and Loss to work as a tensor.""" # Ignore as_ref to not create backward compatibility issues. _ = name, as_ref t = pt_wrapper.tensor if dtype and not dtype.is_compatible_with(t.dtype): raise ValueError( ...
['def', '_conversion_function', '(', 'pt_wrapper', ',', 'dtype', '=', 'None', ',', 'name', '=', 'None', ',', 'as_ref', '=', 'False', ')', ':', '# Ignore as_ref to not create backward compatibility issues.', '_', '=', 'name', ',', 'as_ref', 't', '=', 'pt_wrapper', '.', 'tensor', 'if', 'dtype', 'and', 'not', 'dtype', '.'...
Allows PrettyTensors and Loss to work as a tensor.
['Allows', 'PrettyTensors', 'and', 'Loss', 'to', 'work', 'as', 'a', 'tensor', '.']
train
https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/pretty_tensor_class.py#L2016-L2025
9,560
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/BoolVariable.py
_text2bool
def _text2bool(val): """ Converts strings to True/False depending on the 'truth' expressed by the string. If the string can't be converted, the original value will be returned. See '__true_strings' and '__false_strings' for values considered 'true' or 'false respectively. This is usable as...
python
def _text2bool(val): """ Converts strings to True/False depending on the 'truth' expressed by the string. If the string can't be converted, the original value will be returned. See '__true_strings' and '__false_strings' for values considered 'true' or 'false respectively. This is usable as...
['def', '_text2bool', '(', 'val', ')', ':', 'lval', '=', 'val', '.', 'lower', '(', ')', 'if', 'lval', 'in', '__true_strings', ':', 'return', 'True', 'if', 'lval', 'in', '__false_strings', ':', 'return', 'False', 'raise', 'ValueError', '(', '"Invalid value for boolean option: %s"', '%', 'val', ')']
Converts strings to True/False depending on the 'truth' expressed by the string. If the string can't be converted, the original value will be returned. See '__true_strings' and '__false_strings' for values considered 'true' or 'false respectively. This is usable as 'converter' for SCons' Variables...
['Converts', 'strings', 'to', 'True', '/', 'False', 'depending', 'on', 'the', 'truth', 'expressed', 'by', 'the', 'string', '.', 'If', 'the', 'string', 'can', 't', 'be', 'converted', 'the', 'original', 'value', 'will', 'be', 'returned', '.']
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/BoolVariable.py#L47-L61
9,561
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/filter.py
gaussian_filter
def gaussian_filter(data, sigma): """ Drop-in replacement for scipy.ndimage.gaussian_filter. (note: results are only approximately equal to the output of gaussian_filter) """ if np.isscalar(sigma): sigma = (sigma,) * data.ndim baseline = data.mean() filtered = data - baseline ...
python
def gaussian_filter(data, sigma): """ Drop-in replacement for scipy.ndimage.gaussian_filter. (note: results are only approximately equal to the output of gaussian_filter) """ if np.isscalar(sigma): sigma = (sigma,) * data.ndim baseline = data.mean() filtered = data - baseline ...
['def', 'gaussian_filter', '(', 'data', ',', 'sigma', ')', ':', 'if', 'np', '.', 'isscalar', '(', 'sigma', ')', ':', 'sigma', '=', '(', 'sigma', ',', ')', '*', 'data', '.', 'ndim', 'baseline', '=', 'data', '.', 'mean', '(', ')', 'filtered', '=', 'data', '-', 'baseline', 'for', 'ax', 'in', 'range', '(', 'data', '.', 'nd...
Drop-in replacement for scipy.ndimage.gaussian_filter. (note: results are only approximately equal to the output of gaussian_filter)
['Drop', '-', 'in', 'replacement', 'for', 'scipy', '.', 'ndimage', '.', 'gaussian_filter', '.']
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/filter.py#L8-L44
9,562
Fantomas42/django-blog-zinnia
zinnia/templatetags/zinnia.py
get_tag_cloud
def get_tag_cloud(context, steps=6, min_count=None, template='zinnia/tags/tag_cloud.html'): """ Return a cloud of published tags. """ tags = Tag.objects.usage_for_queryset( Entry.published.all(), counts=True, min_count=min_count) return {'template': template, ...
python
def get_tag_cloud(context, steps=6, min_count=None, template='zinnia/tags/tag_cloud.html'): """ Return a cloud of published tags. """ tags = Tag.objects.usage_for_queryset( Entry.published.all(), counts=True, min_count=min_count) return {'template': template, ...
['def', 'get_tag_cloud', '(', 'context', ',', 'steps', '=', '6', ',', 'min_count', '=', 'None', ',', 'template', '=', "'zinnia/tags/tag_cloud.html'", ')', ':', 'tags', '=', 'Tag', '.', 'objects', '.', 'usage_for_queryset', '(', 'Entry', '.', 'published', '.', 'all', '(', ')', ',', 'counts', '=', 'True', ',', 'min_count...
Return a cloud of published tags.
['Return', 'a', 'cloud', 'of', 'published', 'tags', '.']
train
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/templatetags/zinnia.py#L378-L388
9,563
sibirrer/lenstronomy
lenstronomy/LensModel/Profiles/spp.py
SPP.mass_3d
def mass_3d(self, r, rho0, gamma): """ mass enclosed a 3d sphere or radius r :param r: :param a: :param s: :return: """ mass_3d = 4 * np.pi * rho0 /(-gamma + 3) * r ** (-gamma + 3) return mass_3d
python
def mass_3d(self, r, rho0, gamma): """ mass enclosed a 3d sphere or radius r :param r: :param a: :param s: :return: """ mass_3d = 4 * np.pi * rho0 /(-gamma + 3) * r ** (-gamma + 3) return mass_3d
['def', 'mass_3d', '(', 'self', ',', 'r', ',', 'rho0', ',', 'gamma', ')', ':', 'mass_3d', '=', '4', '*', 'np', '.', 'pi', '*', 'rho0', '/', '(', '-', 'gamma', '+', '3', ')', '*', 'r', '**', '(', '-', 'gamma', '+', '3', ')', 'return', 'mass_3d']
mass enclosed a 3d sphere or radius r :param r: :param a: :param s: :return:
['mass', 'enclosed', 'a', '3d', 'sphere', 'or', 'radius', 'r', ':', 'param', 'r', ':', ':', 'param', 'a', ':', ':', 'param', 's', ':', ':', 'return', ':']
train
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L123-L132
9,564
lowandrew/OLCTools
spadespipeline/quality.py
QualityFeatures.find_n50
def find_n50(self): """ Calculate the N50 for each strain. N50 is defined as the largest contig such that at least half of the total genome size is contained in contigs equal to or larger than this contig """ for sample in self.metadata: # Initialise the N50 attribute...
python
def find_n50(self): """ Calculate the N50 for each strain. N50 is defined as the largest contig such that at least half of the total genome size is contained in contigs equal to or larger than this contig """ for sample in self.metadata: # Initialise the N50 attribute...
['def', 'find_n50', '(', 'self', ')', ':', 'for', 'sample', 'in', 'self', '.', 'metadata', ':', '# Initialise the N50 attribute in case there is no assembly, and the attribute is not created in the loop', 'sample', '[', 'self', '.', 'analysistype', ']', '.', 'n50', '=', "'-'", '# Initialise a variable to store a runnin...
Calculate the N50 for each strain. N50 is defined as the largest contig such that at least half of the total genome size is contained in contigs equal to or larger than this contig
['Calculate', 'the', 'N50', 'for', 'each', 'strain', '.', 'N50', 'is', 'defined', 'as', 'the', 'largest', 'contig', 'such', 'that', 'at', 'least', 'half', 'of', 'the', 'total', 'genome', 'size', 'is', 'contained', 'in', 'contigs', 'equal', 'to', 'or', 'larger', 'than', 'this', 'contig']
train
https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/quality.py#L634-L651
9,565
Rediker-Software/doac
doac/views.py
OAuthView.handle_exception
def handle_exception(self, exception): """ Handle a unspecified exception and return the correct method that should be used for handling it. If the exception has the `can_redirect` property set to False, it is rendered to the browser. Otherwise, it will be redirected to the loc...
python
def handle_exception(self, exception): """ Handle a unspecified exception and return the correct method that should be used for handling it. If the exception has the `can_redirect` property set to False, it is rendered to the browser. Otherwise, it will be redirected to the loc...
['def', 'handle_exception', '(', 'self', ',', 'exception', ')', ':', 'can_redirect', '=', 'getattr', '(', 'exception', ',', '"can_redirect"', ',', 'True', ')', 'redirect_uri', '=', 'getattr', '(', 'self', ',', '"redirect_uri"', ',', 'None', ')', 'if', 'can_redirect', 'and', 'redirect_uri', ':', 'return', 'self', '.', '...
Handle a unspecified exception and return the correct method that should be used for handling it. If the exception has the `can_redirect` property set to False, it is rendered to the browser. Otherwise, it will be redirected to the location provided in the `RedirectUri` object that is ...
['Handle', 'a', 'unspecified', 'exception', 'and', 'return', 'the', 'correct', 'method', 'that', 'should', 'be', 'used', 'for', 'handling', 'it', '.']
train
https://github.com/Rediker-Software/doac/blob/398fdd64452e4ff8662297b0381926addd77505a/doac/views.py#L22-L38
9,566
rwl/pylon
pylon/io/excel.py
ExcelWriter.write_branch_data
def write_branch_data(self, file): """ Writes branch data to an Excel spreadsheet. """ branch_sheet = self.book.add_sheet("Branches") for i, branch in enumerate(self.case.branches): for j, attr in enumerate(BRANCH_ATTRS): branch_sheet.write(i, j, getattr(bran...
python
def write_branch_data(self, file): """ Writes branch data to an Excel spreadsheet. """ branch_sheet = self.book.add_sheet("Branches") for i, branch in enumerate(self.case.branches): for j, attr in enumerate(BRANCH_ATTRS): branch_sheet.write(i, j, getattr(bran...
['def', 'write_branch_data', '(', 'self', ',', 'file', ')', ':', 'branch_sheet', '=', 'self', '.', 'book', '.', 'add_sheet', '(', '"Branches"', ')', 'for', 'i', ',', 'branch', 'in', 'enumerate', '(', 'self', '.', 'case', '.', 'branches', ')', ':', 'for', 'j', ',', 'attr', 'in', 'enumerate', '(', 'BRANCH_ATTRS', ')', ':...
Writes branch data to an Excel spreadsheet.
['Writes', 'branch', 'data', 'to', 'an', 'Excel', 'spreadsheet', '.']
train
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L66-L73
9,567
onecodex/onecodex
onecodex/models/collection.py
SampleCollection._collate_results
def _collate_results(self, field=None): """For a list of objects associated with a classification result, return the results as a DataFrame and dict of taxa info. Parameters ---------- field : {'readcount_w_children', 'readcount', 'abundance'} Which field to use for ...
python
def _collate_results(self, field=None): """For a list of objects associated with a classification result, return the results as a DataFrame and dict of taxa info. Parameters ---------- field : {'readcount_w_children', 'readcount', 'abundance'} Which field to use for ...
['def', '_collate_results', '(', 'self', ',', 'field', '=', 'None', ')', ':', 'import', 'pandas', 'as', 'pd', 'field', '=', 'field', 'if', 'field', 'else', 'self', '.', '_kwargs', '[', '"field"', ']', 'if', 'field', 'not', 'in', '(', '"auto"', ',', '"abundance"', ',', '"readcount"', ',', '"readcount_w_children"', ')', ...
For a list of objects associated with a classification result, return the results as a DataFrame and dict of taxa info. Parameters ---------- field : {'readcount_w_children', 'readcount', 'abundance'} Which field to use for the abundance/count of a particular taxon in a samp...
['For', 'a', 'list', 'of', 'objects', 'associated', 'with', 'a', 'classification', 'result', 'return', 'the', 'results', 'as', 'a', 'DataFrame', 'and', 'dict', 'of', 'taxa', 'info', '.']
train
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L212-L271
9,568
fulfilio/python-magento
magento/sales.py
CreditMemo.addcomment
def addcomment(self, creditmemo_increment_id, comment, email=True, include_in_email=False): """ Add new comment to credit memo :param creditmemo_increment_id: Credit memo increment ID :return: bool """ return bool( self.call( 'sal...
python
def addcomment(self, creditmemo_increment_id, comment, email=True, include_in_email=False): """ Add new comment to credit memo :param creditmemo_increment_id: Credit memo increment ID :return: bool """ return bool( self.call( 'sal...
['def', 'addcomment', '(', 'self', ',', 'creditmemo_increment_id', ',', 'comment', ',', 'email', '=', 'True', ',', 'include_in_email', '=', 'False', ')', ':', 'return', 'bool', '(', 'self', '.', 'call', '(', "'sales_order_creditmemo.addComment'", ',', '[', 'creditmemo_increment_id', ',', 'comment', ',', 'email', ',', '...
Add new comment to credit memo :param creditmemo_increment_id: Credit memo increment ID :return: bool
['Add', 'new', 'comment', 'to', 'credit', 'memo']
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L201-L215
9,569
sbarham/dsrt
build/lib/dsrt/application/Application.py
Application.load_corpus
def load_corpus(self, path, config): '''Load a dialogue corpus; eventually, support pickles and potentially other formats''' # use the default dataset if no path is provided # TODO -- change this to use a pre-saved dataset if path == '': path = self.default_path_to_corpus ...
python
def load_corpus(self, path, config): '''Load a dialogue corpus; eventually, support pickles and potentially other formats''' # use the default dataset if no path is provided # TODO -- change this to use a pre-saved dataset if path == '': path = self.default_path_to_corpus ...
['def', 'load_corpus', '(', 'self', ',', 'path', ',', 'config', ')', ':', '# use the default dataset if no path is provided', '# TODO -- change this to use a pre-saved dataset', 'if', 'path', '==', "''", ':', 'path', '=', 'self', '.', 'default_path_to_corpus', 'self', '.', 'data', '=', 'Corpus', '(', 'path', '=', 'path...
Load a dialogue corpus; eventually, support pickles and potentially other formats
['Load', 'a', 'dialogue', 'corpus', ';', 'eventually', 'support', 'pickles', 'and', 'potentially', 'other', 'formats']
train
https://github.com/sbarham/dsrt/blob/bc664739f2f52839461d3e72773b71146fd56a9a/build/lib/dsrt/application/Application.py#L197-L205
9,570
sebp/scikit-survival
sksurv/svm/survival_svm.py
FastKernelSurvivalSVM.predict
def predict(self, X): """Rank samples according to survival times Lower ranks indicate shorter survival, higher ranks longer survival. Parameters ---------- X : array-like, shape = (n_samples, n_features) The input samples. Returns ------- y...
python
def predict(self, X): """Rank samples according to survival times Lower ranks indicate shorter survival, higher ranks longer survival. Parameters ---------- X : array-like, shape = (n_samples, n_features) The input samples. Returns ------- y...
['def', 'predict', '(', 'self', ',', 'X', ')', ':', 'kernel_mat', '=', 'self', '.', '_get_kernel', '(', 'X', ',', 'self', '.', 'fit_X_', ')', 'val', '=', 'numpy', '.', 'dot', '(', 'kernel_mat', ',', 'self', '.', 'coef_', ')', 'if', 'hasattr', '(', 'self', ',', '"intercept_"', ')', ':', 'val', '+=', 'self', '.', 'interc...
Rank samples according to survival times Lower ranks indicate shorter survival, higher ranks longer survival. Parameters ---------- X : array-like, shape = (n_samples, n_features) The input samples. Returns ------- y : ndarray, shape = (n_samples,) ...
['Rank', 'samples', 'according', 'to', 'survival', 'times']
train
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/svm/survival_svm.py#L1000-L1028
9,571
StanfordVL/robosuite
robosuite/environments/sawyer.py
SawyerEnv._get_reference
def _get_reference(self): """ Sets up necessary reference for robots, grippers, and objects. """ super()._get_reference() # indices for joints in qpos, qvel self.robot_joints = list(self.mujoco_robot.joints) self._ref_joint_pos_indexes = [ self.sim.mo...
python
def _get_reference(self): """ Sets up necessary reference for robots, grippers, and objects. """ super()._get_reference() # indices for joints in qpos, qvel self.robot_joints = list(self.mujoco_robot.joints) self._ref_joint_pos_indexes = [ self.sim.mo...
['def', '_get_reference', '(', 'self', ')', ':', 'super', '(', ')', '.', '_get_reference', '(', ')', '# indices for joints in qpos, qvel', 'self', '.', 'robot_joints', '=', 'list', '(', 'self', '.', 'mujoco_robot', '.', 'joints', ')', 'self', '.', '_ref_joint_pos_indexes', '=', '[', 'self', '.', 'sim', '.', 'model', '....
Sets up necessary reference for robots, grippers, and objects.
['Sets', 'up', 'necessary', 'reference', 'for', 'robots', 'grippers', 'and', 'objects', '.']
train
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/sawyer.py#L118-L174
9,572
praekeltfoundation/molo
molo/core/utils.py
attach_image
def attach_image(field, nested_fields, page, record_keeper=None): ''' Returns a function that attaches an image to page if it exists Currenlty assumes that images have already been imported and info has been stored in record_keeper ''' if (field in nested_fields) and nested_fields[field]: ...
python
def attach_image(field, nested_fields, page, record_keeper=None): ''' Returns a function that attaches an image to page if it exists Currenlty assumes that images have already been imported and info has been stored in record_keeper ''' if (field in nested_fields) and nested_fields[field]: ...
['def', 'attach_image', '(', 'field', ',', 'nested_fields', ',', 'page', ',', 'record_keeper', '=', 'None', ')', ':', 'if', '(', 'field', 'in', 'nested_fields', ')', 'and', 'nested_fields', '[', 'field', ']', ':', 'foreign_image_id', '=', 'nested_fields', '[', 'field', ']', '[', '"id"', ']', '# Handle the following', '...
Returns a function that attaches an image to page if it exists Currenlty assumes that images have already been imported and info has been stored in record_keeper
['Returns', 'a', 'function', 'that', 'attaches', 'an', 'image', 'to', 'page', 'if', 'it', 'exists']
train
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/utils.py#L295-L323
9,573
CamDavidsonPilon/lifetimes
lifetimes/plotting.py
plot_frequency_recency_matrix
def plot_frequency_recency_matrix( model, T=1, max_frequency=None, max_recency=None, title=None, xlabel="Customer's Historical Frequency", ylabel="Customer's Recency", **kwargs ): """ Plot recency frequecy matrix as heatmap. Plot a figure of expected transactions in T next u...
python
def plot_frequency_recency_matrix( model, T=1, max_frequency=None, max_recency=None, title=None, xlabel="Customer's Historical Frequency", ylabel="Customer's Recency", **kwargs ): """ Plot recency frequecy matrix as heatmap. Plot a figure of expected transactions in T next u...
['def', 'plot_frequency_recency_matrix', '(', 'model', ',', 'T', '=', '1', ',', 'max_frequency', '=', 'None', ',', 'max_recency', '=', 'None', ',', 'title', '=', 'None', ',', 'xlabel', '=', '"Customer\'s Historical Frequency"', ',', 'ylabel', '=', '"Customer\'s Recency"', ',', '*', '*', 'kwargs', ')', ':', 'from', 'mat...
Plot recency frequecy matrix as heatmap. Plot a figure of expected transactions in T next units of time by a customer's frequency and recency. Parameters ---------- model: lifetimes model A fitted lifetimes model. T: fload, optional Next units of time to make predictions for ma...
['Plot', 'recency', 'frequecy', 'matrix', 'as', 'heatmap', '.']
train
https://github.com/CamDavidsonPilon/lifetimes/blob/f926308bc03c17c1d12fead729de43885cf13321/lifetimes/plotting.py#L136-L208
9,574
PBR/MQ2
MQ2/add_qtl_to_map.py
add_qtl_to_map
def add_qtl_to_map(qtlfile, mapfile, outputfile='map_with_qtls.csv'): """ This function adds to a genetic map for each marker the number of significant QTLs found. :arg qtlfile, the output from MapQTL transformed to a csv file via 'parse_mapqtl_file' which contains the closest markers. :arg map...
python
def add_qtl_to_map(qtlfile, mapfile, outputfile='map_with_qtls.csv'): """ This function adds to a genetic map for each marker the number of significant QTLs found. :arg qtlfile, the output from MapQTL transformed to a csv file via 'parse_mapqtl_file' which contains the closest markers. :arg map...
['def', 'add_qtl_to_map', '(', 'qtlfile', ',', 'mapfile', ',', 'outputfile', '=', "'map_with_qtls.csv'", ')', ':', 'qtl_list', '=', 'read_input_file', '(', 'qtlfile', ',', "','", ')', 'map_list', '=', 'read_input_file', '(', 'mapfile', ',', "','", ')', 'map_list', '[', '0', ']', '.', 'append', '(', "'# QTLs'", ')', 'ma...
This function adds to a genetic map for each marker the number of significant QTLs found. :arg qtlfile, the output from MapQTL transformed to a csv file via 'parse_mapqtl_file' which contains the closest markers. :arg mapfile, the genetic map with all the markers. :kwarg outputfile, the name of...
['This', 'function', 'adds', 'to', 'a', 'genetic', 'map', 'for', 'each', 'marker', 'the', 'number', 'of', 'significant', 'QTLs', 'found', '.']
train
https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/add_qtl_to_map.py#L54-L76
9,575
HumanCellAtlas/dcp-cli
hca/dss/__init__.py
DSSClient.download
def download(self, bundle_uuid, replica, version="", download_dir="", metadata_files=('*',), data_files=('*',), num_retries=10, min_delay_seconds=0.25): """ Download a bundle and save it to the local filesystem as a directory. :param str bundle_uuid: The uuid o...
python
def download(self, bundle_uuid, replica, version="", download_dir="", metadata_files=('*',), data_files=('*',), num_retries=10, min_delay_seconds=0.25): """ Download a bundle and save it to the local filesystem as a directory. :param str bundle_uuid: The uuid o...
['def', 'download', '(', 'self', ',', 'bundle_uuid', ',', 'replica', ',', 'version', '=', '""', ',', 'download_dir', '=', '""', ',', 'metadata_files', '=', '(', "'*'", ',', ')', ',', 'data_files', '=', '(', "'*'", ',', ')', ',', 'num_retries', '=', '10', ',', 'min_delay_seconds', '=', '0.25', ')', ':', 'errors', '=', '...
Download a bundle and save it to the local filesystem as a directory. :param str bundle_uuid: The uuid of the bundle to download :param str replica: the replica to download from. The supported replicas are: `aws` for Amazon Web Services, and `gcp` for Google Cloud Platform. [aws, gcp] ...
['Download', 'a', 'bundle', 'and', 'save', 'it', 'to', 'the', 'local', 'filesystem', 'as', 'a', 'directory', '.']
train
https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/__init__.py#L87-L140
9,576
dswah/pyGAM
pygam/utils.py
check_y
def check_y(y, link, dist, min_samples=1, verbose=True): """ tool to ensure that the targets: - are in the domain of the link function - are numerical - have at least min_samples - is finite Parameters ---------- y : array-like link : Link object dist : Distribution object ...
python
def check_y(y, link, dist, min_samples=1, verbose=True): """ tool to ensure that the targets: - are in the domain of the link function - are numerical - have at least min_samples - is finite Parameters ---------- y : array-like link : Link object dist : Distribution object ...
['def', 'check_y', '(', 'y', ',', 'link', ',', 'dist', ',', 'min_samples', '=', '1', ',', 'verbose', '=', 'True', ')', ':', 'y', '=', 'np', '.', 'ravel', '(', 'y', ')', 'y', '=', 'check_array', '(', 'y', ',', 'force_2d', '=', 'False', ',', 'min_samples', '=', 'min_samples', ',', 'ndim', '=', '1', ',', 'name', '=', "'y ...
tool to ensure that the targets: - are in the domain of the link function - are numerical - have at least min_samples - is finite Parameters ---------- y : array-like link : Link object dist : Distribution object min_samples : int, default: 1 verbose : bool, default: True ...
['tool', 'to', 'ensure', 'that', 'the', 'targets', ':', '-', 'are', 'in', 'the', 'domain', 'of', 'the', 'link', 'function', '-', 'are', 'numerical', '-', 'have', 'at', 'least', 'min_samples', '-', 'is', 'finite']
train
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L195-L230
9,577
maas/python-libmaas
maas/client/facade.py
facade
def facade(factory): """Declare a method as a facade factory.""" wrapper = FacadeDescriptor(factory.__name__, factory) return update_wrapper(wrapper, factory)
python
def facade(factory): """Declare a method as a facade factory.""" wrapper = FacadeDescriptor(factory.__name__, factory) return update_wrapper(wrapper, factory)
['def', 'facade', '(', 'factory', ')', ':', 'wrapper', '=', 'FacadeDescriptor', '(', 'factory', '.', '__name__', ',', 'factory', ')', 'return', 'update_wrapper', '(', 'wrapper', ',', 'factory', ')']
Declare a method as a facade factory.
['Declare', 'a', 'method', 'as', 'a', 'facade', 'factory', '.']
train
https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/facade.py#L61-L64
9,578
ParthKolekar/django-answerdiff
answerdiff/models.py
question_image_filepath
def question_image_filepath(instance, filename): """ Function DocString """ return '/'.join(['images', str(instance.question_level), str(instance.question_level_id), binascii.b2a_hex(os.urandom(15)), filename])
python
def question_image_filepath(instance, filename): """ Function DocString """ return '/'.join(['images', str(instance.question_level), str(instance.question_level_id), binascii.b2a_hex(os.urandom(15)), filename])
['def', 'question_image_filepath', '(', 'instance', ',', 'filename', ')', ':', 'return', "'/'", '.', 'join', '(', '[', "'images'", ',', 'str', '(', 'instance', '.', 'question_level', ')', ',', 'str', '(', 'instance', '.', 'question_level_id', ')', ',', 'binascii', '.', 'b2a_hex', '(', 'os', '.', 'urandom', '(', '15', '...
Function DocString
['Function', 'DocString']
train
https://github.com/ParthKolekar/django-answerdiff/blob/af4dd31db04431e76384581c3d6c8fbdfba0faf9/answerdiff/models.py#L13-L17
9,579
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/tiger.py
TigerSentenceGraph.__repair_unconnected_nodes
def __repair_unconnected_nodes(self): """ Adds a (``dominance_relation``) edge from the sentence root node to all previously unconnected nodes (token nodes, that either represent a punctuation mark or are part of a headline 'sentence' that has no full syntax structure annotation)...
python
def __repair_unconnected_nodes(self): """ Adds a (``dominance_relation``) edge from the sentence root node to all previously unconnected nodes (token nodes, that either represent a punctuation mark or are part of a headline 'sentence' that has no full syntax structure annotation)...
['def', '__repair_unconnected_nodes', '(', 'self', ')', ':', 'unconnected_node_ids', '=', 'get_unconnected_nodes', '(', 'self', ')', 'if', 'dg', '.', 'istoken', '(', 'self', ',', 'self', '.', 'root', ')', ':', '# This sentence has no hierarchical structure, i.e. the root', '# node is also a terminal / token node.', '# ...
Adds a (``dominance_relation``) edge from the sentence root node to all previously unconnected nodes (token nodes, that either represent a punctuation mark or are part of a headline 'sentence' that has no full syntax structure annotation).
['Adds', 'a', '(', 'dominance_relation', ')', 'edge', 'from', 'the', 'sentence', 'root', 'node', 'to', 'all', 'previously', 'unconnected', 'nodes', '(', 'token', 'nodes', 'that', 'either', 'represent', 'a', 'punctuation', 'mark', 'or', 'are', 'part', 'of', 'a', 'headline', 'sentence', 'that', 'has', 'no', 'full', 'synt...
train
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tiger.py#L266-L287
9,580
nugget/python-insteonplm
insteonplm/messages/standardSend.py
StandardSend.from_raw_message
def from_raw_message(cls, rawmessage): """Create a message from a raw byte stream.""" if (rawmessage[5] & MESSAGE_FLAG_EXTENDED_0X10) == MESSAGE_FLAG_EXTENDED_0X10: if len(rawmessage) >= ExtendedSend.receivedSize: msg = ExtendedSend.from_raw_message(rawmessage...
python
def from_raw_message(cls, rawmessage): """Create a message from a raw byte stream.""" if (rawmessage[5] & MESSAGE_FLAG_EXTENDED_0X10) == MESSAGE_FLAG_EXTENDED_0X10: if len(rawmessage) >= ExtendedSend.receivedSize: msg = ExtendedSend.from_raw_message(rawmessage...
['def', 'from_raw_message', '(', 'cls', ',', 'rawmessage', ')', ':', 'if', '(', 'rawmessage', '[', '5', ']', '&', 'MESSAGE_FLAG_EXTENDED_0X10', ')', '==', 'MESSAGE_FLAG_EXTENDED_0X10', ':', 'if', 'len', '(', 'rawmessage', ')', '>=', 'ExtendedSend', '.', 'receivedSize', ':', 'msg', '=', 'ExtendedSend', '.', 'from_raw_me...
Create a message from a raw byte stream.
['Create', 'a', 'message', 'from', 'a', 'raw', 'byte', 'stream', '.']
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/standardSend.py#L47-L61
9,581
modin-project/modin
modin/experimental/engines/pandas_on_ray/sql.py
is_distributed
def is_distributed(partition_column, lower_bound, upper_bound): """ Check if is possible distribute a query given that args Args: partition_column: column used to share the data between the workers lower_bound: the minimum value to be requested from the partition_column upper_bound: the...
python
def is_distributed(partition_column, lower_bound, upper_bound): """ Check if is possible distribute a query given that args Args: partition_column: column used to share the data between the workers lower_bound: the minimum value to be requested from the partition_column upper_bound: the...
['def', 'is_distributed', '(', 'partition_column', ',', 'lower_bound', ',', 'upper_bound', ')', ':', 'if', '(', '(', 'partition_column', 'is', 'not', 'None', ')', 'and', '(', 'lower_bound', 'is', 'not', 'None', ')', 'and', '(', 'upper_bound', 'is', 'not', 'None', ')', ')', ':', 'if', 'upper_bound', '>', 'lower_bound', ...
Check if is possible distribute a query given that args Args: partition_column: column used to share the data between the workers lower_bound: the minimum value to be requested from the partition_column upper_bound: the maximum value to be requested from the partition_column Returns: ...
['Check', 'if', 'is', 'possible', 'distribute', 'a', 'query', 'given', 'that', 'args']
train
https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/experimental/engines/pandas_on_ray/sql.py#L5-L31
9,582
pgxcentre/geneparse
geneparse/extract/__main__.py
vcf_writer
def vcf_writer(parser, keep, extract, args): """Writes the data in VCF format.""" # The output output = sys.stdout if args.output == "-" else open(args.output, "w") try: # Getting the samples samples = np.array(parser.get_samples(), dtype=str) k = _get_sample_select(samples=samp...
python
def vcf_writer(parser, keep, extract, args): """Writes the data in VCF format.""" # The output output = sys.stdout if args.output == "-" else open(args.output, "w") try: # Getting the samples samples = np.array(parser.get_samples(), dtype=str) k = _get_sample_select(samples=samp...
['def', 'vcf_writer', '(', 'parser', ',', 'keep', ',', 'extract', ',', 'args', ')', ':', '# The output', 'output', '=', 'sys', '.', 'stdout', 'if', 'args', '.', 'output', '==', '"-"', 'else', 'open', '(', 'args', '.', 'output', ',', '"w"', ')', 'try', ':', '# Getting the samples', 'samples', '=', 'np', '.', 'array', '(...
Writes the data in VCF format.
['Writes', 'the', 'data', 'in', 'VCF', 'format', '.']
train
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L133-L184
9,583
yvesalexandre/bandicoot
bandicoot/network.py
network_sampling
def network_sampling(n, filename, directory=None, snowball=False, user=None): """ Selects a few users and exports a CSV of indicators for them. TODO: Returns the network/graph between the selected users. Parameters ---------- n : int Number of users to select. filename : string ...
python
def network_sampling(n, filename, directory=None, snowball=False, user=None): """ Selects a few users and exports a CSV of indicators for them. TODO: Returns the network/graph between the selected users. Parameters ---------- n : int Number of users to select. filename : string ...
['def', 'network_sampling', '(', 'n', ',', 'filename', ',', 'directory', '=', 'None', ',', 'snowball', '=', 'False', ',', 'user', '=', 'None', ')', ':', 'if', 'snowball', ':', 'if', 'user', 'is', 'None', ':', 'raise', 'ValueError', '(', '"Must specify a starting user from whom to initiate the snowball"', ')', 'else', '...
Selects a few users and exports a CSV of indicators for them. TODO: Returns the network/graph between the selected users. Parameters ---------- n : int Number of users to select. filename : string File to export to. directory: string Directory to select users from if us...
['Selects', 'a', 'few', 'users', 'and', 'exports', 'a', 'CSV', 'of', 'indicators', 'for', 'them', '.']
train
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/network.py#L317-L355
9,584
3ll3d00d/vibe
backend/src/analyser/common/measurementcontroller.py
MeasurementController._deleteCompletedMeasurement
def _deleteCompletedMeasurement(self, measurementId): """ Deletes the named measurement from the completed measurement store if it exists. :param measurementId: :return: String: error messages Integer: count of measurements deleted """ message, cou...
python
def _deleteCompletedMeasurement(self, measurementId): """ Deletes the named measurement from the completed measurement store if it exists. :param measurementId: :return: String: error messages Integer: count of measurements deleted """ message, cou...
['def', '_deleteCompletedMeasurement', '(', 'self', ',', 'measurementId', ')', ':', 'message', ',', 'count', ',', 'deleted', '=', 'self', '.', 'deleteFrom', '(', 'measurementId', ',', 'self', '.', 'completeMeasurements', ')', 'if', 'count', 'is', '0', ':', 'message', ',', 'count', ',', 'deleted', '=', 'self', '.', 'del...
Deletes the named measurement from the completed measurement store if it exists. :param measurementId: :return: String: error messages Integer: count of measurements deleted
['Deletes', 'the', 'named', 'measurement', 'from', 'the', 'completed', 'measurement', 'store', 'if', 'it', 'exists', '.', ':', 'param', 'measurementId', ':', ':', 'return', ':', 'String', ':', 'error', 'messages', 'Integer', ':', 'count', 'of', 'measurements', 'deleted']
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L434-L445
9,585
python-diamond/Diamond
src/collectors/tokumx/tokumx.py
TokuMXCollector._publish_metrics
def _publish_metrics(self, prev_keys, key, data, publishfn=None): """Recursively publish keys""" if key not in data: return value = data[key] keys = prev_keys + [key] if not publishfn: publishfn = self.publish if isinstance(value, dict): ...
python
def _publish_metrics(self, prev_keys, key, data, publishfn=None): """Recursively publish keys""" if key not in data: return value = data[key] keys = prev_keys + [key] if not publishfn: publishfn = self.publish if isinstance(value, dict): ...
['def', '_publish_metrics', '(', 'self', ',', 'prev_keys', ',', 'key', ',', 'data', ',', 'publishfn', '=', 'None', ')', ':', 'if', 'key', 'not', 'in', 'data', ':', 'return', 'value', '=', 'data', '[', 'key', ']', 'keys', '=', 'prev_keys', '+', '[', 'key', ']', 'if', 'not', 'publishfn', ':', 'publishfn', '=', 'self', '....
Recursively publish keys
['Recursively', 'publish', 'keys']
train
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/tokumx/tokumx.py#L251-L265
9,586
wmayner/pyphi
pyphi/macro.py
all_groupings
def all_groupings(partition): """Return all possible groupings of states for a particular coarse graining (partition) of a network. Args: partition (tuple[tuple]): A partition of micro-elements into macro elements. Yields: tuple[tuple[tuple]]: A grouping of micro-states int...
python
def all_groupings(partition): """Return all possible groupings of states for a particular coarse graining (partition) of a network. Args: partition (tuple[tuple]): A partition of micro-elements into macro elements. Yields: tuple[tuple[tuple]]: A grouping of micro-states int...
['def', 'all_groupings', '(', 'partition', ')', ':', 'if', 'not', 'all', '(', 'partition', ')', ':', 'raise', 'ValueError', '(', "'Each part of the partition must have at least one '", "'element.'", ')', 'micro_groupings', '=', '[', '_partitions_list', '(', 'len', '(', 'part', ')', '+', '1', ')', 'if', 'len', '(', 'par...
Return all possible groupings of states for a particular coarse graining (partition) of a network. Args: partition (tuple[tuple]): A partition of micro-elements into macro elements. Yields: tuple[tuple[tuple]]: A grouping of micro-states into macro states of system. ...
['Return', 'all', 'possible', 'groupings', 'of', 'states', 'for', 'a', 'particular', 'coarse', 'graining', '(', 'partition', ')', 'of', 'a', 'network', '.']
train
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L707-L731
9,587
heikomuller/sco-datastore
scodata/experiment.py
DefaultExperimentManager.to_dict
def to_dict(self, experiment): """Create a Json-like object for an experiment. Extends the basic object with subject, image group, and (optional) functional data identifiers. Parameters ---------- experiment : ExperimentHandle Returns ------- Jso...
python
def to_dict(self, experiment): """Create a Json-like object for an experiment. Extends the basic object with subject, image group, and (optional) functional data identifiers. Parameters ---------- experiment : ExperimentHandle Returns ------- Jso...
['def', 'to_dict', '(', 'self', ',', 'experiment', ')', ':', '# Get the basic Json object from the super class', 'json_obj', '=', 'super', '(', 'DefaultExperimentManager', ',', 'self', ')', '.', 'to_dict', '(', 'experiment', ')', '# Add associated object references', 'json_obj', '[', "'subject'", ']', '=', 'experiment'...
Create a Json-like object for an experiment. Extends the basic object with subject, image group, and (optional) functional data identifiers. Parameters ---------- experiment : ExperimentHandle Returns ------- Json Object Json-like object, i.e...
['Create', 'a', 'Json', '-', 'like', 'object', 'for', 'an', 'experiment', '.', 'Extends', 'the', 'basic', 'object', 'with', 'subject', 'image', 'group', 'and', '(', 'optional', ')', 'functional', 'data', 'identifiers', '.']
train
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/experiment.py#L226-L247
9,588
zerwes/hiyapyco
hiyapyco/odyldo.py
safe_dump
def safe_dump(data, stream=None, **kwds): """implementation of safe dumper using Ordered Dict Yaml Dumper""" return yaml.dump(data, stream=stream, Dumper=ODYD, **kwds)
python
def safe_dump(data, stream=None, **kwds): """implementation of safe dumper using Ordered Dict Yaml Dumper""" return yaml.dump(data, stream=stream, Dumper=ODYD, **kwds)
['def', 'safe_dump', '(', 'data', ',', 'stream', '=', 'None', ',', '*', '*', 'kwds', ')', ':', 'return', 'yaml', '.', 'dump', '(', 'data', ',', 'stream', '=', 'stream', ',', 'Dumper', '=', 'ODYD', ',', '*', '*', 'kwds', ')']
implementation of safe dumper using Ordered Dict Yaml Dumper
['implementation', 'of', 'safe', 'dumper', 'using', 'Ordered', 'Dict', 'Yaml', 'Dumper']
train
https://github.com/zerwes/hiyapyco/blob/b0b42724cc13b1412f5bb5d92fd4c637d6615edb/hiyapyco/odyldo.py#L76-L78
9,589
dls-controls/pymalcolm
malcolm/core/loggable.py
Loggable.set_logger
def set_logger(self, **fields): """Change the name of the logger that log.* should call Args: **fields: Extra fields to be logged. Logger name will be: ".".join([<module_name>, <cls_name>] + fields_sorted_on_key) """ names = [self.__module__, self.__class__._...
python
def set_logger(self, **fields): """Change the name of the logger that log.* should call Args: **fields: Extra fields to be logged. Logger name will be: ".".join([<module_name>, <cls_name>] + fields_sorted_on_key) """ names = [self.__module__, self.__class__._...
['def', 'set_logger', '(', 'self', ',', '*', '*', 'fields', ')', ':', 'names', '=', '[', 'self', '.', '__module__', ',', 'self', '.', '__class__', '.', '__name__', ']', 'for', 'field', ',', 'value', 'in', 'sorted', '(', 'fields', '.', 'items', '(', ')', ')', ':', 'names', '.', 'append', '(', 'value', ')', '# names shou...
Change the name of the logger that log.* should call Args: **fields: Extra fields to be logged. Logger name will be: ".".join([<module_name>, <cls_name>] + fields_sorted_on_key)
['Change', 'the', 'name', 'of', 'the', 'logger', 'that', 'log', '.', '*', 'should', 'call']
train
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/loggable.py#L20-L36
9,590
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.set_callbacks
def set_callbacks(self, worker_start_callback: callable, worker_end_callback: callable, are_async: bool = False): """ :param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread. """ # We are setting self.worker_start_callback and self.worker_...
python
def set_callbacks(self, worker_start_callback: callable, worker_end_callback: callable, are_async: bool = False): """ :param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread. """ # We are setting self.worker_start_callback and self.worker_...
['def', 'set_callbacks', '(', 'self', ',', 'worker_start_callback', ':', 'callable', ',', 'worker_end_callback', ':', 'callable', ',', 'are_async', ':', 'bool', '=', 'False', ')', ':', '# We are setting self.worker_start_callback and self.worker_end_callback', '# to lambdas instead of saving them in private vars and mo...
:param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread.
[':', 'param', 'are_async', ':', 'True', 'if', 'the', 'callbacks', 'execute', 'asynchronously', 'posting', 'any', 'heavy', 'work', 'to', 'another', 'thread', '.']
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L59-L80
9,591
emc-openstack/storops
storops/unity/resource/port.py
UnityIpPort.get_physical_port
def get_physical_port(self): """Returns the link aggregation object or the ethernet port object.""" obj = None if self.is_link_aggregation(): obj = UnityLinkAggregation.get(self._cli, self.get_id()) else: obj = UnityEthernetPort.get(self._cli, self.get_id()) ...
python
def get_physical_port(self): """Returns the link aggregation object or the ethernet port object.""" obj = None if self.is_link_aggregation(): obj = UnityLinkAggregation.get(self._cli, self.get_id()) else: obj = UnityEthernetPort.get(self._cli, self.get_id()) ...
['def', 'get_physical_port', '(', 'self', ')', ':', 'obj', '=', 'None', 'if', 'self', '.', 'is_link_aggregation', '(', ')', ':', 'obj', '=', 'UnityLinkAggregation', '.', 'get', '(', 'self', '.', '_cli', ',', 'self', '.', 'get_id', '(', ')', ')', 'else', ':', 'obj', '=', 'UnityEthernetPort', '.', 'get', '(', 'self', '.'...
Returns the link aggregation object or the ethernet port object.
['Returns', 'the', 'link', 'aggregation', 'object', 'or', 'the', 'ethernet', 'port', 'object', '.']
train
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/unity/resource/port.py#L51-L58
9,592
mitsei/dlkit
dlkit/handcar/repository/managers.py
RepositoryProxyManager.get_asset_notification_session
def get_asset_notification_session(self, asset_receiver, proxy): """Gets the notification session for notifications pertaining to asset changes. arg: asset_receiver (osid.repository.AssetReceiver): the notification callback arg proxy (osid.proxy.Proxy): a proxy ...
python
def get_asset_notification_session(self, asset_receiver, proxy): """Gets the notification session for notifications pertaining to asset changes. arg: asset_receiver (osid.repository.AssetReceiver): the notification callback arg proxy (osid.proxy.Proxy): a proxy ...
['def', 'get_asset_notification_session', '(', 'self', ',', 'asset_receiver', ',', 'proxy', ')', ':', 'if', 'asset_receiver', 'is', 'None', ':', 'raise', 'NullArgument', '(', ')', 'if', 'not', 'self', '.', 'supports_asset_notification', '(', ')', ':', 'raise', 'Unimplemented', '(', ')', 'try', ':', 'from', '.', 'import...
Gets the notification session for notifications pertaining to asset changes. arg: asset_receiver (osid.repository.AssetReceiver): the notification callback arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.AssetNotificationSession) - an ...
['Gets', 'the', 'notification', 'session', 'for', 'notifications', 'pertaining', 'to', 'asset', 'changes', '.']
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/managers.py#L2156-L2185
9,593
4Catalyzer/flask-resty
flask_resty/api.py
Api.add_resource
def add_resource( self, base_rule, base_view, alternate_view=None, alternate_rule=None, id_rule=None, app=None, ): """Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by...
python
def add_resource( self, base_rule, base_view, alternate_view=None, alternate_rule=None, id_rule=None, app=None, ): """Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by...
['def', 'add_resource', '(', 'self', ',', 'base_rule', ',', 'base_view', ',', 'alternate_view', '=', 'None', ',', 'alternate_rule', '=', 'None', ',', 'id_rule', '=', 'None', ',', 'app', '=', 'None', ',', ')', ':', 'if', 'alternate_view', ':', 'if', 'not', 'alternate_rule', ':', 'id_rule', '=', 'id_rule', 'or', 'DEFAULT...
Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by the API prefix. :param base_view: Class-based view for the resource. :param alternate_view: If specified, an alternate class-based view for the resource. Usu...
['Add', 'route', 'or', 'routes', 'for', 'a', 'resource', '.']
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/api.py#L61-L137
9,594
estnltk/estnltk
estnltk/mw_verbs/basic_verbchain_detection.py
_isVerbExpansible
def _isVerbExpansible( verbObj, clauseTokens, clauseID ): ''' Kontrollib, kas tavaline verb on laiendatav etteantud osalauses: *) verbi kontekstis (osalauses) on veel teisi verbe; *) verb kuulub etteantud osalausesse; *) tegemist ei ole olema-verbiga (neid vaatame mujal e...
python
def _isVerbExpansible( verbObj, clauseTokens, clauseID ): ''' Kontrollib, kas tavaline verb on laiendatav etteantud osalauses: *) verbi kontekstis (osalauses) on veel teisi verbe; *) verb kuulub etteantud osalausesse; *) tegemist ei ole olema-verbiga (neid vaatame mujal e...
['def', '_isVerbExpansible', '(', 'verbObj', ',', 'clauseTokens', ',', 'clauseID', ')', ':', 'global', '_verbInfNonExpansible', '# Leiame, kas fraas kuulub antud osalausesse ning on laiendatav\r', 'if', 'verbObj', '[', 'OTHER_VERBS', ']', 'and', 'verbObj', '[', 'CLAUSE_IDX', ']', '==', 'clauseID', 'and', 're', '.', 'ma...
Kontrollib, kas tavaline verb on laiendatav etteantud osalauses: *) verbi kontekstis (osalauses) on veel teisi verbe; *) verb kuulub etteantud osalausesse; *) tegemist ei ole olema-verbiga (neid vaatame mujal eraldi); *) tegemist pole maks|mas|mast|mata-verbiga; *)...
['Kontrollib', 'kas', 'tavaline', 'verb', 'on', 'laiendatav', 'etteantud', 'osalauses', ':', '*', ')', 'verbi', 'kontekstis', '(', 'osalauses', ')', 'on', 'veel', 'teisi', 'verbe', ';', '*', ')', 'verb', 'kuulub', 'etteantud', 'osalausesse', ';', '*', ')', 'tegemist', 'ei', 'ole', 'olema', '-', 'verbiga', '(', 'neid', ...
train
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L1015-L1050
9,595
titusjan/argos
argos/inspector/debug.py
DebugInspector._createConfig
def _createConfig(self): """ Creates a config tree item (CTI) hierarchy containing default children. """ rootItem = MainGroupCti('debug inspector') if DEBUGGING: # Some test config items. import numpy as np from argos.config.untypedcti import UntypedC...
python
def _createConfig(self): """ Creates a config tree item (CTI) hierarchy containing default children. """ rootItem = MainGroupCti('debug inspector') if DEBUGGING: # Some test config items. import numpy as np from argos.config.untypedcti import UntypedC...
['def', '_createConfig', '(', 'self', ')', ':', 'rootItem', '=', 'MainGroupCti', '(', "'debug inspector'", ')', 'if', 'DEBUGGING', ':', '# Some test config items.', 'import', 'numpy', 'as', 'np', 'from', 'argos', '.', 'config', '.', 'untypedcti', 'import', 'UntypedCti', 'from', 'argos', '.', 'config', '.', 'stringcti',...
Creates a config tree item (CTI) hierarchy containing default children.
['Creates', 'a', 'config', 'tree', 'item', '(', 'CTI', ')', 'hierarchy', 'containing', 'default', 'children', '.']
train
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/debug.py#L52-L95
9,596
BerkeleyAutomation/autolab_core
autolab_core/tensor_dataset.py
TensorDataset.generate_tensor_filename
def generate_tensor_filename(self, field_name, file_num, compressed=True): """ Generate a filename for a tensor. """ file_ext = TENSOR_EXT if compressed: file_ext = COMPRESSED_TENSOR_EXT filename = os.path.join(self.filename, 'tensors', '%s_%05d%s' %(field_name, file_num, fil...
python
def generate_tensor_filename(self, field_name, file_num, compressed=True): """ Generate a filename for a tensor. """ file_ext = TENSOR_EXT if compressed: file_ext = COMPRESSED_TENSOR_EXT filename = os.path.join(self.filename, 'tensors', '%s_%05d%s' %(field_name, file_num, fil...
['def', 'generate_tensor_filename', '(', 'self', ',', 'field_name', ',', 'file_num', ',', 'compressed', '=', 'True', ')', ':', 'file_ext', '=', 'TENSOR_EXT', 'if', 'compressed', ':', 'file_ext', '=', 'COMPRESSED_TENSOR_EXT', 'filename', '=', 'os', '.', 'path', '.', 'join', '(', 'self', '.', 'filename', ',', "'tensors'"...
Generate a filename for a tensor.
['Generate', 'a', 'filename', 'for', 'a', 'tensor', '.']
train
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/tensor_dataset.py#L427-L433
9,597
PMBio/limix-backup
limix/stats/chi2mixture.py
Chi2mixture.estimate_chi2mixture
def estimate_chi2mixture(self, lrt): """ estimates the parameters of a mixture of a chi-squared random variable of degree 0 and a scaled chi-squared random variable of degree d (1-mixture)*chi2(0) + (mixture)*scale*chi2(dof), where scale is the scaling paramet...
python
def estimate_chi2mixture(self, lrt): """ estimates the parameters of a mixture of a chi-squared random variable of degree 0 and a scaled chi-squared random variable of degree d (1-mixture)*chi2(0) + (mixture)*scale*chi2(dof), where scale is the scaling paramet...
['def', 'estimate_chi2mixture', '(', 'self', ',', 'lrt', ')', ':', '"""\n step 1: estimate the probability of being in component one\n """', 'self', '.', 'mixture', '=', '1', '-', '(', 'lrt', '<=', 'self', '.', 'tol', ')', '.', 'mean', '(', ')', 'n_false', '=', 'SP', '.', 'sum', '(', 'lrt', '>', 'self', '...
estimates the parameters of a mixture of a chi-squared random variable of degree 0 and a scaled chi-squared random variable of degree d (1-mixture)*chi2(0) + (mixture)*scale*chi2(dof), where scale is the scaling parameter for the scales chi-square distribution dof ...
['estimates', 'the', 'parameters', 'of', 'a', 'mixture', 'of', 'a', 'chi', '-', 'squared', 'random', 'variable', 'of', 'degree', '0', 'and', 'a', 'scaled', 'chi', '-', 'squared', 'random', 'variable', 'of', 'degree', 'd', '(', '1', '-', 'mixture', ')', '*', 'chi2', '(', '0', ')', '+', '(', 'mixture', ')', '*', 'scale',...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/chi2mixture.py#L36-L83
9,598
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.begin
def begin(self): """ This method will implement the handshake of the Bitcoin protocol. It will send the Version message, and block until it receives a VerAck. Once we receive the version, we'll send the verack, and begin downloading. """ log.debug("handsha...
python
def begin(self): """ This method will implement the handshake of the Bitcoin protocol. It will send the Version message, and block until it receives a VerAck. Once we receive the version, we'll send the verack, and begin downloading. """ log.debug("handsha...
['def', 'begin', '(', 'self', ')', ':', 'log', '.', 'debug', '(', '"handshake (version %s)"', '%', 'PROTOCOL_VERSION', ')', 'version', '=', 'Version', '(', ')', 'version', '.', 'services', '=', '0', "# can't send blocks", 'log', '.', 'debug', '(', '"send Version"', ')', 'self', '.', 'send_message', '(', 'version', ')']
This method will implement the handshake of the Bitcoin protocol. It will send the Version message, and block until it receives a VerAck. Once we receive the version, we'll send the verack, and begin downloading.
['This', 'method', 'will', 'implement', 'the', 'handshake', 'of', 'the', 'Bitcoin', 'protocol', '.', 'It', 'will', 'send', 'the', 'Version', 'message', 'and', 'block', 'until', 'it', 'receives', 'a', 'VerAck', '.', 'Once', 'we', 'receive', 'the', 'version', 'we', 'll', 'send', 'the', 'verack', 'and', 'begin', 'download...
train
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L305-L317
9,599
edx/XBlock
xblock/runtime.py
Runtime.load_block_type
def load_block_type(self, block_type): """ Returns a subclass of :class:`.XBlock` that corresponds to the specified `block_type`. """ return XBlock.load_class(block_type, self.default_class, self.select)
python
def load_block_type(self, block_type): """ Returns a subclass of :class:`.XBlock` that corresponds to the specified `block_type`. """ return XBlock.load_class(block_type, self.default_class, self.select)
['def', 'load_block_type', '(', 'self', ',', 'block_type', ')', ':', 'return', 'XBlock', '.', 'load_class', '(', 'block_type', ',', 'self', '.', 'default_class', ',', 'self', '.', 'select', ')']
Returns a subclass of :class:`.XBlock` that corresponds to the specified `block_type`.
['Returns', 'a', 'subclass', 'of', ':', 'class', ':', '.', 'XBlock', 'that', 'corresponds', 'to', 'the', 'specified', 'block_type', '.']
train
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/runtime.py#L602-L606