K00B404/GPT_2_CODE
Text Generation • 0.4B • Updated • 14 • 1
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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0 | getsentry/libsourcemap | libsourcemap/highlevel.py | View.get_original_function_name | def get_original_function_name(self, line, col, minified_name,
minified_source):
"""Given a token location and a minified function name and the
minified source file this returns the original function name if it
can be found of the minified function in scope.
... | python | def get_original_function_name(self, line, col, minified_name,
minified_source):
"""Given a token location and a minified function name and the
minified source file this returns the original function name if it
can be found of the minified function in scope.
... | ['def', 'get_original_function_name', '(', 'self', ',', 'line', ',', 'col', ',', 'minified_name', ',', 'minified_source', ')', ':', '# Silently ignore underflows', 'if', 'line', '<', '0', 'or', 'col', '<', '0', ':', 'return', 'None', 'minified_name', '=', 'minified_name', '.', 'encode', '(', "'utf-8'", ')', 'sout', '='... | Given a token location and a minified function name and the
minified source file this returns the original function name if it
can be found of the minified function in scope. | ['Given', 'a', 'token', 'location', 'and', 'a', 'minified', 'function', 'name', 'and', 'the', 'minified', 'source', 'file', 'this', 'returns', 'the', 'original', 'function', 'name', 'if', 'it', 'can', 'be', 'found', 'of', 'the', 'minified', 'function', 'in', 'scope', '.'] | train | https://github.com/getsentry/libsourcemap/blob/94b5a34814fafee9dc23da8ec0ccca77f30e3370/libsourcemap/highlevel.py#L163-L185 |
1 | brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_mac_address_table.py | brocade_mac_address_table.get_mac_address_table_input_request_type_get_interface_based_request_mac_type | def get_mac_address_table_input_request_type_get_interface_based_request_mac_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_mac_address_table = ET.Element("get_mac_address_table")
config = get_mac_address_table
input = ET.SubElement(get... | python | def get_mac_address_table_input_request_type_get_interface_based_request_mac_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_mac_address_table = ET.Element("get_mac_address_table")
config = get_mac_address_table
input = ET.SubElement(get... | ['def', 'get_mac_address_table_input_request_type_get_interface_based_request_mac_type', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'config', '=', 'ET', '.', 'Element', '(', '"config"', ')', 'get_mac_address_table', '=', 'ET', '.', 'Element', '(', '"get_mac_address_table"', ')', 'config', '=', 'get_mac_address_tab... | Auto Generated Code | ['Auto', 'Generated', 'Code'] | train | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_mac_address_table.py#L297-L310 |
2 | nicolargo/glances | glances/plugins/glances_memswap.py | Plugin.update_views | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total']) | python | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total']) | ['def', 'update_views', '(', 'self', ')', ':', "# Call the father's method", 'super', '(', 'Plugin', ',', 'self', ')', '.', 'update_views', '(', ')', '# Add specifics informations', '# Alert and log', 'self', '.', 'views', '[', "'used'", ']', '[', "'decoration'", ']', '=', 'self', '.', 'get_alert_log', '(', 'self', '.'... | Update stats views. | ['Update', 'stats', 'views', '.'] | train | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L130-L137 |
3 | DLR-RM/RAFCON | source/rafcon/gui/helpers/meta_data.py | contains_geometric_info | def contains_geometric_info(var):
""" Check whether the passed variable is a tuple with two floats or integers """
return isinstance(var, tuple) and len(var) == 2 and all(isinstance(val, (int, float)) for val in var) | python | def contains_geometric_info(var):
""" Check whether the passed variable is a tuple with two floats or integers """
return isinstance(var, tuple) and len(var) == 2 and all(isinstance(val, (int, float)) for val in var) | ['def', 'contains_geometric_info', '(', 'var', ')', ':', 'return', 'isinstance', '(', 'var', ',', 'tuple', ')', 'and', 'len', '(', 'var', ')', '==', '2', 'and', 'all', '(', 'isinstance', '(', 'val', ',', '(', 'int', ',', 'float', ')', ')', 'for', 'val', 'in', 'var', ')'] | Check whether the passed variable is a tuple with two floats or integers | ['Check', 'whether', 'the', 'passed', 'variable', 'is', 'a', 'tuple', 'with', 'two', 'floats', 'or', 'integers'] | train | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/helpers/meta_data.py#L55-L57 |
4 | ejeschke/ginga | ginga/gtk3w/ImageViewGtk.py | ImageViewGtk.save_plain_image_as_file | def save_plain_image_as_file(self, filepath, format='png', quality=90):
"""Used for generating thumbnails. Does not include overlaid
graphics.
"""
pixbuf = self.get_plain_image_as_pixbuf()
options, values = [], []
if format == 'jpeg':
options.append('quality'... | python | def save_plain_image_as_file(self, filepath, format='png', quality=90):
"""Used for generating thumbnails. Does not include overlaid
graphics.
"""
pixbuf = self.get_plain_image_as_pixbuf()
options, values = [], []
if format == 'jpeg':
options.append('quality'... | ['def', 'save_plain_image_as_file', '(', 'self', ',', 'filepath', ',', 'format', '=', "'png'", ',', 'quality', '=', '90', ')', ':', 'pixbuf', '=', 'self', '.', 'get_plain_image_as_pixbuf', '(', ')', 'options', ',', 'values', '=', '[', ']', ',', '[', ']', 'if', 'format', '==', "'jpeg'", ':', 'options', '.', 'append', '(... | Used for generating thumbnails. Does not include overlaid
graphics. | ['Used', 'for', 'generating', 'thumbnails', '.', 'Does', 'not', 'include', 'overlaid', 'graphics', '.'] | train | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/gtk3w/ImageViewGtk.py#L75-L84 |
5 | poppy-project/pypot | pypot/vrep/remoteApiBindings/vrep.py | simxClearFloatSignal | def simxClearFloatSignal(clientID, signalName, operationMode):
'''
Please have a look at the function description/documentation in the V-REP user manual
'''
if (sys.version_info[0] == 3) and (type(signalName) is str):
signalName=signalName.encode('utf-8')
return c_ClearFloatSignal(clientID,... | python | def simxClearFloatSignal(clientID, signalName, operationMode):
'''
Please have a look at the function description/documentation in the V-REP user manual
'''
if (sys.version_info[0] == 3) and (type(signalName) is str):
signalName=signalName.encode('utf-8')
return c_ClearFloatSignal(clientID,... | ['def', 'simxClearFloatSignal', '(', 'clientID', ',', 'signalName', ',', 'operationMode', ')', ':', 'if', '(', 'sys', '.', 'version_info', '[', '0', ']', '==', '3', ')', 'and', '(', 'type', '(', 'signalName', ')', 'is', 'str', ')', ':', 'signalName', '=', 'signalName', '.', 'encode', '(', "'utf-8'", ')', 'return', 'c_C... | Please have a look at the function description/documentation in the V-REP user manual | ['Please', 'have', 'a', 'look', 'at', 'the', 'function', 'description', '/', 'documentation', 'in', 'the', 'V', '-', 'REP', 'user', 'manual'] | train | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L900-L907 |
6 | cloudify-cosmo/repex | repex.py | Repex.find_matches | def find_matches(self, content, file_to_handle):
"""Find all matches of an expression in a file
"""
# look for all match groups in the content
groups = [match.groupdict() for match in
self.match_expression.finditer(content)]
# filter out content not in the match... | python | def find_matches(self, content, file_to_handle):
"""Find all matches of an expression in a file
"""
# look for all match groups in the content
groups = [match.groupdict() for match in
self.match_expression.finditer(content)]
# filter out content not in the match... | ['def', 'find_matches', '(', 'self', ',', 'content', ',', 'file_to_handle', ')', ':', '# look for all match groups in the content', 'groups', '=', '[', 'match', '.', 'groupdict', '(', ')', 'for', 'match', 'in', 'self', '.', 'match_expression', '.', 'finditer', '(', 'content', ')', ']', '# filter out content not in the ... | Find all matches of an expression in a file | ['Find', 'all', 'matches', 'of', 'an', 'expression', 'in', 'a', 'file'] | train | https://github.com/cloudify-cosmo/repex/blob/589e442857fa4a99fa88670d7df1a72f983bbd28/repex.py#L605-L618 |
7 | mariocj89/github-token | github_token/__init__.py | TokenFactory.create | def create(self):
"""Creates a token
It uses the app_name as the notes and the scopes are
the permissions required by the application. See those
in github when configuring an app token
Raises a TFARequired if a two factor is required after
the atempt to create it withou... | python | def create(self):
"""Creates a token
It uses the app_name as the notes and the scopes are
the permissions required by the application. See those
in github when configuring an app token
Raises a TFARequired if a two factor is required after
the atempt to create it withou... | ['def', 'create', '(', 'self', ')', ':', 'headers', '=', 'dict', '(', ')', 'if', 'self', '.', 'tfa_token', ':', 'headers', '[', '"X-GitHub-OTP"', ']', '=', 'self', '.', 'tfa_token', 'token_name', '=', 'self', '.', 'app_name', '+', 'platform', '.', 'node', '(', ')', '# node specific in case the user has multiple hosts',... | Creates a token
It uses the app_name as the notes and the scopes are
the permissions required by the application. See those
in github when configuring an app token
Raises a TFARequired if a two factor is required after
the atempt to create it without having call tfa before | ['Creates', 'a', 'token'] | train | https://github.com/mariocj89/github-token/blob/8ca85fa51a52aef94cfb4f851eb229ee500bc28f/github_token/__init__.py#L81-L108 |
8 | brycedrennan/eulerian-magnification | eulerian_magnification/base.py | combine_pyramid_and_save | def combine_pyramid_and_save(g_video, orig_video, enlarge_multiple, fps, save_filename='media/output.avi'):
"""Combine a gaussian video representation with the original and save to file"""
width, height = get_frame_dimensions(orig_video[0])
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
print("Outputting to %... | python | def combine_pyramid_and_save(g_video, orig_video, enlarge_multiple, fps, save_filename='media/output.avi'):
"""Combine a gaussian video representation with the original and save to file"""
width, height = get_frame_dimensions(orig_video[0])
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
print("Outputting to %... | ['def', 'combine_pyramid_and_save', '(', 'g_video', ',', 'orig_video', ',', 'enlarge_multiple', ',', 'fps', ',', 'save_filename', '=', "'media/output.avi'", ')', ':', 'width', ',', 'height', '=', 'get_frame_dimensions', '(', 'orig_video', '[', '0', ']', ')', 'fourcc', '=', 'cv2', '.', 'VideoWriter_fourcc', '(', '*', "'... | Combine a gaussian video representation with the original and save to file | ['Combine', 'a', 'gaussian', 'video', 'representation', 'with', 'the', 'original', 'and', 'save', 'to', 'file'] | train | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/base.py#L108-L122 |
9 | PmagPy/PmagPy | pmagpy/pmag.py | PintPars | def PintPars(datablock, araiblock, zijdblock, start, end, accept, **kwargs):
"""
calculate the paleointensity magic parameters make some definitions
"""
if 'version' in list(kwargs.keys()) and kwargs['version'] == 3:
meth_key = 'method_codes'
beta_key = 'int_b_beta'
temp_key, m... | python | def PintPars(datablock, araiblock, zijdblock, start, end, accept, **kwargs):
"""
calculate the paleointensity magic parameters make some definitions
"""
if 'version' in list(kwargs.keys()) and kwargs['version'] == 3:
meth_key = 'method_codes'
beta_key = 'int_b_beta'
temp_key, m... | ['def', 'PintPars', '(', 'datablock', ',', 'araiblock', ',', 'zijdblock', ',', 'start', ',', 'end', ',', 'accept', ',', '*', '*', 'kwargs', ')', ':', 'if', "'version'", 'in', 'list', '(', 'kwargs', '.', 'keys', '(', ')', ')', 'and', 'kwargs', '[', "'version'", ']', '==', '3', ':', 'meth_key', '=', "'method_codes'", 'be... | calculate the paleointensity magic parameters make some definitions | ['calculate', 'the', 'paleointensity', 'magic', 'parameters', 'make', 'some', 'definitions'] | train | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2827-L3374 |
10 | lowandrew/OLCTools | spadespipeline/vtyper.py | Vtyper.epcrparse | def epcrparse(self):
"""
Parse the ePCR text file outputs
"""
logging.info('Parsing ePCR results')
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
if 'stx' in sample.general.datastore:
# Initialise count - t... | python | def epcrparse(self):
"""
Parse the ePCR text file outputs
"""
logging.info('Parsing ePCR results')
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
if 'stx' in sample.general.datastore:
# Initialise count - t... | ['def', 'epcrparse', '(', 'self', ')', ':', 'logging', '.', 'info', '(', "'Parsing ePCR results'", ')', 'for', 'sample', 'in', 'self', '.', 'metadata', ':', 'if', 'sample', '.', 'general', '.', 'bestassemblyfile', '!=', "'NA'", ':', 'if', "'stx'", 'in', 'sample', '.', 'general', '.', 'datastore', ':', '# Initialise cou... | Parse the ePCR text file outputs | ['Parse', 'the', 'ePCR', 'text', 'file', 'outputs'] | train | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/vtyper.py#L96-L131 |
11 | atztogo/phonopy | phonopy/structure/spglib.py | get_pointgroup | def get_pointgroup(rotations):
"""Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11... | python | def get_pointgroup(rotations):
"""Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11... | ['def', 'get_pointgroup', '(', 'rotations', ')', ':', '_set_no_error', '(', ')', '# (symbol, pointgroup_number, transformation_matrix)', 'pointgroup', '=', 'spg', '.', 'pointgroup', '(', 'np', '.', 'array', '(', 'rotations', ',', 'dtype', '=', "'intc'", ',', 'order', '=', "'C'", ')', ')', '_set_error_message', '(', ')'... | Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11 "4/m "
12 "422 "
13 "4mm... | ['Return', 'point', 'group', 'in', 'international', 'table', 'symbol', 'and', 'number', '.'] | train | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L301-L343 |
12 | automl/HpBandSter | hpbandster/core/nameserver.py | NameServer.start | def start(self):
"""
starts a Pyro4 nameserver in a separate thread
Returns
-------
tuple (str, int):
the host name and the used port
"""
if self.host is None:
if self.nic_name is None:
self.host = 'localhost'
else:
self.host = nic_name_to_host(self.nic_name)
uri, self.pyro_ns,... | python | def start(self):
"""
starts a Pyro4 nameserver in a separate thread
Returns
-------
tuple (str, int):
the host name and the used port
"""
if self.host is None:
if self.nic_name is None:
self.host = 'localhost'
else:
self.host = nic_name_to_host(self.nic_name)
uri, self.pyro_ns,... | ['def', 'start', '(', 'self', ')', ':', 'if', 'self', '.', 'host', 'is', 'None', ':', 'if', 'self', '.', 'nic_name', 'is', 'None', ':', 'self', '.', 'host', '=', "'localhost'", 'else', ':', 'self', '.', 'host', '=', 'nic_name_to_host', '(', 'self', '.', 'nic_name', ')', 'uri', ',', 'self', '.', 'pyro_ns', ',', '_', '='... | starts a Pyro4 nameserver in a separate thread
Returns
-------
tuple (str, int):
the host name and the used port | ['starts', 'a', 'Pyro4', 'nameserver', 'in', 'a', 'separate', 'thread', 'Returns', '-------', 'tuple', '(', 'str', 'int', ')', ':', 'the', 'host', 'name', 'and', 'the', 'used', 'port'] | train | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/nameserver.py#L48-L79 |
13 | PixelwarStudio/PyTree | Tree/core.py | Tree.grow | def grow(self, times=1):
"""Let the tree grow.
Args:
times (integer): Indicate how many times the tree will grow.
"""
self.nodes.append([])
for n, node in enumerate(self.nodes[self.age]):
if self.age == 0:
p_node = Node(self.pos[:2])
... | python | def grow(self, times=1):
"""Let the tree grow.
Args:
times (integer): Indicate how many times the tree will grow.
"""
self.nodes.append([])
for n, node in enumerate(self.nodes[self.age]):
if self.age == 0:
p_node = Node(self.pos[:2])
... | ['def', 'grow', '(', 'self', ',', 'times', '=', '1', ')', ':', 'self', '.', 'nodes', '.', 'append', '(', '[', ']', ')', 'for', 'n', ',', 'node', 'in', 'enumerate', '(', 'self', '.', 'nodes', '[', 'self', '.', 'age', ']', ')', ':', 'if', 'self', '.', 'age', '==', '0', ':', 'p_node', '=', 'Node', '(', 'self', '.', 'pos',... | Let the tree grow.
Args:
times (integer): Indicate how many times the tree will grow. | ['Let', 'the', 'tree', 'grow', '.'] | train | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L167-L189 |
14 | saltstack/salt | salt/modules/osquery.py | kernel_integrity | def kernel_integrity(attrs=None, where=None):
'''
Return kernel_integrity information from osquery
CLI Example:
.. code-block:: bash
salt '*' osquery.kernel_integrity
'''
if __grains__['os_family'] in ['RedHat', 'Debian']:
return _osquery_cmd(table='kernel_integrity', attrs=at... | python | def kernel_integrity(attrs=None, where=None):
'''
Return kernel_integrity information from osquery
CLI Example:
.. code-block:: bash
salt '*' osquery.kernel_integrity
'''
if __grains__['os_family'] in ['RedHat', 'Debian']:
return _osquery_cmd(table='kernel_integrity', attrs=at... | ['def', 'kernel_integrity', '(', 'attrs', '=', 'None', ',', 'where', '=', 'None', ')', ':', 'if', '__grains__', '[', "'os_family'", ']', 'in', '[', "'RedHat'", ',', "'Debian'", ']', ':', 'return', '_osquery_cmd', '(', 'table', '=', "'kernel_integrity'", ',', 'attrs', '=', 'attrs', ',', 'where', '=', 'where', ')', 'retu... | Return kernel_integrity information from osquery
CLI Example:
.. code-block:: bash
salt '*' osquery.kernel_integrity | ['Return', 'kernel_integrity', 'information', 'from', 'osquery'] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/osquery.py#L149-L161 |
15 | rackerlabs/lambda-uploader | lambda_uploader/package.py | Package.virtualenv | def virtualenv(self, virtualenv):
'''
Sets the virtual environment for the lambda package
If this is not set then package_dependencies will create a new one.
Takes a path to a virtualenv or a boolean if the virtualenv creation
should be skipped.
'''
# If a boole... | python | def virtualenv(self, virtualenv):
'''
Sets the virtual environment for the lambda package
If this is not set then package_dependencies will create a new one.
Takes a path to a virtualenv or a boolean if the virtualenv creation
should be skipped.
'''
# If a boole... | ['def', 'virtualenv', '(', 'self', ',', 'virtualenv', ')', ':', '# If a boolean is passed then set the internal _skip_virtualenv flag', 'if', 'isinstance', '(', 'virtualenv', ',', 'bool', ')', ':', 'self', '.', '_skip_virtualenv', '=', 'virtualenv', 'else', ':', 'self', '.', '_virtualenv', '=', 'virtualenv', 'if', 'not... | Sets the virtual environment for the lambda package
If this is not set then package_dependencies will create a new one.
Takes a path to a virtualenv or a boolean if the virtualenv creation
should be skipped. | ['Sets', 'the', 'virtual', 'environment', 'for', 'the', 'lambda', 'package'] | train | https://github.com/rackerlabs/lambda-uploader/blob/a5036e60d45d1a4fdc07df071f5b6e3b113388d4/lambda_uploader/package.py#L114-L133 |
16 | agoragames/kairos | kairos/cassandra_backend.py | CassandraSet._insert_stmt | def _insert_stmt(self, name, value, timestamp, interval, config):
'''Helper to generate the insert statement.'''
# Calculate the TTL and abort if inserting into the past
expire, ttl = config['expire'], config['ttl'](timestamp)
if expire and not ttl:
return None
i_time = config['i_calc'].to_bu... | python | def _insert_stmt(self, name, value, timestamp, interval, config):
'''Helper to generate the insert statement.'''
# Calculate the TTL and abort if inserting into the past
expire, ttl = config['expire'], config['ttl'](timestamp)
if expire and not ttl:
return None
i_time = config['i_calc'].to_bu... | ['def', '_insert_stmt', '(', 'self', ',', 'name', ',', 'value', ',', 'timestamp', ',', 'interval', ',', 'config', ')', ':', '# Calculate the TTL and abort if inserting into the past', 'expire', ',', 'ttl', '=', 'config', '[', "'expire'", ']', ',', 'config', '[', "'ttl'", ']', '(', 'timestamp', ')', 'if', 'expire', 'and... | Helper to generate the insert statement. | ['Helper', 'to', 'generate', 'the', 'insert', 'statement', '.'] | train | https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L646-L665 |
17 | pavelsof/ipalint | ipalint/read.py | Reader._determine_dialect | def _determine_dialect(self, lines):
"""
Expects a non-empty [] of strings; these would normally be the first
few lines of a csv file. Returns the most likely Dialect named tuple or
None if the data seems to form a single column.
Ensures that using the returned dialect, all the lines given will have
the sa... | python | def _determine_dialect(self, lines):
"""
Expects a non-empty [] of strings; these would normally be the first
few lines of a csv file. Returns the most likely Dialect named tuple or
None if the data seems to form a single column.
Ensures that using the returned dialect, all the lines given will have
the sa... | ['def', '_determine_dialect', '(', 'self', ',', 'lines', ')', ':', 'permuts', '=', '[', '(', 'quotechar', ',', 'escapechar', ')', 'for', 'quotechar', 'in', 'CSV_QUOTECHARS', 'for', 'escapechar', 'in', 'CSV_ESCAPECHARS', ']', 'for', 'delim', 'in', 'CSV_DELIMITERS', ':', 'counts', '=', '[', 'line', '.', 'count', '(', 'de... | Expects a non-empty [] of strings; these would normally be the first
few lines of a csv file. Returns the most likely Dialect named tuple or
None if the data seems to form a single column.
Ensures that using the returned dialect, all the lines given will have
the same number of columns.
Helper for the get_d... | ['Expects', 'a', 'non', '-', 'empty', '[]', 'of', 'strings', ';', 'these', 'would', 'normally', 'be', 'the', 'first', 'few', 'lines', 'of', 'a', 'csv', 'file', '.', 'Returns', 'the', 'most', 'likely', 'Dialect', 'named', 'tuple', 'or', 'None', 'if', 'the', 'data', 'seems', 'to', 'form', 'a', 'single', 'column', '.'] | train | https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/read.py#L177-L218 |
18 | angr/angr | angr/utils/graph.py | compute_dominance_frontier | def compute_dominance_frontier(graph, domtree):
"""
Compute a dominance frontier based on the given post-dominator tree.
This implementation is based on figure 2 of paper An Efficient Method of Computing Static Single Assignment
Form by Ron Cytron, etc.
:param graph: The graph where we want to c... | python | def compute_dominance_frontier(graph, domtree):
"""
Compute a dominance frontier based on the given post-dominator tree.
This implementation is based on figure 2 of paper An Efficient Method of Computing Static Single Assignment
Form by Ron Cytron, etc.
:param graph: The graph where we want to c... | ['def', 'compute_dominance_frontier', '(', 'graph', ',', 'domtree', ')', ':', 'df', '=', '{', '}', '# Perform a post-order search on the dominator tree', 'for', 'x', 'in', 'networkx', '.', 'dfs_postorder_nodes', '(', 'domtree', ')', ':', 'if', 'x', 'not', 'in', 'graph', ':', '# Skip nodes that are not in the graph', 'c... | Compute a dominance frontier based on the given post-dominator tree.
This implementation is based on figure 2 of paper An Efficient Method of Computing Static Single Assignment
Form by Ron Cytron, etc.
:param graph: The graph where we want to compute the dominance frontier.
:param domtree: The domin... | ['Compute', 'a', 'dominance', 'frontier', 'based', 'on', 'the', 'given', 'post', '-', 'dominator', 'tree', '.'] | train | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/utils/graph.py#L63-L104 |
19 | CI-WATER/mapkit | mapkit/RasterConverter.py | RasterConverter.isNumber | def isNumber(self, value):
"""
Validate whether a value is a number or not
"""
try:
str(value)
float(value)
return True
except ValueError:
return False | python | def isNumber(self, value):
"""
Validate whether a value is a number or not
"""
try:
str(value)
float(value)
return True
except ValueError:
return False | ['def', 'isNumber', '(', 'self', ',', 'value', ')', ':', 'try', ':', 'str', '(', 'value', ')', 'float', '(', 'value', ')', 'return', 'True', 'except', 'ValueError', ':', 'return', 'False'] | Validate whether a value is a number or not | ['Validate', 'whether', 'a', 'value', 'is', 'a', 'number', 'or', 'not'] | train | https://github.com/CI-WATER/mapkit/blob/ce5fbded6af7adabdf1eec85631c6811ef8ecc34/mapkit/RasterConverter.py#L1097-L1107 |
20 | CamDavidsonPilon/lifelines | lifelines/utils/__init__.py | survival_table_from_events | def survival_table_from_events(
death_times,
event_observed,
birth_times=None,
columns=["removed", "observed", "censored", "entrance", "at_risk"],
weights=None,
collapse=False,
intervals=None,
): # pylint: disable=dangerous-default-value,too-many-locals
"""
Parameters
----------... | python | def survival_table_from_events(
death_times,
event_observed,
birth_times=None,
columns=["removed", "observed", "censored", "entrance", "at_risk"],
weights=None,
collapse=False,
intervals=None,
): # pylint: disable=dangerous-default-value,too-many-locals
"""
Parameters
----------... | ['def', 'survival_table_from_events', '(', 'death_times', ',', 'event_observed', ',', 'birth_times', '=', 'None', ',', 'columns', '=', '[', '"removed"', ',', '"observed"', ',', '"censored"', ',', '"entrance"', ',', '"at_risk"', ']', ',', 'weights', '=', 'None', ',', 'collapse', '=', 'False', ',', 'intervals', '=', 'Non... | Parameters
----------
death_times: (n,) array
represent the event times
event_observed: (n,) array
1 if observed event, 0 is censored event.
birth_times: a (n,) array, optional
representing when the subject was first observed. A subject's death event is then at [birth times + duration ... | ['Parameters', '----------', 'death_times', ':', '(', 'n', ')', 'array', 'represent', 'the', 'event', 'times', 'event_observed', ':', '(', 'n', ')', 'array', '1', 'if', 'observed', 'event', '0', 'is', 'censored', 'event', '.', 'birth_times', ':', 'a', '(', 'n', ')', 'array', 'optional', 'representing', 'when', 'the', '... | train | https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/__init__.py#L262-L361 |
21 | django-blog-zinnia/cmsplugin-zinnia | cmsplugin_zinnia/cms_plugins.py | CMSRandomEntriesPlugin.render | def render(self, context, instance, placeholder):
"""
Update the context with plugin's data
"""
context = super(CMSRandomEntriesPlugin, self).render(
context, instance, placeholder)
context['template_to_render'] = (str(instance.template_to_render) or
... | python | def render(self, context, instance, placeholder):
"""
Update the context with plugin's data
"""
context = super(CMSRandomEntriesPlugin, self).render(
context, instance, placeholder)
context['template_to_render'] = (str(instance.template_to_render) or
... | ['def', 'render', '(', 'self', ',', 'context', ',', 'instance', ',', 'placeholder', ')', ':', 'context', '=', 'super', '(', 'CMSRandomEntriesPlugin', ',', 'self', ')', '.', 'render', '(', 'context', ',', 'instance', ',', 'placeholder', ')', 'context', '[', "'template_to_render'", ']', '=', '(', 'str', '(', 'instance', ... | Update the context with plugin's data | ['Update', 'the', 'context', 'with', 'plugin', 's', 'data'] | train | https://github.com/django-blog-zinnia/cmsplugin-zinnia/blob/7613c0d9ae29affe9ab97527e4b6d5bef124afdc/cmsplugin_zinnia/cms_plugins.py#L131-L139 |
22 | rjw57/throw | throw/minus/minus.py | Gallery.SaveGallery | def SaveGallery(self, name=None, items=None):
"""Use this to update the gallery name or change sort order.
Specify which attribute (name or items or both) you want to change."""
url = 'http://min.us/api/SaveGallery'
if not name:
if not self.name:
name = self... | python | def SaveGallery(self, name=None, items=None):
"""Use this to update the gallery name or change sort order.
Specify which attribute (name or items or both) you want to change."""
url = 'http://min.us/api/SaveGallery'
if not name:
if not self.name:
name = self... | ['def', 'SaveGallery', '(', 'self', ',', 'name', '=', 'None', ',', 'items', '=', 'None', ')', ':', 'url', '=', "'http://min.us/api/SaveGallery'", 'if', 'not', 'name', ':', 'if', 'not', 'self', '.', 'name', ':', 'name', '=', 'self', '.', 'GetItems', '(', ')', '[', '0', ']', 'if', 'self', '.', 'name', ':', 'name', '=', '... | Use this to update the gallery name or change sort order.
Specify which attribute (name or items or both) you want to change. | ['Use', 'this', 'to', 'update', 'the', 'gallery', 'name', 'or', 'change', 'sort', 'order', '.', 'Specify', 'which', 'attribute', '(', 'name', 'or', 'items', 'or', 'both', ')', 'you', 'want', 'to', 'change', '.'] | train | https://github.com/rjw57/throw/blob/74a7116362ba5b45635ab247472b25cfbdece4ee/throw/minus/minus.py#L62-L88 |
23 | letuananh/chirptext | chirptext/cli.py | setup_logging | def setup_logging(filename, log_dir=None, force_setup=False):
''' Try to load logging configuration from a file. Set level to INFO if failed.
'''
if not force_setup and ChirpCLI.SETUP_COMPLETED:
logging.debug("Master logging has been setup. This call will be ignored.")
return
if log_dir ... | python | def setup_logging(filename, log_dir=None, force_setup=False):
''' Try to load logging configuration from a file. Set level to INFO if failed.
'''
if not force_setup and ChirpCLI.SETUP_COMPLETED:
logging.debug("Master logging has been setup. This call will be ignored.")
return
if log_dir ... | ['def', 'setup_logging', '(', 'filename', ',', 'log_dir', '=', 'None', ',', 'force_setup', '=', 'False', ')', ':', 'if', 'not', 'force_setup', 'and', 'ChirpCLI', '.', 'SETUP_COMPLETED', ':', 'logging', '.', 'debug', '(', '"Master logging has been setup. This call will be ignored."', ')', 'return', 'if', 'log_dir', 'and... | Try to load logging configuration from a file. Set level to INFO if failed. | ['Try', 'to', 'load', 'logging', 'configuration', 'from', 'a', 'file', '.', 'Set', 'level', 'to', 'INFO', 'if', 'failed', '.'] | train | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L35-L55 |
24 | doconix/django-mako-plus | django_mako_plus/template/adapter.py | MakoTemplateAdapter.name | def name(self):
'''Returns the name of this template (if created from a file) or "string" if not'''
if self.mako_template.filename:
return os.path.basename(self.mako_template.filename)
return 'string' | python | def name(self):
'''Returns the name of this template (if created from a file) or "string" if not'''
if self.mako_template.filename:
return os.path.basename(self.mako_template.filename)
return 'string' | ['def', 'name', '(', 'self', ')', ':', 'if', 'self', '.', 'mako_template', '.', 'filename', ':', 'return', 'os', '.', 'path', '.', 'basename', '(', 'self', '.', 'mako_template', '.', 'filename', ')', 'return', "'string'"] | Returns the name of this template (if created from a file) or "string" if not | ['Returns', 'the', 'name', 'of', 'this', 'template', '(', 'if', 'created', 'from', 'a', 'file', ')', 'or', 'string', 'if', 'not'] | train | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/adapter.py#L39-L43 |
25 | HazyResearch/fonduer | src/fonduer/learning/disc_models/sparse_lstm.py | SparseLSTM.forward | def forward(self, X):
"""Forward function.
:param X: The input (batch) of the model contains word sequences for lstm,
features and feature weights.
:type X: For word sequences: a list of torch.Tensor pair (word sequence
and word mask) of shape (batch_size, sequence_lengt... | python | def forward(self, X):
"""Forward function.
:param X: The input (batch) of the model contains word sequences for lstm,
features and feature weights.
:type X: For word sequences: a list of torch.Tensor pair (word sequence
and word mask) of shape (batch_size, sequence_lengt... | ['def', 'forward', '(', 'self', ',', 'X', ')', ':', 's', '=', 'X', '[', ':', '-', '2', ']', 'f', '=', 'X', '[', '-', '2', ']', 'w', '=', 'X', '[', '-', '1', ']', 'batch_size', '=', 'len', '(', 'f', ')', '# Generate lstm weight indices', 'x_idx', '=', 'self', '.', '_cuda', '(', 'torch', '.', 'as_tensor', '(', 'np', '.',... | Forward function.
:param X: The input (batch) of the model contains word sequences for lstm,
features and feature weights.
:type X: For word sequences: a list of torch.Tensor pair (word sequence
and word mask) of shape (batch_size, sequence_length).
For features: tor... | ['Forward', 'function', '.'] | train | https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/learning/disc_models/sparse_lstm.py#L25-L64 |
26 | google/grr | grr/server/grr_response_server/databases/mysql_flows.py | MySQLDBFlowMixin.CountFlowResultsByType | def CountFlowResultsByType(self, client_id, flow_id, cursor=None):
"""Returns counts of flow results grouped by result type."""
query = ("SELECT type, COUNT(*) FROM flow_results "
"FORCE INDEX (flow_results_by_client_id_flow_id_timestamp) "
"WHERE client_id = %s AND flow_id = %s "
... | python | def CountFlowResultsByType(self, client_id, flow_id, cursor=None):
"""Returns counts of flow results grouped by result type."""
query = ("SELECT type, COUNT(*) FROM flow_results "
"FORCE INDEX (flow_results_by_client_id_flow_id_timestamp) "
"WHERE client_id = %s AND flow_id = %s "
... | ['def', 'CountFlowResultsByType', '(', 'self', ',', 'client_id', ',', 'flow_id', ',', 'cursor', '=', 'None', ')', ':', 'query', '=', '(', '"SELECT type, COUNT(*) FROM flow_results "', '"FORCE INDEX (flow_results_by_client_id_flow_id_timestamp) "', '"WHERE client_id = %s AND flow_id = %s "', '"GROUP BY type"', ')', 'arg... | Returns counts of flow results grouped by result type. | ['Returns', 'counts', 'of', 'flow', 'results', 'grouped', 'by', 'result', 'type', '.'] | train | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_flows.py#L1350-L1360 |
27 | google/grr | grr/client/grr_response_client/client_actions/artifact_collector.py | ArtifactCollector._ProcessGrepSource | def _ProcessGrepSource(self, source):
"""Find files fulfilling regex conditions."""
attributes = source.base_source.attributes
paths = artifact_utils.InterpolateListKbAttributes(
attributes["paths"], self.knowledge_base,
self.ignore_interpolation_errors)
regex = utils.RegexListDisjunctio... | python | def _ProcessGrepSource(self, source):
"""Find files fulfilling regex conditions."""
attributes = source.base_source.attributes
paths = artifact_utils.InterpolateListKbAttributes(
attributes["paths"], self.knowledge_base,
self.ignore_interpolation_errors)
regex = utils.RegexListDisjunctio... | ['def', '_ProcessGrepSource', '(', 'self', ',', 'source', ')', ':', 'attributes', '=', 'source', '.', 'base_source', '.', 'attributes', 'paths', '=', 'artifact_utils', '.', 'InterpolateListKbAttributes', '(', 'attributes', '[', '"paths"', ']', ',', 'self', '.', 'knowledge_base', ',', 'self', '.', 'ignore_interpolation_... | Find files fulfilling regex conditions. | ['Find', 'files', 'fulfilling', 'regex', 'conditions', '.'] | train | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/artifact_collector.py#L208-L225 |
28 | F5Networks/f5-common-python | f5/multi_device/cluster/__init__.py | ClusterManager.manage_extant | def manage_extant(self, **kwargs):
'''Manage an existing cluster
:param kwargs: dict -- keyword args in dict
'''
self._check_device_number(kwargs['devices'])
self.trust_domain = TrustDomain(
devices=kwargs['devices'],
partition=kwargs['device_group_parti... | python | def manage_extant(self, **kwargs):
'''Manage an existing cluster
:param kwargs: dict -- keyword args in dict
'''
self._check_device_number(kwargs['devices'])
self.trust_domain = TrustDomain(
devices=kwargs['devices'],
partition=kwargs['device_group_parti... | ['def', 'manage_extant', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'self', '.', '_check_device_number', '(', 'kwargs', '[', "'devices'", ']', ')', 'self', '.', 'trust_domain', '=', 'TrustDomain', '(', 'devices', '=', 'kwargs', '[', "'devices'", ']', ',', 'partition', '=', 'kwargs', '[', "'device_group_partition'"... | Manage an existing cluster
:param kwargs: dict -- keyword args in dict | ['Manage', 'an', 'existing', 'cluster'] | train | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/cluster/__init__.py#L136-L148 |
29 | google/python-gflags | gflags/flagvalues.py | FlagValues._GetFlagsDefinedByModule | def _GetFlagsDefinedByModule(self, module):
"""Returns the list of flags defined by a module.
Args:
module: A module object or a module name (a string).
Returns:
A new list of Flag objects. Caller may update this list as he
wishes: none of those changes will affect the internals of this... | python | def _GetFlagsDefinedByModule(self, module):
"""Returns the list of flags defined by a module.
Args:
module: A module object or a module name (a string).
Returns:
A new list of Flag objects. Caller may update this list as he
wishes: none of those changes will affect the internals of this... | ['def', '_GetFlagsDefinedByModule', '(', 'self', ',', 'module', ')', ':', 'if', 'not', 'isinstance', '(', 'module', ',', 'str', ')', ':', 'module', '=', 'module', '.', '__name__', 'return', 'list', '(', 'self', '.', 'FlagsByModuleDict', '(', ')', '.', 'get', '(', 'module', ',', '[', ']', ')', ')'] | Returns the list of flags defined by a module.
Args:
module: A module object or a module name (a string).
Returns:
A new list of Flag objects. Caller may update this list as he
wishes: none of those changes will affect the internals of this
FlagValue object. | ['Returns', 'the', 'list', 'of', 'flags', 'defined', 'by', 'a', 'module', '.'] | train | https://github.com/google/python-gflags/blob/4f06c3d0d6cbe9b1fb90ee9fb1c082b3bf9285f6/gflags/flagvalues.py#L265-L279 |
30 | openp2pdesign/makerlabs | makerlabs/hackaday_io.py | get_labs | def get_labs(format):
"""Gets Hackerspaces data from hackaday.io."""
hackerspaces_json = data_from_hackaday_io(hackaday_io_labs_map_url)
hackerspaces = {}
# Load all the Hackerspaces
for i in hackerspaces_json:
current_lab = Hackerspace()
current_lab.id = i["id"]
current_la... | python | def get_labs(format):
"""Gets Hackerspaces data from hackaday.io."""
hackerspaces_json = data_from_hackaday_io(hackaday_io_labs_map_url)
hackerspaces = {}
# Load all the Hackerspaces
for i in hackerspaces_json:
current_lab = Hackerspace()
current_lab.id = i["id"]
current_la... | ['def', 'get_labs', '(', 'format', ')', ':', 'hackerspaces_json', '=', 'data_from_hackaday_io', '(', 'hackaday_io_labs_map_url', ')', 'hackerspaces', '=', '{', '}', '# Load all the Hackerspaces', 'for', 'i', 'in', 'hackerspaces_json', ':', 'current_lab', '=', 'Hackerspace', '(', ')', 'current_lab', '.', 'id', '=', 'i',... | Gets Hackerspaces data from hackaday.io. | ['Gets', 'Hackerspaces', 'data', 'from', 'hackaday', '.', 'io', '.'] | train | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/hackaday_io.py#L57-L137 |
31 | Azure/blobxfer | cli/cli.py | upload | def upload(ctx):
"""Upload files to Azure Storage"""
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Upload)
ctx.initialize(settings.TransferAction.Upload)
specs = settings.create_upload_specifications(
ctx.cli_options, ctx.config)
del ctx.cli_options
for spec in specs:... | python | def upload(ctx):
"""Upload files to Azure Storage"""
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Upload)
ctx.initialize(settings.TransferAction.Upload)
specs = settings.create_upload_specifications(
ctx.cli_options, ctx.config)
del ctx.cli_options
for spec in specs:... | ['def', 'upload', '(', 'ctx', ')', ':', 'settings', '.', 'add_cli_options', '(', 'ctx', '.', 'cli_options', ',', 'settings', '.', 'TransferAction', '.', 'Upload', ')', 'ctx', '.', 'initialize', '(', 'settings', '.', 'TransferAction', '.', 'Upload', ')', 'specs', '=', 'settings', '.', 'create_upload_specifications', '('... | Upload files to Azure Storage | ['Upload', 'files', 'to', 'Azure', 'Storage'] | train | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/cli/cli.py#L1106-L1116 |
32 | mitsei/dlkit | dlkit/json_/resource/sessions.py | ResourceBinAssignmentSession.get_assignable_bin_ids | def get_assignable_bin_ids(self, bin_id):
"""Gets a list of bins including and under the given bin node in which any resource can be assigned.
arg: bin_id (osid.id.Id): the ``Id`` of the ``Bin``
return: (osid.id.IdList) - list of assignable bin ``Ids``
raise: NullArgument - ``bin_id... | python | def get_assignable_bin_ids(self, bin_id):
"""Gets a list of bins including and under the given bin node in which any resource can be assigned.
arg: bin_id (osid.id.Id): the ``Id`` of the ``Bin``
return: (osid.id.IdList) - list of assignable bin ``Ids``
raise: NullArgument - ``bin_id... | ['def', 'get_assignable_bin_ids', '(', 'self', ',', 'bin_id', ')', ':', '# Implemented from template for', '# osid.resource.ResourceBinAssignmentSession.get_assignable_bin_ids', '# This will likely be overridden by an authorization adapter', 'mgr', '=', 'self', '.', '_get_provider_manager', '(', "'RESOURCE'", ',', 'loc... | Gets a list of bins including and under the given bin node in which any resource can be assigned.
arg: bin_id (osid.id.Id): the ``Id`` of the ``Bin``
return: (osid.id.IdList) - list of assignable bin ``Ids``
raise: NullArgument - ``bin_id`` is ``null``
raise: OperationFailed - unab... | ['Gets', 'a', 'list', 'of', 'bins', 'including', 'and', 'under', 'the', 'given', 'bin', 'node', 'in', 'which', 'any', 'resource', 'can', 'be', 'assigned', '.'] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/sessions.py#L1562-L1581 |