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
3,000
saltstack/salt
salt/modules/drbd.py
_analyse_overview_field
def _analyse_overview_field(content): ''' Split the field in drbd-overview ''' if "(" in content: # Output like "Connected(2*)" or "UpToDate(2*)" return content.split("(")[0], content.split("(")[0] elif "/" in content: # Output like "Primar/Second" or "UpToDa/UpToDa" ...
python
def _analyse_overview_field(content): ''' Split the field in drbd-overview ''' if "(" in content: # Output like "Connected(2*)" or "UpToDate(2*)" return content.split("(")[0], content.split("(")[0] elif "/" in content: # Output like "Primar/Second" or "UpToDa/UpToDa" ...
['def', '_analyse_overview_field', '(', 'content', ')', ':', 'if', '"("', 'in', 'content', ':', '# Output like "Connected(2*)" or "UpToDate(2*)"', 'return', 'content', '.', 'split', '(', '"("', ')', '[', '0', ']', ',', 'content', '.', 'split', '(', '"("', ')', '[', '0', ']', 'elif', '"/"', 'in', 'content', ':', '# Outp...
Split the field in drbd-overview
['Split', 'the', 'field', 'in', 'drbd', '-', 'overview']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/drbd.py#L13-L24
3,001
quora/qcore
qcore/events.py
EventHub.trigger
def trigger(self, event, *args): """Triggers the specified event by invoking EventHook.trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used ...
python
def trigger(self, event, *args): """Triggers the specified event by invoking EventHook.trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used ...
['def', 'trigger', '(', 'self', ',', 'event', ',', '*', 'args', ')', ':', 'event_hook', '=', 'self', '.', 'get_or_create', '(', 'event', ')', 'event_hook', '.', 'trigger', '(', '*', 'args', ')', 'return', 'self']
Triggers the specified event by invoking EventHook.trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. @param args: event arg...
['Triggers', 'the', 'specified', 'event', 'by', 'invoking', 'EventHook', '.', 'trigger', 'under', 'the', 'hood', '.']
train
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L245-L257
3,002
watson-developer-cloud/python-sdk
ibm_watson/speech_to_text_v1.py
CustomWord._to_dict
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'word') and self.word is not None: _dict['word'] = self.word if hasattr(self, 'sounds_like') and self.sounds_like is not None: _dict['sounds_like'] = self.sound...
python
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'word') and self.word is not None: _dict['word'] = self.word if hasattr(self, 'sounds_like') and self.sounds_like is not None: _dict['sounds_like'] = self.sound...
['def', '_to_dict', '(', 'self', ')', ':', '_dict', '=', '{', '}', 'if', 'hasattr', '(', 'self', ',', "'word'", ')', 'and', 'self', '.', 'word', 'is', 'not', 'None', ':', '_dict', '[', "'word'", ']', '=', 'self', '.', 'word', 'if', 'hasattr', '(', 'self', ',', "'sounds_like'", ')', 'and', 'self', '.', 'sounds_like', 'i...
Return a json dictionary representing this model.
['Return', 'a', 'json', 'dictionary', 'representing', 'this', 'model', '.']
train
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/speech_to_text_v1.py#L3691-L3700
3,003
callowayproject/Transmogrify
transmogrify/images2gif.py
GifWriter.get_app_ext
def get_app_ext(self, loops=float('inf')): """ get_app_ext(loops=float('inf')) Application extention. This part specifies the amount of loops. If loops is 0 or inf, it goes on infinitely. """ if loops == 0 or loops == float('inf'): loops = 2**16 - 1 # b...
python
def get_app_ext(self, loops=float('inf')): """ get_app_ext(loops=float('inf')) Application extention. This part specifies the amount of loops. If loops is 0 or inf, it goes on infinitely. """ if loops == 0 or loops == float('inf'): loops = 2**16 - 1 # b...
['def', 'get_app_ext', '(', 'self', ',', 'loops', '=', 'float', '(', "'inf'", ')', ')', ':', 'if', 'loops', '==', '0', 'or', 'loops', '==', 'float', '(', "'inf'", ')', ':', 'loops', '=', '2', '**', '16', '-', '1', '# bb = "" # application extension should not be used (the extension interprets zero loops to mean an inf...
get_app_ext(loops=float('inf')) Application extention. This part specifies the amount of loops. If loops is 0 or inf, it goes on infinitely.
['get_app_ext', '(', 'loops', '=', 'float', '(', 'inf', '))']
train
https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/images2gif.py#L199-L216
3,004
automl/HpBandSter
hpbandster/optimizers/kde/kernels.py
WangRyzinOrdinal.sample
def sample(self, sample_indices=None, num_samples=1): """ returns samples according to the KDE Parameters ---------- sample_inices: list of ints Indices into the training data used as centers for the samples num_samples: int if samples_indices is None, this specifies how many samples ...
python
def sample(self, sample_indices=None, num_samples=1): """ returns samples according to the KDE Parameters ---------- sample_inices: list of ints Indices into the training data used as centers for the samples num_samples: int if samples_indices is None, this specifies how many samples ...
['def', 'sample', '(', 'self', ',', 'sample_indices', '=', 'None', ',', 'num_samples', '=', '1', ')', ':', 'if', 'sample_indices', 'is', 'None', ':', 'sample_indices', '=', 'np', '.', 'random', '.', 'choice', '(', 'self', '.', 'data', '.', 'shape', '[', '0', ']', ',', 'size', '=', 'num_samples', ')', 'samples', '=', 's...
returns samples according to the KDE Parameters ---------- sample_inices: list of ints Indices into the training data used as centers for the samples num_samples: int if samples_indices is None, this specifies how many samples are drawn.
['returns', 'samples', 'according', 'to', 'the', 'KDE', 'Parameters', '----------', 'sample_inices', ':', 'list', 'of', 'ints', 'Indices', 'into', 'the', 'training', 'data', 'used', 'as', 'centers', 'for', 'the', 'samples', 'num_samples', ':', 'int', 'if', 'samples_indices', 'is', 'None', 'this', 'specifies', 'how', 'm...
train
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/kde/kernels.py#L157-L190
3,005
google/grr
grr/server/grr_response_server/export_utils.py
IterateAllClients.GetInput
def GetInput(self): """Yield client urns.""" client_list = GetAllClients(token=self.token) logging.debug("Got %d clients", len(client_list)) for client_group in collection.Batch(client_list, self.client_chunksize): for fd in aff4.FACTORY.MultiOpen( client_group, mode="r", ...
python
def GetInput(self): """Yield client urns.""" client_list = GetAllClients(token=self.token) logging.debug("Got %d clients", len(client_list)) for client_group in collection.Batch(client_list, self.client_chunksize): for fd in aff4.FACTORY.MultiOpen( client_group, mode="r", ...
['def', 'GetInput', '(', 'self', ')', ':', 'client_list', '=', 'GetAllClients', '(', 'token', '=', 'self', '.', 'token', ')', 'logging', '.', 'debug', '(', '"Got %d clients"', ',', 'len', '(', 'client_list', ')', ')', 'for', 'client_group', 'in', 'collection', '.', 'Batch', '(', 'client_list', ',', 'self', '.', 'client...
Yield client urns.
['Yield', 'client', 'urns', '.']
train
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/export_utils.py#L118-L132
3,006
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_firmware.py
brocade_firmware.logical_chassis_fwdl_status_output_cluster_fwdl_entries_fwdl_entries_blade_swbd
def logical_chassis_fwdl_status_output_cluster_fwdl_entries_fwdl_entries_blade_swbd(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") logical_chassis_fwdl_status = ET.Element("logical_chassis_fwdl_status") config = logical_chassis_fwdl_status outpu...
python
def logical_chassis_fwdl_status_output_cluster_fwdl_entries_fwdl_entries_blade_swbd(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") logical_chassis_fwdl_status = ET.Element("logical_chassis_fwdl_status") config = logical_chassis_fwdl_status outpu...
['def', 'logical_chassis_fwdl_status_output_cluster_fwdl_entries_fwdl_entries_blade_swbd', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'config', '=', 'ET', '.', 'Element', '(', '"config"', ')', 'logical_chassis_fwdl_status', '=', 'ET', '.', 'Element', '(', '"logical_chassis_fwdl_status"', ')', 'config', '=', 'logic...
Auto Generated Code
['Auto', 'Generated', 'Code']
train
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_firmware.py#L956-L969
3,007
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/subscribe/subscribe.py
RoutingBase.list_all
def list_all(self): """All items""" return list(set( item for items in self._routes.values() for item in items ))
python
def list_all(self): """All items""" return list(set( item for items in self._routes.values() for item in items ))
['def', 'list_all', '(', 'self', ')', ':', 'return', 'list', '(', 'set', '(', 'item', 'for', 'items', 'in', 'self', '.', '_routes', '.', 'values', '(', ')', 'for', 'item', 'in', 'items', ')', ')']
All items
['All', 'items']
train
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/subscribe/subscribe.py#L104-L108
3,008
garyp/sifter
sifter/grammar/grammar.py
p_block
def p_block(p): """block : '{' commands '}' """ # section 3.2: REQUIRE command must come before any other commands, # which means it can't be in the block of another command if any(command.RULE_IDENTIFIER == 'REQUIRE' for command in p[2].commands): print("REQUIRE command not allowed i...
python
def p_block(p): """block : '{' commands '}' """ # section 3.2: REQUIRE command must come before any other commands, # which means it can't be in the block of another command if any(command.RULE_IDENTIFIER == 'REQUIRE' for command in p[2].commands): print("REQUIRE command not allowed i...
['def', 'p_block', '(', 'p', ')', ':', '# section 3.2: REQUIRE command must come before any other commands,', "# which means it can't be in the block of another command", 'if', 'any', '(', 'command', '.', 'RULE_IDENTIFIER', '==', "'REQUIRE'", 'for', 'command', 'in', 'p', '[', '2', ']', '.', 'commands', ')', ':', 'print...
block : '{' commands '}'
['block', ':', '{', 'commands', '}']
train
https://github.com/garyp/sifter/blob/9c472af76853c1196387141e017114d282637474/sifter/grammar/grammar.py#L63-L72
3,009
sbmlteam/libCombine
examples/python/printExample.py
printMetaDataFor
def printMetaDataFor(archive, location): """ Prints metadata for given location. :param archive: CombineArchive instance :param location: :return: """ desc = archive.getMetadataForLocation(location) if desc.isEmpty(): print(" no metadata for '{0}'".format(location)) return ...
python
def printMetaDataFor(archive, location): """ Prints metadata for given location. :param archive: CombineArchive instance :param location: :return: """ desc = archive.getMetadataForLocation(location) if desc.isEmpty(): print(" no metadata for '{0}'".format(location)) return ...
['def', 'printMetaDataFor', '(', 'archive', ',', 'location', ')', ':', 'desc', '=', 'archive', '.', 'getMetadataForLocation', '(', 'location', ')', 'if', 'desc', '.', 'isEmpty', '(', ')', ':', 'print', '(', '" no metadata for \'{0}\'"', '.', 'format', '(', 'location', ')', ')', 'return', 'None', 'print', '(', '" meta...
Prints metadata for given location. :param archive: CombineArchive instance :param location: :return:
['Prints', 'metadata', 'for', 'given', 'location', '.']
train
https://github.com/sbmlteam/libCombine/blob/d7c11a90129dedbcc8bdba8d204be03f1dd0c3e4/examples/python/printExample.py#L11-L31
3,010
earlye/nephele
nephele/AwsStack.py
AwsStack.do_parameter
def do_parameter(self,args): """Print a parameter""" parser = CommandArgumentParser("parameter") parser.add_argument(dest="id",help="Parameter to print") args = vars(parser.parse_args(args)) print "printing parameter {}".format(args['id']) try: index ...
python
def do_parameter(self,args): """Print a parameter""" parser = CommandArgumentParser("parameter") parser.add_argument(dest="id",help="Parameter to print") args = vars(parser.parse_args(args)) print "printing parameter {}".format(args['id']) try: index ...
['def', 'do_parameter', '(', 'self', ',', 'args', ')', ':', 'parser', '=', 'CommandArgumentParser', '(', '"parameter"', ')', 'parser', '.', 'add_argument', '(', 'dest', '=', '"id"', ',', 'help', '=', '"Parameter to print"', ')', 'args', '=', 'vars', '(', 'parser', '.', 'parse_args', '(', 'args', ')', ')', 'print', '"pr...
Print a parameter
['Print', 'a', 'parameter']
train
https://github.com/earlye/nephele/blob/a7dadc68f4124671457f09119419978c4d22013e/nephele/AwsStack.py#L278-L291
3,011
soasme/rio
rio/setup.py
configure_app
def configure_app(app): """Configure Flask/Celery application. * Rio will find environment variable `RIO_SETTINGS` first:: $ export RIO_SETTINGS=/path/to/settings.cfg $ rio worker * If `RIO_SETTINGS` is missing, Rio will try to load configuration module in `rio.settings` according t...
python
def configure_app(app): """Configure Flask/Celery application. * Rio will find environment variable `RIO_SETTINGS` first:: $ export RIO_SETTINGS=/path/to/settings.cfg $ rio worker * If `RIO_SETTINGS` is missing, Rio will try to load configuration module in `rio.settings` according t...
['def', 'configure_app', '(', 'app', ')', ':', 'app', '.', 'config_from_object', '(', "'rio.settings.default'", ')', 'if', 'environ', '.', 'get', '(', "'RIO_SETTINGS'", ')', ':', 'app', '.', 'config_from_envvar', '(', "'RIO_SETTINGS'", ')', 'return', 'config_map', '=', '{', "'dev'", ':', "'rio.settings.dev'", ',', "'st...
Configure Flask/Celery application. * Rio will find environment variable `RIO_SETTINGS` first:: $ export RIO_SETTINGS=/path/to/settings.cfg $ rio worker * If `RIO_SETTINGS` is missing, Rio will try to load configuration module in `rio.settings` according to another environment var...
['Configure', 'Flask', '/', 'Celery', 'application', '.']
train
https://github.com/soasme/rio/blob/f722eb0ff4b0382bceaff77737f0b87cb78429e7/rio/setup.py#L19-L49
3,012
PmagPy/PmagPy
dev_setup.py
windows_install
def windows_install(path_to_python=""): """ Sets the .py extension to be associated with the ftype Python which is then set to the python.exe you provide in the path_to_python variable or after the -p flag if run as a script. Once the python environment is set up the function proceeds to set PATH an...
python
def windows_install(path_to_python=""): """ Sets the .py extension to be associated with the ftype Python which is then set to the python.exe you provide in the path_to_python variable or after the -p flag if run as a script. Once the python environment is set up the function proceeds to set PATH an...
['def', 'windows_install', '(', 'path_to_python', '=', '""', ')', ':', 'if', 'not', 'path_to_python', ':', 'print', '(', '"Please enter the path to your python.exe you wish Windows to use to run python files. If you do not, this script will not be able to set up a full python environment in Windows. If you already have...
Sets the .py extension to be associated with the ftype Python which is then set to the python.exe you provide in the path_to_python variable or after the -p flag if run as a script. Once the python environment is set up the function proceeds to set PATH and PYTHONPATH using setx. Parameters -------...
['Sets', 'the', '.', 'py', 'extension', 'to', 'be', 'associated', 'with', 'the', 'ftype', 'Python', 'which', 'is', 'then', 'set', 'to', 'the', 'python', '.', 'exe', 'you', 'provide', 'in', 'the', 'path_to_python', 'variable', 'or', 'after', 'the', '-', 'p', 'flag', 'if', 'run', 'as', 'a', 'script', '.', 'Once', 'the', ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dev_setup.py#L127-L193
3,013
chaoss/grimoirelab-elk
grimoire_elk/enriched/jira.py
JiraEnrich.get_item_sh
def get_item_sh(self, item, roles=None, date_field=None): """Add sorting hat enrichment fields""" eitem_sh = {} created = str_to_datetime(date_field) for rol in roles: identity = self.get_sh_identity(item, rol) eitem_sh.update(self.get_item_sh_fields(identity, c...
python
def get_item_sh(self, item, roles=None, date_field=None): """Add sorting hat enrichment fields""" eitem_sh = {} created = str_to_datetime(date_field) for rol in roles: identity = self.get_sh_identity(item, rol) eitem_sh.update(self.get_item_sh_fields(identity, c...
['def', 'get_item_sh', '(', 'self', ',', 'item', ',', 'roles', '=', 'None', ',', 'date_field', '=', 'None', ')', ':', 'eitem_sh', '=', '{', '}', 'created', '=', 'str_to_datetime', '(', 'date_field', ')', 'for', 'rol', 'in', 'roles', ':', 'identity', '=', 'self', '.', 'get_sh_identity', '(', 'item', ',', 'rol', ')', 'ei...
Add sorting hat enrichment fields
['Add', 'sorting', 'hat', 'enrichment', 'fields']
train
https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/jira.py#L109-L142
3,014
mrstephenneal/pdfconduit
pdf/transform/slice.py
slicer
def slicer(document, first_page=None, last_page=None, suffix='sliced', tempdir=None): """Slice a PDF document to remove pages.""" # Set output file name if tempdir: with NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False) as temp: output = temp.name elif suffix: outp...
python
def slicer(document, first_page=None, last_page=None, suffix='sliced', tempdir=None): """Slice a PDF document to remove pages.""" # Set output file name if tempdir: with NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False) as temp: output = temp.name elif suffix: outp...
['def', 'slicer', '(', 'document', ',', 'first_page', '=', 'None', ',', 'last_page', '=', 'None', ',', 'suffix', '=', "'sliced'", ',', 'tempdir', '=', 'None', ')', ':', '# Set output file name', 'if', 'tempdir', ':', 'with', 'NamedTemporaryFile', '(', 'suffix', '=', "'.pdf'", ',', 'dir', '=', 'tempdir', ',', 'delete', ...
Slice a PDF document to remove pages.
['Slice', 'a', 'PDF', 'document', 'to', 'remove', 'pages', '.']
train
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/transform/slice.py#L11-L40
3,015
tensorpack/tensorpack
examples/FasterRCNN/model_cascade.py
CascadeRCNNHead.decoded_output_boxes
def decoded_output_boxes(self): """ Returns: Nx#classx4 """ ret = self._cascade_boxes[-1] ret = tf.expand_dims(ret, 1) # class-agnostic return tf.tile(ret, [1, self.num_classes, 1])
python
def decoded_output_boxes(self): """ Returns: Nx#classx4 """ ret = self._cascade_boxes[-1] ret = tf.expand_dims(ret, 1) # class-agnostic return tf.tile(ret, [1, self.num_classes, 1])
['def', 'decoded_output_boxes', '(', 'self', ')', ':', 'ret', '=', 'self', '.', '_cascade_boxes', '[', '-', '1', ']', 'ret', '=', 'tf', '.', 'expand_dims', '(', 'ret', ',', '1', ')', '# class-agnostic', 'return', 'tf', '.', 'tile', '(', 'ret', ',', '[', '1', ',', 'self', '.', 'num_classes', ',', '1', ']', ')']
Returns: Nx#classx4
['Returns', ':', 'Nx#classx4']
train
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/model_cascade.py#L103-L110
3,016
xolox/python-vcs-repo-mgr
vcs_repo_mgr/__init__.py
Repository.release_to_branch
def release_to_branch(self, release_id): """ Shortcut to translate a release identifier to a branch name. :param release_id: A :attr:`Release.identifier` value (a string). :returns: A branch name (a string). :raises: :exc:`~exceptions.TypeError` when :attr:`release_scheme` isn't...
python
def release_to_branch(self, release_id): """ Shortcut to translate a release identifier to a branch name. :param release_id: A :attr:`Release.identifier` value (a string). :returns: A branch name (a string). :raises: :exc:`~exceptions.TypeError` when :attr:`release_scheme` isn't...
['def', 'release_to_branch', '(', 'self', ',', 'release_id', ')', ':', 'self', '.', 'ensure_release_scheme', '(', "'branches'", ')', 'return', 'self', '.', 'releases', '[', 'release_id', ']', '.', 'revision', '.', 'branch']
Shortcut to translate a release identifier to a branch name. :param release_id: A :attr:`Release.identifier` value (a string). :returns: A branch name (a string). :raises: :exc:`~exceptions.TypeError` when :attr:`release_scheme` isn't 'branches'.
['Shortcut', 'to', 'translate', 'a', 'release', 'identifier', 'to', 'a', 'branch', 'name', '.']
train
https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/__init__.py#L1825-L1835
3,017
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._setup_gc2_framework
def _setup_gc2_framework(self): """ This method establishes the GC2 framework for a multi-segment (and indeed multi-typology) case based on the description in Spudich & Chiou (2015) - see section on Generalized Coordinate System for Multiple Rupture Traces """ # G...
python
def _setup_gc2_framework(self): """ This method establishes the GC2 framework for a multi-segment (and indeed multi-typology) case based on the description in Spudich & Chiou (2015) - see section on Generalized Coordinate System for Multiple Rupture Traces """ # G...
['def', '_setup_gc2_framework', '(', 'self', ')', ':', '# Generate cartesian edge set', 'edge_sets', '=', 'self', '.', '_get_cartesian_edge_set', '(', ')', 'self', '.', 'gc2_config', '=', '{', '}', '# Determine furthest two points apart', 'endpoint_set', '=', 'numpy', '.', 'vstack', '(', '[', 'cep', 'for', 'cep', 'in',...
This method establishes the GC2 framework for a multi-segment (and indeed multi-typology) case based on the description in Spudich & Chiou (2015) - see section on Generalized Coordinate System for Multiple Rupture Traces
['This', 'method', 'establishes', 'the', 'GC2', 'framework', 'for', 'a', 'multi', '-', 'segment', '(', 'and', 'indeed', 'multi', '-', 'typology', ')', 'case', 'based', 'on', 'the', 'description', 'in', 'Spudich', '&', 'Chiou', '(', '2015', ')', '-', 'see', 'section', 'on', 'Generalized', 'Coordinate', 'System', 'for', ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L394-L452
3,018
miccoli/pyownet
src/pyownet/protocol.py
_OwnetConnection._read_msg
def _read_msg(self): """read message from server""" # # NOTE: # '_recv_socket(nbytes)' was implemented as # 'socket.recv(nbytes, socket.MSG_WAITALL)' # but socket.MSG_WAITALL proved not reliable # def _recv_socket(nbytes): """read nbytes byte...
python
def _read_msg(self): """read message from server""" # # NOTE: # '_recv_socket(nbytes)' was implemented as # 'socket.recv(nbytes, socket.MSG_WAITALL)' # but socket.MSG_WAITALL proved not reliable # def _recv_socket(nbytes): """read nbytes byte...
['def', '_read_msg', '(', 'self', ')', ':', '#', '# NOTE:', "# '_recv_socket(nbytes)' was implemented as", "# 'socket.recv(nbytes, socket.MSG_WAITALL)'", '# but socket.MSG_WAITALL proved not reliable', '#', 'def', '_recv_socket', '(', 'nbytes', ')', ':', '"""read nbytes bytes from self.socket"""', '#', '# code below is...
read message from server
['read', 'message', 'from', 'server']
train
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L458-L519
3,019
sods/ods
pods/datasets.py
airline_delay
def airline_delay(data_set='airline_delay', num_train=700000, num_test=100000, seed=default_seed): """Airline delay data used in Gaussian Processes for Big Data by Hensman, Fusi and Lawrence""" if not data_available(data_set): download_data(data_set) dir_path = os.path.join(data_path, data_set) ...
python
def airline_delay(data_set='airline_delay', num_train=700000, num_test=100000, seed=default_seed): """Airline delay data used in Gaussian Processes for Big Data by Hensman, Fusi and Lawrence""" if not data_available(data_set): download_data(data_set) dir_path = os.path.join(data_path, data_set) ...
['def', 'airline_delay', '(', 'data_set', '=', "'airline_delay'", ',', 'num_train', '=', '700000', ',', 'num_test', '=', '100000', ',', 'seed', '=', 'default_seed', ')', ':', 'if', 'not', 'data_available', '(', 'data_set', ')', ':', 'download_data', '(', 'data_set', ')', 'dir_path', '=', 'os', '.', 'path', '.', 'join',...
Airline delay data used in Gaussian Processes for Big Data by Hensman, Fusi and Lawrence
['Airline', 'delay', 'data', 'used', 'in', 'Gaussian', 'Processes', 'for', 'Big', 'Data', 'by', 'Hensman', 'Fusi', 'and', 'Lawrence']
train
https://github.com/sods/ods/blob/3995c659f25a0a640f6009ed7fcc2559ce659b1d/pods/datasets.py#L1122-L1155
3,020
SylvanasSun/FishFishJump
fish_dashboard/scrapyd/scrapyd_agent.py
ScrapydAgent.get_job_list
def get_job_list(self, project_name): """ Get the list of pending, running and finished jobs of some project. :param project_name: the project name :return: a dictionary that list inculde job name and status example: {"status": "ok", ...
python
def get_job_list(self, project_name): """ Get the list of pending, running and finished jobs of some project. :param project_name: the project name :return: a dictionary that list inculde job name and status example: {"status": "ok", ...
['def', 'get_job_list', '(', 'self', ',', 'project_name', ')', ':', 'url', ',', 'method', '=', 'self', '.', 'command_set', '[', "'listjobs'", ']', '[', '0', ']', ',', 'self', '.', 'command_set', '[', "'listjobs'", ']', '[', '1', ']', 'data', '=', '{', "'project'", ':', 'project_name', '}', 'response', '=', 'http_utils'...
Get the list of pending, running and finished jobs of some project. :param project_name: the project name :return: a dictionary that list inculde job name and status example: {"status": "ok", "pending": [{"id": "78391cc0fcaf11e1b0090800272a6d06", "sp...
['Get', 'the', 'list', 'of', 'pending', 'running', 'and', 'finished', 'jobs', 'of', 'some', 'project', '.', ':', 'param', 'project_name', ':', 'the', 'project', 'name', ':', 'return', ':', 'a', 'dictionary', 'that', 'list', 'inculde', 'job', 'name', 'and', 'status', 'example', ':', '{', 'status', ':', 'ok', 'pending', ...
train
https://github.com/SylvanasSun/FishFishJump/blob/696212d242d8d572f3f1b43925f3d8ab8acc6a2d/fish_dashboard/scrapyd/scrapyd_agent.py#L214-L233
3,021
PyCQA/astroid
astroid/as_string.py
AsStringVisitor.visit_keyword
def visit_keyword(self, node): """return an astroid.Keyword node as string""" if node.arg is None: return "**%s" % node.value.accept(self) return "%s=%s" % (node.arg, node.value.accept(self))
python
def visit_keyword(self, node): """return an astroid.Keyword node as string""" if node.arg is None: return "**%s" % node.value.accept(self) return "%s=%s" % (node.arg, node.value.accept(self))
['def', 'visit_keyword', '(', 'self', ',', 'node', ')', ':', 'if', 'node', '.', 'arg', 'is', 'None', ':', 'return', '"**%s"', '%', 'node', '.', 'value', '.', 'accept', '(', 'self', ')', 'return', '"%s=%s"', '%', '(', 'node', '.', 'arg', ',', 'node', '.', 'value', '.', 'accept', '(', 'self', ')', ')']
return an astroid.Keyword node as string
['return', 'an', 'astroid', '.', 'Keyword', 'node', 'as', 'string']
train
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/as_string.py#L363-L367
3,022
Kunstmord/datalib
src/misc.py
cutoff_filename
def cutoff_filename(prefix, suffix, input_str): """ Cuts off the start and end of a string, as specified by 2 parameters Parameters ---------- prefix : string, if input_str starts with prefix, will cut off prefix suffix : string, if input_str end with suffix, will cut off suffix input_str :...
python
def cutoff_filename(prefix, suffix, input_str): """ Cuts off the start and end of a string, as specified by 2 parameters Parameters ---------- prefix : string, if input_str starts with prefix, will cut off prefix suffix : string, if input_str end with suffix, will cut off suffix input_str :...
['def', 'cutoff_filename', '(', 'prefix', ',', 'suffix', ',', 'input_str', ')', ':', 'if', 'prefix', 'is', 'not', "''", ':', 'if', 'input_str', '.', 'startswith', '(', 'prefix', ')', ':', 'input_str', '=', 'input_str', '[', 'len', '(', 'prefix', ')', ':', ']', 'if', 'suffix', 'is', 'not', "''", ':', 'if', 'input_str', ...
Cuts off the start and end of a string, as specified by 2 parameters Parameters ---------- prefix : string, if input_str starts with prefix, will cut off prefix suffix : string, if input_str end with suffix, will cut off suffix input_str : the string to be processed Returns ------- A s...
['Cuts', 'off', 'the', 'start', 'and', 'end', 'of', 'a', 'string', 'as', 'specified', 'by', '2', 'parameters']
train
https://github.com/Kunstmord/datalib/blob/9d7db3e7c3a5feeeb5d19eb0dbee858bd2b50886/src/misc.py#L34-L54
3,023
mandiant/ioc_writer
ioc_writer/utils/xmlutils.py
delete_namespace
def delete_namespace(parsed_xml): """ Identifies the namespace associated with the root node of a XML document and removes that names from the document. :param parsed_xml: lxml.Etree object. :return: Returns the sources document with the namespace removed. """ if parsed_xml.getroot().tag.st...
python
def delete_namespace(parsed_xml): """ Identifies the namespace associated with the root node of a XML document and removes that names from the document. :param parsed_xml: lxml.Etree object. :return: Returns the sources document with the namespace removed. """ if parsed_xml.getroot().tag.st...
['def', 'delete_namespace', '(', 'parsed_xml', ')', ':', 'if', 'parsed_xml', '.', 'getroot', '(', ')', '.', 'tag', '.', 'startswith', '(', "'{'", ')', ':', 'root', '=', 'parsed_xml', '.', 'getroot', '(', ')', '.', 'tag', 'end_ns', '=', 'root', '.', 'find', '(', "'}'", ')', 'remove_namespace', '(', 'parsed_xml', ',', 'r...
Identifies the namespace associated with the root node of a XML document and removes that names from the document. :param parsed_xml: lxml.Etree object. :return: Returns the sources document with the namespace removed.
['Identifies', 'the', 'namespace', 'associated', 'with', 'the', 'root', 'node', 'of', 'a', 'XML', 'document', 'and', 'removes', 'that', 'names', 'from', 'the', 'document', '.']
train
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L99-L111
3,024
sixty-north/asq
asq/queryables.py
Queryable.select_many_with_index
def select_many_with_index( self, collection_selector=IndexedElement, result_selector=lambda source_element, collection_element: collection_element): '''Projects each element of a sequence to an intermediate new sequence, incorporati...
python
def select_many_with_index( self, collection_selector=IndexedElement, result_selector=lambda source_element, collection_element: collection_element): '''Projects each element of a sequence to an intermediate new sequence, incorporati...
['def', 'select_many_with_index', '(', 'self', ',', 'collection_selector', '=', 'IndexedElement', ',', 'result_selector', '=', 'lambda', 'source_element', ',', 'collection_element', ':', 'collection_element', ')', ':', 'if', 'self', '.', 'closed', '(', ')', ':', 'raise', 'ValueError', '(', '"Attempt to call select_many...
Projects each element of a sequence to an intermediate new sequence, incorporating the index of the element, flattens the resulting sequence into one sequence and optionally transforms the flattened sequence using a selector function. Note: This method uses deferred execution. ...
['Projects', 'each', 'element', 'of', 'a', 'sequence', 'to', 'an', 'intermediate', 'new', 'sequence', 'incorporating', 'the', 'index', 'of', 'the', 'element', 'flattens', 'the', 'resulting', 'sequence', 'into', 'one', 'sequence', 'and', 'optionally', 'transforms', 'the', 'flattened', 'sequence', 'using', 'a', 'selector...
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L346-L407
3,025
chimera0/accel-brain-code
Generative-Adversarial-Networks/pygan/truesampler/conditionaltruesampler/conditional_image_true_sampler.py
ConditionalImageTrueSampler.draw
def draw(self): ''' Draws samples from the `true` distribution. Returns: `np.ndarray` of samples. ''' observed_arr = self.__image_true_sampler.draw() observed_arr = self.add_condition(observed_arr) return observed_arr
python
def draw(self): ''' Draws samples from the `true` distribution. Returns: `np.ndarray` of samples. ''' observed_arr = self.__image_true_sampler.draw() observed_arr = self.add_condition(observed_arr) return observed_arr
['def', 'draw', '(', 'self', ')', ':', 'observed_arr', '=', 'self', '.', '__image_true_sampler', '.', 'draw', '(', ')', 'observed_arr', '=', 'self', '.', 'add_condition', '(', 'observed_arr', ')', 'return', 'observed_arr']
Draws samples from the `true` distribution. Returns: `np.ndarray` of samples.
['Draws', 'samples', 'from', 'the', 'true', 'distribution', '.', 'Returns', ':', 'np', '.', 'ndarray', 'of', 'samples', '.']
train
https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Generative-Adversarial-Networks/pygan/truesampler/conditionaltruesampler/conditional_image_true_sampler.py#L23-L32
3,026
dwavesystems/dimod
dimod/reference/composites/scalecomposite.py
_scale_back_response
def _scale_back_response(bqm, response, scalar, ignored_interactions, ignored_variables, ignore_offset): """Helper function to scale back the response of sample method""" if len(ignored_interactions) + len( ignored_variables) + ignore_offset == 0: response.record.ene...
python
def _scale_back_response(bqm, response, scalar, ignored_interactions, ignored_variables, ignore_offset): """Helper function to scale back the response of sample method""" if len(ignored_interactions) + len( ignored_variables) + ignore_offset == 0: response.record.ene...
['def', '_scale_back_response', '(', 'bqm', ',', 'response', ',', 'scalar', ',', 'ignored_interactions', ',', 'ignored_variables', ',', 'ignore_offset', ')', ':', 'if', 'len', '(', 'ignored_interactions', ')', '+', 'len', '(', 'ignored_variables', ')', '+', 'ignore_offset', '==', '0', ':', 'response', '.', 'record', '....
Helper function to scale back the response of sample method
['Helper', 'function', 'to', 'scale', 'back', 'the', 'response', 'of', 'sample', 'method']
train
https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/reference/composites/scalecomposite.py#L213-L222
3,027
ianmiell/shutit
shutit_class.py
ShutIt.file_exists
def file_exists(self, filename, shutit_pexpect_child=None, directory=False, note=None, loglevel=logging.DEBUG): """Return True if file exists on the target host, else False @param filename: Filename to determine the existence of...
python
def file_exists(self, filename, shutit_pexpect_child=None, directory=False, note=None, loglevel=logging.DEBUG): """Return True if file exists on the target host, else False @param filename: Filename to determine the existence of...
['def', 'file_exists', '(', 'self', ',', 'filename', ',', 'shutit_pexpect_child', '=', 'None', ',', 'directory', '=', 'False', ',', 'note', '=', 'None', ',', 'loglevel', '=', 'logging', '.', 'DEBUG', ')', ':', 'shutit_global', '.', 'shutit_global_object', '.', 'yield_to_draw', '(', ')', 'shutit_pexpect_child', '=', 'sh...
Return True if file exists on the target host, else False @param filename: Filename to determine the existence of. @param shutit_pexpect_child: See send() @param directory: Indicate that the file is a directory. @param note: See send() @type filename: string @type directory: boolean ...
['Return', 'True', 'if', 'file', 'exists', 'on', 'the', 'target', 'host', 'else', 'False']
train
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1253-L1274
3,028
twilio/twilio-python
twilio/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.py
DependentHostedNumberOrderList.stream
def stream(self, status=values.unset, phone_number=values.unset, incoming_phone_number_sid=values.unset, friendly_name=values.unset, unique_name=values.unset, limit=None, page_size=None): """ Streams DependentHostedNumberOrderInstance records from the API as a generator str...
python
def stream(self, status=values.unset, phone_number=values.unset, incoming_phone_number_sid=values.unset, friendly_name=values.unset, unique_name=values.unset, limit=None, page_size=None): """ Streams DependentHostedNumberOrderInstance records from the API as a generator str...
['def', 'stream', '(', 'self', ',', 'status', '=', 'values', '.', 'unset', ',', 'phone_number', '=', 'values', '.', 'unset', ',', 'incoming_phone_number_sid', '=', 'values', '.', 'unset', ',', 'friendly_name', '=', 'values', '.', 'unset', ',', 'unique_name', '=', 'values', '.', 'unset', ',', 'limit', '=', 'None', ',', ...
Streams DependentHostedNumberOrderInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param DependentHostedNumberO...
['Streams', 'DependentHostedNumberOrderInstance', 'records', 'from', 'the', 'API', 'as', 'a', 'generator', 'stream', '.', 'This', 'operation', 'lazily', 'loads', 'records', 'as', 'efficiently', 'as', 'possible', 'until', 'the', 'limit', 'is', 'reached', '.', 'The', 'results', 'are', 'returned', 'as', 'a', 'generator', ...
train
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.py#L37-L72
3,029
globocom/GloboNetworkAPI-client-python
networkapiclient/Equipamento.py
Equipamento.remover_grupo
def remover_grupo(self, id_equipamento, id_grupo): """Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteE...
python
def remover_grupo(self, id_equipamento, id_grupo): """Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteE...
['def', 'remover_grupo', '(', 'self', ',', 'id_equipamento', ',', 'id_grupo', ')', ':', 'if', 'not', 'is_valid_int_param', '(', 'id_equipamento', ')', ':', 'raise', 'InvalidParameterError', '(', "u'O identificador do equipamento é inválido ou não foi informado.')", '', 'if', 'not', 'is_valid_int_param', '(', 'id_grupo'...
Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteError: Associação entre grupo e equipamento não cadastrada. ...
['Remove', 'a', 'associação', 'de', 'um', 'equipamento', 'com', 'um', 'grupo', 'de', 'equipamento', '.']
train
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Equipamento.py#L671-L700
3,030
JarryShaw/PyPCAPKit
src/utilities/validations.py
list_check
def list_check(*args, func=None): """Check if arguments are list type.""" func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (list, collections.UserList, collections.abc.MutableSequence)): name = type(var).__name__ raise ListError( f'...
python
def list_check(*args, func=None): """Check if arguments are list type.""" func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (list, collections.UserList, collections.abc.MutableSequence)): name = type(var).__name__ raise ListError( f'...
['def', 'list_check', '(', '*', 'args', ',', 'func', '=', 'None', ')', ':', 'func', '=', 'func', 'or', 'inspect', '.', 'stack', '(', ')', '[', '2', ']', '[', '3', ']', 'for', 'var', 'in', 'args', ':', 'if', 'not', 'isinstance', '(', 'var', ',', '(', 'list', ',', 'collections', '.', 'UserList', ',', 'collections', '.', ...
Check if arguments are list type.
['Check', 'if', 'arguments', 'are', 'list', 'type', '.']
train
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/utilities/validations.py#L116-L123
3,031
vinci1it2000/schedula
schedula/utils/sol.py
Solution._check_wait_input_flag
def _check_wait_input_flag(self): """ Returns a function to stop the search of the investigated node of the ArciDispatch algorithm. :return: A function to stop the search. :rtype: (bool, str) -> bool """ wf_pred = self._wf_pred # Namespace shortcuts...
python
def _check_wait_input_flag(self): """ Returns a function to stop the search of the investigated node of the ArciDispatch algorithm. :return: A function to stop the search. :rtype: (bool, str) -> bool """ wf_pred = self._wf_pred # Namespace shortcuts...
['def', '_check_wait_input_flag', '(', 'self', ')', ':', 'wf_pred', '=', 'self', '.', '_wf_pred', '# Namespace shortcuts.', 'pred', '=', '{', 'k', ':', 'set', '(', 'v', ')', '.', 'issubset', 'for', 'k', ',', 'v', 'in', 'self', '.', '_pred', '.', 'items', '(', ')', '}', 'if', 'self', '.', '_wait_in', ':', 'we', '=', 'se...
Returns a function to stop the search of the investigated node of the ArciDispatch algorithm. :return: A function to stop the search. :rtype: (bool, str) -> bool
['Returns', 'a', 'function', 'to', 'stop', 'the', 'search', 'of', 'the', 'investigated', 'node', 'of', 'the', 'ArciDispatch', 'algorithm', '.']
train
https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/sol.py#L452-L496
3,032
mbj4668/pyang
pyang/plugins/jsonxsl.py
JsonXslPlugin.process_module
def process_module(self, yam): """Process data nodes, RPCs and notifications in a single module.""" for ann in yam.search(("ietf-yang-metadata", "annotation")): self.process_annotation(ann) for ch in yam.i_children[:]: if ch.keyword == "rpc": self.process_...
python
def process_module(self, yam): """Process data nodes, RPCs and notifications in a single module.""" for ann in yam.search(("ietf-yang-metadata", "annotation")): self.process_annotation(ann) for ch in yam.i_children[:]: if ch.keyword == "rpc": self.process_...
['def', 'process_module', '(', 'self', ',', 'yam', ')', ':', 'for', 'ann', 'in', 'yam', '.', 'search', '(', '(', '"ietf-yang-metadata"', ',', '"annotation"', ')', ')', ':', 'self', '.', 'process_annotation', '(', 'ann', ')', 'for', 'ch', 'in', 'yam', '.', 'i_children', '[', ':', ']', ':', 'if', 'ch', '.', 'keyword', '=...
Process data nodes, RPCs and notifications in a single module.
['Process', 'data', 'nodes', 'RPCs', 'and', 'notifications', 'in', 'a', 'single', 'module', '.']
train
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/jsonxsl.py#L101-L113
3,033
sosy-lab/benchexec
benchexec/container.py
forward_all_signals_async
def forward_all_signals_async(target_pid, process_name): """Install all signal handler that forwards all signals to the given process.""" def forwarding_signal_handler(signum): _forward_signal(signum, process_name, forwarding_signal_handler.target_pid) # Somehow we get a Python SystemError sometime...
python
def forward_all_signals_async(target_pid, process_name): """Install all signal handler that forwards all signals to the given process.""" def forwarding_signal_handler(signum): _forward_signal(signum, process_name, forwarding_signal_handler.target_pid) # Somehow we get a Python SystemError sometime...
['def', 'forward_all_signals_async', '(', 'target_pid', ',', 'process_name', ')', ':', 'def', 'forwarding_signal_handler', '(', 'signum', ')', ':', '_forward_signal', '(', 'signum', ',', 'process_name', ',', 'forwarding_signal_handler', '.', 'target_pid', ')', '# Somehow we get a Python SystemError sometimes if we acce...
Install all signal handler that forwards all signals to the given process.
['Install', 'all', 'signal', 'handler', 'that', 'forwards', 'all', 'signals', 'to', 'the', 'given', 'process', '.']
train
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/container.py#L324-L339
3,034
mattrobenolt/django-sudo
sudo/decorators.py
sudo_required
def sudo_required(func): """ Enforces a view to have elevated privileges. Should likely be paired with ``@login_required``. >>> @sudo_required >>> def secure_page(request): >>> ... """ @wraps(func) def inner(request, *args, **kwargs): if not request.is_sudo(): ...
python
def sudo_required(func): """ Enforces a view to have elevated privileges. Should likely be paired with ``@login_required``. >>> @sudo_required >>> def secure_page(request): >>> ... """ @wraps(func) def inner(request, *args, **kwargs): if not request.is_sudo(): ...
['def', 'sudo_required', '(', 'func', ')', ':', '@', 'wraps', '(', 'func', ')', 'def', 'inner', '(', 'request', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'if', 'not', 'request', '.', 'is_sudo', '(', ')', ':', 'return', 'redirect_to_sudo', '(', 'request', '.', 'get_full_path', '(', ')', ')', 'return', 'func',...
Enforces a view to have elevated privileges. Should likely be paired with ``@login_required``. >>> @sudo_required >>> def secure_page(request): >>> ...
['Enforces', 'a', 'view', 'to', 'have', 'elevated', 'privileges', '.', 'Should', 'likely', 'be', 'paired', 'with', '@login_required', '.']
train
https://github.com/mattrobenolt/django-sudo/blob/089e21a88bc3ebf9d76ea706f26707d2e4f3f729/sudo/decorators.py#L13-L27
3,035
SecurityInnovation/PGPy
pgpy/pgp.py
PGPSignature.is_expired
def is_expired(self): """ ``True`` if the signature has an expiration date, and is expired. Otherwise, ``False`` """ expires_at = self.expires_at if expires_at is not None and expires_at != self.created: return expires_at < datetime.utcnow() return False
python
def is_expired(self): """ ``True`` if the signature has an expiration date, and is expired. Otherwise, ``False`` """ expires_at = self.expires_at if expires_at is not None and expires_at != self.created: return expires_at < datetime.utcnow() return False
['def', 'is_expired', '(', 'self', ')', ':', 'expires_at', '=', 'self', '.', 'expires_at', 'if', 'expires_at', 'is', 'not', 'None', 'and', 'expires_at', '!=', 'self', '.', 'created', ':', 'return', 'expires_at', '<', 'datetime', '.', 'utcnow', '(', ')', 'return', 'False']
``True`` if the signature has an expiration date, and is expired. Otherwise, ``False``
['True', 'if', 'the', 'signature', 'has', 'an', 'expiration', 'date', 'and', 'is', 'expired', '.', 'Otherwise', 'False']
train
https://github.com/SecurityInnovation/PGPy/blob/f1c3d68e32c334f5aa14c34580925e97f17f4fde/pgpy/pgp.py#L172-L180
3,036
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_tunnels.py
brocade_tunnels.overlay_gateway_access_lists_ipv6_in_cg_ipv6_acl_in_name
def overlay_gateway_access_lists_ipv6_in_cg_ipv6_acl_in_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") overlay_gateway = ET.SubElement(config, "overlay-gateway", xmlns="urn:brocade.com:mgmt:brocade-tunnels") name_key = ET.SubElement(overlay_gateway...
python
def overlay_gateway_access_lists_ipv6_in_cg_ipv6_acl_in_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") overlay_gateway = ET.SubElement(config, "overlay-gateway", xmlns="urn:brocade.com:mgmt:brocade-tunnels") name_key = ET.SubElement(overlay_gateway...
['def', 'overlay_gateway_access_lists_ipv6_in_cg_ipv6_acl_in_name', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'config', '=', 'ET', '.', 'Element', '(', '"config"', ')', 'overlay_gateway', '=', 'ET', '.', 'SubElement', '(', 'config', ',', '"overlay-gateway"', ',', 'xmlns', '=', '"urn:brocade.com:mgmt:brocade-tunne...
Auto Generated Code
['Auto', 'Generated', 'Code']
train
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_tunnels.py#L786-L800
3,037
juju/python-libjuju
juju/client/_client2.py
BackupsFacade.Create
async def Create(self, notes): ''' notes : str Returns -> typing.Union[str, int, _ForwardRef('Number')] ''' # map input types to rpc msg _params = dict() msg = dict(type='Backups', request='Create', version=2, ...
python
async def Create(self, notes): ''' notes : str Returns -> typing.Union[str, int, _ForwardRef('Number')] ''' # map input types to rpc msg _params = dict() msg = dict(type='Backups', request='Create', version=2, ...
['async', 'def', 'Create', '(', 'self', ',', 'notes', ')', ':', '# map input types to rpc msg', '_params', '=', 'dict', '(', ')', 'msg', '=', 'dict', '(', 'type', '=', "'Backups'", ',', 'request', '=', "'Create'", ',', 'version', '=', '2', ',', 'params', '=', '_params', ')', '_params', '[', "'notes'", ']', '=', 'notes'...
notes : str Returns -> typing.Union[str, int, _ForwardRef('Number')]
['notes', ':', 'str', 'Returns', '-', '>', 'typing', '.', 'Union', '[', 'str', 'int', '_ForwardRef', '(', 'Number', ')', ']']
train
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client2.py#L2162-L2175
3,038
saltstack/salt
salt/cloud/__init__.py
CloudClient.destroy
def destroy(self, names): ''' Destroy the named VMs ''' mapper = salt.cloud.Map(self._opts_defaults(destroy=True)) if isinstance(names, six.string_types): names = names.split(',') return salt.utils.data.simple_types_filter( mapper.destroy(names) ...
python
def destroy(self, names): ''' Destroy the named VMs ''' mapper = salt.cloud.Map(self._opts_defaults(destroy=True)) if isinstance(names, six.string_types): names = names.split(',') return salt.utils.data.simple_types_filter( mapper.destroy(names) ...
['def', 'destroy', '(', 'self', ',', 'names', ')', ':', 'mapper', '=', 'salt', '.', 'cloud', '.', 'Map', '(', 'self', '.', '_opts_defaults', '(', 'destroy', '=', 'True', ')', ')', 'if', 'isinstance', '(', 'names', ',', 'six', '.', 'string_types', ')', ':', 'names', '=', 'names', '.', 'split', '(', "','", ')', 'return',...
Destroy the named VMs
['Destroy', 'the', 'named', 'VMs']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/__init__.py#L382-L391
3,039
openstack/proliantutils
proliantutils/ilo/ribcl.py
RIBCLOperations._parse_storage_embedded_health
def _parse_storage_embedded_health(self, data): """Gets the storage data from get_embedded_health Parse the get_host_health_data() for essential properties :param data: the output returned by get_host_health_data() :returns: disk size in GB. """ local_gb = 0 st...
python
def _parse_storage_embedded_health(self, data): """Gets the storage data from get_embedded_health Parse the get_host_health_data() for essential properties :param data: the output returned by get_host_health_data() :returns: disk size in GB. """ local_gb = 0 st...
['def', '_parse_storage_embedded_health', '(', 'self', ',', 'data', ')', ':', 'local_gb', '=', '0', 'storage', '=', 'self', '.', 'get_value_as_list', '(', 'data', '[', "'GET_EMBEDDED_HEALTH_DATA'", ']', ',', "'STORAGE'", ')', 'if', 'storage', 'is', 'None', ':', '# We dont raise exception because this dictionary', '# is...
Gets the storage data from get_embedded_health Parse the get_host_health_data() for essential properties :param data: the output returned by get_host_health_data() :returns: disk size in GB.
['Gets', 'the', 'storage', 'data', 'from', 'get_embedded_health']
train
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ribcl.py#L889-L938
3,040
zarr-developers/zarr
zarr/hierarchy.py
Group.full
def full(self, name, fill_value, **kwargs): """Create an array. Keyword arguments as per :func:`zarr.creation.full`.""" return self._write_op(self._full_nosync, name, fill_value, **kwargs)
python
def full(self, name, fill_value, **kwargs): """Create an array. Keyword arguments as per :func:`zarr.creation.full`.""" return self._write_op(self._full_nosync, name, fill_value, **kwargs)
['def', 'full', '(', 'self', ',', 'name', ',', 'fill_value', ',', '*', '*', 'kwargs', ')', ':', 'return', 'self', '.', '_write_op', '(', 'self', '.', '_full_nosync', ',', 'name', ',', 'fill_value', ',', '*', '*', 'kwargs', ')']
Create an array. Keyword arguments as per :func:`zarr.creation.full`.
['Create', 'an', 'array', '.', 'Keyword', 'arguments', 'as', 'per', ':', 'func', ':', 'zarr', '.', 'creation', '.', 'full', '.']
train
https://github.com/zarr-developers/zarr/blob/fb8e6d5ea6bc26e451e5cf0eaaee36977556d5b5/zarr/hierarchy.py#L893-L896
3,041
mongolab/dex
dex/dex.py
Dex.watch_logfile
def watch_logfile(self, logfile_path): """Analyzes queries from the tail of a given log file""" self._run_stats['logSource'] = logfile_path log_parser = LogParser() # For each new line in the logfile ... output_time = time.time() + WATCH_DISPLAY_REFRESH_SECONDS try: ...
python
def watch_logfile(self, logfile_path): """Analyzes queries from the tail of a given log file""" self._run_stats['logSource'] = logfile_path log_parser = LogParser() # For each new line in the logfile ... output_time = time.time() + WATCH_DISPLAY_REFRESH_SECONDS try: ...
['def', 'watch_logfile', '(', 'self', ',', 'logfile_path', ')', ':', 'self', '.', '_run_stats', '[', "'logSource'", ']', '=', 'logfile_path', 'log_parser', '=', 'LogParser', '(', ')', '# For each new line in the logfile ...', 'output_time', '=', 'time', '.', 'time', '(', ')', '+', 'WATCH_DISPLAY_REFRESH_SECONDS', 'try'...
Analyzes queries from the tail of a given log file
['Analyzes', 'queries', 'from', 'the', 'tail', 'of', 'a', 'given', 'log', 'file']
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L264-L287
3,042
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/cursor.py
Cursor.min
def min(self, spec): """Adds `min` operator that specifies lower bound for specific index. :Parameters: - `spec`: a list of field, limit pairs specifying the inclusive lower bound for all keys of a specific index in order. .. versionadded:: 2.7 """ if not ...
python
def min(self, spec): """Adds `min` operator that specifies lower bound for specific index. :Parameters: - `spec`: a list of field, limit pairs specifying the inclusive lower bound for all keys of a specific index in order. .. versionadded:: 2.7 """ if not ...
['def', 'min', '(', 'self', ',', 'spec', ')', ':', 'if', 'not', 'isinstance', '(', 'spec', ',', '(', 'list', ',', 'tuple', ')', ')', ':', 'raise', 'TypeError', '(', '"spec must be an instance of list or tuple"', ')', 'self', '.', '__check_okay_to_chain', '(', ')', 'self', '.', '__min', '=', 'SON', '(', 'spec', ')', 're...
Adds `min` operator that specifies lower bound for specific index. :Parameters: - `spec`: a list of field, limit pairs specifying the inclusive lower bound for all keys of a specific index in order. .. versionadded:: 2.7
['Adds', 'min', 'operator', 'that', 'specifies', 'lower', 'bound', 'for', 'specific', 'index', '.']
train
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/cursor.py#L620-L634
3,043
saltstack/salt
salt/modules/cassandra_cql.py
list_permissions
def list_permissions(username=None, resource=None, resource_type='keyspace', permission=None, contact_points=None, port=None, cql_user=None, cql_pass=None): ''' List permissions. :param username: The name of the user to list permissions for. :type username: str :pa...
python
def list_permissions(username=None, resource=None, resource_type='keyspace', permission=None, contact_points=None, port=None, cql_user=None, cql_pass=None): ''' List permissions. :param username: The name of the user to list permissions for. :type username: str :pa...
['def', 'list_permissions', '(', 'username', '=', 'None', ',', 'resource', '=', 'None', ',', 'resource_type', '=', "'keyspace'", ',', 'permission', '=', 'None', ',', 'contact_points', '=', 'None', ',', 'port', '=', 'None', ',', 'cql_user', '=', 'None', ',', 'cql_pass', '=', 'None', ')', ':', 'keyspace_cql', '=', '"{0} ...
List permissions. :param username: The name of the user to list permissions for. :type username: str :param resource: The resource (keyspace or table), if None, permissions for all resources are listed. :type resource: str :param resource_type: The resource_type (keyspace...
['List', 'permissions', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cassandra_cql.py#L939-L994
3,044
tadashi-aikawa/owlmixin
owlmixin/owlcollections.py
TList.key_by
def key_by(self, to_key: Callable[[T], str]) -> 'TDict[T]': """ :param to_key: value -> key Usage: >>> TList(['a1', 'b2', 'c3']).key_by(lambda x: x[0]).to_json() '{"a": "a1","b": "b2","c": "c3"}' >>> TList([1, 2, 3, 4, 5]).key_by(lambda x: x % 2).to_json() ...
python
def key_by(self, to_key: Callable[[T], str]) -> 'TDict[T]': """ :param to_key: value -> key Usage: >>> TList(['a1', 'b2', 'c3']).key_by(lambda x: x[0]).to_json() '{"a": "a1","b": "b2","c": "c3"}' >>> TList([1, 2, 3, 4, 5]).key_by(lambda x: x % 2).to_json() ...
['def', 'key_by', '(', 'self', ',', 'to_key', ':', 'Callable', '[', '[', 'T', ']', ',', 'str', ']', ')', '->', "'TDict[T]'", ':', 'return', 'TDict', '(', '{', 'to_key', '(', 'x', ')', ':', 'x', 'for', 'x', 'in', 'self', '}', ')']
:param to_key: value -> key Usage: >>> TList(['a1', 'b2', 'c3']).key_by(lambda x: x[0]).to_json() '{"a": "a1","b": "b2","c": "c3"}' >>> TList([1, 2, 3, 4, 5]).key_by(lambda x: x % 2).to_json() '{"0": 4,"1": 5}'
[':', 'param', 'to_key', ':', 'value', '-', '>', 'key', 'Usage', ':']
train
https://github.com/tadashi-aikawa/owlmixin/blob/7c4a042c3008abddc56a8e8e55ae930d276071f5/owlmixin/owlcollections.py#L208-L218
3,045
HumanCellAtlas/cloud-blobstore
cloud_blobstore/__init__.py
BlobStore.get_copy_token
def get_copy_token( self, bucket: str, key: str, cloud_checksum: str, ) -> typing.Any: """ Given a bucket, key, and the expected cloud-provided checksum, retrieve a token that can be passed into :func:`~cloud_blobstore.BlobStore.copy` that guar...
python
def get_copy_token( self, bucket: str, key: str, cloud_checksum: str, ) -> typing.Any: """ Given a bucket, key, and the expected cloud-provided checksum, retrieve a token that can be passed into :func:`~cloud_blobstore.BlobStore.copy` that guar...
['def', 'get_copy_token', '(', 'self', ',', 'bucket', ':', 'str', ',', 'key', ':', 'str', ',', 'cloud_checksum', ':', 'str', ',', ')', '->', 'typing', '.', 'Any', ':', 'raise', 'NotImplementedError', '(', ')']
Given a bucket, key, and the expected cloud-provided checksum, retrieve a token that can be passed into :func:`~cloud_blobstore.BlobStore.copy` that guarantees the copy refers to the same version of the blob identified by the checksum. :param bucket: the bucket the object resides in. :pa...
['Given', 'a', 'bucket', 'key', 'and', 'the', 'expected', 'cloud', '-', 'provided', 'checksum', 'retrieve', 'a', 'token', 'that', 'can', 'be', 'passed', 'into', ':', 'func', ':', '~cloud_blobstore', '.', 'BlobStore', '.', 'copy', 'that', 'guarantees', 'the', 'copy', 'refers', 'to', 'the', 'same', 'version', 'of', 'the'...
train
https://github.com/HumanCellAtlas/cloud-blobstore/blob/b8a60e8e8c0da0e39dda084cb467a34cd2d1ef0a/cloud_blobstore/__init__.py#L189-L204
3,046
anchor/elasticsearchadmin
esadmin/elasticsearchadmin.py
Connection.get_index_translog_disable_flush
def get_index_translog_disable_flush(self): """Return a dictionary showing the position of the 'translog.disable_flush' knob for each index in the cluster. The dictionary will look like this: { "index1": True, # Autoflushing DISABLED "index2": ...
python
def get_index_translog_disable_flush(self): """Return a dictionary showing the position of the 'translog.disable_flush' knob for each index in the cluster. The dictionary will look like this: { "index1": True, # Autoflushing DISABLED "index2": ...
['def', 'get_index_translog_disable_flush', '(', 'self', ')', ':', 'disabled', '=', '{', '}', 'settings', '=', 'self', '.', 'get', '(', "'/_settings'", ')', 'setting_getters', '=', '[', 'lambda', 's', ':', 's', '[', "'index.translog.disable_flush'", ']', ',', 'lambda', 's', ':', 's', '[', "'index'", ']', '[', "'translo...
Return a dictionary showing the position of the 'translog.disable_flush' knob for each index in the cluster. The dictionary will look like this: { "index1": True, # Autoflushing DISABLED "index2": False, # Autoflushing ENABLED "inde...
['Return', 'a', 'dictionary', 'showing', 'the', 'position', 'of', 'the', 'translog', '.', 'disable_flush', 'knob', 'for', 'each', 'index', 'in', 'the', 'cluster', '.']
train
https://github.com/anchor/elasticsearchadmin/blob/80b5adf79ead341ce0ded34119b087a343425983/esadmin/elasticsearchadmin.py#L103-L131
3,047
knipknap/exscript
Exscript/util/mail.py
Mail.get_smtp_mail
def get_smtp_mail(self): """ Returns the SMTP formatted email, as it may be passed to sendmail. :rtype: string :return: The SMTP formatted mail. """ header = self.get_smtp_header() body = self.get_body().replace('\n', '\r\n') return header + '\r\n' + bod...
python
def get_smtp_mail(self): """ Returns the SMTP formatted email, as it may be passed to sendmail. :rtype: string :return: The SMTP formatted mail. """ header = self.get_smtp_header() body = self.get_body().replace('\n', '\r\n') return header + '\r\n' + bod...
['def', 'get_smtp_mail', '(', 'self', ')', ':', 'header', '=', 'self', '.', 'get_smtp_header', '(', ')', 'body', '=', 'self', '.', 'get_body', '(', ')', '.', 'replace', '(', "'\\n'", ',', "'\\r\\n'", ')', 'return', 'header', '+', "'\\r\\n'", '+', 'body', '+', "'\\r\\n'"]
Returns the SMTP formatted email, as it may be passed to sendmail. :rtype: string :return: The SMTP formatted mail.
['Returns', 'the', 'SMTP', 'formatted', 'email', 'as', 'it', 'may', 'be', 'passed', 'to', 'sendmail', '.']
train
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/util/mail.py#L369-L378
3,048
quantmind/dynts
dynts/lib/fallback/operators.py
roll_mean
def roll_mean(input, window): '''Apply a rolling mean function to an array. This is a simple rolling aggregation.''' nobs, i, j, sum_x = 0,0,0,0. N = len(input) if window > N: raise ValueError('Out of bound') output = np.ndarray(N-window+1,dtype=input.dtype) for val in inpu...
python
def roll_mean(input, window): '''Apply a rolling mean function to an array. This is a simple rolling aggregation.''' nobs, i, j, sum_x = 0,0,0,0. N = len(input) if window > N: raise ValueError('Out of bound') output = np.ndarray(N-window+1,dtype=input.dtype) for val in inpu...
['def', 'roll_mean', '(', 'input', ',', 'window', ')', ':', 'nobs', ',', 'i', ',', 'j', ',', 'sum_x', '=', '0', ',', '0', ',', '0', ',', '0.', 'N', '=', 'len', '(', 'input', ')', 'if', 'window', '>', 'N', ':', 'raise', 'ValueError', '(', "'Out of bound'", ')', 'output', '=', 'np', '.', 'ndarray', '(', 'N', '-', 'window...
Apply a rolling mean function to an array. This is a simple rolling aggregation.
['Apply', 'a', 'rolling', 'mean', 'function', 'to', 'an', 'array', '.', 'This', 'is', 'a', 'simple', 'rolling', 'aggregation', '.']
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L76-L107
3,049
HiPERCAM/hcam_widgets
hcam_widgets/widgets.py
FloatEntry.set_unbind
def set_unbind(self): """ Unsets key bindings. """ self.unbind('<Button-1>') self.unbind('<Button-3>') self.unbind('<Up>') self.unbind('<Down>') self.unbind('<Shift-Up>') self.unbind('<Shift-Down>') self.unbind('<Control-Up>') self....
python
def set_unbind(self): """ Unsets key bindings. """ self.unbind('<Button-1>') self.unbind('<Button-3>') self.unbind('<Up>') self.unbind('<Down>') self.unbind('<Shift-Up>') self.unbind('<Shift-Down>') self.unbind('<Control-Up>') self....
['def', 'set_unbind', '(', 'self', ')', ':', 'self', '.', 'unbind', '(', "'<Button-1>'", ')', 'self', '.', 'unbind', '(', "'<Button-3>'", ')', 'self', '.', 'unbind', '(', "'<Up>'", ')', 'self', '.', 'unbind', '(', "'<Down>'", ')', 'self', '.', 'unbind', '(', "'<Shift-Up>'", ')', 'self', '.', 'unbind', '(', "'<Shift-Dow...
Unsets key bindings.
['Unsets', 'key', 'bindings', '.']
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L899-L917
3,050
juju/charm-helpers
charmhelpers/contrib/openstack/utils.py
clean_storage
def clean_storage(block_device): ''' Ensures a block device is clean. That is: - unmounted - any lvm volume groups are deactivated - any lvm physical device signatures removed - partition table wiped :param block_device: str: Full path to block device to clean. ''' ...
python
def clean_storage(block_device): ''' Ensures a block device is clean. That is: - unmounted - any lvm volume groups are deactivated - any lvm physical device signatures removed - partition table wiped :param block_device: str: Full path to block device to clean. ''' ...
['def', 'clean_storage', '(', 'block_device', ')', ':', 'for', 'mp', ',', 'd', 'in', 'mounts', '(', ')', ':', 'if', 'd', '==', 'block_device', ':', 'juju_log', '(', "'clean_storage(): %s is mounted @ %s, unmounting.'", '%', '(', 'd', ',', 'mp', ')', ',', 'level', '=', 'INFO', ')', 'umount', '(', 'mp', ',', 'persist', '...
Ensures a block device is clean. That is: - unmounted - any lvm volume groups are deactivated - any lvm physical device signatures removed - partition table wiped :param block_device: str: Full path to block device to clean.
['Ensures', 'a', 'block', 'device', 'is', 'clean', '.', 'That', 'is', ':', '-', 'unmounted', '-', 'any', 'lvm', 'volume', 'groups', 'are', 'deactivated', '-', 'any', 'lvm', 'physical', 'device', 'signatures', 'removed', '-', 'partition', 'table', 'wiped']
train
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/utils.py#L694-L714
3,051
gem/oq-engine
openquake/hmtk/seismicity/catalogue.py
Catalogue._get_row_str
def _get_row_str(self, i): """ Returns a string representation of the key information in a row """ row_data = ["{:s}".format(self.data['eventID'][i]), "{:g}".format(self.data['year'][i]), "{:g}".format(self.data['month'][i]), "{...
python
def _get_row_str(self, i): """ Returns a string representation of the key information in a row """ row_data = ["{:s}".format(self.data['eventID'][i]), "{:g}".format(self.data['year'][i]), "{:g}".format(self.data['month'][i]), "{...
['def', '_get_row_str', '(', 'self', ',', 'i', ')', ':', 'row_data', '=', '[', '"{:s}"', '.', 'format', '(', 'self', '.', 'data', '[', "'eventID'", ']', '[', 'i', ']', ')', ',', '"{:g}"', '.', 'format', '(', 'self', '.', 'data', '[', "'year'", ']', '[', 'i', ']', ')', ',', '"{:g}"', '.', 'format', '(', 'self', '.', 'da...
Returns a string representation of the key information in a row
['Returns', 'a', 'string', 'representation', 'of', 'the', 'key', 'information', 'in', 'a', 'row']
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L138-L153
3,052
michaeljoseph/changes
changes/flow.py
publish
def publish(context): """Publishes the project""" commit_version_change(context) if context.github: # github token project_settings = project_config(context.module_name) if not project_settings['gh_token']: click.echo('You need a GitHub token for changes to create a rele...
python
def publish(context): """Publishes the project""" commit_version_change(context) if context.github: # github token project_settings = project_config(context.module_name) if not project_settings['gh_token']: click.echo('You need a GitHub token for changes to create a rele...
['def', 'publish', '(', 'context', ')', ':', 'commit_version_change', '(', 'context', ')', 'if', 'context', '.', 'github', ':', '# github token', 'project_settings', '=', 'project_config', '(', 'context', '.', 'module_name', ')', 'if', 'not', 'project_settings', '[', "'gh_token'", ']', ':', 'click', '.', 'echo', '(', "...
Publishes the project
['Publishes', 'the', 'project']
train
https://github.com/michaeljoseph/changes/blob/a8beb409671c58cdf28ee913bad0a5c7d5374ade/changes/flow.py#L25-L60
3,053
mitsei/dlkit
dlkit/handcar/learning/sessions.py
ActivityLookupSession.get_activities_for_objectives
def get_activities_for_objectives(self, objective_ids=None): """Gets the activities for the given objectives. In plenary mode, the returned list contains all of the activities specified in the objective Id list, in the order of the list, including duplicates, or an error results if a cou...
python
def get_activities_for_objectives(self, objective_ids=None): """Gets the activities for the given objectives. In plenary mode, the returned list contains all of the activities specified in the objective Id list, in the order of the list, including duplicates, or an error results if a cou...
['def', 'get_activities_for_objectives', '(', 'self', ',', 'objective_ids', '=', 'None', ')', ':', 'if', 'objective_ids', 'is', 'None', ':', 'raise', 'NullArgument', '(', ')', '# Should also check if objective_id exists?', 'activities', '=', '[', ']', 'for', 'i', 'in', 'objective_ids', ':', 'acts', '=', 'None', 'url_pa...
Gets the activities for the given objectives. In plenary mode, the returned list contains all of the activities specified in the objective Id list, in the order of the list, including duplicates, or an error results if a course offering Id in the supplied list is not found or inaccessibl...
['Gets', 'the', 'activities', 'for', 'the', 'given', 'objectives', '.', 'In', 'plenary', 'mode', 'the', 'returned', 'list', 'contains', 'all', 'of', 'the', 'activities', 'specified', 'in', 'the', 'objective', 'Id', 'list', 'in', 'the', 'order', 'of', 'the', 'list', 'including', 'duplicates', 'or', 'an', 'error', 'resul...
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L2601-L2637
3,054
globality-corp/microcosm-flask
microcosm_flask/cloning.py
DAGCloningController.clone
def clone(self, substitutions, commit=True, **kwargs): """ Clone a DAG, optionally skipping the commit. """ return self.store.clone(substitutions, **kwargs)
python
def clone(self, substitutions, commit=True, **kwargs): """ Clone a DAG, optionally skipping the commit. """ return self.store.clone(substitutions, **kwargs)
['def', 'clone', '(', 'self', ',', 'substitutions', ',', 'commit', '=', 'True', ',', '*', '*', 'kwargs', ')', ':', 'return', 'self', '.', 'store', '.', 'clone', '(', 'substitutions', ',', '*', '*', 'kwargs', ')']
Clone a DAG, optionally skipping the commit.
['Clone', 'a', 'DAG', 'optionally', 'skipping', 'the', 'commit', '.']
train
https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/cloning.py#L115-L120
3,055
Accelize/pycosio
pycosio/storage/s3.py
_handle_client_error
def _handle_client_error(): """ Handle boto exception and convert to class IO exceptions Raises: OSError subclasses: IO error. """ try: yield except _ClientError as exception: error = exception.response['Error'] if error['Code'] in _ERROR_CODES: ...
python
def _handle_client_error(): """ Handle boto exception and convert to class IO exceptions Raises: OSError subclasses: IO error. """ try: yield except _ClientError as exception: error = exception.response['Error'] if error['Code'] in _ERROR_CODES: ...
['def', '_handle_client_error', '(', ')', ':', 'try', ':', 'yield', 'except', '_ClientError', 'as', 'exception', ':', 'error', '=', 'exception', '.', 'response', '[', "'Error'", ']', 'if', 'error', '[', "'Code'", ']', 'in', '_ERROR_CODES', ':', 'raise', '_ERROR_CODES', '[', 'error', '[', "'Code'", ']', ']', '(', 'error...
Handle boto exception and convert to class IO exceptions Raises: OSError subclasses: IO error.
['Handle', 'boto', 'exception', 'and', 'convert', 'to', 'class', 'IO', 'exceptions']
train
https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L29-L44
3,056
ldo/dbussy
ravel.py
system_bus_async
async def system_bus_async(loop = None, **kwargs) : "returns a Connection object for the D-Bus system bus." return \ Connection \ ( await dbus.Connection.bus_get_async(DBUS.BUS_SYSTEM, private = False, loop = loop) ) \ .register_additional_standard(**kwargs)
python
async def system_bus_async(loop = None, **kwargs) : "returns a Connection object for the D-Bus system bus." return \ Connection \ ( await dbus.Connection.bus_get_async(DBUS.BUS_SYSTEM, private = False, loop = loop) ) \ .register_additional_standard(**kwargs)
['async', 'def', 'system_bus_async', '(', 'loop', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'return', 'Connection', '(', 'await', 'dbus', '.', 'Connection', '.', 'bus_get_async', '(', 'DBUS', '.', 'BUS_SYSTEM', ',', 'private', '=', 'False', ',', 'loop', '=', 'loop', ')', ')', '.', 'register_additional_standard', ...
returns a Connection object for the D-Bus system bus.
['returns', 'a', 'Connection', 'object', 'for', 'the', 'D', '-', 'Bus', 'system', 'bus', '.']
train
https://github.com/ldo/dbussy/blob/59e4fbe8b8111ceead884e50d1973901a0a2d240/ravel.py#L1614-L1621
3,057
thombashi/pytablewriter
pytablewriter/writer/_table_writer.py
AbstractTableWriter.from_series
def from_series(self, series, add_index_column=True): """ Set tabular attributes to the writer from :py:class:`pandas.Series`. Following attributes are set by the method: - :py:attr:`~.headers` - :py:attr:`~.value_matrix` - :py:attr:`~.type_hints` Ar...
python
def from_series(self, series, add_index_column=True): """ Set tabular attributes to the writer from :py:class:`pandas.Series`. Following attributes are set by the method: - :py:attr:`~.headers` - :py:attr:`~.value_matrix` - :py:attr:`~.type_hints` Ar...
['def', 'from_series', '(', 'self', ',', 'series', ',', 'add_index_column', '=', 'True', ')', ':', 'if', 'series', '.', 'name', ':', 'self', '.', 'headers', '=', '[', 'series', '.', 'name', ']', 'else', ':', 'self', '.', 'headers', '=', '[', '"value"', ']', 'self', '.', 'type_hints', '=', '[', 'self', '.', '__get_typeh...
Set tabular attributes to the writer from :py:class:`pandas.Series`. Following attributes are set by the method: - :py:attr:`~.headers` - :py:attr:`~.value_matrix` - :py:attr:`~.type_hints` Args: series(pandas.Series): Input pandas.Series...
['Set', 'tabular', 'attributes', 'to', 'the', 'writer', 'from', ':', 'py', ':', 'class', ':', 'pandas', '.', 'Series', '.', 'Following', 'attributes', 'are', 'set', 'by', 'the', 'method', ':']
train
https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/_table_writer.py#L654-L686
3,058
eng-tools/sfsimodels
sfsimodels/models/soils.py
SoilProfile.get_v_total_stress_at_depth
def get_v_total_stress_at_depth(self, z): """ Determine the vertical total stress at depth z, where z can be a number or an array of numbers. """ if not hasattr(z, "__len__"): return self.one_vertical_total_stress(z) else: sigma_v_effs = [] fo...
python
def get_v_total_stress_at_depth(self, z): """ Determine the vertical total stress at depth z, where z can be a number or an array of numbers. """ if not hasattr(z, "__len__"): return self.one_vertical_total_stress(z) else: sigma_v_effs = [] fo...
['def', 'get_v_total_stress_at_depth', '(', 'self', ',', 'z', ')', ':', 'if', 'not', 'hasattr', '(', 'z', ',', '"__len__"', ')', ':', 'return', 'self', '.', 'one_vertical_total_stress', '(', 'z', ')', 'else', ':', 'sigma_v_effs', '=', '[', ']', 'for', 'value', 'in', 'z', ':', 'sigma_v_effs', '.', 'append', '(', 'self',...
Determine the vertical total stress at depth z, where z can be a number or an array of numbers.
['Determine', 'the', 'vertical', 'total', 'stress', 'at', 'depth', 'z', 'where', 'z', 'can', 'be', 'a', 'number', 'or', 'an', 'array', 'of', 'numbers', '.']
train
https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/models/soils.py#L1112-L1123
3,059
dw/mitogen
mitogen/core.py
Receiver.get
def get(self, timeout=None, block=True, throw_dead=True): """ Sleep waiting for a message to arrive on this receiver. :param float timeout: If not :data:`None`, specifies a timeout in seconds. :raises mitogen.core.ChannelError: The remote end indicated the chann...
python
def get(self, timeout=None, block=True, throw_dead=True): """ Sleep waiting for a message to arrive on this receiver. :param float timeout: If not :data:`None`, specifies a timeout in seconds. :raises mitogen.core.ChannelError: The remote end indicated the chann...
['def', 'get', '(', 'self', ',', 'timeout', '=', 'None', ',', 'block', '=', 'True', ',', 'throw_dead', '=', 'True', ')', ':', '_vv', 'and', 'IOLOG', '.', 'debug', '(', "'%r.get(timeout=%r, block=%r)'", ',', 'self', ',', 'timeout', ',', 'block', ')', 'try', ':', 'msg', '=', 'self', '.', '_latch', '.', 'get', '(', 'timeo...
Sleep waiting for a message to arrive on this receiver. :param float timeout: If not :data:`None`, specifies a timeout in seconds. :raises mitogen.core.ChannelError: The remote end indicated the channel should be closed, communication with it was lost, or :meth:`clo...
['Sleep', 'waiting', 'for', 'a', 'message', 'to', 'arrive', 'on', 'this', 'receiver', '.']
train
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/core.py#L1010-L1035
3,060
pjuren/pyokit
src/pyokit/io/bedIterators.py
pairedBEDIterator
def pairedBEDIterator(inputStreams, mirror=False, mirrorScore=None, ignoreStrand=False, ignoreScore=True, ignoreName=True, sortedby=ITERATOR_SORTED_END, scoreType=float, verbose=False): """ Iterate over multiple BED format files simultaneously and yi...
python
def pairedBEDIterator(inputStreams, mirror=False, mirrorScore=None, ignoreStrand=False, ignoreScore=True, ignoreName=True, sortedby=ITERATOR_SORTED_END, scoreType=float, verbose=False): """ Iterate over multiple BED format files simultaneously and yi...
['def', 'pairedBEDIterator', '(', 'inputStreams', ',', 'mirror', '=', 'False', ',', 'mirrorScore', '=', 'None', ',', 'ignoreStrand', '=', 'False', ',', 'ignoreScore', '=', 'True', ',', 'ignoreName', '=', 'True', ',', 'sortedby', '=', 'ITERATOR_SORTED_END', ',', 'scoreType', '=', 'float', ',', 'verbose', '=', 'False', '...
Iterate over multiple BED format files simultaneously and yield lists of genomic intervals for each matching set of intervals found. By default, regions which are not found in all files will be skipped (mirror = false). Optionally (by setting mirror to true) if a file is missing an interval, it can be added on-...
['Iterate', 'over', 'multiple', 'BED', 'format', 'files', 'simultaneously', 'and', 'yield', 'lists', 'of', 'genomic', 'intervals', 'for', 'each', 'matching', 'set', 'of', 'intervals', 'found', '.', 'By', 'default', 'regions', 'which', 'are', 'not', 'found', 'in', 'all', 'files', 'will', 'be', 'skipped', '(', 'mirror', ...
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/bedIterators.py#L207-L289
3,061
Microsoft/nni
tools/nni_annotation/code_generator.py
parse_annotation
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
python
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
['def', 'parse_annotation', '(', 'code', ')', ':', 'module', '=', 'ast', '.', 'parse', '(', 'code', ')', 'assert', 'type', '(', 'module', ')', 'is', 'ast', '.', 'Module', ',', "'internal error #1'", 'assert', 'len', '(', 'module', '.', 'body', ')', '==', '1', ',', "'Annotation contains more than one expression'", 'asse...
Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@')
['Parse', 'an', 'annotation', 'string', '.', 'Return', 'an', 'AST', 'Expr', 'node', '.', 'code', ':', 'annotation', 'string', '(', 'excluding']
train
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L29-L38
3,062
tanghaibao/goatools
goatools/cli/gosubdag_plot.py
PlotCli.get_outfile
def get_outfile(self, outfile, goids=None): """Return output file for GO Term plot.""" # 1. Use the user-specfied output filename for the GO Term plot if outfile != self.dflt_outfile: return outfile # 2. If only plotting 1 GO term, use GO is in plot name if goids is n...
python
def get_outfile(self, outfile, goids=None): """Return output file for GO Term plot.""" # 1. Use the user-specfied output filename for the GO Term plot if outfile != self.dflt_outfile: return outfile # 2. If only plotting 1 GO term, use GO is in plot name if goids is n...
['def', 'get_outfile', '(', 'self', ',', 'outfile', ',', 'goids', '=', 'None', ')', ':', '# 1. Use the user-specfied output filename for the GO Term plot', 'if', 'outfile', '!=', 'self', '.', 'dflt_outfile', ':', 'return', 'outfile', '# 2. If only plotting 1 GO term, use GO is in plot name', 'if', 'goids', 'is', 'not',...
Return output file for GO Term plot.
['Return', 'output', 'file', 'for', 'GO', 'Term', 'plot', '.']
train
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L304-L316
3,063
DarkEnergySurvey/ugali
ugali/observation/mask.py
Mask.completeness
def completeness(self, delta, method='step'): """ Return the completeness as a function of magnitude. ADW: Eventually want a completeness mask to set overall efficiency. """ delta = np.asarray(delta) if method == 'step': func = lambda delta: (delta > 0).astyp...
python
def completeness(self, delta, method='step'): """ Return the completeness as a function of magnitude. ADW: Eventually want a completeness mask to set overall efficiency. """ delta = np.asarray(delta) if method == 'step': func = lambda delta: (delta > 0).astyp...
['def', 'completeness', '(', 'self', ',', 'delta', ',', 'method', '=', "'step'", ')', ':', 'delta', '=', 'np', '.', 'asarray', '(', 'delta', ')', 'if', 'method', '==', "'step'", ':', 'func', '=', 'lambda', 'delta', ':', '(', 'delta', '>', '0', ')', '.', 'astype', '(', 'float', ')', 'elif', 'method', '==', "'erf'", ':',...
Return the completeness as a function of magnitude. ADW: Eventually want a completeness mask to set overall efficiency.
['Return', 'the', 'completeness', 'as', 'a', 'function', 'of', 'magnitude', '.']
train
https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/observation/mask.py#L297-L326
3,064
9wfox/tornadoweb
tornadoweb/web.py
BaseHandler.signout
def signout(self, redirect_url = "/"): """ 注销登录状态 参数: redirect_url 跳转链接,为 None 时不跳转 (Ajax 可能用得到)。 """ self.clear_cookie(self._USER_NAME) if redirect_url: self.redirect(redirect_url)
python
def signout(self, redirect_url = "/"): """ 注销登录状态 参数: redirect_url 跳转链接,为 None 时不跳转 (Ajax 可能用得到)。 """ self.clear_cookie(self._USER_NAME) if redirect_url: self.redirect(redirect_url)
['def', 'signout', '(', 'self', ',', 'redirect_url', '=', '"/"', ')', ':', 'self', '.', 'clear_cookie', '(', 'self', '.', '_USER_NAME', ')', 'if', 'redirect_url', ':', 'self', '.', 'redirect', '(', 'redirect_url', ')']
注销登录状态 参数: redirect_url 跳转链接,为 None 时不跳转 (Ajax 可能用得到)。
['注销登录状态', '参数', ':', 'redirect_url', '跳转链接,为', 'None', '时不跳转', '(', 'Ajax', '可能用得到', ')', '。']
train
https://github.com/9wfox/tornadoweb/blob/2286b66fbe10e4d9f212b979664c15fa17adf378/tornadoweb/web.py#L122-L130
3,065
CI-WATER/gsshapy
gsshapy/orm/wms_dataset.py
WMSDatasetFile.getAsKmlPngAnimation
def getAsKmlPngAnimation(self, session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0, noDataValue=0, drawOrder=0, cellSize=None, resampleMethod='NearestNeighbour'): """ Retrieve the WMS dataset as a PNG time stamped KMZ Args: ...
python
def getAsKmlPngAnimation(self, session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0, noDataValue=0, drawOrder=0, cellSize=None, resampleMethod='NearestNeighbour'): """ Retrieve the WMS dataset as a PNG time stamped KMZ Args: ...
['def', 'getAsKmlPngAnimation', '(', 'self', ',', 'session', ',', 'projectFile', '=', 'None', ',', 'path', '=', 'None', ',', 'documentName', '=', 'None', ',', 'colorRamp', '=', 'None', ',', 'alpha', '=', '1.0', ',', 'noDataValue', '=', '0', ',', 'drawOrder', '=', '0', ',', 'cellSize', '=', 'None', ',', 'resampleMethod'...
Retrieve the WMS dataset as a PNG time stamped KMZ Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database. projectFile(:class:`gsshapy.orm.ProjectFile`): Project file object for the GSSHA project to which the WMS dataset belong...
['Retrieve', 'the', 'WMS', 'dataset', 'as', 'a', 'PNG', 'time', 'stamped', 'KMZ']
train
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/wms_dataset.py#L236-L306
3,066
vtkiorg/vtki
vtki/filters.py
DataSetFilters.select_enclosed_points
def select_enclosed_points(dataset, surface, tolerance=0.001, inside_out=False, check_surface=True): """Mark points as to whether they are inside a closed surface. This evaluates all the input points to determine whether they are in an enclosed surface. The filter produces a (0,1...
python
def select_enclosed_points(dataset, surface, tolerance=0.001, inside_out=False, check_surface=True): """Mark points as to whether they are inside a closed surface. This evaluates all the input points to determine whether they are in an enclosed surface. The filter produces a (0,1...
['def', 'select_enclosed_points', '(', 'dataset', ',', 'surface', ',', 'tolerance', '=', '0.001', ',', 'inside_out', '=', 'False', ',', 'check_surface', '=', 'True', ')', ':', 'alg', '=', 'vtk', '.', 'vtkSelectEnclosedPoints', '(', ')', 'alg', '.', 'SetInputData', '(', 'dataset', ')', 'alg', '.', 'SetSurfaceData', '(',...
Mark points as to whether they are inside a closed surface. This evaluates all the input points to determine whether they are in an enclosed surface. The filter produces a (0,1) mask (in the form of a vtkDataArray) that indicates whether points are outside (mask value=0) or inside (mask ...
['Mark', 'points', 'as', 'to', 'whether', 'they', 'are', 'inside', 'a', 'closed', 'surface', '.', 'This', 'evaluates', 'all', 'the', 'input', 'points', 'to', 'determine', 'whether', 'they', 'are', 'in', 'an', 'enclosed', 'surface', '.', 'The', 'filter', 'produces', 'a', '(', '0', '1', ')', 'mask', '(', 'in', 'the', 'fo...
train
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/filters.py#L943-L988
3,067
offu/WeRoBot
werobot/pay.py
WeixinPayClient.pay_deliver_notify
def pay_deliver_notify(self, **deliver_info): """ 通知 腾讯发货 一般形式 :: wxclient.pay_delivernotify( openid=openid, transid=transaction_id, out_trade_no=本地订单号, deliver_timestamp=int(time.time()), deliver_status...
python
def pay_deliver_notify(self, **deliver_info): """ 通知 腾讯发货 一般形式 :: wxclient.pay_delivernotify( openid=openid, transid=transaction_id, out_trade_no=本地订单号, deliver_timestamp=int(time.time()), deliver_status...
['def', 'pay_deliver_notify', '(', 'self', ',', '*', '*', 'deliver_info', ')', ':', 'params', ',', 'sign', ',', '_', '=', 'self', '.', '_pay_sign_dict', '(', 'add_noncestr', '=', 'False', ',', 'add_timestamp', '=', 'False', ',', '*', '*', 'deliver_info', ')', 'params', '[', "'app_signature'", ']', '=', 'sign', 'params'...
通知 腾讯发货 一般形式 :: wxclient.pay_delivernotify( openid=openid, transid=transaction_id, out_trade_no=本地订单号, deliver_timestamp=int(time.time()), deliver_status="1", deliver_msg="ok" ) :par...
['通知', '腾讯发货']
train
https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/pay.py#L140-L166
3,068
quantumlib/Cirq
cirq/circuits/_block_diagram_drawer.py
Block.draw_curve
def draw_curve(self, grid_characters: BoxDrawCharacterSet, *, top: bool = False, left: bool = False, right: bool = False, bottom: bool = False, crossing_char: Optional[str] = None): ...
python
def draw_curve(self, grid_characters: BoxDrawCharacterSet, *, top: bool = False, left: bool = False, right: bool = False, bottom: bool = False, crossing_char: Optional[str] = None): ...
['def', 'draw_curve', '(', 'self', ',', 'grid_characters', ':', 'BoxDrawCharacterSet', ',', '*', ',', 'top', ':', 'bool', '=', 'False', ',', 'left', ':', 'bool', '=', 'False', ',', 'right', ':', 'bool', '=', 'False', ',', 'bottom', ':', 'bool', '=', 'False', ',', 'crossing_char', ':', 'Optional', '[', 'str', ']', '=', ...
Draws lines in the box using the given character set. Supports merging the new lines with the lines from a previous call to draw_curve, including when they have different character sets (assuming there exist characters merging the two). Args: grid_characters: The character ...
['Draws', 'lines', 'in', 'the', 'box', 'using', 'the', 'given', 'character', 'set', '.']
train
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_block_diagram_drawer.py#L53-L107
3,069
ClimateImpactLab/DataFS
datafs/managers/manager.py
BaseDataManager.add_tags
def add_tags(self, archive_name, tags): ''' Add tags to an archive Parameters ---------- archive_name:s tr Name of archive tags: list or tuple of strings tags to add to the archive ''' updated_tag_list = list(self._get_tags(archi...
python
def add_tags(self, archive_name, tags): ''' Add tags to an archive Parameters ---------- archive_name:s tr Name of archive tags: list or tuple of strings tags to add to the archive ''' updated_tag_list = list(self._get_tags(archi...
['def', 'add_tags', '(', 'self', ',', 'archive_name', ',', 'tags', ')', ':', 'updated_tag_list', '=', 'list', '(', 'self', '.', '_get_tags', '(', 'archive_name', ')', ')', 'for', 'tag', 'in', 'tags', ':', 'if', 'tag', 'not', 'in', 'updated_tag_list', ':', 'updated_tag_list', '.', 'append', '(', 'tag', ')', 'self', '.',...
Add tags to an archive Parameters ---------- archive_name:s tr Name of archive tags: list or tuple of strings tags to add to the archive
['Add', 'tags', 'to', 'an', 'archive']
train
https://github.com/ClimateImpactLab/DataFS/blob/0d32c2b4e18d300a11b748a552f6adbc3dd8f59d/datafs/managers/manager.py#L451-L469
3,070
inveniosoftware/invenio-accounts
invenio_accounts/sessions.py
add_session
def add_session(session=None): r"""Add a session to the SessionActivity table. :param session: Flask Session object to add. If None, ``session`` is used. The object is expected to have a dictionary entry named ``"user_id"`` and a field ``sid_s`` """ user_id, sid_s = session['user_id'], ...
python
def add_session(session=None): r"""Add a session to the SessionActivity table. :param session: Flask Session object to add. If None, ``session`` is used. The object is expected to have a dictionary entry named ``"user_id"`` and a field ``sid_s`` """ user_id, sid_s = session['user_id'], ...
['def', 'add_session', '(', 'session', '=', 'None', ')', ':', 'user_id', ',', 'sid_s', '=', 'session', '[', "'user_id'", ']', ',', 'session', '.', 'sid_s', 'with', 'db', '.', 'session', '.', 'begin_nested', '(', ')', ':', 'session_activity', '=', 'SessionActivity', '(', 'user_id', '=', 'user_id', ',', 'sid_s', '=', 'si...
r"""Add a session to the SessionActivity table. :param session: Flask Session object to add. If None, ``session`` is used. The object is expected to have a dictionary entry named ``"user_id"`` and a field ``sid_s``
['r', 'Add', 'a', 'session', 'to', 'the', 'SessionActivity', 'table', '.']
train
https://github.com/inveniosoftware/invenio-accounts/blob/b0d2f0739b00dbefea22ca15d7d374a1b4a63aec/invenio_accounts/sessions.py#L49-L67
3,071
JasonKessler/scattertext
scattertext/TermDocMatrix.py
TermDocMatrix.get_term_freq_df
def get_term_freq_df(self, label_append=' freq'): ''' Parameters ------- label_append : str Returns ------- pd.DataFrame indexed on terms, with columns giving frequencies for each ''' ''' row = self._row_category_ids() newX = csr_...
python
def get_term_freq_df(self, label_append=' freq'): ''' Parameters ------- label_append : str Returns ------- pd.DataFrame indexed on terms, with columns giving frequencies for each ''' ''' row = self._row_category_ids() newX = csr_...
['def', 'get_term_freq_df', '(', 'self', ',', 'label_append', '=', "' freq'", ')', ':', "'''\n row = self._row_category_ids()\n newX = csr_matrix((self._X.data, (row, self._X.indices)))\n return self._term_freq_df_from_matrix(newX)\n '''", 'mat', '=', 'self', '.', 'get_term_freq_mat', '(', '...
Parameters ------- label_append : str Returns ------- pd.DataFrame indexed on terms, with columns giving frequencies for each
['Parameters', '-------', 'label_append', ':', 'str']
train
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/TermDocMatrix.py#L87-L106
3,072
HiPERCAM/hcam_widgets
hcam_widgets/hcam.py
RunPars.loadJSON
def loadJSON(self, json_string): """ Sets the values of the run parameters given an JSON string """ g = get_root(self).globals user = json.loads(json_string)['user'] def setField(widget, field): val = user.get(field) if val is not None: ...
python
def loadJSON(self, json_string): """ Sets the values of the run parameters given an JSON string """ g = get_root(self).globals user = json.loads(json_string)['user'] def setField(widget, field): val = user.get(field) if val is not None: ...
['def', 'loadJSON', '(', 'self', ',', 'json_string', ')', ':', 'g', '=', 'get_root', '(', 'self', ')', '.', 'globals', 'user', '=', 'json', '.', 'loads', '(', 'json_string', ')', '[', "'user'", ']', 'def', 'setField', '(', 'widget', ',', 'field', ')', ':', 'val', '=', 'user', '.', 'get', '(', 'field', ')', 'if', 'val',...
Sets the values of the run parameters given an JSON string
['Sets', 'the', 'values', 'of', 'the', 'run', 'parameters', 'given', 'an', 'JSON', 'string']
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1075-L1094
3,073
scanny/python-pptx
pptx/text/fonts.py
_NameTable._read_name_text
def _read_name_text( self, bufr, platform_id, encoding_id, strings_offset, name_str_offset, length): """ Return the unicode name string at *name_str_offset* or |None| if decoding its format is not supported. """ raw_name = self._raw_name_string( ...
python
def _read_name_text( self, bufr, platform_id, encoding_id, strings_offset, name_str_offset, length): """ Return the unicode name string at *name_str_offset* or |None| if decoding its format is not supported. """ raw_name = self._raw_name_string( ...
['def', '_read_name_text', '(', 'self', ',', 'bufr', ',', 'platform_id', ',', 'encoding_id', ',', 'strings_offset', ',', 'name_str_offset', ',', 'length', ')', ':', 'raw_name', '=', 'self', '.', '_raw_name_string', '(', 'bufr', ',', 'strings_offset', ',', 'name_str_offset', ',', 'length', ')', 'return', 'self', '.', '_...
Return the unicode name string at *name_str_offset* or |None| if decoding its format is not supported.
['Return', 'the', 'unicode', 'name', 'string', 'at', '*', 'name_str_offset', '*', 'or', '|None|', 'if', 'decoding', 'its', 'format', 'is', 'not', 'supported', '.']
train
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/fonts.py#L376-L386
3,074
ThreatConnect-Inc/tcex
tcex/tcex_bin_run.py
TcExRun.data_not_in
def data_not_in(db_data, user_data): """Validate data not in user data. Args: db_data (str): The data store in Redis. user_data (list): The user provided data. Returns: bool: True if the data passed validation. """ if isinstance(user_data, li...
python
def data_not_in(db_data, user_data): """Validate data not in user data. Args: db_data (str): The data store in Redis. user_data (list): The user provided data. Returns: bool: True if the data passed validation. """ if isinstance(user_data, li...
['def', 'data_not_in', '(', 'db_data', ',', 'user_data', ')', ':', 'if', 'isinstance', '(', 'user_data', ',', 'list', ')', ':', 'if', 'db_data', 'not', 'in', 'user_data', ':', 'return', 'True', 'return', 'False']
Validate data not in user data. Args: db_data (str): The data store in Redis. user_data (list): The user provided data. Returns: bool: True if the data passed validation.
['Validate', 'data', 'not', 'in', 'user', 'data', '.']
train
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L445-L458
3,075
Microsoft/nni
examples/trials/weight_sharing/ga_squad/data.py
WhitespaceTokenizer.tokenize
def tokenize(self, text): ''' tokenize function in Tokenizer. ''' start = -1 tokens = [] for i, character in enumerate(text): if character == ' ' or character == '\t': if start >= 0: word = text[start:i] ...
python
def tokenize(self, text): ''' tokenize function in Tokenizer. ''' start = -1 tokens = [] for i, character in enumerate(text): if character == ' ' or character == '\t': if start >= 0: word = text[start:i] ...
['def', 'tokenize', '(', 'self', ',', 'text', ')', ':', 'start', '=', '-', '1', 'tokens', '=', '[', ']', 'for', 'i', ',', 'character', 'in', 'enumerate', '(', 'text', ')', ':', 'if', 'character', '==', "' '", 'or', 'character', '==', "'\\t'", ':', 'if', 'start', '>=', '0', ':', 'word', '=', 'text', '[', 'start', ':', '...
tokenize function in Tokenizer.
['tokenize', 'function', 'in', 'Tokenizer', '.']
train
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/data.py#L38-L64
3,076
scott-griffiths/bitstring
bitstring.py
Bits._readbytes
def _readbytes(self, length, start): """Read bytes and return them. Note that length is in bits.""" assert length % 8 == 0 assert start + length <= self.len if not (start + self._offset) % 8: return bytes(self._datastore.getbyteslice((start + self._offset) // 8, ...
python
def _readbytes(self, length, start): """Read bytes and return them. Note that length is in bits.""" assert length % 8 == 0 assert start + length <= self.len if not (start + self._offset) % 8: return bytes(self._datastore.getbyteslice((start + self._offset) // 8, ...
['def', '_readbytes', '(', 'self', ',', 'length', ',', 'start', ')', ':', 'assert', 'length', '%', '8', '==', '0', 'assert', 'start', '+', 'length', '<=', 'self', '.', 'len', 'if', 'not', '(', 'start', '+', 'self', '.', '_offset', ')', '%', '8', ':', 'return', 'bytes', '(', 'self', '.', '_datastore', '.', 'getbyteslice...
Read bytes and return them. Note that length is in bits.
['Read', 'bytes', 'and', 'return', 'them', '.', 'Note', 'that', 'length', 'is', 'in', 'bits', '.']
train
https://github.com/scott-griffiths/bitstring/blob/ab40ae7f0b43fe223a39b63cbc0529b09f3ef653/bitstring.py#L1335-L1342
3,077
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py
ShexOneOfShapeParser.visitSenseFlags
def visitSenseFlags(self, ctx: ShExDocParser.SenseFlagsContext): """ '!' '^'? | '^' '!'? """ if '!' in ctx.getText(): self.expression.negated = True if '^' in ctx.getText(): self.expression.inverse = True
python
def visitSenseFlags(self, ctx: ShExDocParser.SenseFlagsContext): """ '!' '^'? | '^' '!'? """ if '!' in ctx.getText(): self.expression.negated = True if '^' in ctx.getText(): self.expression.inverse = True
['def', 'visitSenseFlags', '(', 'self', ',', 'ctx', ':', 'ShExDocParser', '.', 'SenseFlagsContext', ')', ':', 'if', "'!'", 'in', 'ctx', '.', 'getText', '(', ')', ':', 'self', '.', 'expression', '.', 'negated', '=', 'True', 'if', "'^'", 'in', 'ctx', '.', 'getText', '(', ')', ':', 'self', '.', 'expression', '.', 'inverse...
'!' '^'? | '^' '!'?
['!', '^', '?', '|', '^', '!', '?']
train
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L114-L119
3,078
HiPERCAM/hcam_widgets
hcam_widgets/hcam.py
Observe.setExpertLevel
def setExpertLevel(self): """ Set expert level """ g = get_root(self).globals level = g.cpars['expert_level'] # now set whether buttons are permanently enabled or not if level == 0 or level == 1: self.load.setNonExpert() self.save.setNonEx...
python
def setExpertLevel(self): """ Set expert level """ g = get_root(self).globals level = g.cpars['expert_level'] # now set whether buttons are permanently enabled or not if level == 0 or level == 1: self.load.setNonExpert() self.save.setNonEx...
['def', 'setExpertLevel', '(', 'self', ')', ':', 'g', '=', 'get_root', '(', 'self', ')', '.', 'globals', 'level', '=', 'g', '.', 'cpars', '[', "'expert_level'", ']', '# now set whether buttons are permanently enabled or not', 'if', 'level', '==', '0', 'or', 'level', '==', '1', ':', 'self', '.', 'load', '.', 'setNonExpe...
Set expert level
['Set', 'expert', 'level']
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1846-L1866
3,079
quantum5/2048
_2048/game.py
AnimatedTile.get_position
def get_position(self, dt): """Given dt in [0, 1], return the current position of the tile.""" return self.sx + self.dx * dt, self.sy + self.dy * dt
python
def get_position(self, dt): """Given dt in [0, 1], return the current position of the tile.""" return self.sx + self.dx * dt, self.sy + self.dy * dt
['def', 'get_position', '(', 'self', ',', 'dt', ')', ':', 'return', 'self', '.', 'sx', '+', 'self', '.', 'dx', '*', 'dt', ',', 'self', '.', 'sy', '+', 'self', '.', 'dy', '*', 'dt']
Given dt in [0, 1], return the current position of the tile.
['Given', 'dt', 'in', '[', '0', '1', ']', 'return', 'the', 'current', 'position', 'of', 'the', 'tile', '.']
train
https://github.com/quantum5/2048/blob/93ada2e3026eaf154e1bbee943d0500c9253e66f/_2048/game.py#L28-L30
3,080
secdev/scapy
scapy/arch/unix.py
_guess_iface_name
def _guess_iface_name(netif): """ We attempt to guess the name of interfaces that are truncated from the output of ifconfig -l. If there is only one possible candidate matching the interface name then we return it. If there are none or more, then we return None. """ with os.popen('%s -l'...
python
def _guess_iface_name(netif): """ We attempt to guess the name of interfaces that are truncated from the output of ifconfig -l. If there is only one possible candidate matching the interface name then we return it. If there are none or more, then we return None. """ with os.popen('%s -l'...
['def', '_guess_iface_name', '(', 'netif', ')', ':', 'with', 'os', '.', 'popen', '(', "'%s -l'", '%', 'conf', '.', 'prog', '.', 'ifconfig', ')', 'as', 'fdesc', ':', 'ifaces', '=', 'fdesc', '.', 'readline', '(', ')', '.', 'strip', '(', ')', '.', 'split', '(', "' '", ')', 'matches', '=', '[', 'iface', 'for', 'iface', 'in...
We attempt to guess the name of interfaces that are truncated from the output of ifconfig -l. If there is only one possible candidate matching the interface name then we return it. If there are none or more, then we return None.
['We', 'attempt', 'to', 'guess', 'the', 'name', 'of', 'interfaces', 'that', 'are', 'truncated', 'from', 'the', 'output', 'of', 'ifconfig', '-', 'l', '.', 'If', 'there', 'is', 'only', 'one', 'possible', 'candidate', 'matching', 'the', 'interface', 'name', 'then', 'we', 'return', 'it', '.', 'If', 'there', 'are', 'none', ...
train
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L28-L41
3,081
sassoftware/saspy
saspy/sasbase.py
SASsession.sasdata2dataframe
def sasdata2dataframe(self, table: str, libref: str = '', dsopts: dict = None, method: str = 'MEMORY', **kwargs) -> 'pd.DataFrame': """ This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. SASdata object that refers to the Sas Da...
python
def sasdata2dataframe(self, table: str, libref: str = '', dsopts: dict = None, method: str = 'MEMORY', **kwargs) -> 'pd.DataFrame': """ This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. SASdata object that refers to the Sas Da...
['def', 'sasdata2dataframe', '(', 'self', ',', 'table', ':', 'str', ',', 'libref', ':', 'str', '=', "''", ',', 'dsopts', ':', 'dict', '=', 'None', ',', 'method', ':', 'str', '=', "'MEMORY'", ',', '*', '*', 'kwargs', ')', '->', "'pd.DataFrame'", ':', 'dsopts', '=', 'dsopts', 'if', 'dsopts', 'is', 'not', 'None', 'else', ...
This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame :param table: the name of the SAS Data Set you want to export to a Pandas Data Frame :param libref: the libref f...
['This', 'method', 'exports', 'the', 'SAS', 'Data', 'Set', 'to', 'a', 'Pandas', 'Data', 'Frame', 'returning', 'the', 'Data', 'Frame', 'object', '.', 'SASdata', 'object', 'that', 'refers', 'to', 'the', 'Sas', 'Data', 'Set', 'you', 'want', 'to', 'export', 'to', 'a', 'Pandas', 'Data', 'Frame']
train
https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasbase.py#L939-L979
3,082
klen/makesite
makesite/modules/flask/base/core/models.py
BaseMixin.history
def history(self): """Returns an SQLAlchemy query of the object's history (previous versions). If the class does not support history/versioning, returns None. """ history = self.history_class if history: return self.session.query(history).filter(history.id == ...
python
def history(self): """Returns an SQLAlchemy query of the object's history (previous versions). If the class does not support history/versioning, returns None. """ history = self.history_class if history: return self.session.query(history).filter(history.id == ...
['def', 'history', '(', 'self', ')', ':', 'history', '=', 'self', '.', 'history_class', 'if', 'history', ':', 'return', 'self', '.', 'session', '.', 'query', '(', 'history', ')', '.', 'filter', '(', 'history', '.', 'id', '==', 'self', '.', 'id', ')', 'else', ':', 'return', 'None']
Returns an SQLAlchemy query of the object's history (previous versions). If the class does not support history/versioning, returns None.
['Returns', 'an', 'SQLAlchemy', 'query', 'of', 'the', 'object', 's', 'history', '(', 'previous', 'versions', ')', '.', 'If', 'the', 'class', 'does', 'not', 'support', 'history', '/', 'versioning', 'returns', 'None', '.']
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/modules/flask/base/core/models.py#L71-L80
3,083
aparo/pyes
pyes/mappings.py
get_field
def get_field(name, data, default="object", document_object_field=None, is_document=False): """ Return a valid Field by given data """ if isinstance(data, AbstractField): return data data = keys_to_string(data) _type = data.get('type', default) if _type == "string": return St...
python
def get_field(name, data, default="object", document_object_field=None, is_document=False): """ Return a valid Field by given data """ if isinstance(data, AbstractField): return data data = keys_to_string(data) _type = data.get('type', default) if _type == "string": return St...
['def', 'get_field', '(', 'name', ',', 'data', ',', 'default', '=', '"object"', ',', 'document_object_field', '=', 'None', ',', 'is_document', '=', 'False', ')', ':', 'if', 'isinstance', '(', 'data', ',', 'AbstractField', ')', ':', 'return', 'data', 'data', '=', 'keys_to_string', '(', 'data', ')', '_type', '=', 'data',...
Return a valid Field by given data
['Return', 'a', 'valid', 'Field', 'by', 'given', 'data']
train
https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/mappings.py#L754-L807
3,084
minio/minio-py
minio/helpers.py
is_valid_bucket_notification_config
def is_valid_bucket_notification_config(notifications): """ Validate the notifications config structure :param notifications: Dictionary with specific structure. :return: True if input is a valid bucket notifications structure. Raise :exc:`InvalidArgumentError` otherwise. """ # check if ...
python
def is_valid_bucket_notification_config(notifications): """ Validate the notifications config structure :param notifications: Dictionary with specific structure. :return: True if input is a valid bucket notifications structure. Raise :exc:`InvalidArgumentError` otherwise. """ # check if ...
['def', 'is_valid_bucket_notification_config', '(', 'notifications', ')', ':', '# check if notifications is a dict.', 'if', 'not', 'isinstance', '(', 'notifications', ',', 'dict', ')', ':', 'raise', 'TypeError', '(', "'notifications configuration must be a dictionary'", ')', 'if', 'len', '(', 'notifications', ')', '=='...
Validate the notifications config structure :param notifications: Dictionary with specific structure. :return: True if input is a valid bucket notifications structure. Raise :exc:`InvalidArgumentError` otherwise.
['Validate', 'the', 'notifications', 'config', 'structure']
train
https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/helpers.py#L394-L522
3,085
mypebble/django-feature-flipper
feature_flipper/templatetags/feature_flipper.py
FlipperNode.render
def render(self, context): """Handle the actual rendering. """ user = self._get_value(self.user_key, context) feature = self._get_value(self.feature, context) if feature is None: return '' allowed = show_feature(user, feature) return self.nodelist.re...
python
def render(self, context): """Handle the actual rendering. """ user = self._get_value(self.user_key, context) feature = self._get_value(self.feature, context) if feature is None: return '' allowed = show_feature(user, feature) return self.nodelist.re...
['def', 'render', '(', 'self', ',', 'context', ')', ':', 'user', '=', 'self', '.', '_get_value', '(', 'self', '.', 'user_key', ',', 'context', ')', 'feature', '=', 'self', '.', '_get_value', '(', 'self', '.', 'feature', ',', 'context', ')', 'if', 'feature', 'is', 'None', ':', 'return', "''", 'allowed', '=', 'show_featu...
Handle the actual rendering.
['Handle', 'the', 'actual', 'rendering', '.']
train
https://github.com/mypebble/django-feature-flipper/blob/53ff52296955f2ff8b5b6ae4ea426b3f0665960e/feature_flipper/templatetags/feature_flipper.py#L41-L51
3,086
awslabs/aws-sam-cli
samcli/local/docker/utils.py
to_posix_path
def to_posix_path(code_path): """ Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- ...
python
def to_posix_path(code_path): """ Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- ...
['def', 'to_posix_path', '(', 'code_path', ')', ':', 'return', 're', '.', 'sub', '(', '"^([A-Za-z])+:"', ',', 'lambda', 'match', ':', 'posixpath', '.', 'sep', '+', 'match', '.', 'group', '(', ')', '.', 'replace', '(', '":"', ',', '""', ')', '.', 'lower', '(', ')', ',', 'pathlib', '.', 'PureWindowsPath', '(', 'code_path...
Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- str Posix equivalent of absolute ...
['Change', 'the', 'code_path', 'to', 'be', 'of', 'unix', '-', 'style', 'if', 'running', 'on', 'windows', 'when', 'supplied', 'with', 'an', 'absolute', 'windows', 'path', '.']
train
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/utils.py#L14-L36
3,087
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_firmware.py
brocade_firmware.fwdl_status_output_fwdl_entries_blade_slot
def fwdl_status_output_fwdl_entries_blade_slot(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fwdl_status = ET.Element("fwdl_status") config = fwdl_status output = ET.SubElement(fwdl_status, "output") fwdl_entries = ET.SubElement(output,...
python
def fwdl_status_output_fwdl_entries_blade_slot(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fwdl_status = ET.Element("fwdl_status") config = fwdl_status output = ET.SubElement(fwdl_status, "output") fwdl_entries = ET.SubElement(output,...
['def', 'fwdl_status_output_fwdl_entries_blade_slot', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'config', '=', 'ET', '.', 'Element', '(', '"config"', ')', 'fwdl_status', '=', 'ET', '.', 'Element', '(', '"fwdl_status"', ')', 'config', '=', 'fwdl_status', 'output', '=', 'ET', '.', 'SubElement', '(', 'fwdl_status', ...
Auto Generated Code
['Auto', 'Generated', 'Code']
train
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_firmware.py#L107-L119
3,088
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/modeling/rpn/inference.py
RPNPostProcessor.forward_for_single_feature_map
def forward_for_single_feature_map(self, anchors, objectness, box_regression): """ Arguments: anchors: list[BoxList] objectness: tensor of size N, A, H, W box_regression: tensor of size N, A * 4, H, W """ device = objectness.device N, A, H, W =...
python
def forward_for_single_feature_map(self, anchors, objectness, box_regression): """ Arguments: anchors: list[BoxList] objectness: tensor of size N, A, H, W box_regression: tensor of size N, A * 4, H, W """ device = objectness.device N, A, H, W =...
['def', 'forward_for_single_feature_map', '(', 'self', ',', 'anchors', ',', 'objectness', ',', 'box_regression', ')', ':', 'device', '=', 'objectness', '.', 'device', 'N', ',', 'A', ',', 'H', ',', 'W', '=', 'objectness', '.', 'shape', '# put in the same format as anchors', 'objectness', '=', 'permute_and_flatten', '(',...
Arguments: anchors: list[BoxList] objectness: tensor of size N, A, H, W box_regression: tensor of size N, A * 4, H, W
['Arguments', ':', 'anchors', ':', 'list', '[', 'BoxList', ']', 'objectness', ':', 'tensor', 'of', 'size', 'N', 'A', 'H', 'W', 'box_regression', ':', 'tensor', 'of', 'size', 'N', 'A', '*', '4', 'H', 'W']
train
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/modeling/rpn/inference.py#L74-L121
3,089
markovmodel/PyEMMA
pyemma/_base/estimator.py
_estimate_param_scan_worker
def _estimate_param_scan_worker(estimator, params, X, evaluate, evaluate_args, failfast, return_exceptions): """ Method that runs estimation for several parameter settings. Defined as a worker for parallelization """ # run estimation model = None try: # catch a...
python
def _estimate_param_scan_worker(estimator, params, X, evaluate, evaluate_args, failfast, return_exceptions): """ Method that runs estimation for several parameter settings. Defined as a worker for parallelization """ # run estimation model = None try: # catch a...
['def', '_estimate_param_scan_worker', '(', 'estimator', ',', 'params', ',', 'X', ',', 'evaluate', ',', 'evaluate_args', ',', 'failfast', ',', 'return_exceptions', ')', ':', '# run estimation', 'model', '=', 'None', 'try', ':', '# catch any exception', 'estimator', '.', 'estimate', '(', 'X', ',', '*', '*', 'params', ')...
Method that runs estimation for several parameter settings. Defined as a worker for parallelization
['Method', 'that', 'runs', 'estimation', 'for', 'several', 'parameter', 'settings', '.']
train
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/_base/estimator.py#L127-L191
3,090
swistakm/python-gmaps
src/gmaps/client.py
Client._serialize_parameters
def _serialize_parameters(parameters): """Serialize some parameters to match python native types with formats specified in google api docs like: * True/False -> "true"/"false", * {"a": 1, "b":2} -> "a:1|b:2" :type parameters: dict oif query parameters """ for ke...
python
def _serialize_parameters(parameters): """Serialize some parameters to match python native types with formats specified in google api docs like: * True/False -> "true"/"false", * {"a": 1, "b":2} -> "a:1|b:2" :type parameters: dict oif query parameters """ for ke...
['def', '_serialize_parameters', '(', 'parameters', ')', ':', 'for', 'key', ',', 'value', 'in', 'parameters', '.', 'items', '(', ')', ':', 'if', 'isinstance', '(', 'value', ',', 'bool', ')', ':', 'parameters', '[', 'key', ']', '=', '"true"', 'if', 'value', 'else', '"false"', 'elif', 'isinstance', '(', 'value', ',', 'di...
Serialize some parameters to match python native types with formats specified in google api docs like: * True/False -> "true"/"false", * {"a": 1, "b":2} -> "a:1|b:2" :type parameters: dict oif query parameters
['Serialize', 'some', 'parameters', 'to', 'match', 'python', 'native', 'types', 'with', 'formats', 'specified', 'in', 'google', 'api', 'docs', 'like', ':', '*', 'True', '/', 'False', '-', '>', 'true', '/', 'false', '*', '{', 'a', ':', '1', 'b', ':', '2', '}', '-', '>', 'a', ':', '1|b', ':', '2']
train
https://github.com/swistakm/python-gmaps/blob/ef3bdea6f02277200f21a09f99d4e2aebad762b9/src/gmaps/client.py#L36-L53
3,091
mozilla/python_moztelemetry
moztelemetry/stats.py
ndtr
def ndtr(a): """ Returns the area under the Gaussian probability density function, integrated from minus infinity to x. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr """ sqrth = math.sqrt(2) / 2 x = float(a) * sqrth z = abs(x) ...
python
def ndtr(a): """ Returns the area under the Gaussian probability density function, integrated from minus infinity to x. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr """ sqrth = math.sqrt(2) / 2 x = float(a) * sqrth z = abs(x) ...
['def', 'ndtr', '(', 'a', ')', ':', 'sqrth', '=', 'math', '.', 'sqrt', '(', '2', ')', '/', '2', 'x', '=', 'float', '(', 'a', ')', '*', 'sqrth', 'z', '=', 'abs', '(', 'x', ')', 'if', 'z', '<', 'sqrth', ':', 'y', '=', '0.5', '+', '0.5', '*', 'math', '.', 'erf', '(', 'x', ')', 'else', ':', 'y', '=', '0.5', '*', 'math', '....
Returns the area under the Gaussian probability density function, integrated from minus infinity to x. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr
['Returns', 'the', 'area', 'under', 'the', 'Gaussian', 'probability', 'density', 'function', 'integrated', 'from', 'minus', 'infinity', 'to', 'x', '.']
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/stats.py#L58-L75
3,092
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
UnrealManagerBase._runUnrealBuildTool
def _runUnrealBuildTool(self, target, platform, configuration, args, capture=False): """ Invokes UnrealBuildTool with the specified parameters """ platform = self._transformBuildToolPlatform(platform) arguments = [self.getBuildScript(), target, platform, configuration] + args if capture == True: return U...
python
def _runUnrealBuildTool(self, target, platform, configuration, args, capture=False): """ Invokes UnrealBuildTool with the specified parameters """ platform = self._transformBuildToolPlatform(platform) arguments = [self.getBuildScript(), target, platform, configuration] + args if capture == True: return U...
['def', '_runUnrealBuildTool', '(', 'self', ',', 'target', ',', 'platform', ',', 'configuration', ',', 'args', ',', 'capture', '=', 'False', ')', ':', 'platform', '=', 'self', '.', '_transformBuildToolPlatform', '(', 'platform', ')', 'arguments', '=', '[', 'self', '.', 'getBuildScript', '(', ')', ',', 'target', ',', 'p...
Invokes UnrealBuildTool with the specified parameters
['Invokes', 'UnrealBuildTool', 'with', 'the', 'specified', 'parameters']
train
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L607-L616
3,093
Gandi/gandi.cli
gandi/cli/modules/cert.py
Certificate.from_cn
def from_cn(cls, common_name): """ Retrieve a certificate by its common name. """ # search with cn result_cn = [(cert['id'], [cert['cn']] + cert['altnames']) for cert in cls.list({'status': ['pending', 'valid'], 'items_per_page': 50...
python
def from_cn(cls, common_name): """ Retrieve a certificate by its common name. """ # search with cn result_cn = [(cert['id'], [cert['cn']] + cert['altnames']) for cert in cls.list({'status': ['pending', 'valid'], 'items_per_page': 50...
['def', 'from_cn', '(', 'cls', ',', 'common_name', ')', ':', '# search with cn', 'result_cn', '=', '[', '(', 'cert', '[', "'id'", ']', ',', '[', 'cert', '[', "'cn'", ']', ']', '+', 'cert', '[', "'altnames'", ']', ')', 'for', 'cert', 'in', 'cls', '.', 'list', '(', '{', "'status'", ':', '[', "'pending'", ',', "'valid'", ...
Retrieve a certificate by its common name.
['Retrieve', 'a', 'certificate', 'by', 'its', 'common', 'name', '.']
train
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/cert.py#L121-L144
3,094
apple/turicreate
src/unity/python/turicreate/toolkits/object_detector/util/_visualization.py
draw_bounding_boxes
def draw_bounding_boxes(images, annotations, confidence_threshold=0): """ Visualizes bounding boxes (ground truth or predictions) by returning annotated copies of the images. Parameters ---------- images: SArray or Image An `SArray` of type `Image`. A single `Image` instance may also be...
python
def draw_bounding_boxes(images, annotations, confidence_threshold=0): """ Visualizes bounding boxes (ground truth or predictions) by returning annotated copies of the images. Parameters ---------- images: SArray or Image An `SArray` of type `Image`. A single `Image` instance may also be...
['def', 'draw_bounding_boxes', '(', 'images', ',', 'annotations', ',', 'confidence_threshold', '=', '0', ')', ':', '_numeric_param_check_range', '(', "'confidence_threshold'", ',', 'confidence_threshold', ',', '0.0', ',', '1.0', ')', 'from', 'PIL', 'import', 'Image', 'def', 'draw_single_image', '(', 'row', ')', ':', 'i...
Visualizes bounding boxes (ground truth or predictions) by returning annotated copies of the images. Parameters ---------- images: SArray or Image An `SArray` of type `Image`. A single `Image` instance may also be given. annotations: SArray or list An `SArray` of annotation...
['Visualizes', 'bounding', 'boxes', '(', 'ground', 'truth', 'or', 'predictions', ')', 'by', 'returning', 'annotated', 'copies', 'of', 'the', 'images', '.']
train
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/object_detector/util/_visualization.py#L94-L151
3,095
useblocks/groundwork
groundwork/patterns/gw_commands_pattern.py
CommandsListApplication.unregister
def unregister(self, command): """ Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command """ if command not in self._comman...
python
def unregister(self, command): """ Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command """ if command not in self._comman...
['def', 'unregister', '(', 'self', ',', 'command', ')', ':', 'if', 'command', 'not', 'in', 'self', '.', '_commands', '.', 'keys', '(', ')', ':', 'self', '.', 'log', '.', 'warning', '(', '"Can not unregister command %s"', '%', 'command', ')', 'else', ':', '# Click does not have any kind of a function to unregister/remov...
Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command
['Unregisters', 'an', 'existing', 'command', 'so', 'that', 'this', 'command', 'is', 'no', 'longer', 'available', 'on', 'the', 'command', 'line', 'interface', '.']
train
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_commands_pattern.py#L185-L202
3,096
python-cmd2/cmd2
cmd2/cmd2.py
Cmd.enable_category
def enable_category(self, category: str) -> None: """ Enable an entire category of commands :param category: the category to enable """ for cmd_name in list(self.disabled_commands): func = self.disabled_commands[cmd_name].command_function if hasattr(func, ...
python
def enable_category(self, category: str) -> None: """ Enable an entire category of commands :param category: the category to enable """ for cmd_name in list(self.disabled_commands): func = self.disabled_commands[cmd_name].command_function if hasattr(func, ...
['def', 'enable_category', '(', 'self', ',', 'category', ':', 'str', ')', '->', 'None', ':', 'for', 'cmd_name', 'in', 'list', '(', 'self', '.', 'disabled_commands', ')', ':', 'func', '=', 'self', '.', 'disabled_commands', '[', 'cmd_name', ']', '.', 'command_function', 'if', 'hasattr', '(', 'func', ',', 'HELP_CATEGORY',...
Enable an entire category of commands :param category: the category to enable
['Enable', 'an', 'entire', 'category', 'of', 'commands', ':', 'param', 'category', ':', 'the', 'category', 'to', 'enable']
train
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L3786-L3794
3,097
twisted/txacme
src/txacme/client.py
Client.update_registration
def update_registration(self, regr, uri=None): """ Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registrat...
python
def update_registration(self, regr, uri=None): """ Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registrat...
['def', 'update_registration', '(', 'self', ',', 'regr', ',', 'uri', '=', 'None', ')', ':', 'if', 'uri', 'is', 'None', ':', 'uri', '=', 'regr', '.', 'uri', 'if', 'isinstance', '(', 'regr', ',', 'messages', '.', 'RegistrationResource', ')', ':', 'message', '=', 'messages', '.', 'UpdateRegistration', '(', '*', '*', 'dict...
Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registration. :param str uri: The url to submit to. Must be ...
['Submit', 'a', 'registration', 'to', 'the', 'server', 'to', 'update', 'it', '.']
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L201-L228
3,098
wakatime/wakatime
wakatime/packages/pygments/lexers/__init__.py
_iter_lexerclasses
def _iter_lexerclasses(plugins=True): """Return an iterator over all lexer classes.""" for key in sorted(LEXERS): module_name, name = LEXERS[key][:2] if name not in _lexer_cache: _load_lexers(module_name) yield _lexer_cache[name] if plugins: for lexer in find_plug...
python
def _iter_lexerclasses(plugins=True): """Return an iterator over all lexer classes.""" for key in sorted(LEXERS): module_name, name = LEXERS[key][:2] if name not in _lexer_cache: _load_lexers(module_name) yield _lexer_cache[name] if plugins: for lexer in find_plug...
['def', '_iter_lexerclasses', '(', 'plugins', '=', 'True', ')', ':', 'for', 'key', 'in', 'sorted', '(', 'LEXERS', ')', ':', 'module_name', ',', 'name', '=', 'LEXERS', '[', 'key', ']', '[', ':', '2', ']', 'if', 'name', 'not', 'in', '_lexer_cache', ':', '_load_lexers', '(', 'module_name', ')', 'yield', '_lexer_cache', '[...
Return an iterator over all lexer classes.
['Return', 'an', 'iterator', 'over', 'all', 'lexer', 'classes', '.']
train
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/lexers/__init__.py#L225-L234
3,099
saltstack/salt
salt/modules/win_pkg.py
remove
def remove(name=None, pkgs=None, **kwargs): ''' Remove the passed package(s) from the system using winrepo .. versionadded:: 0.16.0 Args: name (str): The name(s) of the package(s) to be uninstalled. Can be a single package or a comma delimited list of packages, no space...
python
def remove(name=None, pkgs=None, **kwargs): ''' Remove the passed package(s) from the system using winrepo .. versionadded:: 0.16.0 Args: name (str): The name(s) of the package(s) to be uninstalled. Can be a single package or a comma delimited list of packages, no space...
['def', 'remove', '(', 'name', '=', 'None', ',', 'pkgs', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'saltenv', '=', 'kwargs', '.', 'get', '(', "'saltenv'", ',', "'base'", ')', 'refresh', '=', 'salt', '.', 'utils', '.', 'data', '.', 'is_true', '(', 'kwargs', '.', 'get', '(', "'refresh'", ',', 'False', ')', ')', '# ...
Remove the passed package(s) from the system using winrepo .. versionadded:: 0.16.0 Args: name (str): The name(s) of the package(s) to be uninstalled. Can be a single package or a comma delimited list of packages, no spaces. pkgs (list): A list of packages ...
['Remove', 'the', 'passed', 'package', '(', 's', ')', 'from', 'the', 'system', 'using', 'winrepo']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pkg.py#L1757-L2044