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
5,400
rocky/python-uncompyle6
uncompyle6/scanners/scanner15.py
Scanner15.ingest
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. """ tokens, customize = sca...
python
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. """ tokens, customize = sca...
['def', 'ingest', '(', 'self', ',', 'co', ',', 'classname', '=', 'None', ',', 'code_objects', '=', '{', '}', ',', 'show_asm', '=', 'None', ')', ':', 'tokens', ',', 'customize', '=', 'scan', '.', 'Scanner21', '.', 'ingest', '(', 'self', ',', 'co', ',', 'classname', ',', 'code_objects', ',', 'show_asm', ')', 'for', 't', ...
Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar.
['Pick', 'out', 'tokens', 'from', 'an', 'uncompyle6', 'code', 'object', 'and', 'transform', 'them', 'returning', 'a', 'list', 'of', 'uncompyle6', 'Token', 's', '.']
train
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner15.py#L29-L41
5,401
Spinmob/spinmob
_data.py
fitter.autoscale_eydata
def autoscale_eydata(self): """ Rescales the error so the next fit will give reduced chi squareds of 1. Each data set will be scaled independently, and you may wish to run this a few times until it converges. """ if not self.results: self._error("You must com...
python
def autoscale_eydata(self): """ Rescales the error so the next fit will give reduced chi squareds of 1. Each data set will be scaled independently, and you may wish to run this a few times until it converges. """ if not self.results: self._error("You must com...
['def', 'autoscale_eydata', '(', 'self', ')', ':', 'if', 'not', 'self', '.', 'results', ':', 'self', '.', '_error', '(', '"You must complete a fit first."', ')', 'return', 'r', '=', 'self', '.', 'reduced_chi_squareds', '(', ')', '# loop over the eydata and rescale', 'for', 'n', 'in', 'range', '(', 'len', '(', 'r', ')',...
Rescales the error so the next fit will give reduced chi squareds of 1. Each data set will be scaled independently, and you may wish to run this a few times until it converges.
['Rescales', 'the', 'error', 'so', 'the', 'next', 'fit', 'will', 'give', 'reduced', 'chi', 'squareds', 'of', '1', '.', 'Each', 'data', 'set', 'will', 'be', 'scaled', 'independently', 'and', 'you', 'may', 'wish', 'to', 'run', 'this', 'a', 'few', 'times', 'until', 'it', 'converges', '.']
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L2545-L2566
5,402
twilio/twilio-python
twilio/rest/studio/v1/flow/engagement/__init__.py
EngagementContext.engagement_context
def engagement_context(self): """ Access the engagement_context :returns: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextList :rtype: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextList """ if self._engagement_context...
python
def engagement_context(self): """ Access the engagement_context :returns: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextList :rtype: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextList """ if self._engagement_context...
['def', 'engagement_context', '(', 'self', ')', ':', 'if', 'self', '.', '_engagement_context', 'is', 'None', ':', 'self', '.', '_engagement_context', '=', 'EngagementContextList', '(', 'self', '.', '_version', ',', 'flow_sid', '=', 'self', '.', '_solution', '[', "'flow_sid'", ']', ',', 'engagement_sid', '=', 'self', '....
Access the engagement_context :returns: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextList :rtype: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextList
['Access', 'the', 'engagement_context']
train
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/studio/v1/flow/engagement/__init__.py#L285-L298
5,403
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/router/router_bgp/address_family/ipv6/ipv6_unicast/af_ipv6_vrf/neighbor/af_ipv6_vrf_neighbor_address_holder/af_ipv6_neighbor_addr/neighbor_route_map/neighbor_route_map_direction_out/__init__.py
neighbor_route_map_direction_out._set_neighbor_route_map_name_direction_out
def _set_neighbor_route_map_name_direction_out(self, v, load=False): """ Setter method for neighbor_route_map_name_direction_out, mapped from YANG variable /rbridge_id/router/router_bgp/address_family/ipv6/ipv6_unicast/af_ipv6_vrf/neighbor/af_ipv6_vrf_neighbor_address_holder/af_ipv6_neighbor_addr/neighbor_route...
python
def _set_neighbor_route_map_name_direction_out(self, v, load=False): """ Setter method for neighbor_route_map_name_direction_out, mapped from YANG variable /rbridge_id/router/router_bgp/address_family/ipv6/ipv6_unicast/af_ipv6_vrf/neighbor/af_ipv6_vrf_neighbor_address_holder/af_ipv6_neighbor_addr/neighbor_route...
['def', '_set_neighbor_route_map_name_direction_out', '(', 'self', ',', 'v', ',', 'load', '=', 'False', ')', ':', 'if', 'hasattr', '(', 'v', ',', '"_utype"', ')', ':', 'v', '=', 'v', '.', '_utype', '(', 'v', ')', 'try', ':', 't', '=', 'YANGDynClass', '(', 'v', ',', 'base', '=', 'RestrictedClassType', '(', 'base_type', ...
Setter method for neighbor_route_map_name_direction_out, mapped from YANG variable /rbridge_id/router/router_bgp/address_family/ipv6/ipv6_unicast/af_ipv6_vrf/neighbor/af_ipv6_vrf_neighbor_address_holder/af_ipv6_neighbor_addr/neighbor_route_map/neighbor_route_map_direction_out/neighbor_route_map_name_direction_out (comm...
['Setter', 'method', 'for', 'neighbor_route_map_name_direction_out', 'mapped', 'from', 'YANG', 'variable', '/', 'rbridge_id', '/', 'router', '/', 'router_bgp', '/', 'address_family', '/', 'ipv6', '/', 'ipv6_unicast', '/', 'af_ipv6_vrf', '/', 'neighbor', '/', 'af_ipv6_vrf_neighbor_address_holder', '/', 'af_ipv6_neighbor...
train
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/router/router_bgp/address_family/ipv6/ipv6_unicast/af_ipv6_vrf/neighbor/af_ipv6_vrf_neighbor_address_holder/af_ipv6_neighbor_addr/neighbor_route_map/neighbor_route_map_direction_out/__init__.py#L91-L112
5,404
b3j0f/schema
b3j0f/schema/lang/factory.py
SchemaFactory.build
def build(self, _resource, _cache=True, updatecontent=True, **kwargs): """Build a schema class from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use _cache system. :param bool updatecontent: if True (default) update result. :rtyp...
python
def build(self, _resource, _cache=True, updatecontent=True, **kwargs): """Build a schema class from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use _cache system. :param bool updatecontent: if True (default) update result. :rtyp...
['def', 'build', '(', 'self', ',', '_resource', ',', '_cache', '=', 'True', ',', 'updatecontent', '=', 'True', ',', '*', '*', 'kwargs', ')', ':', 'result', '=', 'None', 'if', '_cache', 'and', '_resource', 'in', 'self', '.', '_schemasbyresource', ':', 'result', '=', 'self', '.', '_schemasbyresource', '[', '_resource', '...
Build a schema class from input _resource. :param _resource: object from where get the right schema. :param bool _cache: use _cache system. :param bool updatecontent: if True (default) update result. :rtype: Schema.
['Build', 'a', 'schema', 'class', 'from', 'input', '_resource', '.']
train
https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/lang/factory.py#L93-L127
5,405
cloud-custodian/cloud-custodian
c7n/cwe.py
CloudWatchEvents.get_trail_ids
def get_trail_ids(cls, event, mode): """extract resources ids from a cloud trail event.""" resource_ids = () event_name = event['detail']['eventName'] event_source = event['detail']['eventSource'] for e in mode.get('events', []): if not isinstance(e, dict): ...
python
def get_trail_ids(cls, event, mode): """extract resources ids from a cloud trail event.""" resource_ids = () event_name = event['detail']['eventName'] event_source = event['detail']['eventSource'] for e in mode.get('events', []): if not isinstance(e, dict): ...
['def', 'get_trail_ids', '(', 'cls', ',', 'event', ',', 'mode', ')', ':', 'resource_ids', '=', '(', ')', 'event_name', '=', 'event', '[', "'detail'", ']', '[', "'eventName'", ']', 'event_source', '=', 'event', '[', "'detail'", ']', '[', "'eventSource'", ']', 'for', 'e', 'in', 'mode', '.', 'get', '(', "'events'", ',', '...
extract resources ids from a cloud trail event.
['extract', 'resources', 'ids', 'from', 'a', 'cloud', 'trail', 'event', '.']
train
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/cwe.py#L120-L147
5,406
NaPs/Kolekto
kolekto/commands/importer.py
copy
def copy(tree, source_filename): """ Copy file in tree, show a progress bar during operations, and return the sha1 sum of copied file. """ #_, ext = os.path.splitext(source_filename) filehash = sha1() with printer.progress(os.path.getsize(source_filename)) as update: with open(source...
python
def copy(tree, source_filename): """ Copy file in tree, show a progress bar during operations, and return the sha1 sum of copied file. """ #_, ext = os.path.splitext(source_filename) filehash = sha1() with printer.progress(os.path.getsize(source_filename)) as update: with open(source...
['def', 'copy', '(', 'tree', ',', 'source_filename', ')', ':', '#_, ext = os.path.splitext(source_filename)', 'filehash', '=', 'sha1', '(', ')', 'with', 'printer', '.', 'progress', '(', 'os', '.', 'path', '.', 'getsize', '(', 'source_filename', ')', ')', 'as', 'update', ':', 'with', 'open', '(', 'source_filename', ',',...
Copy file in tree, show a progress bar during operations, and return the sha1 sum of copied file.
['Copy', 'file', 'in', 'tree', 'show', 'a', 'progress', 'bar', 'during', 'operations', 'and', 'return', 'the', 'sha1', 'sum', 'of', 'copied', 'file', '.']
train
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L36-L60
5,407
openeemeter/eeweather
eeweather/ranking.py
select_station
def select_station( candidates, coverage_range=None, min_fraction_coverage=0.9, distance_warnings=(50000, 200000), rank=1, ): """ Select a station from a list of candidates that meets given data quality criteria. Parameters ---------- candidates : :any:`pandas.DataFrame` ...
python
def select_station( candidates, coverage_range=None, min_fraction_coverage=0.9, distance_warnings=(50000, 200000), rank=1, ): """ Select a station from a list of candidates that meets given data quality criteria. Parameters ---------- candidates : :any:`pandas.DataFrame` ...
['def', 'select_station', '(', 'candidates', ',', 'coverage_range', '=', 'None', ',', 'min_fraction_coverage', '=', '0.9', ',', 'distance_warnings', '=', '(', '50000', ',', '200000', ')', ',', 'rank', '=', '1', ',', ')', ':', 'def', '_test_station', '(', 'station', ')', ':', 'if', 'coverage_range', 'is', 'None', ':', '...
Select a station from a list of candidates that meets given data quality criteria. Parameters ---------- candidates : :any:`pandas.DataFrame` A dataframe of the form given by :any:`eeweather.rank_stations` or :any:`eeweather.combine_ranked_stations`, specifically having at least ...
['Select', 'a', 'station', 'from', 'a', 'list', 'of', 'candidates', 'that', 'meets', 'given', 'data', 'quality', 'criteria', '.']
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/ranking.py#L358-L438
5,408
mjirik/imtools
imtools/sample_data.py
get_conda_path
def get_conda_path(): """ Return anaconda or miniconda directory :return: anaconda directory """ dstdir = '' # try: import subprocess import re # cond info --root work only for root environment # p = subprocess.Popen(['conda', 'info', '--root'], stdout=subprocess.PIPE, stderr=s...
python
def get_conda_path(): """ Return anaconda or miniconda directory :return: anaconda directory """ dstdir = '' # try: import subprocess import re # cond info --root work only for root environment # p = subprocess.Popen(['conda', 'info', '--root'], stdout=subprocess.PIPE, stderr=s...
['def', 'get_conda_path', '(', ')', ':', 'dstdir', '=', "''", '# try:', 'import', 'subprocess', 'import', 're', '# cond info --root work only for root environment', "# p = subprocess.Popen(['conda', 'info', '--root'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)", 'p', '=', 'subprocess', '.', 'Popen', '(', '[', "'c...
Return anaconda or miniconda directory :return: anaconda directory
['Return', 'anaconda', 'or', 'miniconda', 'directory', ':', 'return', ':', 'anaconda', 'directory']
train
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/sample_data.py#L227-L253
5,409
inveniosoftware/invenio-files-rest
invenio_files_rest/helpers.py
populate_from_path
def populate_from_path(bucket, source, checksum=True, key_prefix='', chunk_size=None): """Populate a ``bucket`` from all files in path. :param bucket: The bucket (instance or id) to create the object in. :param source: The file or directory path. :param checksum: If ``True`` then...
python
def populate_from_path(bucket, source, checksum=True, key_prefix='', chunk_size=None): """Populate a ``bucket`` from all files in path. :param bucket: The bucket (instance or id) to create the object in. :param source: The file or directory path. :param checksum: If ``True`` then...
['def', 'populate_from_path', '(', 'bucket', ',', 'source', ',', 'checksum', '=', 'True', ',', 'key_prefix', '=', "''", ',', 'chunk_size', '=', 'None', ')', ':', 'from', '.', 'models', 'import', 'FileInstance', ',', 'ObjectVersion', 'def', 'create_file', '(', 'key', ',', 'path', ')', ':', '"""Create new ``ObjectVersion...
Populate a ``bucket`` from all files in path. :param bucket: The bucket (instance or id) to create the object in. :param source: The file or directory path. :param checksum: If ``True`` then a MD5 checksum will be computed for each file. (Default: ``True``) :param key_prefix: The key prefix for...
['Populate', 'a', 'bucket', 'from', 'all', 'files', 'in', 'path', '.']
train
https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/helpers.py#L251-L293
5,410
pandas-dev/pandas
pandas/core/frame.py
DataFrame.to_html
def to_html(self, buf=None, columns=None, col_space=None, header=True, index=True, na_rep='NaN', formatters=None, float_format=None, sparsify=None, index_names=True, justify=None, max_rows=None, max_cols=None, show_dimensions=False, decimal='.', bold_rows=...
python
def to_html(self, buf=None, columns=None, col_space=None, header=True, index=True, na_rep='NaN', formatters=None, float_format=None, sparsify=None, index_names=True, justify=None, max_rows=None, max_cols=None, show_dimensions=False, decimal='.', bold_rows=...
['def', 'to_html', '(', 'self', ',', 'buf', '=', 'None', ',', 'columns', '=', 'None', ',', 'col_space', '=', 'None', ',', 'header', '=', 'True', ',', 'index', '=', 'True', ',', 'na_rep', '=', "'NaN'", ',', 'formatters', '=', 'None', ',', 'float_format', '=', 'None', ',', 'sparsify', '=', 'None', ',', 'index_names', '='...
Render a DataFrame as an HTML table. %(shared_params)s bold_rows : bool, default True Make the row labels bold in the output. classes : str or list or tuple, default None CSS class(es) to apply to the resulting html table. escape : bool, default True C...
['Render', 'a', 'DataFrame', 'as', 'an', 'HTML', 'table', '.', '%', '(', 'shared_params', ')', 's', 'bold_rows', ':', 'bool', 'default', 'True', 'Make', 'the', 'row', 'labels', 'bold', 'in', 'the', 'output', '.', 'classes', ':', 'str', 'or', 'list', 'or', 'tuple', 'default', 'None', 'CSS', 'class', '(', 'es', ')', 'to'...
train
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L2151-L2210
5,411
BeyondTheClouds/enoslib
enoslib/infra/enos_chameleonbaremetal/provider.py
create_blazar_client
def create_blazar_client(config, session): """Check the reservation, creates a new one if nescessary.""" return blazar_client.Client(session=session, service_type="reservation", region_name=os.environ["OS_REGION_NAME"])
python
def create_blazar_client(config, session): """Check the reservation, creates a new one if nescessary.""" return blazar_client.Client(session=session, service_type="reservation", region_name=os.environ["OS_REGION_NAME"])
['def', 'create_blazar_client', '(', 'config', ',', 'session', ')', ':', 'return', 'blazar_client', '.', 'Client', '(', 'session', '=', 'session', ',', 'service_type', '=', '"reservation"', ',', 'region_name', '=', 'os', '.', 'environ', '[', '"OS_REGION_NAME"', ']', ')']
Check the reservation, creates a new one if nescessary.
['Check', 'the', 'reservation', 'creates', 'a', 'new', 'one', 'if', 'nescessary', '.']
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_chameleonbaremetal/provider.py#L46-L50
5,412
google/tangent
tangent/utils.py
shapes_match
def shapes_match(a, b): """Recursively check if shapes of object `a` and `b` match. Will walk lists, tuples and dicts. Args: a: object of type (numpy.ndarray,tf.Tensor,list,tuple,dict) to check for matching shapes against `b`. b: object to check for matching shape against `a`. Returns: A ...
python
def shapes_match(a, b): """Recursively check if shapes of object `a` and `b` match. Will walk lists, tuples and dicts. Args: a: object of type (numpy.ndarray,tf.Tensor,list,tuple,dict) to check for matching shapes against `b`. b: object to check for matching shape against `a`. Returns: A ...
['def', 'shapes_match', '(', 'a', ',', 'b', ')', ':', 'if', 'isinstance', '(', 'a', ',', '(', 'tuple', ',', 'list', ')', ')', 'and', 'isinstance', '(', 'b', ',', '(', 'tuple', ',', 'list', ')', ')', ':', 'if', 'len', '(', 'a', ')', '!=', 'len', '(', 'b', ')', ':', 'return', 'False', 'return', 'all', '(', '[', 'shapes_m...
Recursively check if shapes of object `a` and `b` match. Will walk lists, tuples and dicts. Args: a: object of type (numpy.ndarray,tf.Tensor,list,tuple,dict) to check for matching shapes against `b`. b: object to check for matching shape against `a`. Returns: A boolean indicating whether th...
['Recursively', 'check', 'if', 'shapes', 'of', 'object', 'a', 'and', 'b', 'match', '.']
train
https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/utils.py#L604-L630
5,413
inasafe/inasafe
safe/gui/tools/wizard/step_kw57_extra_keywords.py
StepKwExtraKeywords.set_existing_extra_keywords
def set_existing_extra_keywords(self): """Set extra keywords from the value from metadata.""" extra_keywords = self.parent.get_existing_keyword('extra_keywords') for key, widgets in list(self.widgets_dict.items()): value = extra_keywords.get(key) if value is None: ...
python
def set_existing_extra_keywords(self): """Set extra keywords from the value from metadata.""" extra_keywords = self.parent.get_existing_keyword('extra_keywords') for key, widgets in list(self.widgets_dict.items()): value = extra_keywords.get(key) if value is None: ...
['def', 'set_existing_extra_keywords', '(', 'self', ')', ':', 'extra_keywords', '=', 'self', '.', 'parent', '.', 'get_existing_keyword', '(', "'extra_keywords'", ')', 'for', 'key', ',', 'widgets', 'in', 'list', '(', 'self', '.', 'widgets_dict', '.', 'items', '(', ')', ')', ':', 'value', '=', 'extra_keywords', '.', 'get...
Set extra keywords from the value from metadata.
['Set', 'extra', 'keywords', 'from', 'the', 'value', 'from', 'metadata', '.']
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw57_extra_keywords.py#L131-L163
5,414
spyder-ide/spyder
spyder/widgets/onecolumntree.py
OneColumnTree.item_selection_changed
def item_selection_changed(self): """Item selection has changed""" is_selection = len(self.selectedItems()) > 0 self.expand_selection_action.setEnabled(is_selection) self.collapse_selection_action.setEnabled(is_selection)
python
def item_selection_changed(self): """Item selection has changed""" is_selection = len(self.selectedItems()) > 0 self.expand_selection_action.setEnabled(is_selection) self.collapse_selection_action.setEnabled(is_selection)
['def', 'item_selection_changed', '(', 'self', ')', ':', 'is_selection', '=', 'len', '(', 'self', '.', 'selectedItems', '(', ')', ')', '>', '0', 'self', '.', 'expand_selection_action', '.', 'setEnabled', '(', 'is_selection', ')', 'self', '.', 'collapse_selection_action', '.', 'setEnabled', '(', 'is_selection', ')']
Item selection has changed
['Item', 'selection', 'has', 'changed']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/onecolumntree.py#L139-L143
5,415
koszullab/instaGRAAL
instagraal/pyramid_sparse.py
pyramid.zoom_out_pixel
def zoom_out_pixel(self, curr_pixel): """ return the curr_frag at a lower resolution""" low_frag = curr_pixel[0] high_frag = curr_pixel[1] level = curr_pixel[2] str_level = str(level) if level < self.n_level - 1: low_super = self.spec_level[str_level]["fragmen...
python
def zoom_out_pixel(self, curr_pixel): """ return the curr_frag at a lower resolution""" low_frag = curr_pixel[0] high_frag = curr_pixel[1] level = curr_pixel[2] str_level = str(level) if level < self.n_level - 1: low_super = self.spec_level[str_level]["fragmen...
['def', 'zoom_out_pixel', '(', 'self', ',', 'curr_pixel', ')', ':', 'low_frag', '=', 'curr_pixel', '[', '0', ']', 'high_frag', '=', 'curr_pixel', '[', '1', ']', 'level', '=', 'curr_pixel', '[', '2', ']', 'str_level', '=', 'str', '(', 'level', ')', 'if', 'level', '<', 'self', '.', 'n_level', '-', '1', ':', 'low_super', ...
return the curr_frag at a lower resolution
['return', 'the', 'curr_frag', 'at', 'a', 'lower', 'resolution']
train
https://github.com/koszullab/instaGRAAL/blob/1c02ca838e57d8178eec79f223644b2acd0153dd/instagraal/pyramid_sparse.py#L1787-L1807
5,416
saltstack/salt
salt/modules/lxd.py
pylxd_save_object
def pylxd_save_object(obj): ''' Saves an object (profile/image/container) and translate its execpetion on failure obj : The object to save This is an internal method, no CLI Example. ''' try: obj.save() except pylxd.exceptions.LXDAPIException as e: raise Command...
python
def pylxd_save_object(obj): ''' Saves an object (profile/image/container) and translate its execpetion on failure obj : The object to save This is an internal method, no CLI Example. ''' try: obj.save() except pylxd.exceptions.LXDAPIException as e: raise Command...
['def', 'pylxd_save_object', '(', 'obj', ')', ':', 'try', ':', 'obj', '.', 'save', '(', ')', 'except', 'pylxd', '.', 'exceptions', '.', 'LXDAPIException', 'as', 'e', ':', 'raise', 'CommandExecutionError', '(', 'six', '.', 'text_type', '(', 'e', ')', ')', 'return', 'True']
Saves an object (profile/image/container) and translate its execpetion on failure obj : The object to save This is an internal method, no CLI Example.
['Saves', 'an', 'object', '(', 'profile', '/', 'image', '/', 'container', ')', 'and', 'translate', 'its', 'execpetion', 'on', 'failure']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L402-L416
5,417
JIC-CSB/jicimagelib
jicimagelib/util/array.py
check_dtype
def check_dtype(array, allowed): """Raises TypeError if the array is not of an allowed dtype. :param array: array whose dtype is to be checked :param allowed: instance or list of allowed dtypes """ if not hasattr(allowed, "__iter__"): allowed = [allowed,] if array.dtype not in allowed: ...
python
def check_dtype(array, allowed): """Raises TypeError if the array is not of an allowed dtype. :param array: array whose dtype is to be checked :param allowed: instance or list of allowed dtypes """ if not hasattr(allowed, "__iter__"): allowed = [allowed,] if array.dtype not in allowed: ...
['def', 'check_dtype', '(', 'array', ',', 'allowed', ')', ':', 'if', 'not', 'hasattr', '(', 'allowed', ',', '"__iter__"', ')', ':', 'allowed', '=', '[', 'allowed', ',', ']', 'if', 'array', '.', 'dtype', 'not', 'in', 'allowed', ':', 'raise', '(', 'TypeError', '(', '"Invalid dtype {}. Allowed dtype(s): {}"', '.', 'format...
Raises TypeError if the array is not of an allowed dtype. :param array: array whose dtype is to be checked :param allowed: instance or list of allowed dtypes
['Raises', 'TypeError', 'if', 'the', 'array', 'is', 'not', 'of', 'an', 'allowed', 'dtype', '.']
train
https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/util/array.py#L54-L64
5,418
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.list_config_variables
def list_config_variables(self, offset): """List defined config variables up to 9 at a time.""" names = sorted(self._config_variables) names = names[offset:offset + 9] count = len(names) if len(names) < 9: names += [0]*(9 - count) return [count] + names
python
def list_config_variables(self, offset): """List defined config variables up to 9 at a time.""" names = sorted(self._config_variables) names = names[offset:offset + 9] count = len(names) if len(names) < 9: names += [0]*(9 - count) return [count] + names
['def', 'list_config_variables', '(', 'self', ',', 'offset', ')', ':', 'names', '=', 'sorted', '(', 'self', '.', '_config_variables', ')', 'names', '=', 'names', '[', 'offset', ':', 'offset', '+', '9', ']', 'count', '=', 'len', '(', 'names', ')', 'if', 'len', '(', 'names', ')', '<', '9', ':', 'names', '+=', '[', '0', '...
List defined config variables up to 9 at a time.
['List', 'defined', 'config', 'variables', 'up', 'to', '9', 'at', 'a', 'time', '.']
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L383-L393
5,419
callowayproject/Transmogrify
transmogrify/images2gif.py
GifWriter.get_sub_rectangles
def get_sub_rectangles(self, ims): """ get_sub_rectangles(ims) Calculate the minimal rectangles that need updating each frame. Returns a two-element tuple containing the cropped images and a list of x-y positions. Calculating the subrectangles takes extra time, obviously. Howev...
python
def get_sub_rectangles(self, ims): """ get_sub_rectangles(ims) Calculate the minimal rectangles that need updating each frame. Returns a two-element tuple containing the cropped images and a list of x-y positions. Calculating the subrectangles takes extra time, obviously. Howev...
['def', 'get_sub_rectangles', '(', 'self', ',', 'ims', ')', ':', '# Check image count', 'if', 'len', '(', 'ims', ')', '<', '2', ':', 'return', 'ims', ',', '[', '(', '0', ',', '0', ')', 'for', 'i', 'in', 'ims', ']', '# We need numpy', 'if', 'np', 'is', 'None', ':', 'raise', 'RuntimeError', '(', '"Need Numpy to calculate...
get_sub_rectangles(ims) Calculate the minimal rectangles that need updating each frame. Returns a two-element tuple containing the cropped images and a list of x-y positions. Calculating the subrectangles takes extra time, obviously. However, if the image sizes were reduced, th...
['get_sub_rectangles', '(', 'ims', ')']
train
https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/images2gif.py#L294-L344
5,420
juergberinger/cmdhelper
cmdhelper.py
LogWriter.write
def write(self, text): """Write text. An additional attribute terminator with a value of None is added to the logging record to indicate that StreamHandler should not add a newline.""" self.logger.log(self.loglevel, text, extra={'terminator': None})
python
def write(self, text): """Write text. An additional attribute terminator with a value of None is added to the logging record to indicate that StreamHandler should not add a newline.""" self.logger.log(self.loglevel, text, extra={'terminator': None})
['def', 'write', '(', 'self', ',', 'text', ')', ':', 'self', '.', 'logger', '.', 'log', '(', 'self', '.', 'loglevel', ',', 'text', ',', 'extra', '=', '{', "'terminator'", ':', 'None', '}', ')']
Write text. An additional attribute terminator with a value of None is added to the logging record to indicate that StreamHandler should not add a newline.
['Write', 'text', '.', 'An', 'additional', 'attribute', 'terminator', 'with', 'a', 'value', 'of', 'None', 'is', 'added', 'to', 'the', 'logging', 'record', 'to', 'indicate', 'that', 'StreamHandler', 'should', 'not', 'add', 'a', 'newline', '.']
train
https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L110-L114
5,421
ltworf/typedload
typedload/dataloader.py
_enumload
def _enumload(l: Loader, value, type_) -> Enum: """ This loads something into an Enum. It tries with basic types first. If that fails, it tries to look for type annotations inside the Enum, and tries to use those to load the value into something that is compatible with the Enum. Of course...
python
def _enumload(l: Loader, value, type_) -> Enum: """ This loads something into an Enum. It tries with basic types first. If that fails, it tries to look for type annotations inside the Enum, and tries to use those to load the value into something that is compatible with the Enum. Of course...
['def', '_enumload', '(', 'l', ':', 'Loader', ',', 'value', ',', 'type_', ')', '->', 'Enum', ':', 'try', ':', '# Try naïve conversion', 'return', 'type_', '(', 'value', ')', 'except', ':', 'pass', '# Try with the typing hints', 'for', '_', ',', 't', 'in', 'get_type_hints', '(', 'type_', ')', '.', 'items', '(', ')', ':'...
This loads something into an Enum. It tries with basic types first. If that fails, it tries to look for type annotations inside the Enum, and tries to use those to load the value into something that is compatible with the Enum. Of course if that fails too, a ValueError is raised.
['This', 'loads', 'something', 'into', 'an', 'Enum', '.']
train
https://github.com/ltworf/typedload/blob/7fd130612963bfcec3242698463ef863ca4af927/typedload/dataloader.py#L436-L464
5,422
VasilyStepanov/pywidl
pywidl/grammar.py
p_OptionalOrRequiredArgument_optional
def p_OptionalOrRequiredArgument_optional(p): """OptionalOrRequiredArgument : optional Type IDENTIFIER Default""" p[0] = model.OperationArgument( type=p[2], name=p[3], optional=True, default=p[4])
python
def p_OptionalOrRequiredArgument_optional(p): """OptionalOrRequiredArgument : optional Type IDENTIFIER Default""" p[0] = model.OperationArgument( type=p[2], name=p[3], optional=True, default=p[4])
['def', 'p_OptionalOrRequiredArgument_optional', '(', 'p', ')', ':', 'p', '[', '0', ']', '=', 'model', '.', 'OperationArgument', '(', 'type', '=', 'p', '[', '2', ']', ',', 'name', '=', 'p', '[', '3', ']', ',', 'optional', '=', 'True', ',', 'default', '=', 'p', '[', '4', ']', ')']
OptionalOrRequiredArgument : optional Type IDENTIFIER Default
['OptionalOrRequiredArgument', ':', 'optional', 'Type', 'IDENTIFIER', 'Default']
train
https://github.com/VasilyStepanov/pywidl/blob/8d84b2e53157bfe276bf16301c19e8b6b32e861e/pywidl/grammar.py#L510-L513
5,423
Hackerfleet/hfos
hfos/database.py
backup
def backup(schema, uuid, export_filter, export_format, filename, pretty, export_all, omit): """Exports all collections to (JSON-) files.""" export_format = export_format.upper() if pretty: indent = 4 else: indent = 0 f = None if filename: try: f = open(fil...
python
def backup(schema, uuid, export_filter, export_format, filename, pretty, export_all, omit): """Exports all collections to (JSON-) files.""" export_format = export_format.upper() if pretty: indent = 4 else: indent = 0 f = None if filename: try: f = open(fil...
['def', 'backup', '(', 'schema', ',', 'uuid', ',', 'export_filter', ',', 'export_format', ',', 'filename', ',', 'pretty', ',', 'export_all', ',', 'omit', ')', ':', 'export_format', '=', 'export_format', '.', 'upper', '(', ')', 'if', 'pretty', ':', 'indent', '=', '4', 'else', ':', 'indent', '=', '0', 'f', '=', 'None', '...
Exports all collections to (JSON-) files.
['Exports', 'all', 'collections', 'to', '(', 'JSON', '-', ')', 'files', '.']
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L657-L733
5,424
ibis-project/ibis
ibis/expr/api.py
ifelse
def ifelse(arg, true_expr, false_expr): """ Shorthand for implementing ternary expressions bool_expr.ifelse(0, 1) e.g., in SQL: CASE WHEN bool_expr THEN 0 else 1 END """ # Result will be the result of promotion of true/false exprs. These # might be conflicting types; same type resolution as...
python
def ifelse(arg, true_expr, false_expr): """ Shorthand for implementing ternary expressions bool_expr.ifelse(0, 1) e.g., in SQL: CASE WHEN bool_expr THEN 0 else 1 END """ # Result will be the result of promotion of true/false exprs. These # might be conflicting types; same type resolution as...
['def', 'ifelse', '(', 'arg', ',', 'true_expr', ',', 'false_expr', ')', ':', '# Result will be the result of promotion of true/false exprs. These', '# might be conflicting types; same type resolution as case expressions', '# must be used.', 'case', '=', 'ops', '.', 'SearchedCaseBuilder', '(', ')', 'return', 'case', '.'...
Shorthand for implementing ternary expressions bool_expr.ifelse(0, 1) e.g., in SQL: CASE WHEN bool_expr THEN 0 else 1 END
['Shorthand', 'for', 'implementing', 'ternary', 'expressions']
train
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/api.py#L1899-L1910
5,425
konstantinstadler/country_converter
country_converter/country_converter.py
CountryConverter._separate_exclude_cases
def _separate_exclude_cases(name, exclude_prefix): """ Splits the excluded Parameters ---------- name : str Name of the country/region to convert. exclude_prefix : list of valid regex strings List of indicators which negate the subsequent country/region....
python
def _separate_exclude_cases(name, exclude_prefix): """ Splits the excluded Parameters ---------- name : str Name of the country/region to convert. exclude_prefix : list of valid regex strings List of indicators which negate the subsequent country/region....
['def', '_separate_exclude_cases', '(', 'name', ',', 'exclude_prefix', ')', ':', 'excluder', '=', 're', '.', 'compile', '(', "'|'", '.', 'join', '(', 'exclude_prefix', ')', ')', 'split_entries', '=', 'excluder', '.', 'split', '(', 'name', ')', 'return', '{', "'clean_name'", ':', 'split_entries', '[', '0', ']', ',', "'e...
Splits the excluded Parameters ---------- name : str Name of the country/region to convert. exclude_prefix : list of valid regex strings List of indicators which negate the subsequent country/region. These prefixes and everything following will not b...
['Splits', 'the', 'excluded']
train
https://github.com/konstantinstadler/country_converter/blob/b78622dfa6700480df632fe061d6837b96f31b71/country_converter/country_converter.py#L332-L361
5,426
TeamHG-Memex/eli5
eli5/formatters/html.py
_format_feature
def _format_feature(feature, weight, hl_spaces): # type: (...) -> str """ Format any feature. """ if isinstance(feature, FormattedFeatureName): return feature.format() elif (isinstance(feature, list) and all('name' in x and 'sign' in x for x in feature)): return _format_u...
python
def _format_feature(feature, weight, hl_spaces): # type: (...) -> str """ Format any feature. """ if isinstance(feature, FormattedFeatureName): return feature.format() elif (isinstance(feature, list) and all('name' in x and 'sign' in x for x in feature)): return _format_u...
['def', '_format_feature', '(', 'feature', ',', 'weight', ',', 'hl_spaces', ')', ':', '# type: (...) -> str', 'if', 'isinstance', '(', 'feature', ',', 'FormattedFeatureName', ')', ':', 'return', 'feature', '.', 'format', '(', ')', 'elif', '(', 'isinstance', '(', 'feature', ',', 'list', ')', 'and', 'all', '(', "'name'",...
Format any feature.
['Format', 'any', 'feature', '.']
train
https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/html.py#L299-L309
5,427
rtfd/sphinxcontrib-dotnetdomain
sphinxcontrib/dotnetdomain.py
DotNetSignature.full_name
def full_name(self): """Return full name of member""" if self.prefix is not None: return '.'.join([self.prefix, self.member]) return self.member
python
def full_name(self): """Return full name of member""" if self.prefix is not None: return '.'.join([self.prefix, self.member]) return self.member
['def', 'full_name', '(', 'self', ')', ':', 'if', 'self', '.', 'prefix', 'is', 'not', 'None', ':', 'return', "'.'", '.', 'join', '(', '[', 'self', '.', 'prefix', ',', 'self', '.', 'member', ']', ')', 'return', 'self', '.', 'member']
Return full name of member
['Return', 'full', 'name', 'of', 'member']
train
https://github.com/rtfd/sphinxcontrib-dotnetdomain/blob/fbc6a81b9993dc5d06866c4483593421b53b9a61/sphinxcontrib/dotnetdomain.py#L70-L74
5,428
pytroll/satpy
satpy/writers/cf_writer.py
omerc2cf
def omerc2cf(area): """Return the cf grid mapping for the omerc projection.""" proj_dict = area.proj_dict args = dict(azimuth_of_central_line=proj_dict.get('alpha'), latitude_of_projection_origin=proj_dict.get('lat_0'), longitude_of_projection_origin=proj_dict.get('lonc'), ...
python
def omerc2cf(area): """Return the cf grid mapping for the omerc projection.""" proj_dict = area.proj_dict args = dict(azimuth_of_central_line=proj_dict.get('alpha'), latitude_of_projection_origin=proj_dict.get('lat_0'), longitude_of_projection_origin=proj_dict.get('lonc'), ...
['def', 'omerc2cf', '(', 'area', ')', ':', 'proj_dict', '=', 'area', '.', 'proj_dict', 'args', '=', 'dict', '(', 'azimuth_of_central_line', '=', 'proj_dict', '.', 'get', '(', "'alpha'", ')', ',', 'latitude_of_projection_origin', '=', 'proj_dict', '.', 'get', '(', "'lat_0'", ')', ',', 'longitude_of_projection_origin', '...
Return the cf grid mapping for the omerc projection.
['Return', 'the', 'cf', 'grid', 'mapping', 'for', 'the', 'omerc', 'projection', '.']
train
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/writers/cf_writer.py#L39-L55
5,429
jobovy/galpy
galpy/potential/TwoPowerSphericalPotential.py
NFWPotential._R2deriv
def _R2deriv(self,R,z,phi=0.,t=0.): """ NAME: _R2deriv PURPOSE: evaluate the second radial derivative for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPU...
python
def _R2deriv(self,R,z,phi=0.,t=0.): """ NAME: _R2deriv PURPOSE: evaluate the second radial derivative for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPU...
['def', '_R2deriv', '(', 'self', ',', 'R', ',', 'z', ',', 'phi', '=', '0.', ',', 't', '=', '0.', ')', ':', 'Rz', '=', 'R', '**', '2.', '+', 'z', '**', '2.', 'sqrtRz', '=', 'numpy', '.', 'sqrt', '(', 'Rz', ')', 'return', '(', '3.', '*', 'R', '**', '4.', '+', '2.', '*', 'R', '**', '2.', '*', '(', 'z', '**', '2.', '+', 's...
NAME: _R2deriv PURPOSE: evaluate the second radial derivative for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the second radial derivative HISTO...
['NAME', ':', '_R2deriv', 'PURPOSE', ':', 'evaluate', 'the', 'second', 'radial', 'derivative', 'for', 'this', 'potential', 'INPUT', ':', 'R', '-', 'Galactocentric', 'cylindrical', 'radius', 'z', '-', 'vertical', 'height', 'phi', '-', 'azimuth', 't', '-', 'time', 'OUTPUT', ':', 'the', 'second', 'radial', 'derivative', '...
train
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/TwoPowerSphericalPotential.py#L937-L959
5,430
davenquinn/Attitude
attitude/error/axes.py
statistical_axes
def statistical_axes(fit, **kw): """ Hyperbolic error using a statistical process (either sampling or noise errors) Integrates covariance with error level and degrees of freedom for plotting confidence intervals. Degrees of freedom is set to 2, which is the relevant number of independe...
python
def statistical_axes(fit, **kw): """ Hyperbolic error using a statistical process (either sampling or noise errors) Integrates covariance with error level and degrees of freedom for plotting confidence intervals. Degrees of freedom is set to 2, which is the relevant number of independe...
['def', 'statistical_axes', '(', 'fit', ',', '*', '*', 'kw', ')', ':', 'method', '=', 'kw', '.', 'pop', '(', "'method'", ',', "'noise'", ')', 'confidence_level', '=', 'kw', '.', 'pop', '(', "'confidence_level'", ',', '0.95', ')', 'dof', '=', 'kw', '.', 'pop', '(', "'dof'", ',', '2', ')', 'nominal', '=', 'fit', '.', 'ei...
Hyperbolic error using a statistical process (either sampling or noise errors) Integrates covariance with error level and degrees of freedom for plotting confidence intervals. Degrees of freedom is set to 2, which is the relevant number of independent dimensions to planar fitting of *a pri...
['Hyperbolic', 'error', 'using', 'a', 'statistical', 'process', '(', 'either', 'sampling', 'or', 'noise', 'errors', ')']
train
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/error/axes.py#L108-L146
5,431
pyupio/changelogs
changelogs/pypi.py
get_url_map
def get_url_map(): """ Loads custom/pypi/map.txt and builds a dict where map[package_name] = url :return: dict, urls """ map = {} path = os.path.join( os.path.dirname(os.path.realpath(__file__)), # current working dir ../ "custom", # ../custom/ "pypi", # ../custom/pypi...
python
def get_url_map(): """ Loads custom/pypi/map.txt and builds a dict where map[package_name] = url :return: dict, urls """ map = {} path = os.path.join( os.path.dirname(os.path.realpath(__file__)), # current working dir ../ "custom", # ../custom/ "pypi", # ../custom/pypi...
['def', 'get_url_map', '(', ')', ':', 'map', '=', '{', '}', 'path', '=', 'os', '.', 'path', '.', 'join', '(', 'os', '.', 'path', '.', 'dirname', '(', 'os', '.', 'path', '.', 'realpath', '(', '__file__', ')', ')', ',', '# current working dir ../', '"custom"', ',', '# ../custom/', '"pypi"', ',', '# ../custom/pypi/', '"ma...
Loads custom/pypi/map.txt and builds a dict where map[package_name] = url :return: dict, urls
['Loads', 'custom', '/', 'pypi', '/', 'map', '.', 'txt', 'and', 'builds', 'a', 'dict', 'where', 'map', '[', 'package_name', ']', '=', 'url', ':', 'return', ':', 'dict', 'urls']
train
https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/pypi.py#L34-L50
5,432
tanghaibao/goatools
goatools/gosubdag/godag_rcnt.py
CountRelatives.get_d1str
def get_d1str(self, goobj, reverse=False): """Get D1-string representing all parent terms which are depth-01 GO terms.""" return "".join(sorted(self.get_parents_letters(goobj), reverse=reverse))
python
def get_d1str(self, goobj, reverse=False): """Get D1-string representing all parent terms which are depth-01 GO terms.""" return "".join(sorted(self.get_parents_letters(goobj), reverse=reverse))
['def', 'get_d1str', '(', 'self', ',', 'goobj', ',', 'reverse', '=', 'False', ')', ':', 'return', '""', '.', 'join', '(', 'sorted', '(', 'self', '.', 'get_parents_letters', '(', 'goobj', ')', ',', 'reverse', '=', 'reverse', ')', ')']
Get D1-string representing all parent terms which are depth-01 GO terms.
['Get', 'D1', '-', 'string', 'representing', 'all', 'parent', 'terms', 'which', 'are', 'depth', '-', '01', 'GO', 'terms', '.']
train
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt.py#L36-L38
5,433
eventbrite/pysoa
pysoa/server/django/cache.py
PySOAPyLibMCCache.close
def close(self, for_shutdown=False, **_kwargs): """ Only call super().close() if the server is shutting down (not between requests). :param for_shutdown: If `False` (the default) """ if for_shutdown: super(PySOAPyLibMCCache, self).close()
python
def close(self, for_shutdown=False, **_kwargs): """ Only call super().close() if the server is shutting down (not between requests). :param for_shutdown: If `False` (the default) """ if for_shutdown: super(PySOAPyLibMCCache, self).close()
['def', 'close', '(', 'self', ',', 'for_shutdown', '=', 'False', ',', '*', '*', '_kwargs', ')', ':', 'if', 'for_shutdown', ':', 'super', '(', 'PySOAPyLibMCCache', ',', 'self', ')', '.', 'close', '(', ')']
Only call super().close() if the server is shutting down (not between requests). :param for_shutdown: If `False` (the default)
['Only', 'call', 'super', '()', '.', 'close', '()', 'if', 'the', 'server', 'is', 'shutting', 'down', '(', 'not', 'between', 'requests', ')', '.']
train
https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/django/cache.py#L71-L78
5,434
inspirehep/inspire-query-parser
inspire_query_parser/visitors/restructuring_visitor.py
RestructuringVisitor.visit_spires_keyword_query
def visit_spires_keyword_query(self, node): """Transform a :class:`SpiresKeywordQuery` into a :class:`KeywordOp`. Notes: In case the value being a :class:`SimpleValueBooleanQuery`, the subtree is transformed to chained :class:`AndOp` queries containing :class:`KeywordOp`, whose ...
python
def visit_spires_keyword_query(self, node): """Transform a :class:`SpiresKeywordQuery` into a :class:`KeywordOp`. Notes: In case the value being a :class:`SimpleValueBooleanQuery`, the subtree is transformed to chained :class:`AndOp` queries containing :class:`KeywordOp`, whose ...
['def', 'visit_spires_keyword_query', '(', 'self', ',', 'node', ')', ':', 'keyword', '=', 'node', '.', 'left', '.', 'accept', '(', 'self', ')', 'value', '=', 'node', '.', 'right', '.', 'accept', '(', 'self', ')', 'if', 'isinstance', '(', 'value', ',', 'SimpleValueBooleanQuery', ')', ':', 'return', '_convert_simple_valu...
Transform a :class:`SpiresKeywordQuery` into a :class:`KeywordOp`. Notes: In case the value being a :class:`SimpleValueBooleanQuery`, the subtree is transformed to chained :class:`AndOp` queries containing :class:`KeywordOp`, whose keyword is the keyword of the current node and ...
['Transform', 'a', ':', 'class', ':', 'SpiresKeywordQuery', 'into', 'a', ':', 'class', ':', 'KeywordOp', '.']
train
https://github.com/inspirehep/inspire-query-parser/blob/9dde20d7caef89a48bb419b866f4535c88cfc00d/inspire_query_parser/visitors/restructuring_visitor.py#L206-L221
5,435
toros-astro/corral
corral/db/__init__.py
session_scope
def session_scope(session_cls=None): """Provide a transactional scope around a series of operations.""" session = session_cls() if session_cls else Session() try: yield session session.commit() except Exception: session.rollback() raise finally: session.close(...
python
def session_scope(session_cls=None): """Provide a transactional scope around a series of operations.""" session = session_cls() if session_cls else Session() try: yield session session.commit() except Exception: session.rollback() raise finally: session.close(...
['def', 'session_scope', '(', 'session_cls', '=', 'None', ')', ':', 'session', '=', 'session_cls', '(', ')', 'if', 'session_cls', 'else', 'Session', '(', ')', 'try', ':', 'yield', 'session', 'session', '.', 'commit', '(', ')', 'except', 'Exception', ':', 'session', '.', 'rollback', '(', ')', 'raise', 'finally', ':', 's...
Provide a transactional scope around a series of operations.
['Provide', 'a', 'transactional', 'scope', 'around', 'a', 'series', 'of', 'operations', '.']
train
https://github.com/toros-astro/corral/blob/75474b38ff366330d33644461a902d07374a5bbc/corral/db/__init__.py#L143-L153
5,436
MarcMeszaros/envitro
envitro/docker.py
isset
def isset(alias_name): """Return a boolean if the docker link is set or not and is a valid looking docker link value. Args: alias_name: The link alias name """ warnings.warn('Will be removed in v1.0', DeprecationWarning, stacklevel=2) raw_value = read(alias_name, allow_none=True) if raw...
python
def isset(alias_name): """Return a boolean if the docker link is set or not and is a valid looking docker link value. Args: alias_name: The link alias name """ warnings.warn('Will be removed in v1.0', DeprecationWarning, stacklevel=2) raw_value = read(alias_name, allow_none=True) if raw...
['def', 'isset', '(', 'alias_name', ')', ':', 'warnings', '.', 'warn', '(', "'Will be removed in v1.0'", ',', 'DeprecationWarning', ',', 'stacklevel', '=', '2', ')', 'raw_value', '=', 'read', '(', 'alias_name', ',', 'allow_none', '=', 'True', ')', 'if', 'raw_value', ':', 'if', 're', '.', 'compile', '(', "r'.+://.+:\\d+...
Return a boolean if the docker link is set or not and is a valid looking docker link value. Args: alias_name: The link alias name
['Return', 'a', 'boolean', 'if', 'the', 'docker', 'link', 'is', 'set', 'or', 'not', 'and', 'is', 'a', 'valid', 'looking', 'docker', 'link', 'value', '.']
train
https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/docker.py#L47-L62
5,437
materialsproject/pymatgen
pymatgen/io/abinit/utils.py
Dirviz.get_cluster_graph
def get_cluster_graph(self, engine="fdp", graph_attr=None, node_attr=None, edge_attr=None): """ Generate directory graph in the DOT language. Directories are shown as clusters .. warning:: This function scans the entire directory tree starting from top so the resulting ...
python
def get_cluster_graph(self, engine="fdp", graph_attr=None, node_attr=None, edge_attr=None): """ Generate directory graph in the DOT language. Directories are shown as clusters .. warning:: This function scans the entire directory tree starting from top so the resulting ...
['def', 'get_cluster_graph', '(', 'self', ',', 'engine', '=', '"fdp"', ',', 'graph_attr', '=', 'None', ',', 'node_attr', '=', 'None', ',', 'edge_attr', '=', 'None', ')', ':', '# https://www.graphviz.org/doc/info/', 'from', 'graphviz', 'import', 'Digraph', 'g', '=', 'Digraph', '(', '"directory"', ',', '#filename="flow_%...
Generate directory graph in the DOT language. Directories are shown as clusters .. warning:: This function scans the entire directory tree starting from top so the resulting graph can be really big. Args: engine: Layout command used. ['dot', 'neato', 'twopi', 'circ...
['Generate', 'directory', 'graph', 'in', 'the', 'DOT', 'language', '.', 'Directories', 'are', 'shown', 'as', 'clusters']
train
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/utils.py#L902-L988
5,438
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
visual
def visual(title, X, activation): '''create a grid of images and save it as a final image title : grid image name X : array of images ''' assert len(X.shape) == 4 X = X.transpose((0, 2, 3, 1)) if activation == 'sigmoid': X = np.clip((X)*(255.0), 0, 255).astype(np.uint8) elif act...
python
def visual(title, X, activation): '''create a grid of images and save it as a final image title : grid image name X : array of images ''' assert len(X.shape) == 4 X = X.transpose((0, 2, 3, 1)) if activation == 'sigmoid': X = np.clip((X)*(255.0), 0, 255).astype(np.uint8) elif act...
['def', 'visual', '(', 'title', ',', 'X', ',', 'activation', ')', ':', 'assert', 'len', '(', 'X', '.', 'shape', ')', '==', '4', 'X', '=', 'X', '.', 'transpose', '(', '(', '0', ',', '2', ',', '3', ',', '1', ')', ')', 'if', 'activation', '==', "'sigmoid'", ':', 'X', '=', 'np', '.', 'clip', '(', '(', 'X', ')', '*', '(', '...
create a grid of images and save it as a final image title : grid image name X : array of images
['create', 'a', 'grid', 'of', 'images', 'and', 'save', 'it', 'as', 'a', 'final', 'image', 'title', ':', 'grid', 'image', 'name', 'X', ':', 'array', 'of', 'images']
train
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L270-L286
5,439
tmux-python/libtmux
libtmux/window.py
Window.show_window_option
def show_window_option(self, option, g=False): """ Return a list of options for the window. todo: test and return True/False for on/off string Parameters ---------- option : str g : bool, optional Pass ``-g`` flag, global. Default False. Ret...
python
def show_window_option(self, option, g=False): """ Return a list of options for the window. todo: test and return True/False for on/off string Parameters ---------- option : str g : bool, optional Pass ``-g`` flag, global. Default False. Ret...
['def', 'show_window_option', '(', 'self', ',', 'option', ',', 'g', '=', 'False', ')', ':', 'tmux_args', '=', 'tuple', '(', ')', 'if', 'g', ':', 'tmux_args', '+=', '(', "'-g'", ',', ')', 'tmux_args', '+=', '(', 'option', ',', ')', 'cmd', '=', 'self', '.', 'cmd', '(', "'show-window-options'", ',', '*', 'tmux_args', ')',...
Return a list of options for the window. todo: test and return True/False for on/off string Parameters ---------- option : str g : bool, optional Pass ``-g`` flag, global. Default False. Returns ------- str, int Raises -----...
['Return', 'a', 'list', 'of', 'options', 'for', 'the', 'window', '.']
train
https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/window.py#L232-L274
5,440
UDST/orca
orca/server/server.py
column_definition
def column_definition(table_name, col_name): """ Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "tex...
python
def column_definition(table_name, col_name): """ Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "tex...
['def', 'column_definition', '(', 'table_name', ',', 'col_name', ')', ':', 'col_type', '=', 'orca', '.', 'get_table', '(', 'table_name', ')', '.', 'column_type', '(', 'col_name', ')', 'if', 'col_type', '!=', "'function'", ':', 'return', 'jsonify', '(', 'type', '=', 'col_type', ')', 'filename', ',', 'lineno', ',', 'sour...
Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw text of the functio...
['Get', 'the', 'source', 'of', 'a', 'column', 'function', '.']
train
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L290-L314
5,441
thombashi/SimpleSQLite
simplesqlite/sqlquery.py
SqlQuery.make_insert
def make_insert(cls, table, insert_tuple): """ [Deprecated] Make INSERT query. :param str table: Table name of executing the query. :param list/tuple insert_tuple: Insertion data. :return: Query of SQLite. :rtype: str :raises ValueError: If ``insert_tuple`` is em...
python
def make_insert(cls, table, insert_tuple): """ [Deprecated] Make INSERT query. :param str table: Table name of executing the query. :param list/tuple insert_tuple: Insertion data. :return: Query of SQLite. :rtype: str :raises ValueError: If ``insert_tuple`` is em...
['def', 'make_insert', '(', 'cls', ',', 'table', ',', 'insert_tuple', ')', ':', 'validate_table_name', '(', 'table', ')', 'table', '=', 'Table', '(', 'table', ')', 'if', 'typepy', '.', 'is_empty_sequence', '(', 'insert_tuple', ')', ':', 'raise', 'ValueError', '(', '"empty insert list/tuple"', ')', 'return', '"INSERT IN...
[Deprecated] Make INSERT query. :param str table: Table name of executing the query. :param list/tuple insert_tuple: Insertion data. :return: Query of SQLite. :rtype: str :raises ValueError: If ``insert_tuple`` is empty |list|/|tuple|. :raises simplesqlite.NameValidation...
['[', 'Deprecated', ']', 'Make', 'INSERT', 'query', '.']
train
https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/sqlquery.py#L22-L44
5,442
materialsproject/pymatgen
pymatgen/io/babel.py
BabelMolAdaptor.from_string
def from_string(string_data, file_format="xyz"): """ Uses OpenBabel to read a molecule from a string in all supported formats. Args: string_data: String containing molecule data. file_format: String specifying any OpenBabel supported formats. Returns: ...
python
def from_string(string_data, file_format="xyz"): """ Uses OpenBabel to read a molecule from a string in all supported formats. Args: string_data: String containing molecule data. file_format: String specifying any OpenBabel supported formats. Returns: ...
['def', 'from_string', '(', 'string_data', ',', 'file_format', '=', '"xyz"', ')', ':', 'mols', '=', 'pb', '.', 'readstring', '(', 'str', '(', 'file_format', ')', ',', 'str', '(', 'string_data', ')', ')', 'return', 'BabelMolAdaptor', '(', 'mols', '.', 'OBMol', ')']
Uses OpenBabel to read a molecule from a string in all supported formats. Args: string_data: String containing molecule data. file_format: String specifying any OpenBabel supported formats. Returns: BabelMolAdaptor object
['Uses', 'OpenBabel', 'to', 'read', 'a', 'molecule', 'from', 'a', 'string', 'in', 'all', 'supported', 'formats', '.']
train
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/babel.py#L332-L345
5,443
mozilla/treeherder
treeherder/services/elasticsearch/helpers.py
search
def search(query, index=INDEX_NAME, doc_type=DOC_TYPE): """ Thin wrapper of the main query function to provide just the resulting objects """ results = raw_query(query, index=index, doc_type=doc_type) return [r['_source'] for r in results]
python
def search(query, index=INDEX_NAME, doc_type=DOC_TYPE): """ Thin wrapper of the main query function to provide just the resulting objects """ results = raw_query(query, index=index, doc_type=doc_type) return [r['_source'] for r in results]
['def', 'search', '(', 'query', ',', 'index', '=', 'INDEX_NAME', ',', 'doc_type', '=', 'DOC_TYPE', ')', ':', 'results', '=', 'raw_query', '(', 'query', ',', 'index', '=', 'index', ',', 'doc_type', '=', 'doc_type', ')', 'return', '[', 'r', '[', "'_source'", ']', 'for', 'r', 'in', 'results', ']']
Thin wrapper of the main query function to provide just the resulting objects
['Thin', 'wrapper', 'of', 'the', 'main', 'query', 'function', 'to', 'provide', 'just', 'the', 'resulting', 'objects']
train
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/services/elasticsearch/helpers.py#L147-L152
5,444
PlaidWeb/Publ
publ/queries.py
where_entry_tag
def where_entry_tag(query, tag): """ Generate a where clause for entries with the given tag """ if isinstance(tag, (list, set, tuple)): tags = [t.lower() for t in tag] return orm.select(e for e in query for t in e.tags if t.key in tags) return orm.select(e for e in query for t in e.tags if t...
python
def where_entry_tag(query, tag): """ Generate a where clause for entries with the given tag """ if isinstance(tag, (list, set, tuple)): tags = [t.lower() for t in tag] return orm.select(e for e in query for t in e.tags if t.key in tags) return orm.select(e for e in query for t in e.tags if t...
['def', 'where_entry_tag', '(', 'query', ',', 'tag', ')', ':', 'if', 'isinstance', '(', 'tag', ',', '(', 'list', ',', 'set', ',', 'tuple', ')', ')', ':', 'tags', '=', '[', 't', '.', 'lower', '(', ')', 'for', 't', 'in', 'tag', ']', 'return', 'orm', '.', 'select', '(', 'e', 'for', 'e', 'in', 'query', 'for', 't', 'in', 'e...
Generate a where clause for entries with the given tag
['Generate', 'a', 'where', 'clause', 'for', 'entries', 'with', 'the', 'given', 'tag']
train
https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L137-L142
5,445
SBRG/ssbio
ssbio/databases/uniprot.py
uniprot_ec
def uniprot_ec(uniprot_id): """Retrieve the EC number annotation for a UniProt ID. Args: uniprot_id: Valid UniProt ID Returns: """ r = requests.post('http://www.uniprot.org/uniprot/?query=%s&columns=ec&format=tab' % uniprot_id) ec = r.content.decode('utf-8').splitlines()[1] if le...
python
def uniprot_ec(uniprot_id): """Retrieve the EC number annotation for a UniProt ID. Args: uniprot_id: Valid UniProt ID Returns: """ r = requests.post('http://www.uniprot.org/uniprot/?query=%s&columns=ec&format=tab' % uniprot_id) ec = r.content.decode('utf-8').splitlines()[1] if le...
['def', 'uniprot_ec', '(', 'uniprot_id', ')', ':', 'r', '=', 'requests', '.', 'post', '(', "'http://www.uniprot.org/uniprot/?query=%s&columns=ec&format=tab'", '%', 'uniprot_id', ')', 'ec', '=', 'r', '.', 'content', '.', 'decode', '(', "'utf-8'", ')', '.', 'splitlines', '(', ')', '[', '1', ']', 'if', 'len', '(', 'ec', '...
Retrieve the EC number annotation for a UniProt ID. Args: uniprot_id: Valid UniProt ID Returns:
['Retrieve', 'the', 'EC', 'number', 'annotation', 'for', 'a', 'UniProt', 'ID', '.']
train
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/databases/uniprot.py#L409-L424
5,446
dotzero/tilda-api-python
tilda/client.py
Client.get_page_full
def get_page_full(self, page_id): """ Get full page info and full html code """ try: result = self._request('/getpagefull/', {'pageid': page_id}) return TildaPage(**result) except NetworkError: return []
python
def get_page_full(self, page_id): """ Get full page info and full html code """ try: result = self._request('/getpagefull/', {'pageid': page_id}) return TildaPage(**result) except NetworkError: return []
['def', 'get_page_full', '(', 'self', ',', 'page_id', ')', ':', 'try', ':', 'result', '=', 'self', '.', '_request', '(', "'/getpagefull/'", ',', '{', "'pageid'", ':', 'page_id', '}', ')', 'return', 'TildaPage', '(', '*', '*', 'result', ')', 'except', 'NetworkError', ':', 'return', '[', ']']
Get full page info and full html code
['Get', 'full', 'page', 'info', 'and', 'full', 'html', 'code']
train
https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L119-L126
5,447
T-002/pycast
pycast/errors/medianabsolutepercentageerror.py
MedianAbsolutePercentageError._calculate
def _calculate(self, startingPercentage, endPercentage, startDate, endDate): """This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. Th...
python
def _calculate(self, startingPercentage, endPercentage, startDate, endDate): """This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. Th...
['def', '_calculate', '(', 'self', ',', 'startingPercentage', ',', 'endPercentage', ',', 'startDate', ',', 'endDate', ')', ':', '# get the defined subset of error values', 'errorValues', '=', 'self', '.', '_get_error_values', '(', 'startingPercentage', ',', 'endPercentage', ',', 'startDate', ',', 'endDate', ')', 'error...
This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. This has to be a value in [0.0, 100.0]. It represents the value, where the err...
['This', 'is', 'the', 'error', 'calculation', 'function', 'that', 'gets', 'called', 'by', ':', 'py', ':', 'meth', ':', 'BaseErrorMeasure', '.', 'get_error', '.']
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/medianabsolutepercentageerror.py#L31-L52
5,448
xolox/python-vcs-repo-mgr
vcs_repo_mgr/__init__.py
Repository.ensure_hexadecimal_string
def ensure_hexadecimal_string(self, value, command=None): """ Make sure the given value is a hexadecimal string. :param value: The value to check (a string). :param command: The command that produced the value (a string or :data:`None`). :returns: The validated hexadecimal strin...
python
def ensure_hexadecimal_string(self, value, command=None): """ Make sure the given value is a hexadecimal string. :param value: The value to check (a string). :param command: The command that produced the value (a string or :data:`None`). :returns: The validated hexadecimal strin...
['def', 'ensure_hexadecimal_string', '(', 'self', ',', 'value', ',', 'command', '=', 'None', ')', ':', 'if', 'not', 'HEX_PATTERN', '.', 'match', '(', 'value', ')', ':', 'msg', '=', '"Expected a hexadecimal string, got \'%s\' instead!"', 'if', 'command', ':', 'msg', '+=', '" (\'%s\' gave unexpected output)"', 'msg', '%=...
Make sure the given value is a hexadecimal string. :param value: The value to check (a string). :param command: The command that produced the value (a string or :data:`None`). :returns: The validated hexadecimal string. :raises: :exc:`~exceptions.ValueError` when `value` is not a hexade...
['Make', 'sure', 'the', 'given', 'value', 'is', 'a', 'hexadecimal', 'string', '.']
train
https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/__init__.py#L1224-L1241
5,449
bcbnz/python-rofi
rofi.py
Rofi.integer_entry
def integer_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter an integer. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the...
python
def integer_entry(self, prompt, message=None, min=None, max=None, rofi_args=None, **kwargs): """Prompt the user to enter an integer. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the...
['def', 'integer_entry', '(', 'self', ',', 'prompt', ',', 'message', '=', 'None', ',', 'min', '=', 'None', ',', 'max', '=', 'None', ',', 'rofi_args', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', '# Sanity check.', 'if', '(', 'min', 'is', 'not', 'None', ')', 'and', '(', 'max', 'is', 'not', 'None', ')', 'and', 'not', ...
Prompt the user to enter an integer. Parameters ---------- prompt: string Prompt to display to the user. message: string, optional Message to display under the entry line. min, max: integer, optional Minimum and maximum values to allow. If Non...
['Prompt', 'the', 'user', 'to', 'enter', 'an', 'integer', '.']
train
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L569-L607
5,450
n1analytics/python-paillier
phe/util.py
powmod
def powmod(a, b, c): """ Uses GMP, if available, to do a^b mod c where a, b, c are integers. :return int: (a ** b) % c """ if a == 1: return 1 if not HAVE_GMP or max(a, b, c) < _USE_MOD_FROM_GMP_SIZE: return pow(a, b, c) else: return int(gmpy2.powmod(a, b, c))
python
def powmod(a, b, c): """ Uses GMP, if available, to do a^b mod c where a, b, c are integers. :return int: (a ** b) % c """ if a == 1: return 1 if not HAVE_GMP or max(a, b, c) < _USE_MOD_FROM_GMP_SIZE: return pow(a, b, c) else: return int(gmpy2.powmod(a, b, c))
['def', 'powmod', '(', 'a', ',', 'b', ',', 'c', ')', ':', 'if', 'a', '==', '1', ':', 'return', '1', 'if', 'not', 'HAVE_GMP', 'or', 'max', '(', 'a', ',', 'b', ',', 'c', ')', '<', '_USE_MOD_FROM_GMP_SIZE', ':', 'return', 'pow', '(', 'a', ',', 'b', ',', 'c', ')', 'else', ':', 'return', 'int', '(', 'gmpy2', '.', 'powmod', ...
Uses GMP, if available, to do a^b mod c where a, b, c are integers. :return int: (a ** b) % c
['Uses', 'GMP', 'if', 'available', 'to', 'do', 'a^b', 'mod', 'c', 'where', 'a', 'b', 'c', 'are', 'integers', '.']
train
https://github.com/n1analytics/python-paillier/blob/955f8c0bfa9623be15b75462b121d28acf70f04b/phe/util.py#L38-L50
5,451
vertexproject/synapse
synapse/lib/reflect.py
getClsNames
def getClsNames(item): ''' Return a list of "fully qualified" class names for an instance. Example: for name in getClsNames(foo): print(name) ''' mro = inspect.getmro(item.__class__) mro = [c for c in mro if c not in clsskip] return ['%s.%s' % (c.__module__, c.__name__...
python
def getClsNames(item): ''' Return a list of "fully qualified" class names for an instance. Example: for name in getClsNames(foo): print(name) ''' mro = inspect.getmro(item.__class__) mro = [c for c in mro if c not in clsskip] return ['%s.%s' % (c.__module__, c.__name__...
['def', 'getClsNames', '(', 'item', ')', ':', 'mro', '=', 'inspect', '.', 'getmro', '(', 'item', '.', '__class__', ')', 'mro', '=', '[', 'c', 'for', 'c', 'in', 'mro', 'if', 'c', 'not', 'in', 'clsskip', ']', 'return', '[', "'%s.%s'", '%', '(', 'c', '.', '__module__', ',', 'c', '.', '__name__', ')', 'for', 'c', 'in', 'mr...
Return a list of "fully qualified" class names for an instance. Example: for name in getClsNames(foo): print(name)
['Return', 'a', 'list', 'of', 'fully', 'qualified', 'class', 'names', 'for', 'an', 'instance', '.']
train
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/reflect.py#L11-L23
5,452
sdispater/orator
orator/query/builder.py
QueryBuilder.chunk
def chunk(self, count): """ Chunk the results of the query :param count: The chunk size :type count: int :return: The current chunk :rtype: list """ for chunk in self._connection.select_many( count, self.to_sql(), self.get_bindings(), not sel...
python
def chunk(self, count): """ Chunk the results of the query :param count: The chunk size :type count: int :return: The current chunk :rtype: list """ for chunk in self._connection.select_many( count, self.to_sql(), self.get_bindings(), not sel...
['def', 'chunk', '(', 'self', ',', 'count', ')', ':', 'for', 'chunk', 'in', 'self', '.', '_connection', '.', 'select_many', '(', 'count', ',', 'self', '.', 'to_sql', '(', ')', ',', 'self', '.', 'get_bindings', '(', ')', ',', 'not', 'self', '.', '_use_write_connection', ')', ':', 'yield', 'chunk']
Chunk the results of the query :param count: The chunk size :type count: int :return: The current chunk :rtype: list
['Chunk', 'the', 'results', 'of', 'the', 'query']
train
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/builder.py#L1146-L1159
5,453
Azure/azure-cosmos-python
azure/cosmos/resource_throttle_retry_policy.py
_ResourceThrottleRetryPolicy.ShouldRetry
def ShouldRetry(self, exception): """Returns true if should retry based on the passed-in exception. :param (errors.HTTPFailure instance) exception: :rtype: boolean """ if self.current_retry_attempt_count < self._max_retry_attempt_count: self.current_ret...
python
def ShouldRetry(self, exception): """Returns true if should retry based on the passed-in exception. :param (errors.HTTPFailure instance) exception: :rtype: boolean """ if self.current_retry_attempt_count < self._max_retry_attempt_count: self.current_ret...
['def', 'ShouldRetry', '(', 'self', ',', 'exception', ')', ':', 'if', 'self', '.', 'current_retry_attempt_count', '<', 'self', '.', '_max_retry_attempt_count', ':', 'self', '.', 'current_retry_attempt_count', '+=', '1', 'self', '.', 'retry_after_in_milliseconds', '=', '0', 'if', 'self', '.', '_fixed_retry_interval_in_m...
Returns true if should retry based on the passed-in exception. :param (errors.HTTPFailure instance) exception: :rtype: boolean
['Returns', 'true', 'if', 'should', 'retry', 'based', 'on', 'the', 'passed', '-', 'in', 'exception', '.']
train
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/resource_throttle_retry_policy.py#L36-L58
5,454
mediaburst/clockwork-python
clockwork/clockwork.py
API.get_balance
def get_balance(self): """Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set""" xml_root ...
python
def get_balance(self): """Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set""" xml_root ...
['def', 'get_balance', '(', 'self', ')', ':', 'xml_root', '=', 'self', '.', '__init_xml', '(', "'Balance'", ')', 'response', '=', 'clockwork_http', '.', 'request', '(', 'BALANCE_URL', ',', 'etree', '.', 'tostring', '(', 'xml_root', ',', 'encoding', '=', "'utf-8'", ')', ')', 'data_etree', '=', 'etree', '.', 'fromstring'...
Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set
['Check', 'the', 'balance', 'fot', 'this', 'account', '.', 'Returns', 'a', 'dictionary', 'containing', ':', 'account_type', ':', 'The', 'account', 'type', 'balance', ':', 'The', 'balance', 'remaining', 'on', 'the', 'account', 'currency', ':', 'The', 'currency', 'used', 'for', 'the', 'account', 'balance', '.', 'Assume',...
train
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L47-L67
5,455
cloudtools/stacker
stacker/blueprints/raw.py
get_template_path
def get_template_path(filename): """Find raw template in working directory or in sys.path. template_path from config may refer to templates colocated with the Stacker config, or files in remote package_sources. Here, we emulate python module loading to find the path to the template. Args: ...
python
def get_template_path(filename): """Find raw template in working directory or in sys.path. template_path from config may refer to templates colocated with the Stacker config, or files in remote package_sources. Here, we emulate python module loading to find the path to the template. Args: ...
['def', 'get_template_path', '(', 'filename', ')', ':', 'if', 'os', '.', 'path', '.', 'isfile', '(', 'filename', ')', ':', 'return', 'os', '.', 'path', '.', 'abspath', '(', 'filename', ')', 'for', 'i', 'in', 'sys', '.', 'path', ':', 'if', 'os', '.', 'path', '.', 'isfile', '(', 'os', '.', 'path', '.', 'join', '(', 'i', ...
Find raw template in working directory or in sys.path. template_path from config may refer to templates colocated with the Stacker config, or files in remote package_sources. Here, we emulate python module loading to find the path to the template. Args: filename (str): Template filename. ...
['Find', 'raw', 'template', 'in', 'working', 'directory', 'or', 'in', 'sys', '.', 'path', '.']
train
https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/blueprints/raw.py#L18-L38
5,456
Microsoft/nni
tools/nni_cmd/updater.py
import_data
def import_data(args): '''import additional data to the experiment''' validate_file(args.filename) validate_dispatcher(args) content = load_search_space(args.filename) args.port = get_experiment_port(args) if args.port is not None: if import_data_to_restful_server(args, content): ...
python
def import_data(args): '''import additional data to the experiment''' validate_file(args.filename) validate_dispatcher(args) content = load_search_space(args.filename) args.port = get_experiment_port(args) if args.port is not None: if import_data_to_restful_server(args, content): ...
['def', 'import_data', '(', 'args', ')', ':', 'validate_file', '(', 'args', '.', 'filename', ')', 'validate_dispatcher', '(', 'args', ')', 'content', '=', 'load_search_space', '(', 'args', '.', 'filename', ')', 'args', '.', 'port', '=', 'get_experiment_port', '(', 'args', ')', 'if', 'args', '.', 'port', 'is', 'not', 'N...
import additional data to the experiment
['import', 'additional', 'data', 'to', 'the', 'experiment']
train
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/updater.py#L131-L141
5,457
galaxy-genome-annotation/python-apollo
arrow/commands/annotations/set_symbol.py
cli
def cli(ctx, feature_id, symbol, organism="", sequence=""): """Set a feature's description Output: A standard apollo feature dictionary ({"features": [{...}]}) """ return ctx.gi.annotations.set_symbol(feature_id, symbol, organism=organism, sequence=sequence)
python
def cli(ctx, feature_id, symbol, organism="", sequence=""): """Set a feature's description Output: A standard apollo feature dictionary ({"features": [{...}]}) """ return ctx.gi.annotations.set_symbol(feature_id, symbol, organism=organism, sequence=sequence)
['def', 'cli', '(', 'ctx', ',', 'feature_id', ',', 'symbol', ',', 'organism', '=', '""', ',', 'sequence', '=', '""', ')', ':', 'return', 'ctx', '.', 'gi', '.', 'annotations', '.', 'set_symbol', '(', 'feature_id', ',', 'symbol', ',', 'organism', '=', 'organism', ',', 'sequence', '=', 'sequence', ')']
Set a feature's description Output: A standard apollo feature dictionary ({"features": [{...}]})
['Set', 'a', 'feature', 's', 'description']
train
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/arrow/commands/annotations/set_symbol.py#L22-L29
5,458
mollie/mollie-api-python
mollie/api/objects/payment.py
Payment.order
def order(self): """Return the order for this payment. """ from ..resources.orders import Order url = self._get_link('order') if url: resp = self.client.orders.perform_api_call(self.client.orders.REST_READ, url) return Order(resp, self.client)
python
def order(self): """Return the order for this payment. """ from ..resources.orders import Order url = self._get_link('order') if url: resp = self.client.orders.perform_api_call(self.client.orders.REST_READ, url) return Order(resp, self.client)
['def', 'order', '(', 'self', ')', ':', 'from', '.', '.', 'resources', '.', 'orders', 'import', 'Order', 'url', '=', 'self', '.', '_get_link', '(', "'order'", ')', 'if', 'url', ':', 'resp', '=', 'self', '.', 'client', '.', 'orders', '.', 'perform_api_call', '(', 'self', '.', 'client', '.', 'orders', '.', 'REST_READ', '...
Return the order for this payment.
['Return', 'the', 'order', 'for', 'this', 'payment', '.']
train
https://github.com/mollie/mollie-api-python/blob/307836b70f0439c066718f1e375fa333dc6e5d77/mollie/api/objects/payment.py#L193-L199
5,459
AtteqCom/zsl
src/zsl/resource/json_server_resource.py
JsonServerResource._create_filter_by
def _create_filter_by(self): """Transform the json-server filter arguments to model-resource ones.""" filter_by = [] for name, values in request.args.copy().lists(): # copy.lists works in py2 and py3 if name not in _SKIPPED_ARGUMENTS: column = _re_column_name.search...
python
def _create_filter_by(self): """Transform the json-server filter arguments to model-resource ones.""" filter_by = [] for name, values in request.args.copy().lists(): # copy.lists works in py2 and py3 if name not in _SKIPPED_ARGUMENTS: column = _re_column_name.search...
['def', '_create_filter_by', '(', 'self', ')', ':', 'filter_by', '=', '[', ']', 'for', 'name', ',', 'values', 'in', 'request', '.', 'args', '.', 'copy', '(', ')', '.', 'lists', '(', ')', ':', '# copy.lists works in py2 and py3', 'if', 'name', 'not', 'in', '_SKIPPED_ARGUMENTS', ':', 'column', '=', '_re_column_name', '.'...
Transform the json-server filter arguments to model-resource ones.
['Transform', 'the', 'json', '-', 'server', 'filter', 'arguments', 'to', 'model', '-', 'resource', 'ones', '.']
train
https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/json_server_resource.py#L95-L120
5,460
NickMonzillo/SmartCloud
SmartCloud/__init__.py
Cloud.collides
def collides(self,position,size): '''Returns True if the word collides with another plotted word.''' word_rect = pygame.Rect(position,self.word_size) if word_rect.collidelistall(self.used_pos) == []: return False else: return True
python
def collides(self,position,size): '''Returns True if the word collides with another plotted word.''' word_rect = pygame.Rect(position,self.word_size) if word_rect.collidelistall(self.used_pos) == []: return False else: return True
['def', 'collides', '(', 'self', ',', 'position', ',', 'size', ')', ':', 'word_rect', '=', 'pygame', '.', 'Rect', '(', 'position', ',', 'self', '.', 'word_size', ')', 'if', 'word_rect', '.', 'collidelistall', '(', 'self', '.', 'used_pos', ')', '==', '[', ']', ':', 'return', 'False', 'else', ':', 'return', 'True']
Returns True if the word collides with another plotted word.
['Returns', 'True', 'if', 'the', 'word', 'collides', 'with', 'another', 'plotted', 'word', '.']
train
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L29-L35
5,461
jkenlooper/chill
src/chill/public.py
PageView.post
def post(self, uri=''): "For sql queries that start with 'INSERT ...'" # get node... (node, rule_kw) = node_from_uri(uri, method=request.method) rule_kw.update( node ) values = rule_kw xhr_data = request.get_json() if xhr_data: values.update( xhr_dat...
python
def post(self, uri=''): "For sql queries that start with 'INSERT ...'" # get node... (node, rule_kw) = node_from_uri(uri, method=request.method) rule_kw.update( node ) values = rule_kw xhr_data = request.get_json() if xhr_data: values.update( xhr_dat...
['def', 'post', '(', 'self', ',', 'uri', '=', "''", ')', ':', '# get node...', '(', 'node', ',', 'rule_kw', ')', '=', 'node_from_uri', '(', 'uri', ',', 'method', '=', 'request', '.', 'method', ')', 'rule_kw', '.', 'update', '(', 'node', ')', 'values', '=', 'rule_kw', 'xhr_data', '=', 'request', '.', 'get_json', '(', ')...
For sql queries that start with 'INSERT ...
['For', 'sql', 'queries', 'that', 'start', 'with', 'INSERT', '...']
train
https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L156-L175
5,462
SatelliteQE/nailgun
nailgun/entity_mixins.py
Entity.get_values
def get_values(self): """Return a copy of field values on the current object. This method is almost identical to ``vars(self).copy()``. However, only instance attributes that correspond to a field are included in the returned dict. :return: A dict mapping field names to user-pr...
python
def get_values(self): """Return a copy of field values on the current object. This method is almost identical to ``vars(self).copy()``. However, only instance attributes that correspond to a field are included in the returned dict. :return: A dict mapping field names to user-pr...
['def', 'get_values', '(', 'self', ')', ':', 'attrs', '=', 'vars', '(', 'self', ')', '.', 'copy', '(', ')', 'attrs', '.', 'pop', '(', "'_server_config'", ')', 'attrs', '.', 'pop', '(', "'_fields'", ')', 'attrs', '.', 'pop', '(', "'_meta'", ')', 'if', "'_path_fields'", 'in', 'attrs', ':', 'attrs', '.', 'pop', '(', "'_pa...
Return a copy of field values on the current object. This method is almost identical to ``vars(self).copy()``. However, only instance attributes that correspond to a field are included in the returned dict. :return: A dict mapping field names to user-provided values.
['Return', 'a', 'copy', 'of', 'field', 'values', 'on', 'the', 'current', 'object', '.']
train
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entity_mixins.py#L501-L516
5,463
kubernetes-client/python
kubernetes/client/apis/policy_v1beta1_api.py
PolicyV1beta1Api.list_pod_disruption_budget_for_all_namespaces
def list_pod_disruption_budget_for_all_namespaces(self, **kwargs): """ list or watch objects of kind PodDisruptionBudget This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_pod_disruption_...
python
def list_pod_disruption_budget_for_all_namespaces(self, **kwargs): """ list or watch objects of kind PodDisruptionBudget This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_pod_disruption_...
['def', 'list_pod_disruption_budget_for_all_namespaces', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'kwargs', '[', "'_return_http_data_only'", ']', '=', 'True', 'if', 'kwargs', '.', 'get', '(', "'async_req'", ')', ':', 'return', 'self', '.', 'list_pod_disruption_budget_for_all_namespaces_with_http_info', '(', '*',...
list or watch objects of kind PodDisruptionBudget This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_pod_disruption_budget_for_all_namespaces(async_req=True) >>> result = thread.get() :p...
['list', 'or', 'watch', 'objects', 'of', 'kind', 'PodDisruptionBudget', 'This', 'method', 'makes', 'a', 'synchronous', 'HTTP', 'request', 'by', 'default', '.', 'To', 'make', 'an', 'asynchronous', 'HTTP', 'request', 'please', 'pass', 'async_req', '=', 'True', '>>>', 'thread', '=', 'api', '.', 'list_pod_disruption_budget...
train
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/policy_v1beta1_api.py#L973-L999
5,464
smdabdoub/phylotoast
phylotoast/biom_calc.py
transform_raw_abundance
def transform_raw_abundance(biomf, fn=math.log10, sampleIDs=None, sample_abd=True): """ Function to transform the total abundance calculation for each sample ID to another format based on user given transformation function. :type biomf: A BIOM file. :param biomf: OTU table format. :param fn: M...
python
def transform_raw_abundance(biomf, fn=math.log10, sampleIDs=None, sample_abd=True): """ Function to transform the total abundance calculation for each sample ID to another format based on user given transformation function. :type biomf: A BIOM file. :param biomf: OTU table format. :param fn: M...
['def', 'transform_raw_abundance', '(', 'biomf', ',', 'fn', '=', 'math', '.', 'log10', ',', 'sampleIDs', '=', 'None', ',', 'sample_abd', '=', 'True', ')', ':', 'totals', '=', 'raw_abundance', '(', 'biomf', ',', 'sampleIDs', ',', 'sample_abd', ')', 'return', '{', 'sid', ':', 'fn', '(', 'abd', ')', 'for', 'sid', ',', 'ab...
Function to transform the total abundance calculation for each sample ID to another format based on user given transformation function. :type biomf: A BIOM file. :param biomf: OTU table format. :param fn: Mathematical function which is used to transform smax to another format. By defaul...
['Function', 'to', 'transform', 'the', 'total', 'abundance', 'calculation', 'for', 'each', 'sample', 'ID', 'to', 'another', 'format', 'based', 'on', 'user', 'given', 'transformation', 'function', '.']
train
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L138-L155
5,465
oasiswork/zimsoap
zimsoap/client.py
ZimbraAccountClient.get_share_info
def get_share_info(self, grantee_type=None, grantee_id=None, grantee_name=None, owner=None, owner_type='name'): """ :returns: list of dict representing shares informations """ params = {} if grantee_type: if 'grantee' not in params.keys(): ...
python
def get_share_info(self, grantee_type=None, grantee_id=None, grantee_name=None, owner=None, owner_type='name'): """ :returns: list of dict representing shares informations """ params = {} if grantee_type: if 'grantee' not in params.keys(): ...
['def', 'get_share_info', '(', 'self', ',', 'grantee_type', '=', 'None', ',', 'grantee_id', '=', 'None', ',', 'grantee_name', '=', 'None', ',', 'owner', '=', 'None', ',', 'owner_type', '=', "'name'", ')', ':', 'params', '=', '{', '}', 'if', 'grantee_type', ':', 'if', "'grantee'", 'not', 'in', 'params', '.', 'keys', '('...
:returns: list of dict representing shares informations
[':', 'returns', ':', 'list', 'of', 'dict', 'representing', 'shares', 'informations']
train
https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/client.py#L333-L367
5,466
meraki-analytics/datapipelines-python
datapipelines/pipelines.py
_SourceHandler.get
def get(self, query: Mapping[str, Any], context: PipelineContext = None) -> T: """Gets a query from the data source. 1) Extracts the query from the data source. 2) Inserts the result into any data sinks. 3) Transforms the result into the requested type if it wasn't already. 4) I...
python
def get(self, query: Mapping[str, Any], context: PipelineContext = None) -> T: """Gets a query from the data source. 1) Extracts the query from the data source. 2) Inserts the result into any data sinks. 3) Transforms the result into the requested type if it wasn't already. 4) I...
['def', 'get', '(', 'self', ',', 'query', ':', 'Mapping', '[', 'str', ',', 'Any', ']', ',', 'context', ':', 'PipelineContext', '=', 'None', ')', '->', 'T', ':', 'result', '=', 'self', '.', '_source', '.', 'get', '(', 'self', '.', '_source_type', ',', 'deepcopy', '(', 'query', ')', ',', 'context', ')', 'LOGGER', '.', 'i...
Gets a query from the data source. 1) Extracts the query from the data source. 2) Inserts the result into any data sinks. 3) Transforms the result into the requested type if it wasn't already. 4) Inserts the transformed result into any data sinks. Args: query: The q...
['Gets', 'a', 'query', 'from', 'the', 'data', 'source', '.']
train
https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/pipelines.py#L170-L199
5,467
ejeschke/ginga
ginga/BaseImage.py
BaseImage.cutout_data
def cutout_data(self, x1, y1, x2, y2, xstep=1, ystep=1, astype=None): """cut out data area based on coords. """ view = np.s_[y1:y2:ystep, x1:x2:xstep] data = self._slice(view) if astype: data = data.astype(astype, copy=False) return data
python
def cutout_data(self, x1, y1, x2, y2, xstep=1, ystep=1, astype=None): """cut out data area based on coords. """ view = np.s_[y1:y2:ystep, x1:x2:xstep] data = self._slice(view) if astype: data = data.astype(astype, copy=False) return data
['def', 'cutout_data', '(', 'self', ',', 'x1', ',', 'y1', ',', 'x2', ',', 'y2', ',', 'xstep', '=', '1', ',', 'ystep', '=', '1', ',', 'astype', '=', 'None', ')', ':', 'view', '=', 'np', '.', 's_', '[', 'y1', ':', 'y2', ':', 'ystep', ',', 'x1', ':', 'x2', ':', 'xstep', ']', 'data', '=', 'self', '.', '_slice', '(', 'view'...
cut out data area based on coords.
['cut', 'out', 'data', 'area', 'based', 'on', 'coords', '.']
train
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/BaseImage.py#L293-L300
5,468
inveniosoftware/invenio-github
invenio_github/ext.py
InvenioGitHub.init_app
def init_app(self, app): """Flask application initialization.""" self.init_config(app) app.extensions['invenio-github'] = self @app.before_first_request def connect_signals(): """Connect OAuthClient signals.""" from invenio_oauthclient.models import Remot...
python
def init_app(self, app): """Flask application initialization.""" self.init_config(app) app.extensions['invenio-github'] = self @app.before_first_request def connect_signals(): """Connect OAuthClient signals.""" from invenio_oauthclient.models import Remot...
['def', 'init_app', '(', 'self', ',', 'app', ')', ':', 'self', '.', 'init_config', '(', 'app', ')', 'app', '.', 'extensions', '[', "'invenio-github'", ']', '=', 'self', '@', 'app', '.', 'before_first_request', 'def', 'connect_signals', '(', ')', ':', '"""Connect OAuthClient signals."""', 'from', 'invenio_oauthclient', ...
Flask application initialization.
['Flask', 'application', 'initialization', '.']
train
https://github.com/inveniosoftware/invenio-github/blob/ec42fd6a06079310dcbe2c46d9fd79d5197bbe26/invenio_github/ext.py#L63-L84
5,469
inveniosoftware/invenio-collections
invenio_collections/views.py
collection
def collection(name=None): """Render the collection page. It renders it either with a collection specific template (aka collection_{collection_name}.html) or with the default collection template (collection.html). """ if name is None: collection = Collection.query.get_or_404(1) else...
python
def collection(name=None): """Render the collection page. It renders it either with a collection specific template (aka collection_{collection_name}.html) or with the default collection template (collection.html). """ if name is None: collection = Collection.query.get_or_404(1) else...
['def', 'collection', '(', 'name', '=', 'None', ')', ':', 'if', 'name', 'is', 'None', ':', 'collection', '=', 'Collection', '.', 'query', '.', 'get_or_404', '(', '1', ')', 'else', ':', 'collection', '=', 'Collection', '.', 'query', '.', 'filter', '(', 'Collection', '.', 'name', '==', 'name', ')', '.', 'first_or_404', '...
Render the collection page. It renders it either with a collection specific template (aka collection_{collection_name}.html) or with the default collection template (collection.html).
['Render', 'the', 'collection', 'page', '.']
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/views.py#L44-L63
5,470
bcbio/bcbio-nextgen
bcbio/structural/prioritize.py
_combine_files
def _combine_files(tsv_files, work_dir, data): """Combine multiple priority tsv files into a final sorted output. """ header = "\t".join(["caller", "sample", "chrom", "start", "end", "svtype", "lof", "annotation", "split_read_support", "paired_support_PE", "paired_support_PR"]) s...
python
def _combine_files(tsv_files, work_dir, data): """Combine multiple priority tsv files into a final sorted output. """ header = "\t".join(["caller", "sample", "chrom", "start", "end", "svtype", "lof", "annotation", "split_read_support", "paired_support_PE", "paired_support_PR"]) s...
['def', '_combine_files', '(', 'tsv_files', ',', 'work_dir', ',', 'data', ')', ':', 'header', '=', '"\\t"', '.', 'join', '(', '[', '"caller"', ',', '"sample"', ',', '"chrom"', ',', '"start"', ',', '"end"', ',', '"svtype"', ',', '"lof"', ',', '"annotation"', ',', '"split_read_support"', ',', '"paired_support_PE"', ',', ...
Combine multiple priority tsv files into a final sorted output.
['Combine', 'multiple', 'priority', 'tsv', 'files', 'into', 'a', 'final', 'sorted', 'output', '.']
train
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/prioritize.py#L145-L159
5,471
pysathq/pysat
examples/rc2.py
parse_options
def parse_options(): """ Parses command-line option """ try: opts, args = getopt.getopt(sys.argv[1:], 'ac:e:hilms:t:vx', ['adapt', 'comp=', 'enum=', 'exhaust', 'help', 'incr', 'blo', 'minimize', 'solver=', 'trim=', 'verbose']) except getopt.GetoptErro...
python
def parse_options(): """ Parses command-line option """ try: opts, args = getopt.getopt(sys.argv[1:], 'ac:e:hilms:t:vx', ['adapt', 'comp=', 'enum=', 'exhaust', 'help', 'incr', 'blo', 'minimize', 'solver=', 'trim=', 'verbose']) except getopt.GetoptErro...
['def', 'parse_options', '(', ')', ':', 'try', ':', 'opts', ',', 'args', '=', 'getopt', '.', 'getopt', '(', 'sys', '.', 'argv', '[', '1', ':', ']', ',', "'ac:e:hilms:t:vx'", ',', '[', "'adapt'", ',', "'comp='", ',', "'enum='", ',', "'exhaust'", ',', "'help'", ',', "'incr'", ',', "'blo'", ',', "'minimize'", ',', "'solve...
Parses command-line option
['Parses', 'command', '-', 'line', 'option']
train
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L1463-L1520
5,472
jplusplus/statscraper
statscraper/base_scraper.py
ResultSet.append
def append(self, val): """Connect any new results to the resultset. This is where all the heavy lifting is done for creating results: - We add a datatype here, so that each result can handle validation etc independently. This is so that scraper authors don't need to worry about...
python
def append(self, val): """Connect any new results to the resultset. This is where all the heavy lifting is done for creating results: - We add a datatype here, so that each result can handle validation etc independently. This is so that scraper authors don't need to worry about...
['def', 'append', '(', 'self', ',', 'val', ')', ':', 'val', '.', 'resultset', '=', 'self', 'val', '.', 'dataset', '=', 'self', '.', 'dataset', '# Check result dimensions against available dimensions for this dataset', 'if', 'val', '.', 'dataset', ':', 'dataset_dimensions', '=', 'self', '.', 'dataset', '.', 'dimensions'...
Connect any new results to the resultset. This is where all the heavy lifting is done for creating results: - We add a datatype here, so that each result can handle validation etc independently. This is so that scraper authors don't need to worry about creating and passing around datat...
['Connect', 'any', 'new', 'results', 'to', 'the', 'resultset', '.']
train
https://github.com/jplusplus/statscraper/blob/932ec048b23d15b3dbdaf829facc55fd78ec0109/statscraper/base_scraper.py#L88-L140
5,473
jjjake/internetarchive
internetarchive/session.py
ArchiveSession.set_file_logger
def set_file_logger(self, log_level, path, logger_name='internetarchive'): """Convenience function to quickly configure any level of logging to a file. :type log_level: str :param log_level: A log level as specified in the `logging` module. :type path: string :param pat...
python
def set_file_logger(self, log_level, path, logger_name='internetarchive'): """Convenience function to quickly configure any level of logging to a file. :type log_level: str :param log_level: A log level as specified in the `logging` module. :type path: string :param pat...
['def', 'set_file_logger', '(', 'self', ',', 'log_level', ',', 'path', ',', 'logger_name', '=', "'internetarchive'", ')', ':', '_log_level', '=', '{', "'CRITICAL'", ':', '50', ',', "'ERROR'", ':', '40', ',', "'WARNING'", ':', '30', ',', "'INFO'", ':', '20', ',', "'DEBUG'", ':', '10', ',', "'NOTSET'", ':', '0', ',', '}'...
Convenience function to quickly configure any level of logging to a file. :type log_level: str :param log_level: A log level as specified in the `logging` module. :type path: string :param path: Path to the log file. The file will be created if it doesn't already ...
['Convenience', 'function', 'to', 'quickly', 'configure', 'any', 'level', 'of', 'logging', 'to', 'a', 'file', '.']
train
https://github.com/jjjake/internetarchive/blob/7c0c71bfe52490927a37ade15bd09b2733fea660/internetarchive/session.py#L183-L217
5,474
fopina/tgbotplug
tgbot/tgbot.py
TGBot.print_commands
def print_commands(self, out=sys.stdout): ''' utility method to print commands and descriptions for @BotFather ''' cmds = self.list_commands() for ck in cmds: if ck.printable: out.write('%s\n' % ck)
python
def print_commands(self, out=sys.stdout): ''' utility method to print commands and descriptions for @BotFather ''' cmds = self.list_commands() for ck in cmds: if ck.printable: out.write('%s\n' % ck)
['def', 'print_commands', '(', 'self', ',', 'out', '=', 'sys', '.', 'stdout', ')', ':', 'cmds', '=', 'self', '.', 'list_commands', '(', ')', 'for', 'ck', 'in', 'cmds', ':', 'if', 'ck', '.', 'printable', ':', 'out', '.', 'write', '(', "'%s\\n'", '%', 'ck', ')']
utility method to print commands and descriptions for @BotFather
['utility', 'method', 'to', 'print', 'commands', 'and', 'descriptions', 'for']
train
https://github.com/fopina/tgbotplug/blob/c115733b03f2e23ddcdecfce588d1a6a1e5bde91/tgbot/tgbot.py#L161-L169
5,475
devopshq/youtrack
youtrack/connection.py
Connection.import_links
def import_links(self, links): """ Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links) Accepts result of getLinks() Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'}, ...
python
def import_links(self, links): """ Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links) Accepts result of getLinks() Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'}, ...
['def', 'import_links', '(', 'self', ',', 'links', ')', ':', 'xml', '=', "'<list>\\n'", 'for', 'l', 'in', 'links', ':', '# ignore typeOutward and typeInward returned by getLinks()', 'xml', '+=', "' <link '", '+', '""', '.', 'join', '(', 'attr', '+', "'='", '+', 'quoteattr', '(', 'l', '[', 'attr', ']', ')', '+', "' '",...
Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links) Accepts result of getLinks() Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'}, {'login':'maxim', 'fullName':'...
['Import', 'links', 'returns', 'import', 'result', '(', 'http', ':', '//', 'confluence', '.', 'jetbrains', '.', 'net', '/', 'display', '/', 'YTD2', '/', 'Import', '+', 'Links', ')', 'Accepts', 'result', 'of', 'getLinks', '()', 'Example', ':', 'importLinks', '(', '[', '{', 'login', ':', 'vadim', 'fullName', ':', 'vadim'...
train
https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L356-L370
5,476
abingham/docopt-subcommands
docopt_subcommands/subcommands.py
Subcommands.add_command
def add_command(self, handler, name=None): """Add a subcommand `name` which invokes `handler`. """ if name is None: name = docstring_to_subcommand(handler.__doc__) # TODO: Prevent overwriting 'help'? self._commands[name] = handler
python
def add_command(self, handler, name=None): """Add a subcommand `name` which invokes `handler`. """ if name is None: name = docstring_to_subcommand(handler.__doc__) # TODO: Prevent overwriting 'help'? self._commands[name] = handler
['def', 'add_command', '(', 'self', ',', 'handler', ',', 'name', '=', 'None', ')', ':', 'if', 'name', 'is', 'None', ':', 'name', '=', 'docstring_to_subcommand', '(', 'handler', '.', '__doc__', ')', "# TODO: Prevent overwriting 'help'?", 'self', '.', '_commands', '[', 'name', ']', '=', 'handler']
Add a subcommand `name` which invokes `handler`.
['Add', 'a', 'subcommand', 'name', 'which', 'invokes', 'handler', '.']
train
https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/subcommands.py#L98-L105
5,477
avinassh/haxor
hackernews/__init__.py
HackerNews.get_item
def get_item(self, item_id, expand=False): """Returns Hacker News `Item` object. Fetches the data from url: https://hacker-news.firebaseio.com/v0/item/<item_id>.json e.g. https://hacker-news.firebaseio.com/v0/item/69696969.json Args: item_id (int or string): Un...
python
def get_item(self, item_id, expand=False): """Returns Hacker News `Item` object. Fetches the data from url: https://hacker-news.firebaseio.com/v0/item/<item_id>.json e.g. https://hacker-news.firebaseio.com/v0/item/69696969.json Args: item_id (int or string): Un...
['def', 'get_item', '(', 'self', ',', 'item_id', ',', 'expand', '=', 'False', ')', ':', 'url', '=', 'urljoin', '(', 'self', '.', 'item_url', ',', 'F"{item_id}.json"', ')', 'response', '=', 'self', '.', '_get_sync', '(', 'url', ')', 'if', 'not', 'response', ':', 'raise', 'InvalidItemID', 'item', '=', 'Item', '(', 'respo...
Returns Hacker News `Item` object. Fetches the data from url: https://hacker-news.firebaseio.com/v0/item/<item_id>.json e.g. https://hacker-news.firebaseio.com/v0/item/69696969.json Args: item_id (int or string): Unique item id of Hacker News story, comment...
['Returns', 'Hacker', 'News', 'Item', 'object', '.']
train
https://github.com/avinassh/haxor/blob/71dbecf87531f7a24bb39c736d53127427aaca84/hackernews/__init__.py#L165-L202
5,478
pmorissette/bt
bt/core.py
SecurityBase.allocate
def allocate(self, amount, update=True): """ This allocates capital to the Security. This is the method used to buy/sell the security. A given amount of shares will be determined on the current price, a commission will be calculated based on the parent's commission fn, and ...
python
def allocate(self, amount, update=True): """ This allocates capital to the Security. This is the method used to buy/sell the security. A given amount of shares will be determined on the current price, a commission will be calculated based on the parent's commission fn, and ...
['def', 'allocate', '(', 'self', ',', 'amount', ',', 'update', '=', 'True', ')', ':', '# will need to update if this has been idle for a while...', '# update if needupdate or if now is stale', "# fetch parent's now since our now is stale", 'if', 'self', '.', '_needupdate', 'or', 'self', '.', 'now', '!=', 'self', '.', '...
This allocates capital to the Security. This is the method used to buy/sell the security. A given amount of shares will be determined on the current price, a commission will be calculated based on the parent's commission fn, and any remaining capital will be passed back up to parent as...
['This', 'allocates', 'capital', 'to', 'the', 'Security', '.', 'This', 'is', 'the', 'method', 'used', 'to', 'buy', '/', 'sell', 'the', 'security', '.']
train
https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L987-L1156
5,479
hydraplatform/hydra-base
hydra_base/lib/project.py
get_project_by_network_id
def get_project_by_network_id(network_id,**kwargs): """ get a project complexmodel by a network_id """ user_id = kwargs.get('user_id') projects_i = db.DBSession.query(Project).join(ProjectOwner).join(Network, Project.id==Network.project_id).filter( ...
python
def get_project_by_network_id(network_id,**kwargs): """ get a project complexmodel by a network_id """ user_id = kwargs.get('user_id') projects_i = db.DBSession.query(Project).join(ProjectOwner).join(Network, Project.id==Network.project_id).filter( ...
['def', 'get_project_by_network_id', '(', 'network_id', ',', '*', '*', 'kwargs', ')', ':', 'user_id', '=', 'kwargs', '.', 'get', '(', "'user_id'", ')', 'projects_i', '=', 'db', '.', 'DBSession', '.', 'query', '(', 'Project', ')', '.', 'join', '(', 'ProjectOwner', ')', '.', 'join', '(', 'Network', ',', 'Project', '.', '...
get a project complexmodel by a network_id
['get', 'a', 'project', 'complexmodel', 'by', 'a', 'network_id']
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L149-L166
5,480
bpsmith/tia
tia/rlab/builder.py
PdfBuilder.new_title_bar
def new_title_bar(self, title, color=None): """Return an array of Pdf Objects which constitute a Header""" # Build a title bar for top of page w, t, c = '100%', 2, color or HexColor('#404040') title = '<b>{0}</b>'.format(title) if 'TitleBar' not in self.stylesheet: tb...
python
def new_title_bar(self, title, color=None): """Return an array of Pdf Objects which constitute a Header""" # Build a title bar for top of page w, t, c = '100%', 2, color or HexColor('#404040') title = '<b>{0}</b>'.format(title) if 'TitleBar' not in self.stylesheet: tb...
['def', 'new_title_bar', '(', 'self', ',', 'title', ',', 'color', '=', 'None', ')', ':', '# Build a title bar for top of page', 'w', ',', 't', ',', 'c', '=', "'100%'", ',', '2', ',', 'color', 'or', 'HexColor', '(', "'#404040'", ')', 'title', '=', "'<b>{0}</b>'", '.', 'format', '(', 'title', ')', 'if', "'TitleBar'", 'no...
Return an array of Pdf Objects which constitute a Header
['Return', 'an', 'array', 'of', 'Pdf', 'Objects', 'which', 'constitute', 'a', 'Header']
train
https://github.com/bpsmith/tia/blob/a7043b6383e557aeea8fc7112bbffd6e36a230e9/tia/rlab/builder.py#L174-L185
5,481
Yelp/detect-secrets
detect_secrets/core/potential_secret.py
PotentialSecret.json
def json(self): """Custom JSON encoder""" attributes = { 'type': self.type, 'filename': self.filename, 'line_number': self.lineno, 'hashed_secret': self.secret_hash, } if self.is_secret is not None: attributes['is_secret'] = se...
python
def json(self): """Custom JSON encoder""" attributes = { 'type': self.type, 'filename': self.filename, 'line_number': self.lineno, 'hashed_secret': self.secret_hash, } if self.is_secret is not None: attributes['is_secret'] = se...
['def', 'json', '(', 'self', ')', ':', 'attributes', '=', '{', "'type'", ':', 'self', '.', 'type', ',', "'filename'", ':', 'self', '.', 'filename', ',', "'line_number'", ':', 'self', '.', 'lineno', ',', "'hashed_secret'", ':', 'self', '.', 'secret_hash', ',', '}', 'if', 'self', '.', 'is_secret', 'is', 'not', 'None', ':...
Custom JSON encoder
['Custom', 'JSON', 'encoder']
train
https://github.com/Yelp/detect-secrets/blob/473923ea71f1ac2b5ea1eacc49b98f97967e3d05/detect_secrets/core/potential_secret.py#L65-L77
5,482
pvlib/pvlib-python
pvlib/iotools/surfrad.py
read_surfrad
def read_surfrad(filename, map_variables=True): """Read in a daily NOAA SURFRAD[1] file. Parameters ---------- filename: str Filepath or url. map_variables: bool When true, renames columns of the Dataframe to pvlib variable names where applicable. See variable SURFRAD_COLUMN...
python
def read_surfrad(filename, map_variables=True): """Read in a daily NOAA SURFRAD[1] file. Parameters ---------- filename: str Filepath or url. map_variables: bool When true, renames columns of the Dataframe to pvlib variable names where applicable. See variable SURFRAD_COLUMN...
['def', 'read_surfrad', '(', 'filename', ',', 'map_variables', '=', 'True', ')', ':', 'if', 'filename', '.', 'startswith', '(', "'ftp'", ')', ':', 'req', '=', 'Request', '(', 'filename', ')', 'response', '=', 'urlopen', '(', 'req', ')', 'file_buffer', '=', 'io', '.', 'StringIO', '(', 'response', '.', 'read', '(', ')', ...
Read in a daily NOAA SURFRAD[1] file. Parameters ---------- filename: str Filepath or url. map_variables: bool When true, renames columns of the Dataframe to pvlib variable names where applicable. See variable SURFRAD_COLUMNS. Returns ------- Tuple of the form (data...
['Read', 'in', 'a', 'daily', 'NOAA', 'SURFRAD', '[', '1', ']', 'file', '.']
train
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/iotools/surfrad.py#L46-L160
5,483
DataDog/integrations-core
hdfs_namenode/datadog_checks/hdfs_namenode/hdfs_namenode.py
HDFSNameNode._set_metric
def _set_metric(self, metric_name, metric_type, value, tags=None): """ Set a metric """ if metric_type == self.GAUGE: self.gauge(metric_name, value, tags=tags) else: self.log.error('Metric type "{}" unknown'.format(metric_type))
python
def _set_metric(self, metric_name, metric_type, value, tags=None): """ Set a metric """ if metric_type == self.GAUGE: self.gauge(metric_name, value, tags=tags) else: self.log.error('Metric type "{}" unknown'.format(metric_type))
['def', '_set_metric', '(', 'self', ',', 'metric_name', ',', 'metric_type', ',', 'value', ',', 'tags', '=', 'None', ')', ':', 'if', 'metric_type', '==', 'self', '.', 'GAUGE', ':', 'self', '.', 'gauge', '(', 'metric_name', ',', 'value', ',', 'tags', '=', 'tags', ')', 'else', ':', 'self', '.', 'log', '.', 'error', '(', '...
Set a metric
['Set', 'a', 'metric']
train
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/hdfs_namenode/datadog_checks/hdfs_namenode/hdfs_namenode.py#L131-L138
5,484
nwilming/ocupy
ocupy/datamat.py
Datamat.parameter_to_field
def parameter_to_field(self, name): """ Promotes a parameter to a field by creating a new array of same size as the other existing fields, filling it with the current value of the parameter, and then removing that parameter. """ if name not in self._parameters: ...
python
def parameter_to_field(self, name): """ Promotes a parameter to a field by creating a new array of same size as the other existing fields, filling it with the current value of the parameter, and then removing that parameter. """ if name not in self._parameters: ...
['def', 'parameter_to_field', '(', 'self', ',', 'name', ')', ':', 'if', 'name', 'not', 'in', 'self', '.', '_parameters', ':', 'raise', 'ValueError', '(', '"no \'%s\' parameter found"', '%', '(', 'name', ')', ')', 'if', 'self', '.', '_fields', '.', 'count', '(', 'name', ')', '>', '0', ':', 'raise', 'ValueError', '(', '"...
Promotes a parameter to a field by creating a new array of same size as the other existing fields, filling it with the current value of the parameter, and then removing that parameter.
['Promotes', 'a', 'parameter', 'to', 'a', 'field', 'by', 'creating', 'a', 'new', 'array', 'of', 'same', 'size', 'as', 'the', 'other', 'existing', 'fields', 'filling', 'it', 'with', 'the', 'current', 'value', 'of', 'the', 'parameter', 'and', 'then', 'removing', 'that', 'parameter', '.']
train
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L450-L464
5,485
boriel/zxbasic
asm.py
AsmInstruction.bytes
def bytes(self): """ Returns a t-uple with instruction bytes (integers) """ result = [] op = self.opcode.split(' ') argi = 0 while op: q = op.pop(0) if q == 'XX': for k in range(self.argbytes[argi] - 1): op.pop...
python
def bytes(self): """ Returns a t-uple with instruction bytes (integers) """ result = [] op = self.opcode.split(' ') argi = 0 while op: q = op.pop(0) if q == 'XX': for k in range(self.argbytes[argi] - 1): op.pop...
['def', 'bytes', '(', 'self', ')', ':', 'result', '=', '[', ']', 'op', '=', 'self', '.', 'opcode', '.', 'split', '(', "' '", ')', 'argi', '=', '0', 'while', 'op', ':', 'q', '=', 'op', '.', 'pop', '(', '0', ')', 'if', 'q', '==', "'XX'", ':', 'for', 'k', 'in', 'range', '(', 'self', '.', 'argbytes', '[', 'argi', ']', '-',...
Returns a t-uple with instruction bytes (integers)
['Returns', 'a', 't', '-', 'uple', 'with', 'instruction', 'bytes', '(', 'integers', ')']
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asm.py#L128-L150
5,486
yyuu/botornado
boto/ec2/elb/__init__.py
ELBConnection.attach_lb_to_subnets
def attach_lb_to_subnets(self, name, subnets): """ Attaches load balancer to one or more subnets. Attaching subnets that are already registered with the Load Balancer has no effect. :type name: string :param name: The name of the Load Balancer :type subnets: Li...
python
def attach_lb_to_subnets(self, name, subnets): """ Attaches load balancer to one or more subnets. Attaching subnets that are already registered with the Load Balancer has no effect. :type name: string :param name: The name of the Load Balancer :type subnets: Li...
['def', 'attach_lb_to_subnets', '(', 'self', ',', 'name', ',', 'subnets', ')', ':', 'params', '=', '{', "'LoadBalancerName'", ':', 'name', '}', 'self', '.', 'build_list_params', '(', 'params', ',', 'subnets', ',', "'Subnets.member.%d'", ')', 'return', 'self', '.', 'get_list', '(', "'AttachLoadBalancerToSubnets'", ',', ...
Attaches load balancer to one or more subnets. Attaching subnets that are already registered with the Load Balancer has no effect. :type name: string :param name: The name of the Load Balancer :type subnets: List of strings :param subnets: The name of the subnet(s) to ...
['Attaches', 'load', 'balancer', 'to', 'one', 'or', 'more', 'subnets', '.', 'Attaching', 'subnets', 'that', 'are', 'already', 'registered', 'with', 'the', 'Load', 'Balancer', 'has', 'no', 'effect', '.']
train
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/elb/__init__.py#L484-L505
5,487
scrapinghub/flatson
flatson/flatson.py
Flatson.flatten_dict
def flatten_dict(self, obj): """Return an OrderedDict dict preserving order of keys in fieldnames """ return OrderedDict(zip(self.fieldnames, self.flatten(obj)))
python
def flatten_dict(self, obj): """Return an OrderedDict dict preserving order of keys in fieldnames """ return OrderedDict(zip(self.fieldnames, self.flatten(obj)))
['def', 'flatten_dict', '(', 'self', ',', 'obj', ')', ':', 'return', 'OrderedDict', '(', 'zip', '(', 'self', '.', 'fieldnames', ',', 'self', '.', 'flatten', '(', 'obj', ')', ')', ')']
Return an OrderedDict dict preserving order of keys in fieldnames
['Return', 'an', 'OrderedDict', 'dict', 'preserving', 'order', 'of', 'keys', 'in', 'fieldnames']
train
https://github.com/scrapinghub/flatson/blob/dcbcea32ad6d4df1df85fff8366bce40438d469a/flatson/flatson.py#L136-L139
5,488
mdiener/grace
grace/py27/pyjsdoc.py
make_index
def make_index(css_class, entities): """ Generate the HTML index (a short description and a link to the full documentation) for a list of FunctionDocs or ClassDocs. """ def make_entry(entity): return ('<dt><a href = "%(url)s">%(name)s</a></dt>\n' + '<dd>%(doc)s</dd>') % { ...
python
def make_index(css_class, entities): """ Generate the HTML index (a short description and a link to the full documentation) for a list of FunctionDocs or ClassDocs. """ def make_entry(entity): return ('<dt><a href = "%(url)s">%(name)s</a></dt>\n' + '<dd>%(doc)s</dd>') % { ...
['def', 'make_index', '(', 'css_class', ',', 'entities', ')', ':', 'def', 'make_entry', '(', 'entity', ')', ':', 'return', '(', '\'<dt><a href = "%(url)s">%(name)s</a></dt>\\n\'', '+', "'<dd>%(doc)s</dd>'", ')', '%', '{', "'name'", ':', 'entity', '.', 'name', ',', "'url'", ':', 'entity', '.', 'url', ',', "'doc'", ':', ...
Generate the HTML index (a short description and a link to the full documentation) for a list of FunctionDocs or ClassDocs.
['Generate', 'the', 'HTML', 'index', '(', 'a', 'short', 'description', 'and', 'a', 'link', 'to', 'the', 'full', 'documentation', ')', 'for', 'a', 'list', 'of', 'FunctionDocs', 'or', 'ClassDocs', '.']
train
https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/pyjsdoc.py#L1442-L1458
5,489
googlefonts/fontmake
Lib/fontmake/font_project.py
FontProject.remove_overlaps
def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)): """Remove overlaps in UFOs' glyphs' contours.""" from booleanOperations import union, BooleanOperationsError for ufo in ufos: font_name = self._font_name(ufo) logger.info("Removing overlaps for " + font_name...
python
def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)): """Remove overlaps in UFOs' glyphs' contours.""" from booleanOperations import union, BooleanOperationsError for ufo in ufos: font_name = self._font_name(ufo) logger.info("Removing overlaps for " + font_name...
['def', 'remove_overlaps', '(', 'self', ',', 'ufos', ',', 'glyph_filter', '=', 'lambda', 'g', ':', 'len', '(', 'g', ')', ')', ':', 'from', 'booleanOperations', 'import', 'union', ',', 'BooleanOperationsError', 'for', 'ufo', 'in', 'ufos', ':', 'font_name', '=', 'self', '.', '_font_name', '(', 'ufo', ')', 'logger', '.', ...
Remove overlaps in UFOs' glyphs' contours.
['Remove', 'overlaps', 'in', 'UFOs', 'glyphs', 'contours', '.']
train
https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L187-L205
5,490
nion-software/nionswift-instrumentation-kit
nion/instrumentation/camera_base.py
CameraSettings.set_frame_parameters
def set_frame_parameters(self, profile_index: int, frame_parameters) -> None: """Set the frame parameters with the settings index and fire the frame parameters changed event. If the settings index matches the current settings index, call set current frame parameters. If the settings index matc...
python
def set_frame_parameters(self, profile_index: int, frame_parameters) -> None: """Set the frame parameters with the settings index and fire the frame parameters changed event. If the settings index matches the current settings index, call set current frame parameters. If the settings index matc...
['def', 'set_frame_parameters', '(', 'self', ',', 'profile_index', ':', 'int', ',', 'frame_parameters', ')', '->', 'None', ':', 'self', '.', 'frame_parameters_changed_event', '.', 'fire', '(', 'profile_index', ',', 'frame_parameters', ')']
Set the frame parameters with the settings index and fire the frame parameters changed event. If the settings index matches the current settings index, call set current frame parameters. If the settings index matches the record settings index, call set record frame parameters.
['Set', 'the', 'frame', 'parameters', 'with', 'the', 'settings', 'index', 'and', 'fire', 'the', 'frame', 'parameters', 'changed', 'event', '.']
train
https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nion/instrumentation/camera_base.py#L504-L511
5,491
log2timeline/dfvfs
dfvfs/lib/data_format.py
DataFormat._ReadStructure
def _ReadStructure( self, file_object, file_offset, data_size, data_type_map, description): """Reads a structure. Args: file_object (FileIO): file-like object. file_offset (int): offset of the data relative from the start of the file-like object. data_size (int): data size of ...
python
def _ReadStructure( self, file_object, file_offset, data_size, data_type_map, description): """Reads a structure. Args: file_object (FileIO): file-like object. file_offset (int): offset of the data relative from the start of the file-like object. data_size (int): data size of ...
['def', '_ReadStructure', '(', 'self', ',', 'file_object', ',', 'file_offset', ',', 'data_size', ',', 'data_type_map', ',', 'description', ')', ':', 'data', '=', 'self', '.', '_ReadData', '(', 'file_object', ',', 'file_offset', ',', 'data_size', ',', 'description', ')', 'return', 'self', '.', '_ReadStructureFromByteStr...
Reads a structure. Args: file_object (FileIO): file-like object. file_offset (int): offset of the data relative from the start of the file-like object. data_size (int): data size of the structure. data_type_map (dtfabric.DataTypeMap): data type map of the structure. descript...
['Reads', 'a', 'structure', '.']
train
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/lib/data_format.py#L93-L115
5,492
DataBiosphere/toil
src/toil/common.py
Toil.createBatchSystem
def createBatchSystem(config): """ Creates an instance of the batch system specified in the given config. :param toil.common.Config config: the current configuration :rtype: batchSystems.abstractBatchSystem.AbstractBatchSystem :return: an instance of a concrete subclass of Abs...
python
def createBatchSystem(config): """ Creates an instance of the batch system specified in the given config. :param toil.common.Config config: the current configuration :rtype: batchSystems.abstractBatchSystem.AbstractBatchSystem :return: an instance of a concrete subclass of Abs...
['def', 'createBatchSystem', '(', 'config', ')', ':', 'kwargs', '=', 'dict', '(', 'config', '=', 'config', ',', 'maxCores', '=', 'config', '.', 'maxCores', ',', 'maxMemory', '=', 'config', '.', 'maxMemory', ',', 'maxDisk', '=', 'config', '.', 'maxDisk', ')', 'from', 'toil', '.', 'batchSystems', '.', 'registry', 'import...
Creates an instance of the batch system specified in the given config. :param toil.common.Config config: the current configuration :rtype: batchSystems.abstractBatchSystem.AbstractBatchSystem :return: an instance of a concrete subclass of AbstractBatchSystem
['Creates', 'an', 'instance', 'of', 'the', 'batch', 'system', 'specified', 'in', 'the', 'given', 'config', '.']
train
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/common.py#L870-L900
5,493
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginpool.py
PluginPool.get_plugin_by_model
def get_plugin_by_model(self, model_class): """ Return the corresponding plugin for a given model. You can also use the :attr:`ContentItem.plugin <fluent_contents.models.ContentItem.plugin>` property directly. This is the low-level function that supports that feature. """ ...
python
def get_plugin_by_model(self, model_class): """ Return the corresponding plugin for a given model. You can also use the :attr:`ContentItem.plugin <fluent_contents.models.ContentItem.plugin>` property directly. This is the low-level function that supports that feature. """ ...
['def', 'get_plugin_by_model', '(', 'self', ',', 'model_class', ')', ':', 'self', '.', '_import_plugins', '(', ')', '# could happen during rendering that no plugin scan happened yet.', 'assert', 'issubclass', '(', 'model_class', ',', 'ContentItem', ')', '# avoid confusion between model instance and class here!', 'try',...
Return the corresponding plugin for a given model. You can also use the :attr:`ContentItem.plugin <fluent_contents.models.ContentItem.plugin>` property directly. This is the low-level function that supports that feature.
['Return', 'the', 'corresponding', 'plugin', 'for', 'a', 'given', 'model', '.']
train
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginpool.py#L154-L168
5,494
hangyan/shaw
shaw/web/web.py
error_response
def error_response(message, status=400, code=None): """"Return error message(in dict).""" from django.http import JsonResponse data = {'message': message} if code: data['code'] = code LOG.error("Error response, status code is : {} | {}".format(status, data)) return JsonResponse(data=data...
python
def error_response(message, status=400, code=None): """"Return error message(in dict).""" from django.http import JsonResponse data = {'message': message} if code: data['code'] = code LOG.error("Error response, status code is : {} | {}".format(status, data)) return JsonResponse(data=data...
['def', 'error_response', '(', 'message', ',', 'status', '=', '400', ',', 'code', '=', 'None', ')', ':', 'from', 'django', '.', 'http', 'import', 'JsonResponse', 'data', '=', '{', "'message'", ':', 'message', '}', 'if', 'code', ':', 'data', '[', "'code'", ']', '=', 'code', 'LOG', '.', 'error', '(', '"Error response, st...
Return error message(in dict).
['Return', 'error', 'message', '(', 'in', 'dict', ')', '.']
train
https://github.com/hangyan/shaw/blob/63d01d35e225ba4edb9c61edaf351e1bc0e8fd15/shaw/web/web.py#L23-L30
5,495
lucuma/Clay
clay/manage.py
run
def run(host=DEFAULT_HOST, port=DEFAULT_PORT, path='.'): """Run the development server """ path = abspath(path) c = Clay(path) c.run(host=host, port=port)
python
def run(host=DEFAULT_HOST, port=DEFAULT_PORT, path='.'): """Run the development server """ path = abspath(path) c = Clay(path) c.run(host=host, port=port)
['def', 'run', '(', 'host', '=', 'DEFAULT_HOST', ',', 'port', '=', 'DEFAULT_PORT', ',', 'path', '=', "'.'", ')', ':', 'path', '=', 'abspath', '(', 'path', ')', 'c', '=', 'Clay', '(', 'path', ')', 'c', '.', 'run', '(', 'host', '=', 'host', ',', 'port', '=', 'port', ')']
Run the development server
['Run', 'the', 'development', 'server']
train
https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/manage.py#L44-L49
5,496
nugget/python-anthemav
anthemav/connection.py
Connection.close
def close(self): """Close the AVR device connection and don't try to reconnect.""" self.log.warning('Closing connection to AVR') self._closing = True if self.protocol.transport: self.protocol.transport.close()
python
def close(self): """Close the AVR device connection and don't try to reconnect.""" self.log.warning('Closing connection to AVR') self._closing = True if self.protocol.transport: self.protocol.transport.close()
['def', 'close', '(', 'self', ')', ':', 'self', '.', 'log', '.', 'warning', '(', "'Closing connection to AVR'", ')', 'self', '.', '_closing', '=', 'True', 'if', 'self', '.', 'protocol', '.', 'transport', ':', 'self', '.', 'protocol', '.', 'transport', '.', 'close', '(', ')']
Close the AVR device connection and don't try to reconnect.
['Close', 'the', 'AVR', 'device', 'connection', 'and', 'don', 't', 'try', 'to', 'reconnect', '.']
train
https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/connection.py#L117-L122
5,497
ic-labs/django-icekit
icekit/publishing/admin.py
_PublishingHelpersMixin.has_preview_permission
def has_preview_permission(self, request, obj=None): """ Return `True` if the user has permissions to preview a publishable item. NOTE: this method does not actually change who can or cannot preview any particular item, just whether to show the preview link. The real dci...
python
def has_preview_permission(self, request, obj=None): """ Return `True` if the user has permissions to preview a publishable item. NOTE: this method does not actually change who can or cannot preview any particular item, just whether to show the preview link. The real dci...
['def', 'has_preview_permission', '(', 'self', ',', 'request', ',', 'obj', '=', 'None', ')', ':', '# User who can publish always has preview permission.', 'if', 'self', '.', 'has_publish_permission', '(', 'request', ',', 'obj', '=', 'obj', ')', ':', 'return', 'True', 'user_obj', '=', 'request', '.', 'user', 'if', 'not'...
Return `True` if the user has permissions to preview a publishable item. NOTE: this method does not actually change who can or cannot preview any particular item, just whether to show the preview link. The real dcision is made by a combination of: - `PublishingMiddleware` which...
['Return', 'True', 'if', 'the', 'user', 'has', 'permissions', 'to', 'preview', 'a', 'publishable', 'item', '.']
train
https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit/publishing/admin.py#L312-L337
5,498
pyviz/holoviews
holoviews/plotting/util.py
process_cmap
def process_cmap(cmap, ncolors=None, provider=None, categorical=False): """ Convert valid colormap specifications to a list of colors. """ providers_checked="matplotlib, bokeh, or colorcet" if provider is None else provider if isinstance(cmap, Cycle): palette = [rgb2hex(c) if isinstance(c, ...
python
def process_cmap(cmap, ncolors=None, provider=None, categorical=False): """ Convert valid colormap specifications to a list of colors. """ providers_checked="matplotlib, bokeh, or colorcet" if provider is None else provider if isinstance(cmap, Cycle): palette = [rgb2hex(c) if isinstance(c, ...
['def', 'process_cmap', '(', 'cmap', ',', 'ncolors', '=', 'None', ',', 'provider', '=', 'None', ',', 'categorical', '=', 'False', ')', ':', 'providers_checked', '=', '"matplotlib, bokeh, or colorcet"', 'if', 'provider', 'is', 'None', 'else', 'provider', 'if', 'isinstance', '(', 'cmap', ',', 'Cycle', ')', ':', 'palette'...
Convert valid colormap specifications to a list of colors.
['Convert', 'valid', 'colormap', 'specifications', 'to', 'a', 'list', 'of', 'colors', '.']
train
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/util.py#L868-L906
5,499
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/input_readers.py
NamespaceInputReader.from_json
def from_json(cls, json): """Create new DatastoreInputReader from the json, encoded by to_json. Args: json: json map representation of DatastoreInputReader. Returns: an instance of DatastoreInputReader with all data deserialized from json. """ return cls( namespace_range.Namesp...
python
def from_json(cls, json): """Create new DatastoreInputReader from the json, encoded by to_json. Args: json: json map representation of DatastoreInputReader. Returns: an instance of DatastoreInputReader with all data deserialized from json. """ return cls( namespace_range.Namesp...
['def', 'from_json', '(', 'cls', ',', 'json', ')', ':', 'return', 'cls', '(', 'namespace_range', '.', 'NamespaceRange', '.', 'from_json_object', '(', 'json', '[', 'cls', '.', 'NAMESPACE_RANGE_PARAM', ']', ')', ',', 'json', '[', 'cls', '.', 'BATCH_SIZE_PARAM', ']', ')']
Create new DatastoreInputReader from the json, encoded by to_json. Args: json: json map representation of DatastoreInputReader. Returns: an instance of DatastoreInputReader with all data deserialized from json.
['Create', 'new', 'DatastoreInputReader', 'from', 'the', 'json', 'encoded', 'by', 'to_json', '.']
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/input_readers.py#L1954-L1966