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
2,400
astraw/stdeb
stdeb/util.py
apply_patch
def apply_patch(patchfile,cwd=None,posix=False,level=0): """call 'patch -p[level] [--posix] < arg1' posix mode is sometimes necessary. It keeps empty files so that dpkg-source removes their contents. """ if not os.path.exists(patchfile): raise RuntimeError('patchfile "%s" does not exist'%p...
python
def apply_patch(patchfile,cwd=None,posix=False,level=0): """call 'patch -p[level] [--posix] < arg1' posix mode is sometimes necessary. It keeps empty files so that dpkg-source removes their contents. """ if not os.path.exists(patchfile): raise RuntimeError('patchfile "%s" does not exist'%p...
['def', 'apply_patch', '(', 'patchfile', ',', 'cwd', '=', 'None', ',', 'posix', '=', 'False', ',', 'level', '=', '0', ')', ':', 'if', 'not', 'os', '.', 'path', '.', 'exists', '(', 'patchfile', ')', ':', 'raise', 'RuntimeError', '(', '\'patchfile "%s" does not exist\'', '%', 'patchfile', ')', 'fd', '=', 'open', '(', 'pa...
call 'patch -p[level] [--posix] < arg1' posix mode is sometimes necessary. It keeps empty files so that dpkg-source removes their contents.
['call', 'patch', '-', 'p', '[', 'level', ']', '[', '--', 'posix', ']', '<', 'arg1']
train
https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L544-L593
2,401
jkitzes/macroeco
macroeco/models/_distributions.py
plnorm_gen.rank
def rank(self, n, mu, sigma, crit=.5, upper=10000, xtol=1): """%(super)s Additional Parameters ---------------------- {0} """ return _make_rank(self, n, mu, sigma, crit=crit, upper=upper, xtol=xtol)
python
def rank(self, n, mu, sigma, crit=.5, upper=10000, xtol=1): """%(super)s Additional Parameters ---------------------- {0} """ return _make_rank(self, n, mu, sigma, crit=crit, upper=upper, xtol=xtol)
['def', 'rank', '(', 'self', ',', 'n', ',', 'mu', ',', 'sigma', ',', 'crit', '=', '.5', ',', 'upper', '=', '10000', ',', 'xtol', '=', '1', ')', ':', 'return', '_make_rank', '(', 'self', ',', 'n', ',', 'mu', ',', 'sigma', ',', 'crit', '=', 'crit', ',', 'upper', '=', 'upper', ',', 'xtol', '=', 'xtol', ')']
%(super)s Additional Parameters ---------------------- {0}
['%', '(', 'super', ')', 's']
train
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/models/_distributions.py#L1430-L1440
2,402
vertexproject/synapse
synapse/lib/compat.py
cellAuthToHive
async def cellAuthToHive(dirn, auth): ''' Migrate old cell Auth() data into a HiveAuth(). ''' logger.warning('migrating old cell auth to hive') path = os.path.join(dirn, 'auth.lmdb') lenv = lmdb.open(path, max_dbs=128) userdb = lenv.open_db(b'users') roledb = lenv.open_db(b'roles') ...
python
async def cellAuthToHive(dirn, auth): ''' Migrate old cell Auth() data into a HiveAuth(). ''' logger.warning('migrating old cell auth to hive') path = os.path.join(dirn, 'auth.lmdb') lenv = lmdb.open(path, max_dbs=128) userdb = lenv.open_db(b'users') roledb = lenv.open_db(b'roles') ...
['async', 'def', 'cellAuthToHive', '(', 'dirn', ',', 'auth', ')', ':', 'logger', '.', 'warning', '(', "'migrating old cell auth to hive'", ')', 'path', '=', 'os', '.', 'path', '.', 'join', '(', 'dirn', ',', "'auth.lmdb'", ')', 'lenv', '=', 'lmdb', '.', 'open', '(', 'path', ',', 'max_dbs', '=', '128', ')', 'userdb', '='...
Migrate old cell Auth() data into a HiveAuth().
['Migrate', 'old', 'cell', 'Auth', '()', 'data', 'into', 'a', 'HiveAuth', '()', '.']
train
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/compat.py#L13-L91
2,403
praekelt/django-ultracache
ultracache/decorators.py
cached_get
def cached_get(timeout, *params): """Decorator applied specifically to a view's get method""" def decorator(view_func): @wraps(view_func, assigned=available_attrs(view_func)) def _wrapped_view(view_or_request, *args, **kwargs): # The type of the request gets muddled when using a fu...
python
def cached_get(timeout, *params): """Decorator applied specifically to a view's get method""" def decorator(view_func): @wraps(view_func, assigned=available_attrs(view_func)) def _wrapped_view(view_or_request, *args, **kwargs): # The type of the request gets muddled when using a fu...
['def', 'cached_get', '(', 'timeout', ',', '*', 'params', ')', ':', 'def', 'decorator', '(', 'view_func', ')', ':', '@', 'wraps', '(', 'view_func', ',', 'assigned', '=', 'available_attrs', '(', 'view_func', ')', ')', 'def', '_wrapped_view', '(', 'view_or_request', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', '#...
Decorator applied specifically to a view's get method
['Decorator', 'applied', 'specifically', 'to', 'a', 'view', 's', 'get', 'method']
train
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/decorators.py#L16-L101
2,404
inasafe/inasafe
safe/plugin.py
Plugin._create_metadata_converter_action
def _create_metadata_converter_action(self): """Create action for showing metadata converter dialog.""" icon = resources_path('img', 'icons', 'show-metadata-converter.svg') self.action_metadata_converter = QAction( QIcon(icon), self.tr('InaSAFE Metadata Converter'), ...
python
def _create_metadata_converter_action(self): """Create action for showing metadata converter dialog.""" icon = resources_path('img', 'icons', 'show-metadata-converter.svg') self.action_metadata_converter = QAction( QIcon(icon), self.tr('InaSAFE Metadata Converter'), ...
['def', '_create_metadata_converter_action', '(', 'self', ')', ':', 'icon', '=', 'resources_path', '(', "'img'", ',', "'icons'", ',', "'show-metadata-converter.svg'", ')', 'self', '.', 'action_metadata_converter', '=', 'QAction', '(', 'QIcon', '(', 'icon', ')', ',', 'self', '.', 'tr', '(', "'InaSAFE Metadata Converter'...
Create action for showing metadata converter dialog.
['Create', 'action', 'for', 'showing', 'metadata', 'converter', 'dialog', '.']
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/plugin.py#L381-L395
2,405
sanger-pathogens/circlator
circlator/merge.py
Merger._orientation_ok_to_bridge_contigs
def _orientation_ok_to_bridge_contigs(self, start_hit, end_hit): '''Returns True iff the orientation of the hits means that the query contig of both hits can bridge the reference contigs of the hits''' assert start_hit.qry_name == end_hit.qry_name if start_hit.ref_name == end_hit.ref_name: ...
python
def _orientation_ok_to_bridge_contigs(self, start_hit, end_hit): '''Returns True iff the orientation of the hits means that the query contig of both hits can bridge the reference contigs of the hits''' assert start_hit.qry_name == end_hit.qry_name if start_hit.ref_name == end_hit.ref_name: ...
['def', '_orientation_ok_to_bridge_contigs', '(', 'self', ',', 'start_hit', ',', 'end_hit', ')', ':', 'assert', 'start_hit', '.', 'qry_name', '==', 'end_hit', '.', 'qry_name', 'if', 'start_hit', '.', 'ref_name', '==', 'end_hit', '.', 'ref_name', ':', 'return', 'False', 'if', '(', '(', 'self', '.', '_is_at_ref_end', '('...
Returns True iff the orientation of the hits means that the query contig of both hits can bridge the reference contigs of the hits
['Returns', 'True', 'iff', 'the', 'orientation', 'of', 'the', 'hits', 'means', 'that', 'the', 'query', 'contig', 'of', 'both', 'hits', 'can', 'bridge', 'the', 'reference', 'contigs', 'of', 'the', 'hits']
train
https://github.com/sanger-pathogens/circlator/blob/a4befb8c9dbbcd4b3ad1899a95aa3e689d58b638/circlator/merge.py#L451-L473
2,406
inasafe/inasafe
safe/utilities/pivot_table.py
FlatTable.get_value
def get_value(self, **kwargs): """Return the value for a specific key.""" key = tuple(kwargs[group] for group in self.groups) if key not in self.data: self.data[key] = 0 return self.data[key]
python
def get_value(self, **kwargs): """Return the value for a specific key.""" key = tuple(kwargs[group] for group in self.groups) if key not in self.data: self.data[key] = 0 return self.data[key]
['def', 'get_value', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'key', '=', 'tuple', '(', 'kwargs', '[', 'group', ']', 'for', 'group', 'in', 'self', '.', 'groups', ')', 'if', 'key', 'not', 'in', 'self', '.', 'data', ':', 'self', '.', 'data', '[', 'key', ']', '=', '0', 'return', 'self', '.', 'data', '[', 'key', ']'...
Return the value for a specific key.
['Return', 'the', 'value', 'for', 'a', 'specific', 'key', '.']
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/pivot_table.py#L52-L57
2,407
DeepHorizons/iarm
iarm/arm_instructions/_meta.py
_Meta.get_one_parameter
def get_one_parameter(self, regex_exp, parameters): """ Get three parameters from a given regex expression Raise an exception if more than three were found :param regex_exp: :param parameters: :return: """ Rx, other = self.get_parameters(regex_exp, parame...
python
def get_one_parameter(self, regex_exp, parameters): """ Get three parameters from a given regex expression Raise an exception if more than three were found :param regex_exp: :param parameters: :return: """ Rx, other = self.get_parameters(regex_exp, parame...
['def', 'get_one_parameter', '(', 'self', ',', 'regex_exp', ',', 'parameters', ')', ':', 'Rx', ',', 'other', '=', 'self', '.', 'get_parameters', '(', 'regex_exp', ',', 'parameters', ')', 'if', 'other', 'is', 'not', 'None', 'and', 'other', '.', 'strip', '(', ')', ':', 'raise', 'iarm', '.', 'exceptions', '.', 'ParsingErr...
Get three parameters from a given regex expression Raise an exception if more than three were found :param regex_exp: :param parameters: :return:
['Get', 'three', 'parameters', 'from', 'a', 'given', 'regex', 'expression']
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/_meta.py#L259-L271
2,408
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/shell.py
ShellWidget.silent_execute
def silent_execute(self, code): """Execute code in the kernel without increasing the prompt""" try: self.kernel_client.execute(to_text_string(code), silent=True) except AttributeError: pass
python
def silent_execute(self, code): """Execute code in the kernel without increasing the prompt""" try: self.kernel_client.execute(to_text_string(code), silent=True) except AttributeError: pass
['def', 'silent_execute', '(', 'self', ',', 'code', ')', ':', 'try', ':', 'self', '.', 'kernel_client', '.', 'execute', '(', 'to_text_string', '(', 'code', ')', ',', 'silent', '=', 'True', ')', 'except', 'AttributeError', ':', 'pass']
Execute code in the kernel without increasing the prompt
['Execute', 'code', 'in', 'the', 'kernel', 'without', 'increasing', 'the', 'prompt']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/shell.py#L326-L331
2,409
diffeo/rejester
rejester/_queue.py
RejesterQueue.check_out_item
def check_out_item(self, expiration): """Get the highest-priority item out of this queue. Returns the item, or None if no items are available. The item must be either ``return_item()`` or ``renew_item()`` before ``expiration`` seconds pass, or it will become available to future...
python
def check_out_item(self, expiration): """Get the highest-priority item out of this queue. Returns the item, or None if no items are available. The item must be either ``return_item()`` or ``renew_item()`` before ``expiration`` seconds pass, or it will become available to future...
['def', 'check_out_item', '(', 'self', ',', 'expiration', ')', ':', 'conn', '=', 'redis', '.', 'StrictRedis', '(', 'connection_pool', '=', 'self', '.', 'pool', ')', 'self', '.', '_run_expiration', '(', 'conn', ')', 'expiration', '+=', 'time', '.', 'time', '(', ')', 'script', '=', 'conn', '.', 'register_script', '(', '"...
Get the highest-priority item out of this queue. Returns the item, or None if no items are available. The item must be either ``return_item()`` or ``renew_item()`` before ``expiration`` seconds pass, or it will become available to future callers. The item will be marked as being owned...
['Get', 'the', 'highest', '-', 'priority', 'item', 'out', 'of', 'this', 'queue', '.']
train
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L170-L196
2,410
OnroerendErfgoed/pyramid_urireferencer
pyramid_urireferencer/renderers.py
application_adapter
def application_adapter(obj, request): """ Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json. :param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered. :rtype: :class:`dict` """ return { 'title': obj.title, ...
python
def application_adapter(obj, request): """ Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json. :param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered. :rtype: :class:`dict` """ return { 'title': obj.title, ...
['def', 'application_adapter', '(', 'obj', ',', 'request', ')', ':', 'return', '{', "'title'", ':', 'obj', '.', 'title', ',', "'uri'", ':', 'obj', '.', 'uri', ',', "'service_url'", ':', 'obj', '.', 'service_url', ',', "'success'", ':', 'obj', '.', 'success', ',', "'has_references'", ':', 'obj', '.', 'has_references', '...
Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json. :param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered. :rtype: :class:`dict`
['Adapter', 'for', 'rendering', 'a', ':', 'class', ':', 'pyramid_urireferencer', '.', 'models', '.', 'ApplicationResponse', 'to', 'json', '.']
train
https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/renderers.py#L41-L59
2,411
ValvePython/steam
steam/client/__init__.py
SteamClient.store_sentry
def store_sentry(self, username, sentry_bytes): """ Store sentry bytes under a username :param username: username :type username: :class:`str` :return: Whenver the operation succeed :rtype: :class:`bool` """ filepath = self._get_sentry_path(username) ...
python
def store_sentry(self, username, sentry_bytes): """ Store sentry bytes under a username :param username: username :type username: :class:`str` :return: Whenver the operation succeed :rtype: :class:`bool` """ filepath = self._get_sentry_path(username) ...
['def', 'store_sentry', '(', 'self', ',', 'username', ',', 'sentry_bytes', ')', ':', 'filepath', '=', 'self', '.', '_get_sentry_path', '(', 'username', ')', 'if', 'filepath', ':', 'try', ':', 'with', 'open', '(', 'filepath', ',', "'wb'", ')', 'as', 'f', ':', 'f', '.', 'write', '(', 'sentry_bytes', ')', 'return', 'True'...
Store sentry bytes under a username :param username: username :type username: :class:`str` :return: Whenver the operation succeed :rtype: :class:`bool`
['Store', 'sentry', 'bytes', 'under', 'a', 'username']
train
https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/client/__init__.py#L386-L404
2,412
jobovy/galpy
galpy/actionAngle/actionAngleTorus.py
actionAngleTorus.Freqs
def Freqs(self,jr,jphi,jz,**kwargs): """ NAME: Freqs PURPOSE: return the frequencies corresponding to a torus INPUT: jr - radial action (scalar) jphi - azimuthal action (scalar) jz - vertical action (scalar) tol= (...
python
def Freqs(self,jr,jphi,jz,**kwargs): """ NAME: Freqs PURPOSE: return the frequencies corresponding to a torus INPUT: jr - radial action (scalar) jphi - azimuthal action (scalar) jz - vertical action (scalar) tol= (...
['def', 'Freqs', '(', 'self', ',', 'jr', ',', 'jphi', ',', 'jz', ',', '*', '*', 'kwargs', ')', ':', 'out', '=', 'actionAngleTorus_c', '.', 'actionAngleTorus_Freqs_c', '(', 'self', '.', '_pot', ',', 'jr', ',', 'jphi', ',', 'jz', ',', 'tol', '=', 'kwargs', '.', 'get', '(', "'tol'", ',', 'self', '.', '_tol', ')', ')', 'if...
NAME: Freqs PURPOSE: return the frequencies corresponding to a torus INPUT: jr - radial action (scalar) jphi - azimuthal action (scalar) jz - vertical action (scalar) tol= (object-wide value) goal for |dJ|/|J| along the torus ...
['NAME', ':']
train
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/actionAngle/actionAngleTorus.py#L159-L195
2,413
GeospatialPython/pyshp
shapefile.py
Writer.__dbfRecord
def __dbfRecord(self, record): """Writes the dbf records.""" f = self.__getFileObj(self.dbf) if self.recNum == 0: # first records, so all fields should be set # allowing us to write the dbf header # cannot change the fields after this point ...
python
def __dbfRecord(self, record): """Writes the dbf records.""" f = self.__getFileObj(self.dbf) if self.recNum == 0: # first records, so all fields should be set # allowing us to write the dbf header # cannot change the fields after this point ...
['def', '__dbfRecord', '(', 'self', ',', 'record', ')', ':', 'f', '=', 'self', '.', '__getFileObj', '(', 'self', '.', 'dbf', ')', 'if', 'self', '.', 'recNum', '==', '0', ':', '# first records, so all fields should be set\r', '# allowing us to write the dbf header\r', '# cannot change the fields after this point\r', 'se...
Writes the dbf records.
['Writes', 'the', 'dbf', 'records', '.']
train
https://github.com/GeospatialPython/pyshp/blob/71231ddc5aa54f155d4f0563c56006fffbfc84e7/shapefile.py#L1535-L1600
2,414
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/jsonclassfield.py
JsonClassField.to_python
def to_python(self, value): """ "Called during deserialization and during the clean() method used from forms.... [s]hould deal gracefully with... (*) an instance of the correct type; (*) a string; (*) None (if the field allows null=True)." "For ``to_python()``, if anythi...
python
def to_python(self, value): """ "Called during deserialization and during the clean() method used from forms.... [s]hould deal gracefully with... (*) an instance of the correct type; (*) a string; (*) None (if the field allows null=True)." "For ``to_python()``, if anythi...
['def', 'to_python', '(', 'self', ',', 'value', ')', ':', 'if', 'value', 'is', 'None', ':', 'return', 'value', 'if', 'not', 'isinstance', '(', 'value', ',', 'str', ')', ':', 'return', 'value', 'try', ':', 'return', 'json_decode', '(', 'value', ')', 'except', 'Exception', 'as', 'err', ':', 'raise', 'ValidationError', '(...
"Called during deserialization and during the clean() method used from forms.... [s]hould deal gracefully with... (*) an instance of the correct type; (*) a string; (*) None (if the field allows null=True)." "For ``to_python()``, if anything goes wrong during value conversion, y...
['Called', 'during', 'deserialization', 'and', 'during', 'the', 'clean', '()', 'method', 'used', 'from', 'forms', '....', '[', 's', ']', 'hould', 'deal', 'gracefully', 'with', '...', '(', '*', ')', 'an', 'instance', 'of', 'the', 'correct', 'type', ';', '(', '*', ')', 'a', 'string', ';', '(', '*', ')', 'None', '(', 'if'...
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/jsonclassfield.py#L161-L178
2,415
Esri/ArcREST
src/arcrest/common/symbology.py
SimpleMarkerSymbol.value
def value(self): """returns the object as dictionary""" if self._outline is None: return { "type" : "esriSMS", "style" : self._style, "color" : self._color.value, "size" : self._size, "angle" : self._angle, ...
python
def value(self): """returns the object as dictionary""" if self._outline is None: return { "type" : "esriSMS", "style" : self._style, "color" : self._color.value, "size" : self._size, "angle" : self._angle, ...
['def', 'value', '(', 'self', ')', ':', 'if', 'self', '.', '_outline', 'is', 'None', ':', 'return', '{', '"type"', ':', '"esriSMS"', ',', '"style"', ':', 'self', '.', '_style', ',', '"color"', ':', 'self', '.', '_color', '.', 'value', ',', '"size"', ':', 'self', '.', '_size', ',', '"angle"', ':', 'self', '.', '_angle',...
returns the object as dictionary
['returns', 'the', 'object', 'as', 'dictionary']
train
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/symbology.py#L157-L182
2,416
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.getAggregation
def getAggregation(self): """Returns: str : URIRef of the Aggregation entity """ self._check_initialized() return [ o for o in self.subjects(predicate=rdflib.RDF.type, object=ORE.Aggregation) ][0]
python
def getAggregation(self): """Returns: str : URIRef of the Aggregation entity """ self._check_initialized() return [ o for o in self.subjects(predicate=rdflib.RDF.type, object=ORE.Aggregation) ][0]
['def', 'getAggregation', '(', 'self', ')', ':', 'self', '.', '_check_initialized', '(', ')', 'return', '[', 'o', 'for', 'o', 'in', 'self', '.', 'subjects', '(', 'predicate', '=', 'rdflib', '.', 'RDF', '.', 'type', ',', 'object', '=', 'ORE', '.', 'Aggregation', ')', ']', '[', '0', ']']
Returns: str : URIRef of the Aggregation entity
['Returns', ':']
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L307-L316
2,417
jermnelson/flask-fedora-commons
flask_fedora_commons/__init__.py
Repository.connect
def connect(self, fedora_url, data=None, method='Get'): """Method attempts to connect to REST servers of the Fedora Commons repository using optional data parameter. Args: fedora_url(string): Fedora URL data(dict): Data to ...
python
def connect(self, fedora_url, data=None, method='Get'): """Method attempts to connect to REST servers of the Fedora Commons repository using optional data parameter. Args: fedora_url(string): Fedora URL data(dict): Data to ...
['def', 'connect', '(', 'self', ',', 'fedora_url', ',', 'data', '=', 'None', ',', 'method', '=', "'Get'", ')', ':', 'if', 'data', 'is', 'None', ':', 'data', '=', '{', '}', 'if', 'not', 'fedora_url', '.', 'startswith', '(', '"http"', ')', ':', 'fedora_url', '=', 'urllib', '.', 'parse', '.', 'urljoin', '(', 'self', '.', ...
Method attempts to connect to REST servers of the Fedora Commons repository using optional data parameter. Args: fedora_url(string): Fedora URL data(dict): Data to through to REST endpoint method(str): REST Method, defaults to GET Returns: result...
['Method', 'attempts', 'to', 'connect', 'to', 'REST', 'servers', 'of', 'the', 'Fedora', 'Commons', 'repository', 'using', 'optional', 'data', 'parameter', '.']
train
https://github.com/jermnelson/flask-fedora-commons/blob/81cee0d8c9e79fa2bdd1a101facb9e8c0f307af4/flask_fedora_commons/__init__.py#L223-L261
2,418
deepmind/sonnet
sonnet/python/modules/conv.py
_ConvND.padding
def padding(self): """Returns the padding algorithm used, if this is the same for all dims. Use `.paddings` if you want a tuple with the padding algorithm used for each dimension. Returns: The padding algorithm used, if this is the same for all dimensions. Raises: ValueError: If diffe...
python
def padding(self): """Returns the padding algorithm used, if this is the same for all dims. Use `.paddings` if you want a tuple with the padding algorithm used for each dimension. Returns: The padding algorithm used, if this is the same for all dimensions. Raises: ValueError: If diffe...
['def', 'padding', '(', 'self', ')', ':', '# This is for backwards compatibility -- previously only a single', '# padding setting was supported across all dimensions.', 'if', 'all', '(', 'p', '==', 'self', '.', '_padding', '[', '0', ']', 'for', 'p', 'in', 'self', '.', '_padding', ')', ':', 'return', 'self', '.', '_padd...
Returns the padding algorithm used, if this is the same for all dims. Use `.paddings` if you want a tuple with the padding algorithm used for each dimension. Returns: The padding algorithm used, if this is the same for all dimensions. Raises: ValueError: If different padding algorithms ar...
['Returns', 'the', 'padding', 'algorithm', 'used', 'if', 'this', 'is', 'the', 'same', 'for', 'all', 'dims', '.']
train
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L739-L759
2,419
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/docbook/__init__.py
__detect_cl_tool
def __detect_cl_tool(env, chainkey, cdict, cpriority=None): """ Helper function, picks a command line tool from the list and initializes its environment variables. """ if env.get(chainkey,'') == '': clpath = '' if cpriority is None: cpriority = cdict.keys() for c...
python
def __detect_cl_tool(env, chainkey, cdict, cpriority=None): """ Helper function, picks a command line tool from the list and initializes its environment variables. """ if env.get(chainkey,'') == '': clpath = '' if cpriority is None: cpriority = cdict.keys() for c...
['def', '__detect_cl_tool', '(', 'env', ',', 'chainkey', ',', 'cdict', ',', 'cpriority', '=', 'None', ')', ':', 'if', 'env', '.', 'get', '(', 'chainkey', ',', "''", ')', '==', "''", ':', 'clpath', '=', "''", 'if', 'cpriority', 'is', 'None', ':', 'cpriority', '=', 'cdict', '.', 'keys', '(', ')', 'for', 'cltool', 'in', '...
Helper function, picks a command line tool from the list and initializes its environment variables.
['Helper', 'function', 'picks', 'a', 'command', 'line', 'tool', 'from', 'the', 'list', 'and', 'initializes', 'its', 'environment', 'variables', '.']
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/docbook/__init__.py#L176-L196
2,420
pypa/pipenv
pipenv/vendor/requirementslib/models/utils.py
clean_requires_python
def clean_requires_python(candidates): """Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.""" all_candidates = [] sys_version = ".".join(map(str, sys.version_info[:3])) from packaging.version import parse as parse_version py_version = parse_version...
python
def clean_requires_python(candidates): """Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.""" all_candidates = [] sys_version = ".".join(map(str, sys.version_info[:3])) from packaging.version import parse as parse_version py_version = parse_version...
['def', 'clean_requires_python', '(', 'candidates', ')', ':', 'all_candidates', '=', '[', ']', 'sys_version', '=', '"."', '.', 'join', '(', 'map', '(', 'str', ',', 'sys', '.', 'version_info', '[', ':', '3', ']', ')', ')', 'from', 'packaging', '.', 'version', 'import', 'parse', 'as', 'parse_version', 'py_version', '=', ...
Get a cleaned list of all the candidates with valid specifiers in the `requires_python` attributes.
['Get', 'a', 'cleaned', 'list', 'of', 'all', 'the', 'candidates', 'with', 'valid', 'specifiers', 'in', 'the', 'requires_python', 'attributes', '.']
train
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L803-L828
2,421
ArchiveTeam/wpull
wpull/network/pool.py
ConnectionPool.acquire
def acquire(self, host: str, port: int, use_ssl: bool=False, host_key: Optional[Any]=None) \ -> Union[Connection, SSLConnection]: '''Return an available connection. Args: host: A hostname or IP address. port: Port number. use_ssl: Whether ...
python
def acquire(self, host: str, port: int, use_ssl: bool=False, host_key: Optional[Any]=None) \ -> Union[Connection, SSLConnection]: '''Return an available connection. Args: host: A hostname or IP address. port: Port number. use_ssl: Whether ...
['def', 'acquire', '(', 'self', ',', 'host', ':', 'str', ',', 'port', ':', 'int', ',', 'use_ssl', ':', 'bool', '=', 'False', ',', 'host_key', ':', 'Optional', '[', 'Any', ']', '=', 'None', ')', '->', 'Union', '[', 'Connection', ',', 'SSLConnection', ']', ':', 'assert', 'isinstance', '(', 'port', ',', 'int', ')', ',', "...
Return an available connection. Args: host: A hostname or IP address. port: Port number. use_ssl: Whether to return a SSL connection. host_key: If provided, it overrides the key used for per-host connection pooling. This is useful for proxies for ...
['Return', 'an', 'available', 'connection', '.']
train
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/network/pool.py#L153-L211
2,422
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/_gapic.py
add_methods
def add_methods(source_class, blacklist=()): """Add wrapped versions of the `api` member's methods to the class. Any methods passed in `blacklist` are not added. Additionally, any methods explicitly defined on the wrapped class are not added. """ def wrap(wrapped_fx): """Wrap a GAPIC m...
python
def add_methods(source_class, blacklist=()): """Add wrapped versions of the `api` member's methods to the class. Any methods passed in `blacklist` are not added. Additionally, any methods explicitly defined on the wrapped class are not added. """ def wrap(wrapped_fx): """Wrap a GAPIC m...
['def', 'add_methods', '(', 'source_class', ',', 'blacklist', '=', '(', ')', ')', ':', 'def', 'wrap', '(', 'wrapped_fx', ')', ':', '"""Wrap a GAPIC method; preserve its name and docstring."""', '# If this is a static or class method, then we need to *not*', '# send self as the first argument.', '#', '# Similarly, for i...
Add wrapped versions of the `api` member's methods to the class. Any methods passed in `blacklist` are not added. Additionally, any methods explicitly defined on the wrapped class are not added.
['Add', 'wrapped', 'versions', 'of', 'the', 'api', 'member', 's', 'methods', 'to', 'the', 'class', '.']
train
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/_gapic.py#L20-L77
2,423
AmanoTeam/amanobot
amanobot/__init__.py
Bot.sendDocument
def sendDocument(self, chat_id, document, thumb=None, caption=None, parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): """ See: https://cor...
python
def sendDocument(self, chat_id, document, thumb=None, caption=None, parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): """ See: https://cor...
['def', 'sendDocument', '(', 'self', ',', 'chat_id', ',', 'document', ',', 'thumb', '=', 'None', ',', 'caption', '=', 'None', ',', 'parse_mode', '=', 'None', ',', 'disable_notification', '=', 'None', ',', 'reply_to_message_id', '=', 'None', ',', 'reply_markup', '=', 'None', ')', ':', 'p', '=', '_strip', '(', 'locals', ...
See: https://core.telegram.org/bots/api#senddocument :param document: Same as ``photo`` in :meth:`amanobot.Bot.sendPhoto`
['See', ':', 'https', ':', '//', 'core', '.', 'telegram', '.', 'org', '/', 'bots', '/', 'api#senddocument']
train
https://github.com/AmanoTeam/amanobot/blob/fe546e2e294eec88e637da0b2567c7e7e8662437/amanobot/__init__.py#L564-L577
2,424
inveniosoftware/invenio-userprofiles
invenio_userprofiles/views.py
handle_verification_form
def handle_verification_form(form): """Handle email sending verification form.""" form.process(formdata=request.form) if form.validate_on_submit(): send_confirmation_instructions(current_user) # NOTE: Flash message. flash(_("Verification email sent."), category="success")
python
def handle_verification_form(form): """Handle email sending verification form.""" form.process(formdata=request.form) if form.validate_on_submit(): send_confirmation_instructions(current_user) # NOTE: Flash message. flash(_("Verification email sent."), category="success")
['def', 'handle_verification_form', '(', 'form', ')', ':', 'form', '.', 'process', '(', 'formdata', '=', 'request', '.', 'form', ')', 'if', 'form', '.', 'validate_on_submit', '(', ')', ':', 'send_confirmation_instructions', '(', 'current_user', ')', '# NOTE: Flash message.', 'flash', '(', '_', '(', '"Verification email...
Handle email sending verification form.
['Handle', 'email', 'sending', 'verification', 'form', '.']
train
https://github.com/inveniosoftware/invenio-userprofiles/blob/4c682e7d67a4cab8dc38472a31fa1c34cbba03dd/invenio_userprofiles/views.py#L123-L130
2,425
heronotears/lazyxml
lazyxml/builder.py
Builder.build_tree
def build_tree(self, data, tagname, attrs=None, depth=0): r"""Build xml tree. :param data: data for build xml. :param tagname: element tag name. :param attrs: element attributes. Default:``None``. :type attrs: dict or None :param depth: element depth of the hierarchy. De...
python
def build_tree(self, data, tagname, attrs=None, depth=0): r"""Build xml tree. :param data: data for build xml. :param tagname: element tag name. :param attrs: element attributes. Default:``None``. :type attrs: dict or None :param depth: element depth of the hierarchy. De...
['def', 'build_tree', '(', 'self', ',', 'data', ',', 'tagname', ',', 'attrs', '=', 'None', ',', 'depth', '=', '0', ')', ':', 'if', 'data', 'is', 'None', ':', 'data', '=', "''", 'indent', '=', '(', "'\\n%s'", '%', '(', 'self', '.', '__options', '[', "'indent'", ']', '*', 'depth', ')', ')', 'if', 'self', '.', '__options'...
r"""Build xml tree. :param data: data for build xml. :param tagname: element tag name. :param attrs: element attributes. Default:``None``. :type attrs: dict or None :param depth: element depth of the hierarchy. Default:``0``. :type depth: int
['r', 'Build', 'xml', 'tree', '.']
train
https://github.com/heronotears/lazyxml/blob/e3f1ebd3f34cfa03d022ddec90e17d60c1c81953/lazyxml/builder.py#L94-L128
2,426
lago-project/lago
lago/utils.py
_run_command
def _run_command( command, input_data=None, stdin=None, out_pipe=subprocess.PIPE, err_pipe=subprocess.PIPE, env=None, uuid=None, **kwargs ): """ Runs a command Args: command(list of str): args of the command to execute, including the command itself as com...
python
def _run_command( command, input_data=None, stdin=None, out_pipe=subprocess.PIPE, err_pipe=subprocess.PIPE, env=None, uuid=None, **kwargs ): """ Runs a command Args: command(list of str): args of the command to execute, including the command itself as com...
['def', '_run_command', '(', 'command', ',', 'input_data', '=', 'None', ',', 'stdin', '=', 'None', ',', 'out_pipe', '=', 'subprocess', '.', 'PIPE', ',', 'err_pipe', '=', 'subprocess', '.', 'PIPE', ',', 'env', '=', 'None', ',', 'uuid', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', '# add libexec to PATH if needed', 'i...
Runs a command Args: command(list of str): args of the command to execute, including the command itself as command[0] as `['ls', '-l']` input_data(str): If passed, will feed that data to the subprocess through stdin out_pipe(int or file): File descriptor as passed to...
['Runs', 'a', 'command']
train
https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/utils.py#L123-L199
2,427
wummel/linkchecker
linkcheck/updater.py
check_update
def check_update (): """Return the following values: (False, errmsg) - online version could not be determined (True, None) - user has newest version (True, (version, url string)) - update available (True, (version, None)) - current version is newer than online version """ version...
python
def check_update (): """Return the following values: (False, errmsg) - online version could not be determined (True, None) - user has newest version (True, (version, url string)) - update available (True, (version, None)) - current version is newer than online version """ version...
['def', 'check_update', '(', ')', ':', 'version', ',', 'value', '=', 'get_online_version', '(', ')', 'if', 'version', 'is', 'None', ':', '# value is an error message', 'return', 'False', ',', 'value', 'if', 'version', '==', 'CurrentVersion', ':', '# user has newest version', 'return', 'True', ',', 'None', 'if', 'is_new...
Return the following values: (False, errmsg) - online version could not be determined (True, None) - user has newest version (True, (version, url string)) - update available (True, (version, None)) - current version is newer than online version
['Return', 'the', 'following', 'values', ':', '(', 'False', 'errmsg', ')', '-', 'online', 'version', 'could', 'not', 'be', 'determined', '(', 'True', 'None', ')', '-', 'user', 'has', 'newest', 'version', '(', 'True', '(', 'version', 'url', 'string', '))', '-', 'update', 'available', '(', 'True', '(', 'version', 'None',...
train
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/updater.py#L36-L54
2,428
gabrielfalcao/sure
sure/__init__.py
chainproperty
def chainproperty(func): """Extend sure with a custom chain property.""" func = assertionproperty(func) setattr(AssertionBuilder, func.fget.__name__, func) return func
python
def chainproperty(func): """Extend sure with a custom chain property.""" func = assertionproperty(func) setattr(AssertionBuilder, func.fget.__name__, func) return func
['def', 'chainproperty', '(', 'func', ')', ':', 'func', '=', 'assertionproperty', '(', 'func', ')', 'setattr', '(', 'AssertionBuilder', ',', 'func', '.', 'fget', '.', '__name__', ',', 'func', ')', 'return', 'func']
Extend sure with a custom chain property.
['Extend', 'sure', 'with', 'a', 'custom', 'chain', 'property', '.']
train
https://github.com/gabrielfalcao/sure/blob/ac23b6b87306ec502b8719534ab23965d97a95f9/sure/__init__.py#L941-L945
2,429
uber/doubles
doubles/method_double.py
MethodDouble.add_allowance
def add_allowance(self, caller): """Adds a new allowance for the method. :param: tuple caller: A tuple indicating where the method was called :return: The new ``Allowance``. :rtype: Allowance """ allowance = Allowance(self._target, self._method_name, caller) sel...
python
def add_allowance(self, caller): """Adds a new allowance for the method. :param: tuple caller: A tuple indicating where the method was called :return: The new ``Allowance``. :rtype: Allowance """ allowance = Allowance(self._target, self._method_name, caller) sel...
['def', 'add_allowance', '(', 'self', ',', 'caller', ')', ':', 'allowance', '=', 'Allowance', '(', 'self', '.', '_target', ',', 'self', '.', '_method_name', ',', 'caller', ')', 'self', '.', '_allowances', '.', 'insert', '(', '0', ',', 'allowance', ')', 'return', 'allowance']
Adds a new allowance for the method. :param: tuple caller: A tuple indicating where the method was called :return: The new ``Allowance``. :rtype: Allowance
['Adds', 'a', 'new', 'allowance', 'for', 'the', 'method', '.']
train
https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L30-L40
2,430
rstoneback/pysat
pysat/instruments/supermag_magnetometer.py
load
def load(fnames, tag='', sat_id=None): """ Load the SuperMAG files Parameters ----------- fnames : (list) List of filenames tag : (str or NoneType) Denotes type of file to load. Accepted types are 'indices', 'all', 'stations', and '' (for just magnetometer measurements). (d...
python
def load(fnames, tag='', sat_id=None): """ Load the SuperMAG files Parameters ----------- fnames : (list) List of filenames tag : (str or NoneType) Denotes type of file to load. Accepted types are 'indices', 'all', 'stations', and '' (for just magnetometer measurements). (d...
['def', 'load', '(', 'fnames', ',', 'tag', '=', "''", ',', 'sat_id', '=', 'None', ')', ':', '# Ensure that there are files to load', 'if', 'len', '(', 'fnames', ')', '<=', '0', ':', 'return', 'pysat', '.', 'DataFrame', '(', 'None', ')', ',', 'pysat', '.', 'Meta', '(', 'None', ')', '# Ensure that the files are in a list...
Load the SuperMAG files Parameters ----------- fnames : (list) List of filenames tag : (str or NoneType) Denotes type of file to load. Accepted types are 'indices', 'all', 'stations', and '' (for just magnetometer measurements). (default='') sat_id : (str or NoneType) ...
['Load', 'the', 'SuperMAG', 'files']
train
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/supermag_magnetometer.py#L131-L195
2,431
TkTech/Jawa
jawa/fields.py
FieldTable.create
def create(self, name: str, descriptor: str, value: Constant=None) -> Field: """ Creates a new field from `name` and `descriptor`. For example:: >>> from jawa.cf import ClassFile >>> cf = ClassFile.create('BeerCounter') >>> field = cf.fields.create('BeerCount', 'I') ...
python
def create(self, name: str, descriptor: str, value: Constant=None) -> Field: """ Creates a new field from `name` and `descriptor`. For example:: >>> from jawa.cf import ClassFile >>> cf = ClassFile.create('BeerCounter') >>> field = cf.fields.create('BeerCount', 'I') ...
['def', 'create', '(', 'self', ',', 'name', ':', 'str', ',', 'descriptor', ':', 'str', ',', 'value', ':', 'Constant', '=', 'None', ')', '->', 'Field', ':', 'field', '=', 'Field', '(', 'self', '.', '_cf', ')', 'name', '=', 'self', '.', '_cf', '.', 'constants', '.', 'create_utf8', '(', 'name', ')', 'descriptor', '=', 'se...
Creates a new field from `name` and `descriptor`. For example:: >>> from jawa.cf import ClassFile >>> cf = ClassFile.create('BeerCounter') >>> field = cf.fields.create('BeerCount', 'I') To automatically create a static field, pass a value:: >>> from jawa.cf imp...
['Creates', 'a', 'new', 'field', 'from', 'name', 'and', 'descriptor', '.', 'For', 'example', '::']
train
https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/fields.py#L110-L144
2,432
hydraplatform/hydra-base
hydra_base/lib/data.py
get_dataset
def get_dataset(dataset_id,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) if dataset_id is None: return None try: dataset_rs = db.DBSession.query(Dataset.id, Dataset.type, Dataset.unit_id, ...
python
def get_dataset(dataset_id,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) if dataset_id is None: return None try: dataset_rs = db.DBSession.query(Dataset.id, Dataset.type, Dataset.unit_id, ...
['def', 'get_dataset', '(', 'dataset_id', ',', '*', '*', 'kwargs', ')', ':', 'user_id', '=', 'int', '(', 'kwargs', '.', 'get', '(', "'user_id'", ')', ')', 'if', 'dataset_id', 'is', 'None', ':', 'return', 'None', 'try', ':', 'dataset_rs', '=', 'db', '.', 'DBSession', '.', 'query', '(', 'Dataset', '.', 'id', ',', 'Datase...
Get a single dataset, by ID
['Get', 'a', 'single', 'dataset', 'by', 'ID']
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L63-L106
2,433
cltk/cltk
cltk/corpus/readers.py
TesseraeCorpusReader.lines
def lines(self: object, fileids: str, plaintext: bool = True): """ Tokenizes documents in the corpus by line """ for text in self.texts(fileids, plaintext): text = re.sub(r'\n\s*\n', '\n', text, re.MULTILINE) # Remove blank lines for line in text.split('\n'): ...
python
def lines(self: object, fileids: str, plaintext: bool = True): """ Tokenizes documents in the corpus by line """ for text in self.texts(fileids, plaintext): text = re.sub(r'\n\s*\n', '\n', text, re.MULTILINE) # Remove blank lines for line in text.split('\n'): ...
['def', 'lines', '(', 'self', ':', 'object', ',', 'fileids', ':', 'str', ',', 'plaintext', ':', 'bool', '=', 'True', ')', ':', 'for', 'text', 'in', 'self', '.', 'texts', '(', 'fileids', ',', 'plaintext', ')', ':', 'text', '=', 're', '.', 'sub', '(', "r'\\n\\s*\\n'", ',', "'\\n'", ',', 'text', ',', 're', '.', 'MULTILINE...
Tokenizes documents in the corpus by line
['Tokenizes', 'documents', 'in', 'the', 'corpus', 'by', 'line']
train
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/readers.py#L444-L452
2,434
jbeluch/xbmcswift2
xbmcswift2/xbmcmixin.py
XBMCMixin._add_subtitles
def _add_subtitles(self, subtitles): '''Adds subtitles to playing video. :param subtitles: A URL to a remote subtitles file or a local filename for a subtitles file. .. warning:: You must start playing a video before calling this method or it will...
python
def _add_subtitles(self, subtitles): '''Adds subtitles to playing video. :param subtitles: A URL to a remote subtitles file or a local filename for a subtitles file. .. warning:: You must start playing a video before calling this method or it will...
['def', '_add_subtitles', '(', 'self', ',', 'subtitles', ')', ':', '# This method is named with an underscore to suggest that callers pass', '# the subtitles argument to set_resolved_url instead of calling this', '# method directly. This is to ensure a video is played before calling', '# this method.', 'player', '=', '...
Adds subtitles to playing video. :param subtitles: A URL to a remote subtitles file or a local filename for a subtitles file. .. warning:: You must start playing a video before calling this method or it will loop for an indefinite length.
['Adds', 'subtitles', 'to', 'playing', 'video', '.']
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/xbmcmixin.py#L317-L338
2,435
numberoverzero/bloop
bloop/conditions.py
iter_columns
def iter_columns(condition): """ Yield all columns in the condition or its inner conditions. Unwraps proxies when the condition's column (or any of its values) include paths. """ # Like iter_conditions, this can't live in each condition without going possibly infinite on the # recursion, or pas...
python
def iter_columns(condition): """ Yield all columns in the condition or its inner conditions. Unwraps proxies when the condition's column (or any of its values) include paths. """ # Like iter_conditions, this can't live in each condition without going possibly infinite on the # recursion, or pas...
['def', 'iter_columns', '(', 'condition', ')', ':', "# Like iter_conditions, this can't live in each condition without going possibly infinite on the", '# recursion, or passing the visited set through every call. That makes the signature ugly, so we', "# take care of it here. Luckily, it's pretty easy to leverage ite...
Yield all columns in the condition or its inner conditions. Unwraps proxies when the condition's column (or any of its values) include paths.
['Yield', 'all', 'columns', 'in', 'the', 'condition', 'or', 'its', 'inner', 'conditions', '.']
train
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/conditions.py#L938-L970
2,436
jbaiter/gphoto2-cffi
gphoto2cffi/backend.py
_logging_callback
def _logging_callback(level, domain, message, data): """ Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: ...
python
def _logging_callback(level, domain, message, data): """ Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: ...
['def', '_logging_callback', '(', 'level', ',', 'domain', ',', 'message', ',', 'data', ')', ':', 'domain', '=', 'ffi', '.', 'string', '(', 'domain', ')', '.', 'decode', '(', ')', 'message', '=', 'ffi', '.', 'string', '(', 'message', ')', '.', 'decode', '(', ')', 'logger', '=', 'LOGGER', '.', 'getChild', '(', 'domain', ...
Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: Other data in the logging record (unused)
['Callback', 'that', 'outputs', 'libgphoto2', 's', 'logging', 'message', 'via', 'Python', 's', 'standard', 'logging', 'facilities', '.']
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/backend.py#L75-L90
2,437
google/grr
grr/core/grr_response_core/lib/rdfvalues/crypto.py
SignedBlob.Sign
def Sign(self, data, signing_key, verify_key=None): """Use the data to sign this blob. Args: data: String containing the blob data. signing_key: The key to sign with. verify_key: Key to verify with. If None we assume the signing key also contains the public key. Returns: se...
python
def Sign(self, data, signing_key, verify_key=None): """Use the data to sign this blob. Args: data: String containing the blob data. signing_key: The key to sign with. verify_key: Key to verify with. If None we assume the signing key also contains the public key. Returns: se...
['def', 'Sign', '(', 'self', ',', 'data', ',', 'signing_key', ',', 'verify_key', '=', 'None', ')', ':', 'if', 'signing_key', '.', 'KeyLen', '(', ')', '<', '2048', ':', 'logging', '.', 'warning', '(', '"signing key is too short."', ')', 'self', '.', 'signature', '=', 'signing_key', '.', 'Sign', '(', 'data', ')', 'self',...
Use the data to sign this blob. Args: data: String containing the blob data. signing_key: The key to sign with. verify_key: Key to verify with. If None we assume the signing key also contains the public key. Returns: self for call chaining.
['Use', 'the', 'data', 'to', 'sign', 'this', 'blob', '.']
train
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/crypto.py#L561-L591
2,438
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.initializerepo
def initializerepo(self): """ Fill empty directory with products and make first commit """ try: os.mkdir(self.repopath) except OSError: pass cmd = self.repo.init(bare=self.bare, shared=self.shared) if not self.bare: self.write_testing_data([...
python
def initializerepo(self): """ Fill empty directory with products and make first commit """ try: os.mkdir(self.repopath) except OSError: pass cmd = self.repo.init(bare=self.bare, shared=self.shared) if not self.bare: self.write_testing_data([...
['def', 'initializerepo', '(', 'self', ')', ':', 'try', ':', 'os', '.', 'mkdir', '(', 'self', '.', 'repopath', ')', 'except', 'OSError', ':', 'pass', 'cmd', '=', 'self', '.', 'repo', '.', 'init', '(', 'bare', '=', 'self', '.', 'bare', ',', 'shared', '=', 'self', '.', 'shared', ')', 'if', 'not', 'self', '.', 'bare', ':'...
Fill empty directory with products and make first commit
['Fill', 'empty', 'directory', 'with', 'products', 'and', 'make', 'first', 'commit']
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L54-L75
2,439
gem/oq-engine
openquake/hmtk/seismicity/utils.py
decimal_year
def decimal_year(year, month, day): """ Allows to calculate the decimal year for a vector of dates (TODO this is legacy code kept to maintain comparability with previous declustering algorithms!) :param year: year column from catalogue matrix :type year: numpy.ndarray :param month: month co...
python
def decimal_year(year, month, day): """ Allows to calculate the decimal year for a vector of dates (TODO this is legacy code kept to maintain comparability with previous declustering algorithms!) :param year: year column from catalogue matrix :type year: numpy.ndarray :param month: month co...
['def', 'decimal_year', '(', 'year', ',', 'month', ',', 'day', ')', ':', 'marker', '=', 'np', '.', 'array', '(', '[', '0.', ',', '31.', ',', '59.', ',', '90.', ',', '120.', ',', '151.', ',', '181.', ',', '212.', ',', '243.', ',', '273.', ',', '304.', ',', '334.', ']', ')', 'tmonth', '=', '(', 'month', '-', '1', ')', '....
Allows to calculate the decimal year for a vector of dates (TODO this is legacy code kept to maintain comparability with previous declustering algorithms!) :param year: year column from catalogue matrix :type year: numpy.ndarray :param month: month column from catalogue matrix :type month: nump...
['Allows', 'to', 'calculate', 'the', 'decimal', 'year', 'for', 'a', 'vector', 'of', 'dates', '(', 'TODO', 'this', 'is', 'legacy', 'code', 'kept', 'to', 'maintain', 'comparability', 'with', 'previous', 'declustering', 'algorithms!', ')']
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L105-L126
2,440
robinandeer/puzzle
puzzle/plugins/gemini/mixins/case.py
CaseMixin.case
def case(self, case_id=None): """Return a Case object If no case_id is given return one case Args: case_id (str): A case id Returns: case(Case): A Case object """ cases = self.cases() if case_id: for case ...
python
def case(self, case_id=None): """Return a Case object If no case_id is given return one case Args: case_id (str): A case id Returns: case(Case): A Case object """ cases = self.cases() if case_id: for case ...
['def', 'case', '(', 'self', ',', 'case_id', '=', 'None', ')', ':', 'cases', '=', 'self', '.', 'cases', '(', ')', 'if', 'case_id', ':', 'for', 'case', 'in', 'cases', ':', 'if', 'case', '.', 'case_id', '==', 'case_id', ':', 'return', 'case', 'else', ':', 'if', 'cases', ':', 'return', 'cases', '[', '0', ']', 'return', 'N...
Return a Case object If no case_id is given return one case Args: case_id (str): A case id Returns: case(Case): A Case object
['Return', 'a', 'Case', 'object']
train
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/case.py#L48-L68
2,441
Bystroushaak/pyDHTMLParser
src/dhtmlparser/__init__.py
_parseDOM
def _parseDOM(istack): """ Recursively go through element array and create DOM. Args: istack (list): List of :class:`.HTMLElement` objects. Returns: list: DOM tree as list. """ ostack = [] end_tag_index = 0 def neither_nonpair_or_end_or_comment(el): return not ...
python
def _parseDOM(istack): """ Recursively go through element array and create DOM. Args: istack (list): List of :class:`.HTMLElement` objects. Returns: list: DOM tree as list. """ ostack = [] end_tag_index = 0 def neither_nonpair_or_end_or_comment(el): return not ...
['def', '_parseDOM', '(', 'istack', ')', ':', 'ostack', '=', '[', ']', 'end_tag_index', '=', '0', 'def', 'neither_nonpair_or_end_or_comment', '(', 'el', ')', ':', 'return', 'not', '(', 'el', '.', 'isNonPairTag', '(', ')', 'or', 'el', '.', 'isEndTag', '(', ')', 'or', 'el', '.', 'isComment', '(', ')', ')', 'index', '=', ...
Recursively go through element array and create DOM. Args: istack (list): List of :class:`.HTMLElement` objects. Returns: list: DOM tree as list.
['Recursively', 'go', 'through', 'element', 'array', 'and', 'create', 'DOM', '.']
train
https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/__init__.py#L186-L227
2,442
ghukill/pyfc4
pyfc4/models.py
Repository.create_resource
def create_resource(self, resource_type=None, uri=None): ''' Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), B...
python
def create_resource(self, resource_type=None, uri=None): ''' Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), B...
['def', 'create_resource', '(', 'self', ',', 'resource_type', '=', 'None', ',', 'uri', '=', 'None', ')', ':', 'if', 'resource_type', 'in', '[', 'NonRDFSource', ',', 'Binary', ',', 'BasicContainer', ',', 'DirectContainer', ',', 'IndirectContainer', ']', ':', 'return', 'resource_type', '(', 'self', ',', 'uri', ')', 'else...
Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), BasicContainer, DirectContainer, IndirectContainer): resource type...
['Convenience', 'method', 'for', 'creating', 'a', 'new', 'resource']
train
https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L141-L159
2,443
saltstack/salt
salt/modules/minion.py
list_
def list_(): ''' Return a list of accepted, denied, unaccepted and rejected keys. This is the same output as `salt-key -L` CLI Example: .. code-block:: bash salt 'master' minion.list ''' pki_dir = __salt__['config.get']('pki_dir', '') # We have to replace the minion/master di...
python
def list_(): ''' Return a list of accepted, denied, unaccepted and rejected keys. This is the same output as `salt-key -L` CLI Example: .. code-block:: bash salt 'master' minion.list ''' pki_dir = __salt__['config.get']('pki_dir', '') # We have to replace the minion/master di...
['def', 'list_', '(', ')', ':', 'pki_dir', '=', '__salt__', '[', "'config.get'", ']', '(', "'pki_dir'", ',', "''", ')', '# We have to replace the minion/master directories', 'pki_dir', '=', 'pki_dir', '.', 'replace', '(', "'minion'", ',', "'master'", ')', '# The source code below is (nearly) a copy of salt.key.Key.list...
Return a list of accepted, denied, unaccepted and rejected keys. This is the same output as `salt-key -L` CLI Example: .. code-block:: bash salt 'master' minion.list
['Return', 'a', 'list', 'of', 'accepted', 'denied', 'unaccepted', 'and', 'rejected', 'keys', '.', 'This', 'is', 'the', 'same', 'output', 'as', 'salt', '-', 'key', '-', 'L']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/minion.py#L26-L58
2,444
poppy-project/pypot
pypot/dynamixel/__init__.py
get_port_vendor_info
def get_port_vendor_info(port=None): """ Return vendor informations of a usb2serial device. It may depends on the Operating System. :param string port: port of the usb2serial device :Example: Result with a USB2Dynamixel on Linux: In [1]: import pypot.dynamixel In [2...
python
def get_port_vendor_info(port=None): """ Return vendor informations of a usb2serial device. It may depends on the Operating System. :param string port: port of the usb2serial device :Example: Result with a USB2Dynamixel on Linux: In [1]: import pypot.dynamixel In [2...
['def', 'get_port_vendor_info', '(', 'port', '=', 'None', ')', ':', 'port_info_dict', '=', 'dict', '(', '(', 'x', '[', '0', ']', ',', 'x', '[', '2', ']', ')', 'for', 'x', 'in', 'serial', '.', 'tools', '.', 'list_ports', '.', 'comports', '(', ')', ')', 'return', 'port_info_dict', '[', 'port', ']', 'if', 'port', 'is', 'n...
Return vendor informations of a usb2serial device. It may depends on the Operating System. :param string port: port of the usb2serial device :Example: Result with a USB2Dynamixel on Linux: In [1]: import pypot.dynamixel In [2]: pypot.dynamixel.get_port_vendor_info('/dev...
['Return', 'vendor', 'informations', 'of', 'a', 'usb2serial', 'device', '.', 'It', 'may', 'depends', 'on', 'the', 'Operating', 'System', '.', ':', 'param', 'string', 'port', ':', 'port', 'of', 'the', 'usb2serial', 'device']
train
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/__init__.py#L58-L71
2,445
andrewsnowden/dota2py
dota2py/summary.py
debug_dump
def debug_dump(message, file_prefix="dump"): """ Utility while developing to dump message data to play with in the interpreter """ global index index += 1 with open("%s_%s.dump" % (file_prefix, index), 'w') as f: f.write(message.SerializeToString()) f.close()
python
def debug_dump(message, file_prefix="dump"): """ Utility while developing to dump message data to play with in the interpreter """ global index index += 1 with open("%s_%s.dump" % (file_prefix, index), 'w') as f: f.write(message.SerializeToString()) f.close()
['def', 'debug_dump', '(', 'message', ',', 'file_prefix', '=', '"dump"', ')', ':', 'global', 'index', 'index', '+=', '1', 'with', 'open', '(', '"%s_%s.dump"', '%', '(', 'file_prefix', ',', 'index', ')', ',', "'w'", ')', 'as', 'f', ':', 'f', '.', 'write', '(', 'message', '.', 'SerializeToString', '(', ')', ')', 'f', '.'...
Utility while developing to dump message data to play with in the interpreter
['Utility', 'while', 'developing', 'to', 'dump', 'message', 'data', 'to', 'play', 'with', 'in', 'the', 'interpreter']
train
https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/summary.py#L14-L25
2,446
spookylukey/django-paypal
paypal/pro/models.py
PayPalNVP.process
def process(self, request, item): """Do a direct payment.""" warn_untested() from paypal.pro.helpers import PayPalWPP wpp = PayPalWPP(request) # Change the model information into a dict that PayPal can understand. params = model_to_dict(self, exclude=self.ADMIN_FIELDS) ...
python
def process(self, request, item): """Do a direct payment.""" warn_untested() from paypal.pro.helpers import PayPalWPP wpp = PayPalWPP(request) # Change the model information into a dict that PayPal can understand. params = model_to_dict(self, exclude=self.ADMIN_FIELDS) ...
['def', 'process', '(', 'self', ',', 'request', ',', 'item', ')', ':', 'warn_untested', '(', ')', 'from', 'paypal', '.', 'pro', '.', 'helpers', 'import', 'PayPalWPP', 'wpp', '=', 'PayPalWPP', '(', 'request', ')', '# Change the model information into a dict that PayPal can understand.', 'params', '=', 'model_to_dict', '...
Do a direct payment.
['Do', 'a', 'direct', 'payment', '.']
train
https://github.com/spookylukey/django-paypal/blob/b07d0a3ad91b5c5fe7bb27be3e5d70aabcdef76f/paypal/pro/models.py#L130-L150
2,447
payu-org/payu
payu/models/um.py
date_to_um_dump_date
def date_to_um_dump_date(date): """ Convert a time date object to a um dump format date which is <decade><year><month><day>0 To accommodate two digit months and days the UM uses letters. e.g. 1st oct is writing 01a10. """ assert(date.month <= 12) decade = date.year // 10 # UM can ...
python
def date_to_um_dump_date(date): """ Convert a time date object to a um dump format date which is <decade><year><month><day>0 To accommodate two digit months and days the UM uses letters. e.g. 1st oct is writing 01a10. """ assert(date.month <= 12) decade = date.year // 10 # UM can ...
['def', 'date_to_um_dump_date', '(', 'date', ')', ':', 'assert', '(', 'date', '.', 'month', '<=', '12', ')', 'decade', '=', 'date', '.', 'year', '//', '10', '# UM can only handle 36 decades then goes back to the beginning.', 'decade', '=', 'decade', '%', '36', 'year', '=', 'date', '.', 'year', '%', '10', 'month', '=', ...
Convert a time date object to a um dump format date which is <decade><year><month><day>0 To accommodate two digit months and days the UM uses letters. e.g. 1st oct is writing 01a10.
['Convert', 'a', 'time', 'date', 'object', 'to', 'a', 'um', 'dump', 'format', 'date', 'which', 'is', '<decade', '>', '<year', '>', '<month', '>', '<day', '>', '0']
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/um.py#L181-L209
2,448
cltk/cltk
cltk/prosody/latin/clausulae_analysis.py
Clausulae.clausulae_analysis
def clausulae_analysis(prosody): """ Return dictionary in which the key is a type of clausula and the value is its frequency. :param prosody: the prosody of a prose text (must be in the format of the scansion produced by the scanner classes. :return: dictionary of prosody """ ...
python
def clausulae_analysis(prosody): """ Return dictionary in which the key is a type of clausula and the value is its frequency. :param prosody: the prosody of a prose text (must be in the format of the scansion produced by the scanner classes. :return: dictionary of prosody """ ...
['def', 'clausulae_analysis', '(', 'prosody', ')', ':', 'prosody', '=', "''", '.', 'join', '(', 'prosody', ')', 'return', '{', "'cretic + trochee'", ':', 'prosody', '.', 'count', '(', "'¯˘¯¯x'),", '', '', "'4th paeon + trochee'", ':', 'prosody', '.', 'count', '(', "'˘˘˘¯¯x'),", '', '', "'1st paeon + trochee'", ':', 'pr...
Return dictionary in which the key is a type of clausula and the value is its frequency. :param prosody: the prosody of a prose text (must be in the format of the scansion produced by the scanner classes. :return: dictionary of prosody
['Return', 'dictionary', 'in', 'which', 'the', 'key', 'is', 'a', 'type', 'of', 'clausula', 'and', 'the', 'value', 'is', 'its', 'frequency', '.', ':', 'param', 'prosody', ':', 'the', 'prosody', 'of', 'a', 'prose', 'text', '(', 'must', 'be', 'in', 'the', 'format', 'of', 'the', 'scansion', 'produced', 'by', 'the', 'scanne...
train
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/prosody/latin/clausulae_analysis.py#L21-L49
2,449
awslabs/aws-shell
awsshell/app.py
AWSShell.load_config
def load_config(self): """Load the config from the config file or template.""" config = Config() self.config_obj = config.load('awsshellrc') self.config_section = self.config_obj['aws-shell'] self.model_completer.match_fuzzy = self.config_section.as_bool( 'match_fuzzy...
python
def load_config(self): """Load the config from the config file or template.""" config = Config() self.config_obj = config.load('awsshellrc') self.config_section = self.config_obj['aws-shell'] self.model_completer.match_fuzzy = self.config_section.as_bool( 'match_fuzzy...
['def', 'load_config', '(', 'self', ')', ':', 'config', '=', 'Config', '(', ')', 'self', '.', 'config_obj', '=', 'config', '.', 'load', '(', "'awsshellrc'", ')', 'self', '.', 'config_section', '=', 'self', '.', 'config_obj', '[', "'aws-shell'", ']', 'self', '.', 'model_completer', '.', 'match_fuzzy', '=', 'self', '.', ...
Load the config from the config file or template.
['Load', 'the', 'config', 'from', 'the', 'config', 'file', 'or', 'template', '.']
train
https://github.com/awslabs/aws-shell/blob/8950f03d9d720879890af6c11537b8f9789ce5a9/awsshell/app.py#L258-L270
2,450
saltstack/salt
salt/states/esxdatacenter.py
datacenter_configured
def datacenter_configured(name): ''' Makes sure a datacenter exists. If the state is run by an ``esxdatacenter`` minion, the name of the datacenter is retrieved from the proxy details, otherwise the datacenter has the same name as the state. Supported proxies: esxdatacenter name: ...
python
def datacenter_configured(name): ''' Makes sure a datacenter exists. If the state is run by an ``esxdatacenter`` minion, the name of the datacenter is retrieved from the proxy details, otherwise the datacenter has the same name as the state. Supported proxies: esxdatacenter name: ...
['def', 'datacenter_configured', '(', 'name', ')', ':', 'proxy_type', '=', '__salt__', '[', "'vsphere.get_proxy_type'", ']', '(', ')', 'if', 'proxy_type', '==', "'esxdatacenter'", ':', 'dc_name', '=', '__salt__', '[', "'esxdatacenter.get_details'", ']', '(', ')', '[', "'datacenter'", ']', 'else', ':', 'dc_name', '=', '...
Makes sure a datacenter exists. If the state is run by an ``esxdatacenter`` minion, the name of the datacenter is retrieved from the proxy details, otherwise the datacenter has the same name as the state. Supported proxies: esxdatacenter name: Datacenter name. Ignored if the proxytype is ...
['Makes', 'sure', 'a', 'datacenter', 'exists', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxdatacenter.py#L72-L126
2,451
saltstack/salt
salt/modules/infoblox.py
get_host_ipv4
def get_host_ipv4(name=None, mac=None, allow_array=False, **api_opts): ''' Get ipv4 address from host record. Use `allow_array` to return possible multiple values. CLI Examples: .. code-block:: bash salt-call infoblox.get_host_ipv4 host=localhost.domain.com salt-call infoblox.get...
python
def get_host_ipv4(name=None, mac=None, allow_array=False, **api_opts): ''' Get ipv4 address from host record. Use `allow_array` to return possible multiple values. CLI Examples: .. code-block:: bash salt-call infoblox.get_host_ipv4 host=localhost.domain.com salt-call infoblox.get...
['def', 'get_host_ipv4', '(', 'name', '=', 'None', ',', 'mac', '=', 'None', ',', 'allow_array', '=', 'False', ',', '*', '*', 'api_opts', ')', ':', 'data', '=', 'get_host', '(', 'name', '=', 'name', ',', 'mac', '=', 'mac', ',', '*', '*', 'api_opts', ')', 'if', 'data', 'and', "'ipv4addrs'", 'in', 'data', ':', 'l', '=', '...
Get ipv4 address from host record. Use `allow_array` to return possible multiple values. CLI Examples: .. code-block:: bash salt-call infoblox.get_host_ipv4 host=localhost.domain.com salt-call infoblox.get_host_ipv4 mac=00:50:56:84:6e:ae
['Get', 'ipv4', 'address', 'from', 'host', 'record', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/infoblox.py#L410-L433
2,452
awslabs/serverless-application-model
samtranslator/swagger/swagger.py
SwaggerEditor.has_integration
def has_integration(self, path, method): """ Checks if an API Gateway integration is already present at the given path/method :param string path: Path name :param string method: HTTP method :return: True, if an API Gateway integration is already present """ metho...
python
def has_integration(self, path, method): """ Checks if an API Gateway integration is already present at the given path/method :param string path: Path name :param string method: HTTP method :return: True, if an API Gateway integration is already present """ metho...
['def', 'has_integration', '(', 'self', ',', 'path', ',', 'method', ')', ':', 'method', '=', 'self', '.', '_normalize_method_name', '(', 'method', ')', 'path_dict', '=', 'self', '.', 'get_path', '(', 'path', ')', 'return', 'self', '.', 'has_path', '(', 'path', ',', 'method', ')', 'and', 'isinstance', '(', 'path_dict', ...
Checks if an API Gateway integration is already present at the given path/method :param string path: Path name :param string method: HTTP method :return: True, if an API Gateway integration is already present
['Checks', 'if', 'an', 'API', 'Gateway', 'integration', 'is', 'already', 'present', 'at', 'the', 'given', 'path', '/', 'method']
train
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L99-L112
2,453
DataDog/integrations-core
vsphere/datadog_checks/vsphere/objects_queue.py
ObjectsQueue.pop
def pop(self, key, resource_type): """ Extract an object from the list. If the key is not in the cache, this will raise a KeyError. If the list is empty, method will return None """ with self._objects_queue_lock: objects = self._objects_queue[key].get(resource...
python
def pop(self, key, resource_type): """ Extract an object from the list. If the key is not in the cache, this will raise a KeyError. If the list is empty, method will return None """ with self._objects_queue_lock: objects = self._objects_queue[key].get(resource...
['def', 'pop', '(', 'self', ',', 'key', ',', 'resource_type', ')', ':', 'with', 'self', '.', '_objects_queue_lock', ':', 'objects', '=', 'self', '.', '_objects_queue', '[', 'key', ']', '.', 'get', '(', 'resource_type', ',', '[', ']', ')', 'return', 'objects', '.', 'pop', '(', ')', 'if', 'objects', 'else', 'None']
Extract an object from the list. If the key is not in the cache, this will raise a KeyError. If the list is empty, method will return None
['Extract', 'an', 'object', 'from', 'the', 'list', '.', 'If', 'the', 'key', 'is', 'not', 'in', 'the', 'cache', 'this', 'will', 'raise', 'a', 'KeyError', '.', 'If', 'the', 'list', 'is', 'empty', 'method', 'will', 'return', 'None']
train
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/vsphere/datadog_checks/vsphere/objects_queue.py#L37-L45
2,454
gwastro/pycbc
pycbc/workflow/segment.py
get_sci_segs_for_ifo
def get_sci_segs_for_ifo(ifo, cp, start_time, end_time, out_dir, tags=None): """ Obtain science segments for the selected ifo Parameters ----------- ifo : string The string describing the ifo to obtain science times for. start_time : gps time (either int/LIGOTimeGPS) The time at...
python
def get_sci_segs_for_ifo(ifo, cp, start_time, end_time, out_dir, tags=None): """ Obtain science segments for the selected ifo Parameters ----------- ifo : string The string describing the ifo to obtain science times for. start_time : gps time (either int/LIGOTimeGPS) The time at...
['def', 'get_sci_segs_for_ifo', '(', 'ifo', ',', 'cp', ',', 'start_time', ',', 'end_time', ',', 'out_dir', ',', 'tags', '=', 'None', ')', ':', 'if', 'tags', 'is', 'None', ':', 'tags', '=', '[', ']', 'seg_valid_seg', '=', 'segments', '.', 'segment', '(', '[', 'start_time', ',', 'end_time', ']', ')', 'sci_seg_name', '=',...
Obtain science segments for the selected ifo Parameters ----------- ifo : string The string describing the ifo to obtain science times for. start_time : gps time (either int/LIGOTimeGPS) The time at which to begin searching for segments. end_time : gps time (either int/LIGOTimeGPS) ...
['Obtain', 'science', 'segments', 'for', 'the', 'selected', 'ifo']
train
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/segment.py#L627-L702
2,455
jsommers/switchyard
switchyard/lib/topo/topobuild.py
Topology.unserialize
def unserialize(jsonstr): ''' Unserialize a JSON string representation of a topology ''' topod = json.loads(jsonstr) G = json_graph.node_link_graph(topod) for n,ndict in G.nodes(data=True): if 'nodeobj' not in ndict or 'type' not in ndict: rais...
python
def unserialize(jsonstr): ''' Unserialize a JSON string representation of a topology ''' topod = json.loads(jsonstr) G = json_graph.node_link_graph(topod) for n,ndict in G.nodes(data=True): if 'nodeobj' not in ndict or 'type' not in ndict: rais...
['def', 'unserialize', '(', 'jsonstr', ')', ':', 'topod', '=', 'json', '.', 'loads', '(', 'jsonstr', ')', 'G', '=', 'json_graph', '.', 'node_link_graph', '(', 'topod', ')', 'for', 'n', ',', 'ndict', 'in', 'G', '.', 'nodes', '(', 'data', '=', 'True', ')', ':', 'if', "'nodeobj'", 'not', 'in', 'ndict', 'or', "'type'", 'no...
Unserialize a JSON string representation of a topology
['Unserialize', 'a', 'JSON', 'string', 'representation', 'of', 'a', 'topology']
train
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L273-L286
2,456
inasafe/inasafe
safe/common/utilities.py
temp_dir
def temp_dir(sub_dir='work'): """Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a tem...
python
def temp_dir(sub_dir='work'): """Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a tem...
['def', 'temp_dir', '(', 'sub_dir', '=', "'work'", ')', ':', 'user', '=', 'getpass', '.', 'getuser', '(', ')', '.', 'replace', '(', "' '", ',', "'_'", ')', 'current_date', '=', 'date', '.', 'today', '(', ')', 'date_string', '=', 'current_date', '.', 'isoformat', '(', ')', 'if', "'INASAFE_WORK_DIR'", 'in', 'os', '.', 'e...
Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a temporary directory under the inasafe wo...
['Obtain', 'the', 'temporary', 'working', 'directory', 'for', 'the', 'operating', 'system', '.']
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L106-L154
2,457
MIT-LCP/wfdb-python
wfdb/io/record.py
is_monotonic
def is_monotonic(full_list): """ Determine whether elements in a list are monotonic. ie. unique elements are clustered together. ie. [5,5,3,4] is, [5,3,5] is not. """ prev_elements = set({full_list[0]}) prev_item = full_list[0] for item in full_list: if item != prev_item: ...
python
def is_monotonic(full_list): """ Determine whether elements in a list are monotonic. ie. unique elements are clustered together. ie. [5,5,3,4] is, [5,3,5] is not. """ prev_elements = set({full_list[0]}) prev_item = full_list[0] for item in full_list: if item != prev_item: ...
['def', 'is_monotonic', '(', 'full_list', ')', ':', 'prev_elements', '=', 'set', '(', '{', 'full_list', '[', '0', ']', '}', ')', 'prev_item', '=', 'full_list', '[', '0', ']', 'for', 'item', 'in', 'full_list', ':', 'if', 'item', '!=', 'prev_item', ':', 'if', 'item', 'in', 'prev_elements', ':', 'return', 'False', 'prev_i...
Determine whether elements in a list are monotonic. ie. unique elements are clustered together. ie. [5,5,3,4] is, [5,3,5] is not.
['Determine', 'whether', 'elements', 'in', 'a', 'list', 'are', 'monotonic', '.', 'ie', '.', 'unique', 'elements', 'are', 'clustered', 'together', '.']
train
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L1542-L1559
2,458
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/query.py
Query._to_protobuf
def _to_protobuf(self): """Convert the current query into the equivalent protobuf. Returns: google.cloud.firestore_v1beta1.types.StructuredQuery: The query protobuf. """ projection = self._normalize_projection(self._projection) orders = self._normalize_or...
python
def _to_protobuf(self): """Convert the current query into the equivalent protobuf. Returns: google.cloud.firestore_v1beta1.types.StructuredQuery: The query protobuf. """ projection = self._normalize_projection(self._projection) orders = self._normalize_or...
['def', '_to_protobuf', '(', 'self', ')', ':', 'projection', '=', 'self', '.', '_normalize_projection', '(', 'self', '.', '_projection', ')', 'orders', '=', 'self', '.', '_normalize_orders', '(', ')', 'start_at', '=', 'self', '.', '_normalize_cursor', '(', 'self', '.', '_start_at', ',', 'orders', ')', 'end_at', '=', 's...
Convert the current query into the equivalent protobuf. Returns: google.cloud.firestore_v1beta1.types.StructuredQuery: The query protobuf.
['Convert', 'the', 'current', 'query', 'into', 'the', 'equivalent', 'protobuf', '.']
train
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/query.py#L666-L695
2,459
satellogic/telluric
telluric/georaster.py
GeoRaster2.center
def center(self): """Return footprint center in world coordinates, as GeoVector.""" image_center = Point(self.width / 2, self.height / 2) return self.to_world(image_center)
python
def center(self): """Return footprint center in world coordinates, as GeoVector.""" image_center = Point(self.width / 2, self.height / 2) return self.to_world(image_center)
['def', 'center', '(', 'self', ')', ':', 'image_center', '=', 'Point', '(', 'self', '.', 'width', '/', '2', ',', 'self', '.', 'height', '/', '2', ')', 'return', 'self', '.', 'to_world', '(', 'image_center', ')']
Return footprint center in world coordinates, as GeoVector.
['Return', 'footprint', 'center', 'in', 'world', 'coordinates', 'as', 'GeoVector', '.']
train
https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1576-L1579
2,460
saltstack/salt
salt/modules/boto_elb.py
apply_security_groups
def apply_security_groups(name, security_groups, region=None, key=None, keyid=None, profile=None): ''' Apply security groups to ELB. CLI example: .. code-block:: bash salt myminion boto_elb.apply_security_groups myelb '["mysecgroup1"]' ''' conn = _get_conn(re...
python
def apply_security_groups(name, security_groups, region=None, key=None, keyid=None, profile=None): ''' Apply security groups to ELB. CLI example: .. code-block:: bash salt myminion boto_elb.apply_security_groups myelb '["mysecgroup1"]' ''' conn = _get_conn(re...
['def', 'apply_security_groups', '(', 'name', ',', 'security_groups', ',', 'region', '=', 'None', ',', 'key', '=', 'None', ',', 'keyid', '=', 'None', ',', 'profile', '=', 'None', ')', ':', 'conn', '=', '_get_conn', '(', 'region', '=', 'region', ',', 'key', '=', 'key', ',', 'keyid', '=', 'keyid', ',', 'profile', '=', 'p...
Apply security groups to ELB. CLI example: .. code-block:: bash salt myminion boto_elb.apply_security_groups myelb '["mysecgroup1"]'
['Apply', 'security', 'groups', 'to', 'ELB', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elb.py#L357-L380
2,461
aws/sagemaker-python-sdk
src/sagemaker/tuner.py
HyperparameterTuner.transfer_learning_tuner
def transfer_learning_tuner(self, additional_parents=None, estimator=None): """Creates a new ``HyperparameterTuner`` by copying the request fields from the provided parent to the new instance of ``HyperparameterTuner``. Followed by addition of warm start configuration with the type as "TransferL...
python
def transfer_learning_tuner(self, additional_parents=None, estimator=None): """Creates a new ``HyperparameterTuner`` by copying the request fields from the provided parent to the new instance of ``HyperparameterTuner``. Followed by addition of warm start configuration with the type as "TransferL...
['def', 'transfer_learning_tuner', '(', 'self', ',', 'additional_parents', '=', 'None', ',', 'estimator', '=', 'None', ')', ':', 'return', 'self', '.', '_create_warm_start_tuner', '(', 'additional_parents', '=', 'additional_parents', ',', 'warm_start_type', '=', 'WarmStartTypes', '.', 'TRANSFER_LEARNING', ',', 'estimat...
Creates a new ``HyperparameterTuner`` by copying the request fields from the provided parent to the new instance of ``HyperparameterTuner``. Followed by addition of warm start configuration with the type as "TransferLearning" and parents as the union of provided list of ``additional_parents`` and the ``...
['Creates', 'a', 'new', 'HyperparameterTuner', 'by', 'copying', 'the', 'request', 'fields', 'from', 'the', 'provided', 'parent', 'to', 'the', 'new', 'instance', 'of', 'HyperparameterTuner', '.', 'Followed', 'by', 'addition', 'of', 'warm', 'start', 'configuration', 'with', 'the', 'type', 'as', 'TransferLearning', 'and',...
train
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/tuner.py#L532-L557
2,462
basho/riak-python-client
riak/transports/transport.py
Transport.delete
def delete(self, robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Deletes an object. """ raise NotImplementedError
python
def delete(self, robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Deletes an object. """ raise NotImplementedError
['def', 'delete', '(', 'self', ',', 'robj', ',', 'rw', '=', 'None', ',', 'r', '=', 'None', ',', 'w', '=', 'None', ',', 'dw', '=', 'None', ',', 'pr', '=', 'None', ',', 'pw', '=', 'None', ',', 'timeout', '=', 'None', ')', ':', 'raise', 'NotImplementedError']
Deletes an object.
['Deletes', 'an', 'object', '.']
train
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L84-L89
2,463
dhermes/bezier
src/bezier/_surface_helpers.py
quadratic_jacobian_polynomial
def quadratic_jacobian_polynomial(nodes): r"""Compute the Jacobian determinant of a quadratic surface. .. note:: This is used **only** by :meth:`Surface._compute_valid` (which is in turn used to compute / cache the :attr:`Surface.is_valid` property). Converts :math:`\det(J(s, t))` to...
python
def quadratic_jacobian_polynomial(nodes): r"""Compute the Jacobian determinant of a quadratic surface. .. note:: This is used **only** by :meth:`Surface._compute_valid` (which is in turn used to compute / cache the :attr:`Surface.is_valid` property). Converts :math:`\det(J(s, t))` to...
['def', 'quadratic_jacobian_polynomial', '(', 'nodes', ')', ':', '# First evaluate the Jacobian at each of the 6 nodes.', 'jac_parts', '=', '_helpers', '.', 'matrix_product', '(', 'nodes', ',', '_QUADRATIC_JACOBIAN_HELPER', ')', 'jac_at_nodes', '=', 'np', '.', 'empty', '(', '(', '1', ',', '6', ')', ',', 'order', '=', '...
r"""Compute the Jacobian determinant of a quadratic surface. .. note:: This is used **only** by :meth:`Surface._compute_valid` (which is in turn used to compute / cache the :attr:`Surface.is_valid` property). Converts :math:`\det(J(s, t))` to a polynomial on the reference triangle an...
['r', 'Compute', 'the', 'Jacobian', 'determinant', 'of', 'a', 'quadratic', 'surface', '.']
train
https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_surface_helpers.py#L815-L851
2,464
thriftrw/thriftrw-python
thriftrw/compile/compiler.py
ModuleSpec.link
def link(self): """Link all the types in this module and all included modules.""" if self.linked: return self self.linked = True included_modules = [] # Link includes for include in self.includes.values(): included_modules.append(include.link()....
python
def link(self): """Link all the types in this module and all included modules.""" if self.linked: return self self.linked = True included_modules = [] # Link includes for include in self.includes.values(): included_modules.append(include.link()....
['def', 'link', '(', 'self', ')', ':', 'if', 'self', '.', 'linked', ':', 'return', 'self', 'self', '.', 'linked', '=', 'True', 'included_modules', '=', '[', ']', '# Link includes', 'for', 'include', 'in', 'self', '.', 'includes', '.', 'values', '(', ')', ':', 'included_modules', '.', 'append', '(', 'include', '.', 'lin...
Link all the types in this module and all included modules.
['Link', 'all', 'the', 'types', 'in', 'this', 'module', 'and', 'all', 'included', 'modules', '.']
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/compiler.py#L112-L135
2,465
architv/soccer-cli
soccer/main.py
main
def main(league, time, standings, team, live, use12hour, players, output_format, output_file, upcoming, lookup, listcodes, apikey): """ A CLI for live and past football scores from various football leagues. League codes: \b - WC: World Cup - EC: European Championship - CL: Champio...
python
def main(league, time, standings, team, live, use12hour, players, output_format, output_file, upcoming, lookup, listcodes, apikey): """ A CLI for live and past football scores from various football leagues. League codes: \b - WC: World Cup - EC: European Championship - CL: Champio...
['def', 'main', '(', 'league', ',', 'time', ',', 'standings', ',', 'team', ',', 'live', ',', 'use12hour', ',', 'players', ',', 'output_format', ',', 'output_file', ',', 'upcoming', ',', 'lookup', ',', 'listcodes', ',', 'apikey', ')', ':', 'headers', '=', '{', "'X-Auth-Token'", ':', 'apikey', '}', 'try', ':', 'if', 'out...
A CLI for live and past football scores from various football leagues. League codes: \b - WC: World Cup - EC: European Championship - CL: Champions League - PL: English Premier League - ELC: English Championship - FL1: French Ligue 1 - BL: German Bundesliga - SA: Serie A - ...
['A', 'CLI', 'for', 'live', 'and', 'past', 'football', 'scores', 'from', 'various', 'football', 'leagues', '.']
train
https://github.com/architv/soccer-cli/blob/472e9f492f7633a8e9739e228a6c31de454da88b/soccer/main.py#L133-L194
2,466
glyphobet/fragments
fragments/commands.py
status
def status(*args): """ Get the current status of the fragments repository, limited to FILENAME(s) if specified. Limit output to files with status STATUS, if present. """ parser = argparse.ArgumentParser(prog="%s %s" % (__package__, status.__name__), description=status.__doc__) parser.add_argumen...
python
def status(*args): """ Get the current status of the fragments repository, limited to FILENAME(s) if specified. Limit output to files with status STATUS, if present. """ parser = argparse.ArgumentParser(prog="%s %s" % (__package__, status.__name__), description=status.__doc__) parser.add_argumen...
['def', 'status', '(', '*', 'args', ')', ':', 'parser', '=', 'argparse', '.', 'ArgumentParser', '(', 'prog', '=', '"%s %s"', '%', '(', '__package__', ',', 'status', '.', '__name__', ')', ',', 'description', '=', 'status', '.', '__doc__', ')', 'parser', '.', 'add_argument', '(', "'FILENAME'", ',', 'help', '=', '"files t...
Get the current status of the fragments repository, limited to FILENAME(s) if specified. Limit output to files with status STATUS, if present.
['Get', 'the', 'current', 'status', 'of', 'the', 'fragments', 'repository', 'limited', 'to', 'FILENAME', '(', 's', ')', 'if', 'specified', '.', 'Limit', 'output', 'to', 'files', 'with', 'status', 'STATUS', 'if', 'present', '.']
train
https://github.com/glyphobet/fragments/blob/b58473604e2db47b98703260b8ee8605264247e3/fragments/commands.py#L80-L94
2,467
konstantint/matplotlib-venn
matplotlib_venn/_region.py
VennArcgonRegion.verify
def verify(self): ''' Verify the correctness of the region arcs. Throws an VennRegionException if verification fails (or any other exception if it happens during verification). ''' # Verify size of arcs list if (len(self.arcs) < 2): raise VennRegionException("...
python
def verify(self): ''' Verify the correctness of the region arcs. Throws an VennRegionException if verification fails (or any other exception if it happens during verification). ''' # Verify size of arcs list if (len(self.arcs) < 2): raise VennRegionException("...
['def', 'verify', '(', 'self', ')', ':', '# Verify size of arcs list', 'if', '(', 'len', '(', 'self', '.', 'arcs', ')', '<', '2', ')', ':', 'raise', 'VennRegionException', '(', '"At least two arcs needed in a poly-arc region"', ')', 'if', '(', 'len', '(', 'self', '.', 'arcs', ')', '>', '4', ')', ':', 'raise', 'VennRegi...
Verify the correctness of the region arcs. Throws an VennRegionException if verification fails (or any other exception if it happens during verification).
['Verify', 'the', 'correctness', 'of', 'the', 'region', 'arcs', '.', 'Throws', 'an', 'VennRegionException', 'if', 'verification', 'fails', '(', 'or', 'any', 'other', 'exception', 'if', 'it', 'happens', 'during', 'verification', ')', '.']
train
https://github.com/konstantint/matplotlib-venn/blob/c26796c9925bdac512edf48387452fbd1848c791/matplotlib_venn/_region.py#L242-L279
2,468
sarugaku/pythonfinder
tasks/vendoring/__init__.py
rewrite_file_imports
def rewrite_file_imports(item, vendored_libs): """Rewrite 'import xxx' and 'from xxx import' for vendored_libs""" text = item.read_text(encoding='utf-8') for lib in vendored_libs: text = re.sub( r'(\n\s*)import %s(\n\s*)' % lib, r'\1from pythonfinder._vendor import %s\2' % li...
python
def rewrite_file_imports(item, vendored_libs): """Rewrite 'import xxx' and 'from xxx import' for vendored_libs""" text = item.read_text(encoding='utf-8') for lib in vendored_libs: text = re.sub( r'(\n\s*)import %s(\n\s*)' % lib, r'\1from pythonfinder._vendor import %s\2' % li...
['def', 'rewrite_file_imports', '(', 'item', ',', 'vendored_libs', ')', ':', 'text', '=', 'item', '.', 'read_text', '(', 'encoding', '=', "'utf-8'", ')', 'for', 'lib', 'in', 'vendored_libs', ':', 'text', '=', 're', '.', 'sub', '(', "r'(\\n\\s*)import %s(\\n\\s*)'", '%', 'lib', ',', "r'\\1from pythonfinder._vendor impor...
Rewrite 'import xxx' and 'from xxx import' for vendored_libs
['Rewrite', 'import', 'xxx', 'and', 'from', 'xxx', 'import', 'for', 'vendored_libs']
train
https://github.com/sarugaku/pythonfinder/blob/6f5a4143ff6b52093b4de54650bc09c92d239bf4/tasks/vendoring/__init__.py#L78-L92
2,469
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/exmaralda.py
ExmaraldaDocumentGraph.is_token_annotation_tier
def is_token_annotation_tier(self, tier): """ returns True, iff all events in the given tier annotate exactly one token. """ for i, event in enumerate(tier.iter('event')): if self.indexdelta(event.attrib['end'], event.attrib['start']) != 1: return Fals...
python
def is_token_annotation_tier(self, tier): """ returns True, iff all events in the given tier annotate exactly one token. """ for i, event in enumerate(tier.iter('event')): if self.indexdelta(event.attrib['end'], event.attrib['start']) != 1: return Fals...
['def', 'is_token_annotation_tier', '(', 'self', ',', 'tier', ')', ':', 'for', 'i', ',', 'event', 'in', 'enumerate', '(', 'tier', '.', 'iter', '(', "'event'", ')', ')', ':', 'if', 'self', '.', 'indexdelta', '(', 'event', '.', 'attrib', '[', "'end'", ']', ',', 'event', '.', 'attrib', '[', "'start'", ']', ')', '!=', '1',...
returns True, iff all events in the given tier annotate exactly one token.
['returns', 'True', 'iff', 'all', 'events', 'in', 'the', 'given', 'tier', 'annotate', 'exactly', 'one', 'token', '.']
train
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/exmaralda.py#L356-L364
2,470
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.alloc
def alloc(self): """from _mosquitto_packet_alloc.""" byte = 0 remaining_bytes = bytearray(5) i = 0 remaining_length = self.remaining_length self.payload = None self.remaining_count = 0 loop_flag = True #self.dump() ...
python
def alloc(self): """from _mosquitto_packet_alloc.""" byte = 0 remaining_bytes = bytearray(5) i = 0 remaining_length = self.remaining_length self.payload = None self.remaining_count = 0 loop_flag = True #self.dump() ...
['def', 'alloc', '(', 'self', ')', ':', 'byte', '=', '0', 'remaining_bytes', '=', 'bytearray', '(', '5', ')', 'i', '=', '0', 'remaining_length', '=', 'self', '.', 'remaining_length', 'self', '.', 'payload', '=', 'None', 'self', '.', 'remaining_count', '=', '0', 'loop_flag', '=', 'True', '#self.dump()', 'while', 'loop_f...
from _mosquitto_packet_alloc.
['from', '_mosquitto_packet_alloc', '.']
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L47-L88
2,471
bachya/pyflunearyou
pyflunearyou/cdc.py
adjust_status
def adjust_status(info: dict) -> dict: """Apply status mapping to a raw API result.""" modified_info = deepcopy(info) modified_info.update({ 'level': get_nearest_by_numeric_key(STATUS_MAP, int(info['level'])), 'level2': STATUS_MAP[99] if info['level2'] is None else ...
python
def adjust_status(info: dict) -> dict: """Apply status mapping to a raw API result.""" modified_info = deepcopy(info) modified_info.update({ 'level': get_nearest_by_numeric_key(STATUS_MAP, int(info['level'])), 'level2': STATUS_MAP[99] if info['level2'] is None else ...
['def', 'adjust_status', '(', 'info', ':', 'dict', ')', '->', 'dict', ':', 'modified_info', '=', 'deepcopy', '(', 'info', ')', 'modified_info', '.', 'update', '(', '{', "'level'", ':', 'get_nearest_by_numeric_key', '(', 'STATUS_MAP', ',', 'int', '(', 'info', '[', "'level'", ']', ')', ')', ',', "'level2'", ':', 'STATUS_...
Apply status mapping to a raw API result.
['Apply', 'status', 'mapping', 'to', 'a', 'raw', 'API', 'result', '.']
train
https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/cdc.py#L23-L34
2,472
saltstack/salt
salt/modules/boto_vpc.py
describe_subnet
def describe_subnet(subnet_id=None, subnet_name=None, region=None, key=None, keyid=None, profile=None): ''' Given a subnet id or name, describe its properties. Returns a dictionary of interesting properties. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash ...
python
def describe_subnet(subnet_id=None, subnet_name=None, region=None, key=None, keyid=None, profile=None): ''' Given a subnet id or name, describe its properties. Returns a dictionary of interesting properties. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash ...
['def', 'describe_subnet', '(', 'subnet_id', '=', 'None', ',', 'subnet_name', '=', 'None', ',', 'region', '=', 'None', ',', 'key', '=', 'None', ',', 'keyid', '=', 'None', ',', 'profile', '=', 'None', ')', ':', 'try', ':', 'subnet', '=', '_get_resource', '(', "'subnet'", ',', 'name', '=', 'subnet_name', ',', 'resource_i...
Given a subnet id or name, describe its properties. Returns a dictionary of interesting properties. .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt myminion boto_vpc.describe_subnet subnet_id=subnet-123456 salt myminion boto_vpc.describe_subnet subnet_name=mysubne...
['Given', 'a', 'subnet', 'id', 'or', 'name', 'describe', 'its', 'properties', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_vpc.py#L1018-L1053
2,473
raamana/hiwenet
hiwenet/pairwise_dist.py
run_cli
def run_cli(): "Command line interface to hiwenet." features_path, groups_path, weight_method, num_bins, edge_range, \ trim_outliers, trim_percentile, return_networkx_graph, out_weights_path = parse_args() # TODO add the possibility to process multiple combinations of parameters: diff subjects, diff m...
python
def run_cli(): "Command line interface to hiwenet." features_path, groups_path, weight_method, num_bins, edge_range, \ trim_outliers, trim_percentile, return_networkx_graph, out_weights_path = parse_args() # TODO add the possibility to process multiple combinations of parameters: diff subjects, diff m...
['def', 'run_cli', '(', ')', ':', 'features_path', ',', 'groups_path', ',', 'weight_method', ',', 'num_bins', ',', 'edge_range', ',', 'trim_outliers', ',', 'trim_percentile', ',', 'return_networkx_graph', ',', 'out_weights_path', '=', 'parse_args', '(', ')', '# TODO add the possibility to process multiple combinations ...
Command line interface to hiwenet.
['Command', 'line', 'interface', 'to', 'hiwenet', '.']
train
https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L577-L592
2,474
jelmer/python-fastimport
fastimport/parser.py
ImportParser.iter_commands
def iter_commands(self): """Iterator returning ImportCommand objects.""" while True: line = self.next_line() if line is None: if b'done' in self.features: raise errors.PrematureEndOfStream(self.lineno) break elif len...
python
def iter_commands(self): """Iterator returning ImportCommand objects.""" while True: line = self.next_line() if line is None: if b'done' in self.features: raise errors.PrematureEndOfStream(self.lineno) break elif len...
['def', 'iter_commands', '(', 'self', ')', ':', 'while', 'True', ':', 'line', '=', 'self', '.', 'next_line', '(', ')', 'if', 'line', 'is', 'None', ':', 'if', "b'done'", 'in', 'self', '.', 'features', ':', 'raise', 'errors', '.', 'PrematureEndOfStream', '(', 'self', '.', 'lineno', ')', 'break', 'elif', 'len', '(', 'line...
Iterator returning ImportCommand objects.
['Iterator', 'returning', 'ImportCommand', 'objects', '.']
train
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/parser.py#L290-L318
2,475
PmagPy/PmagPy
pmagpy/ipmag.py
pmag_results_extract
def pmag_results_extract(res_file="pmag_results.txt", crit_file="", spec_file="", age_file="", latex=False, grade=False, WD="."): """ Generate tab delimited output file(s) with result data. Save output files and return True if successful. Possible output files: Directions, Inten...
python
def pmag_results_extract(res_file="pmag_results.txt", crit_file="", spec_file="", age_file="", latex=False, grade=False, WD="."): """ Generate tab delimited output file(s) with result data. Save output files and return True if successful. Possible output files: Directions, Inten...
['def', 'pmag_results_extract', '(', 'res_file', '=', '"pmag_results.txt"', ',', 'crit_file', '=', '""', ',', 'spec_file', '=', '""', ',', 'age_file', '=', '""', ',', 'latex', '=', 'False', ',', 'grade', '=', 'False', ',', 'WD', '=', '"."', ')', ':', '# format outfiles', 'if', 'latex', ':', 'latex', '=', '1', 'file_typ...
Generate tab delimited output file(s) with result data. Save output files and return True if successful. Possible output files: Directions, Intensities, SiteNfo, Criteria, Specimens Optional Parameters (defaults are used if not specified) ---------- res_file : name of pma...
['Generate', 'tab', 'delimited', 'output', 'file', '(', 's', ')', 'with', 'result', 'data', '.', 'Save', 'output', 'files', 'and', 'return', 'True', 'if', 'successful', '.', 'Possible', 'output', 'files', ':', 'Directions', 'Intensities', 'SiteNfo', 'Criteria', 'Specimens']
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/ipmag.py#L7097-L7456
2,476
wright-group/WrightTools
WrightTools/data/_data.py
Data.source
def source(self): """Source.""" if "source" not in self.attrs.keys(): self.attrs["source"] = "None" value = self.attrs["source"] return value if not value == "None" else None
python
def source(self): """Source.""" if "source" not in self.attrs.keys(): self.attrs["source"] = "None" value = self.attrs["source"] return value if not value == "None" else None
['def', 'source', '(', 'self', ')', ':', 'if', '"source"', 'not', 'in', 'self', '.', 'attrs', '.', 'keys', '(', ')', ':', 'self', '.', 'attrs', '[', '"source"', ']', '=', '"None"', 'value', '=', 'self', '.', 'attrs', '[', '"source"', ']', 'return', 'value', 'if', 'not', 'value', '==', '"None"', 'else', 'None']
Source.
['Source', '.']
train
https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/data/_data.py#L168-L173
2,477
manns/pyspread
pyspread/src/gui/_grid.py
GridEventHandlers.OnRowSize
def OnRowSize(self, event): """Row size event handler""" row = event.GetRowOrCol() tab = self.grid.current_table rowsize = self.grid.GetRowSize(row) / self.grid.grid_renderer.zoom # Detect for resizing group of rows rows = self.grid.GetSelectedRows() if len(rows...
python
def OnRowSize(self, event): """Row size event handler""" row = event.GetRowOrCol() tab = self.grid.current_table rowsize = self.grid.GetRowSize(row) / self.grid.grid_renderer.zoom # Detect for resizing group of rows rows = self.grid.GetSelectedRows() if len(rows...
['def', 'OnRowSize', '(', 'self', ',', 'event', ')', ':', 'row', '=', 'event', '.', 'GetRowOrCol', '(', ')', 'tab', '=', 'self', '.', 'grid', '.', 'current_table', 'rowsize', '=', 'self', '.', 'grid', '.', 'GetRowSize', '(', 'row', ')', '/', 'self', '.', 'grid', '.', 'grid_renderer', '.', 'zoom', '# Detect for resizing...
Row size event handler
['Row', 'size', 'event', 'handler']
train
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1486-L1518
2,478
kpdyer/regex2dfa
third_party/re2/lib/codereview/codereview.py
VersionControlSystem.GetBaseFiles
def GetBaseFiles(self, diff): """Helper that calls GetBase file for each file in the patch. Returns: A dictionary that maps from filename to GetBaseFile's tuple. Filenames are retrieved based on lines that start with "Index:" or "Property changes on:". """ files = {} for line in diff.splitlines(Tru...
python
def GetBaseFiles(self, diff): """Helper that calls GetBase file for each file in the patch. Returns: A dictionary that maps from filename to GetBaseFile's tuple. Filenames are retrieved based on lines that start with "Index:" or "Property changes on:". """ files = {} for line in diff.splitlines(Tru...
['def', 'GetBaseFiles', '(', 'self', ',', 'diff', ')', ':', 'files', '=', '{', '}', 'for', 'line', 'in', 'diff', '.', 'splitlines', '(', 'True', ')', ':', 'if', 'line', '.', 'startswith', '(', "'Index:'", ')', 'or', 'line', '.', 'startswith', '(', "'Property changes on:'", ')', ':', 'unused', ',', 'filename', '=', 'lin...
Helper that calls GetBase file for each file in the patch. Returns: A dictionary that maps from filename to GetBaseFile's tuple. Filenames are retrieved based on lines that start with "Index:" or "Property changes on:".
['Helper', 'that', 'calls', 'GetBase', 'file', 'for', 'each', 'file', 'in', 'the', 'patch', '.']
train
https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3241-L3257
2,479
SBRG/ssbio
ssbio/protein/structure/properties/residues.py
hse_output
def hse_output(pdb_file, file_type): """ The solvent exposure of an amino acid residue is important for analyzing, understanding and predicting aspects of protein structure and function [73]. A residue's solvent exposure can be classified as four categories: exposed, partly exposed, buried and deepl...
python
def hse_output(pdb_file, file_type): """ The solvent exposure of an amino acid residue is important for analyzing, understanding and predicting aspects of protein structure and function [73]. A residue's solvent exposure can be classified as four categories: exposed, partly exposed, buried and deepl...
['def', 'hse_output', '(', 'pdb_file', ',', 'file_type', ')', ':', '# Get the first model', 'my_structure', '=', 'StructureIO', '(', 'pdb_file', ')', 'model', '=', 'my_structure', '.', 'first_model', '# Calculate HSEalpha', 'exp_ca', '=', 'HSExposureCA', '(', 'model', ')', '# Calculate HSEbeta', 'exp_cb', '=', 'HSExpos...
The solvent exposure of an amino acid residue is important for analyzing, understanding and predicting aspects of protein structure and function [73]. A residue's solvent exposure can be classified as four categories: exposed, partly exposed, buried and deeply buried residues. Hamelryck et al. [73] establi...
['The', 'solvent', 'exposure', 'of', 'an', 'amino', 'acid', 'residue', 'is', 'important', 'for', 'analyzing', 'understanding', 'and', 'predicting', 'aspects', 'of', 'protein', 'structure', 'and', 'function', '[', '73', ']', '.', 'A', 'residue', 's', 'solvent', 'exposure', 'can', 'be', 'classified', 'as', 'four', 'categ...
train
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/properties/residues.py#L391-L421
2,480
creare-com/pydem
pydem/dem_processing.py
TileEdge.fix_shapes
def fix_shapes(self): """ Fixes the shape of the data fields on edges. Left edges should be column vectors, and top edges should be row vectors, for example. """ for i in xrange(self.n_chunks): for side in ['left', 'right', 'top', 'bottom']: edge = get...
python
def fix_shapes(self): """ Fixes the shape of the data fields on edges. Left edges should be column vectors, and top edges should be row vectors, for example. """ for i in xrange(self.n_chunks): for side in ['left', 'right', 'top', 'bottom']: edge = get...
['def', 'fix_shapes', '(', 'self', ')', ':', 'for', 'i', 'in', 'xrange', '(', 'self', '.', 'n_chunks', ')', ':', 'for', 'side', 'in', '[', "'left'", ',', "'right'", ',', "'top'", ',', "'bottom'", ']', ':', 'edge', '=', 'getattr', '(', 'self', ',', 'side', ')', '.', 'ravel', '(', ')', '[', 'i', ']', 'if', 'side', 'in', ...
Fixes the shape of the data fields on edges. Left edges should be column vectors, and top edges should be row vectors, for example.
['Fixes', 'the', 'shape', 'of', 'the', 'data', 'fields', 'on', 'edges', '.', 'Left', 'edges', 'should', 'be', 'column', 'vectors', 'and', 'top', 'edges', 'should', 'be', 'row', 'vectors', 'for', 'example', '.']
train
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L400-L414
2,481
lingthio/Flask-User
flask_user/email_manager.py
EmailManager.send_registered_email
def send_registered_email(self, user, user_email, request_email_confirmation): """Send the 'user has registered' notification email.""" # Verify config settings if not self.user_manager.USER_ENABLE_EMAIL: return if not self.user_manager.USER_SEND_REGISTERED_EMAIL: return # The ...
python
def send_registered_email(self, user, user_email, request_email_confirmation): """Send the 'user has registered' notification email.""" # Verify config settings if not self.user_manager.USER_ENABLE_EMAIL: return if not self.user_manager.USER_SEND_REGISTERED_EMAIL: return # The ...
['def', 'send_registered_email', '(', 'self', ',', 'user', ',', 'user_email', ',', 'request_email_confirmation', ')', ':', '# Verify config settings', 'if', 'not', 'self', '.', 'user_manager', '.', 'USER_ENABLE_EMAIL', ':', 'return', 'if', 'not', 'self', '.', 'user_manager', '.', 'USER_SEND_REGISTERED_EMAIL', ':', 'ret...
Send the 'user has registered' notification email.
['Send', 'the', 'user', 'has', 'registered', 'notification', 'email', '.']
train
https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/email_manager.py#L130-L154
2,482
ThreatConnect-Inc/tcex
tcex/tcex_ti/tcex_ti_tc_request.py
TiTcRequest._iterate
def _iterate(self, url, params, api_entity): """ Args: url: params: api_entity: Return: """ params['resultLimit'] = self.result_limit should_iterate = True result_start = 0 while should_iterate: # params['re...
python
def _iterate(self, url, params, api_entity): """ Args: url: params: api_entity: Return: """ params['resultLimit'] = self.result_limit should_iterate = True result_start = 0 while should_iterate: # params['re...
['def', '_iterate', '(', 'self', ',', 'url', ',', 'params', ',', 'api_entity', ')', ':', 'params', '[', "'resultLimit'", ']', '=', 'self', '.', 'result_limit', 'should_iterate', '=', 'True', 'result_start', '=', '0', 'while', 'should_iterate', ':', "# params['resultOffset'] = result_offset", 'params', '[', "'resultStar...
Args: url: params: api_entity: Return:
['Args', ':', 'url', ':', 'params', ':', 'api_entity', ':']
train
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/tcex_ti_tc_request.py#L149-L176
2,483
joferkington/mpldatacursor
mpldatacursor/datacursor.py
DataCursor._show_annotation_box
def _show_annotation_box(self, event): """Update an existing box or create an annotation box for an event.""" ax = event.artist.axes # Get the pre-created annotation box for the axes or create a new one. if self.display != 'multiple': annotation = self.annotations[ax] ...
python
def _show_annotation_box(self, event): """Update an existing box or create an annotation box for an event.""" ax = event.artist.axes # Get the pre-created annotation box for the axes or create a new one. if self.display != 'multiple': annotation = self.annotations[ax] ...
['def', '_show_annotation_box', '(', 'self', ',', 'event', ')', ':', 'ax', '=', 'event', '.', 'artist', '.', 'axes', '# Get the pre-created annotation box for the axes or create a new one.', 'if', 'self', '.', 'display', '!=', "'multiple'", ':', 'annotation', '=', 'self', '.', 'annotations', '[', 'ax', ']', 'elif', 'ev...
Update an existing box or create an annotation box for an event.
['Update', 'an', 'existing', 'box', 'or', 'create', 'an', 'annotation', 'box', 'for', 'an', 'event', '.']
train
https://github.com/joferkington/mpldatacursor/blob/7dabc589ed02c35ac5d89de5931f91e0323aa795/mpldatacursor/datacursor.py#L256-L275
2,484
hendrix/hendrix
hendrix/contrib/concurrency/messaging.py
send_json_message
def send_json_message(address, message, **kwargs): """ a shortcut for message sending """ data = { 'message': message, } if not kwargs.get('subject_id'): data['subject_id'] = address data.update(kwargs) hxdispatcher.send(address, data)
python
def send_json_message(address, message, **kwargs): """ a shortcut for message sending """ data = { 'message': message, } if not kwargs.get('subject_id'): data['subject_id'] = address data.update(kwargs) hxdispatcher.send(address, data)
['def', 'send_json_message', '(', 'address', ',', 'message', ',', '*', '*', 'kwargs', ')', ':', 'data', '=', '{', "'message'", ':', 'message', ',', '}', 'if', 'not', 'kwargs', '.', 'get', '(', "'subject_id'", ')', ':', 'data', '[', "'subject_id'", ']', '=', 'address', 'data', '.', 'update', '(', 'kwargs', ')', 'hxdispa...
a shortcut for message sending
['a', 'shortcut', 'for', 'message', 'sending']
train
https://github.com/hendrix/hendrix/blob/175af011a7e5822b772bfec0e11a46466bb8688d/hendrix/contrib/concurrency/messaging.py#L125-L139
2,485
apache/spark
python/pyspark/sql/streaming.py
DataStreamReader.orc
def orc(self, path): """Loads a ORC file stream, returning the result as a :class:`DataFrame`. .. note:: Evolving. >>> orc_sdf = spark.readStream.schema(sdf_schema).orc(tempfile.mkdtemp()) >>> orc_sdf.isStreaming True >>> orc_sdf.schema == sdf_schema True ...
python
def orc(self, path): """Loads a ORC file stream, returning the result as a :class:`DataFrame`. .. note:: Evolving. >>> orc_sdf = spark.readStream.schema(sdf_schema).orc(tempfile.mkdtemp()) >>> orc_sdf.isStreaming True >>> orc_sdf.schema == sdf_schema True ...
['def', 'orc', '(', 'self', ',', 'path', ')', ':', 'if', 'isinstance', '(', 'path', ',', 'basestring', ')', ':', 'return', 'self', '.', '_df', '(', 'self', '.', '_jreader', '.', 'orc', '(', 'path', ')', ')', 'else', ':', 'raise', 'TypeError', '(', '"path can be only a single string"', ')']
Loads a ORC file stream, returning the result as a :class:`DataFrame`. .. note:: Evolving. >>> orc_sdf = spark.readStream.schema(sdf_schema).orc(tempfile.mkdtemp()) >>> orc_sdf.isStreaming True >>> orc_sdf.schema == sdf_schema True
['Loads', 'a', 'ORC', 'file', 'stream', 'returning', 'the', 'result', 'as', 'a', ':', 'class', ':', 'DataFrame', '.']
train
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/streaming.py#L506-L520
2,486
HazyResearch/fonduer
src/fonduer/parser/spacy_parser.py
Spacy.model_installed
def model_installed(name): """Check if spaCy language model is installed. From https://github.com/explosion/spaCy/blob/master/spacy/util.py :param name: :return: """ data_path = util.get_data_path() if not data_path or not data_path.exists(): raise I...
python
def model_installed(name): """Check if spaCy language model is installed. From https://github.com/explosion/spaCy/blob/master/spacy/util.py :param name: :return: """ data_path = util.get_data_path() if not data_path or not data_path.exists(): raise I...
['def', 'model_installed', '(', 'name', ')', ':', 'data_path', '=', 'util', '.', 'get_data_path', '(', ')', 'if', 'not', 'data_path', 'or', 'not', 'data_path', '.', 'exists', '(', ')', ':', 'raise', 'IOError', '(', 'f"Can\'t find spaCy data path: {data_path}"', ')', 'if', 'name', 'in', '{', 'd', '.', 'name', 'for', 'd'...
Check if spaCy language model is installed. From https://github.com/explosion/spaCy/blob/master/spacy/util.py :param name: :return:
['Check', 'if', 'spaCy', 'language', 'model', 'is', 'installed', '.']
train
https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/parser/spacy_parser.py#L87-L104
2,487
jbloomlab/phydms
phydmslib/models.py
ExpCM_fitprefs._update_dPrxy
def _update_dPrxy(self): """Update `dPrxy`.""" super(ExpCM_fitprefs, self)._update_dPrxy() if 'zeta' in self.freeparams: tildeFrxyQxy = self.tildeFrxy * self.Qxy j = 0 zetaxterm = scipy.ndarray((self.nsites, N_CODON, N_CODON), dtype='float') zetay...
python
def _update_dPrxy(self): """Update `dPrxy`.""" super(ExpCM_fitprefs, self)._update_dPrxy() if 'zeta' in self.freeparams: tildeFrxyQxy = self.tildeFrxy * self.Qxy j = 0 zetaxterm = scipy.ndarray((self.nsites, N_CODON, N_CODON), dtype='float') zetay...
['def', '_update_dPrxy', '(', 'self', ')', ':', 'super', '(', 'ExpCM_fitprefs', ',', 'self', ')', '.', '_update_dPrxy', '(', ')', 'if', "'zeta'", 'in', 'self', '.', 'freeparams', ':', 'tildeFrxyQxy', '=', 'self', '.', 'tildeFrxy', '*', 'self', '.', 'Qxy', 'j', '=', '0', 'zetaxterm', '=', 'scipy', '.', 'ndarray', '(', '...
Update `dPrxy`.
['Update', 'dPrxy', '.']
train
https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/models.py#L1068-L1088
2,488
libtcod/python-tcod
tcod/libtcodpy.py
noise_get_fbm
def noise_get_fbm( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. ...
python
def noise_get_fbm( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. ...
['def', 'noise_get_fbm', '(', 'n', ':', 'tcod', '.', 'noise', '.', 'Noise', ',', 'f', ':', 'Sequence', '[', 'float', ']', ',', 'oc', ':', 'float', ',', 'typ', ':', 'int', '=', 'NOISE_DEFAULT', ',', ')', '->', 'float', ':', 'return', 'float', '(', 'lib', '.', 'TCOD_noise_get_fbm_ex', '(', 'n', '.', 'noise_c', ',', 'ffi'...
Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: ...
['Return', 'the', 'fractal', 'Brownian', 'motion', 'sampled', 'from', 'the', 'f', 'coordinate', '.']
train
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3409-L3428
2,489
datajoint/datajoint-python
datajoint/utils.py
safe_write
def safe_write(filename, blob): """ A two-step write. :param filename: full path :param blob: binary data :return: None """ temp_file = filename + '.saving' with open(temp_file, 'bw') as f: f.write(blob) os.rename(temp_file, filename)
python
def safe_write(filename, blob): """ A two-step write. :param filename: full path :param blob: binary data :return: None """ temp_file = filename + '.saving' with open(temp_file, 'bw') as f: f.write(blob) os.rename(temp_file, filename)
['def', 'safe_write', '(', 'filename', ',', 'blob', ')', ':', 'temp_file', '=', 'filename', '+', "'.saving'", 'with', 'open', '(', 'temp_file', ',', "'bw'", ')', 'as', 'f', ':', 'f', '.', 'write', '(', 'blob', ')', 'os', '.', 'rename', '(', 'temp_file', ',', 'filename', ')']
A two-step write. :param filename: full path :param blob: binary data :return: None
['A', 'two', '-', 'step', 'write', '.', ':', 'param', 'filename', ':', 'full', 'path', ':', 'param', 'blob', ':', 'binary', 'data', ':', 'return', ':', 'None']
train
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/utils.py#L73-L83
2,490
phareous/insteonlocal
insteonlocal/Dimmer.py
Dimmer.stop_change
def stop_change(self): """Stop changing light level manually""" self.logger.info("Dimmer %s stop_change", self.device_id) self.hub.direct_command(self.device_id, '18', '00') success = self.hub.check_success(self.device_id, '18', '00') if success: self.logger.info("Di...
python
def stop_change(self): """Stop changing light level manually""" self.logger.info("Dimmer %s stop_change", self.device_id) self.hub.direct_command(self.device_id, '18', '00') success = self.hub.check_success(self.device_id, '18', '00') if success: self.logger.info("Di...
['def', 'stop_change', '(', 'self', ')', ':', 'self', '.', 'logger', '.', 'info', '(', '"Dimmer %s stop_change"', ',', 'self', '.', 'device_id', ')', 'self', '.', 'hub', '.', 'direct_command', '(', 'self', '.', 'device_id', ',', "'18'", ',', "'00'", ')', 'success', '=', 'self', '.', 'hub', '.', 'check_success', '(', 's...
Stop changing light level manually
['Stop', 'changing', 'light', 'level', 'manually']
train
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Dimmer.py#L183-L197
2,491
avihad/twistes
twistes/parser.py
EsParser._parse_string_host
def _parse_string_host(host_str): """ Parse host string into a dictionary host :param host_str: :return: """ host_str = EsParser._fix_host_prefix(host_str) parsed_url = urlparse(host_str) host = {HostParsing.HOST: parsed_url.hostname} if parsed_url...
python
def _parse_string_host(host_str): """ Parse host string into a dictionary host :param host_str: :return: """ host_str = EsParser._fix_host_prefix(host_str) parsed_url = urlparse(host_str) host = {HostParsing.HOST: parsed_url.hostname} if parsed_url...
['def', '_parse_string_host', '(', 'host_str', ')', ':', 'host_str', '=', 'EsParser', '.', '_fix_host_prefix', '(', 'host_str', ')', 'parsed_url', '=', 'urlparse', '(', 'host_str', ')', 'host', '=', '{', 'HostParsing', '.', 'HOST', ':', 'parsed_url', '.', 'hostname', '}', 'if', 'parsed_url', '.', 'port', ':', 'host', '...
Parse host string into a dictionary host :param host_str: :return:
['Parse', 'host', 'string', 'into', 'a', 'dictionary', 'host', ':', 'param', 'host_str', ':', ':', 'return', ':']
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/parser.py#L70-L91
2,492
karan/TPB
tpb/tpb.py
List.items
def items(self): """ Request URL and parse response. Yield a ``Torrent`` for every torrent on page. """ request = get(str(self.url), headers={'User-Agent' : "Magic Browser","origin_req_host" : "thepiratebay.se"}) root = html.fromstring(request.text) items = [self....
python
def items(self): """ Request URL and parse response. Yield a ``Torrent`` for every torrent on page. """ request = get(str(self.url), headers={'User-Agent' : "Magic Browser","origin_req_host" : "thepiratebay.se"}) root = html.fromstring(request.text) items = [self....
['def', 'items', '(', 'self', ')', ':', 'request', '=', 'get', '(', 'str', '(', 'self', '.', 'url', ')', ',', 'headers', '=', '{', "'User-Agent'", ':', '"Magic Browser"', ',', '"origin_req_host"', ':', '"thepiratebay.se"', '}', ')', 'root', '=', 'html', '.', 'fromstring', '(', 'request', '.', 'text', ')', 'items', '=',...
Request URL and parse response. Yield a ``Torrent`` for every torrent on page.
['Request', 'URL', 'and', 'parse', 'response', '.', 'Yield', 'a', 'Torrent', 'for', 'every', 'torrent', 'on', 'page', '.']
train
https://github.com/karan/TPB/blob/f424a73a10d4bcf4e363d7e7e8cb915a3a057671/tpb/tpb.py#L54-L64
2,493
KelSolaar/Umbra
umbra/ui/widgets/delayed_QSplashScreen.py
Delayed_QSplashScreen.text_color
def text_color(self, value): """ Setter for **self.__text_color** attribute. :param value: Attribute value. :type value: int or QColor """ if value is not None: assert type(value) in (Qt.GlobalColor, QColor), \ "'{0}' attribute: '{1}' type is...
python
def text_color(self, value): """ Setter for **self.__text_color** attribute. :param value: Attribute value. :type value: int or QColor """ if value is not None: assert type(value) in (Qt.GlobalColor, QColor), \ "'{0}' attribute: '{1}' type is...
['def', 'text_color', '(', 'self', ',', 'value', ')', ':', 'if', 'value', 'is', 'not', 'None', ':', 'assert', 'type', '(', 'value', ')', 'in', '(', 'Qt', '.', 'GlobalColor', ',', 'QColor', ')', ',', '"\'{0}\' attribute: \'{1}\' type is not \'int\' or \'QColor\'!"', '.', 'format', '(', '"text_color"', ',', 'value', ')',...
Setter for **self.__text_color** attribute. :param value: Attribute value. :type value: int or QColor
['Setter', 'for', '**', 'self', '.', '__text_color', '**', 'attribute', '.']
train
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/delayed_QSplashScreen.py#L122-L133
2,494
mozilla-releng/scriptworker
scriptworker/ed25519.py
ed25519_public_key_to_string
def ed25519_public_key_to_string(key): """Convert an ed25519 public key to a base64-encoded string. Args: key (Ed25519PublicKey): the key to write to the file. Returns: str: the key representation as a str """ return base64.b64encode(key.public_bytes( encoding=serializatio...
python
def ed25519_public_key_to_string(key): """Convert an ed25519 public key to a base64-encoded string. Args: key (Ed25519PublicKey): the key to write to the file. Returns: str: the key representation as a str """ return base64.b64encode(key.public_bytes( encoding=serializatio...
['def', 'ed25519_public_key_to_string', '(', 'key', ')', ':', 'return', 'base64', '.', 'b64encode', '(', 'key', '.', 'public_bytes', '(', 'encoding', '=', 'serialization', '.', 'Encoding', '.', 'Raw', ',', 'format', '=', 'serialization', '.', 'PublicFormat', '.', 'Raw', ',', ')', ',', 'None', ')', '.', 'decode', '(', "...
Convert an ed25519 public key to a base64-encoded string. Args: key (Ed25519PublicKey): the key to write to the file. Returns: str: the key representation as a str
['Convert', 'an', 'ed25519', 'public', 'key', 'to', 'a', 'base64', '-', 'encoded', 'string', '.']
train
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/ed25519.py#L103-L116
2,495
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
QueryRoot.to_gremlin
def to_gremlin(self): """Return a unicode object with the Gremlin representation of this block.""" self.validate() if len(self.start_class) == 1: # The official Gremlin documentation claims that this approach # is generally faster than the one below, since it makes using ...
python
def to_gremlin(self): """Return a unicode object with the Gremlin representation of this block.""" self.validate() if len(self.start_class) == 1: # The official Gremlin documentation claims that this approach # is generally faster than the one below, since it makes using ...
['def', 'to_gremlin', '(', 'self', ')', ':', 'self', '.', 'validate', '(', ')', 'if', 'len', '(', 'self', '.', 'start_class', ')', '==', '1', ':', '# The official Gremlin documentation claims that this approach', '# is generally faster than the one below, since it makes using indexes easier.', '# http://gremlindocs.spm...
Return a unicode object with the Gremlin representation of this block.
['Return', 'a', 'unicode', 'object', 'with', 'the', 'Gremlin', 'representation', 'of', 'this', 'block', '.']
train
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L44-L55
2,496
ergoithz/browsepy
browsepy/file.py
check_forbidden_filename
def check_forbidden_filename(filename, destiny_os=os.name, restricted_names=restricted_names): ''' Get if given filename is forbidden for current OS or filesystem. :param filename: :param destiny_os: destination operative system :param fs_en...
python
def check_forbidden_filename(filename, destiny_os=os.name, restricted_names=restricted_names): ''' Get if given filename is forbidden for current OS or filesystem. :param filename: :param destiny_os: destination operative system :param fs_en...
['def', 'check_forbidden_filename', '(', 'filename', ',', 'destiny_os', '=', 'os', '.', 'name', ',', 'restricted_names', '=', 'restricted_names', ')', ':', 'return', '(', 'filename', 'in', 'restricted_names', 'or', 'destiny_os', '==', "'nt'", 'and', 'filename', '.', 'split', '(', "'.'", ',', '1', ')', '[', '0', ']', '....
Get if given filename is forbidden for current OS or filesystem. :param filename: :param destiny_os: destination operative system :param fs_encoding: destination filesystem filename encoding :return: wether is forbidden on given OS (or filesystem) or not :rtype: bool
['Get', 'if', 'given', 'filename', 'is', 'forbidden', 'for', 'current', 'OS', 'or', 'filesystem', '.']
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L828-L844
2,497
zetaops/zengine
zengine/views/task_manager_actions.py
TaskManagerActionsView.assign_yourself
def assign_yourself(self): """ Assigning the workflow to itself. The selected job is checked to see if there is an assigned role. If it does not have a role assigned to it, it takes the job to itself and displays a message that the process is successful. ...
python
def assign_yourself(self): """ Assigning the workflow to itself. The selected job is checked to see if there is an assigned role. If it does not have a role assigned to it, it takes the job to itself and displays a message that the process is successful. ...
['def', 'assign_yourself', '(', 'self', ')', ':', 'task_invitation', '=', 'TaskInvitation', '.', 'objects', '.', 'get', '(', 'self', '.', 'task_invitation_key', ')', 'wfi', '=', 'task_invitation', '.', 'instance', 'if', 'not', 'wfi', '.', 'current_actor', '.', 'exist', ':', 'wfi', '.', 'current_actor', '=', 'self', '.'...
Assigning the workflow to itself. The selected job is checked to see if there is an assigned role. If it does not have a role assigned to it, it takes the job to itself and displays a message that the process is successful. If there is a role assigned to it, it does not d...
['Assigning', 'the', 'workflow', 'to', 'itself', '.', 'The', 'selected', 'job', 'is', 'checked', 'to', 'see', 'if', 'there', 'is', 'an', 'assigned', 'role', '.', 'If', 'it', 'does', 'not', 'have', 'a', 'role', 'assigned', 'to', 'it', 'it', 'takes', 'the', 'job', 'to', 'itself', 'and', 'displays', 'a', 'message', 'that'...
train
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L29-L60
2,498
tanghaibao/jcvi
jcvi/algorithms/ec.py
eaSimpleConverge
def eaSimpleConverge(population, toolbox, cxpb, mutpb, ngen, stats=None, halloffame=None, callback=None, verbose=True): """This algorithm reproduce the simplest evolutionary algorithm as presented in chapter 7 of [Back2000]_. Modified to allow checking if there is no change for ngen, a...
python
def eaSimpleConverge(population, toolbox, cxpb, mutpb, ngen, stats=None, halloffame=None, callback=None, verbose=True): """This algorithm reproduce the simplest evolutionary algorithm as presented in chapter 7 of [Back2000]_. Modified to allow checking if there is no change for ngen, a...
['def', 'eaSimpleConverge', '(', 'population', ',', 'toolbox', ',', 'cxpb', ',', 'mutpb', ',', 'ngen', ',', 'stats', '=', 'None', ',', 'halloffame', '=', 'None', ',', 'callback', '=', 'None', ',', 'verbose', '=', 'True', ')', ':', '# Evaluate the individuals with an invalid fitness', 'invalid_ind', '=', '[', 'ind', 'fo...
This algorithm reproduce the simplest evolutionary algorithm as presented in chapter 7 of [Back2000]_. Modified to allow checking if there is no change for ngen, as a simple rule for convergence. Interface is similar to eaSimple(). However, in eaSimple, ngen is total number of iterations; in eaSimpleCo...
['This', 'algorithm', 'reproduce', 'the', 'simplest', 'evolutionary', 'algorithm', 'as', 'presented', 'in', 'chapter', '7', 'of', '[', 'Back2000', ']', '_', '.']
train
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/algorithms/ec.py#L99-L161
2,499
ThreatConnect-Inc/tcex
tcex/tcex_ti/tcex_ti.py
TcExTi.signature
def signature(self, name, file_name, file_type, file_content, owner=None, **kwargs): """ Create the Signature TI object. Args: owner: file_content: file_name: file_type: name: **kwargs: Return: """ ...
python
def signature(self, name, file_name, file_type, file_content, owner=None, **kwargs): """ Create the Signature TI object. Args: owner: file_content: file_name: file_type: name: **kwargs: Return: """ ...
['def', 'signature', '(', 'self', ',', 'name', ',', 'file_name', ',', 'file_type', ',', 'file_content', ',', 'owner', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'return', 'Signature', '(', 'self', '.', 'tcex', ',', 'name', ',', 'file_name', ',', 'file_type', ',', 'file_content', ',', 'owner', '=', 'owner', ',', '*...
Create the Signature TI object. Args: owner: file_content: file_name: file_type: name: **kwargs: Return:
['Create', 'the', 'Signature', 'TI', 'object', '.']
train
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/tcex_ti.py#L356-L371