Unnamed: 0
int64
0
10k
repository_name
stringlengths
7
54
func_path_in_repository
stringlengths
5
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
100
30.3k
language
stringclasses
1 value
func_code_string
stringlengths
100
30.3k
func_code_tokens
stringlengths
138
33.2k
func_documentation_string
stringlengths
1
15k
func_documentation_tokens
stringlengths
5
5.14k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
9,300
senaite/senaite.api
src/senaite/api/__init__.py
get_cancellation_status
def get_cancellation_status(brain_or_object, default="active"): """Get the `cancellation_state` of an object :param brain_or_object: A single catalog brain or content object :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain :returns: Value of the review_status variable :rtype: ...
python
def get_cancellation_status(brain_or_object, default="active"): """Get the `cancellation_state` of an object :param brain_or_object: A single catalog brain or content object :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain :returns: Value of the review_status variable :rtype: ...
['def', 'get_cancellation_status', '(', 'brain_or_object', ',', 'default', '=', '"active"', ')', ':', 'if', 'is_brain', '(', 'brain_or_object', ')', ':', 'return', 'getattr', '(', 'brain_or_object', ',', '"cancellation_state"', ',', 'default', ')', 'workflows', '=', 'get_workflows_for', '(', 'brain_or_object', ')', 'if...
Get the `cancellation_state` of an object :param brain_or_object: A single catalog brain or content object :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain :returns: Value of the review_status variable :rtype: String
['Get', 'the', 'cancellation_state', 'of', 'an', 'object']
train
https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L759-L772
9,301
guaix-ucm/pyemir
emirdrp/processing/bardetect.py
overlap
def overlap(intv1, intv2): """Overlaping of two intervals""" return max(0, min(intv1[1], intv2[1]) - max(intv1[0], intv2[0]))
python
def overlap(intv1, intv2): """Overlaping of two intervals""" return max(0, min(intv1[1], intv2[1]) - max(intv1[0], intv2[0]))
['def', 'overlap', '(', 'intv1', ',', 'intv2', ')', ':', 'return', 'max', '(', '0', ',', 'min', '(', 'intv1', '[', '1', ']', ',', 'intv2', '[', '1', ']', ')', '-', 'max', '(', 'intv1', '[', '0', ']', ',', 'intv2', '[', '0', ']', ')', ')']
Overlaping of two intervals
['Overlaping', 'of', 'two', 'intervals']
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L430-L432
9,302
piglei/uwsgi-sloth
uwsgi_sloth/tailer.py
Tailer.follow
def follow(self, delay=1.0): """\ Iterator generator that returns lines as data is added to the file. Based on: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035 """ # TODO: Handle log file rotation self.trailing = True unchanged_stats = 0 ...
python
def follow(self, delay=1.0): """\ Iterator generator that returns lines as data is added to the file. Based on: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035 """ # TODO: Handle log file rotation self.trailing = True unchanged_stats = 0 ...
['def', 'follow', '(', 'self', ',', 'delay', '=', '1.0', ')', ':', '# TODO: Handle log file rotation', 'self', '.', 'trailing', '=', 'True', 'unchanged_stats', '=', '0', 'while', 'not', 'self', '.', 'should_stop_follow', ':', 'where', '=', 'self', '.', 'file', '.', 'tell', '(', ')', 'line', '=', 'self', '.', 'file', '....
\ Iterator generator that returns lines as data is added to the file. Based on: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157035
['\\', 'Iterator', 'generator', 'that', 'returns', 'lines', 'as', 'data', 'is', 'added', 'to', 'the', 'file', '.']
train
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/tailer.py#L167-L207
9,303
exxeleron/qPython
qpython/qconnection.py
QConnection.receive
def receive(self, data_only = True, **options): '''Reads and (optionally) parses the response from a q service. Retrieves query result along with meta-information: >>> q.query(qconnection.MessageType.SYNC,'{x}', 10) >>> print(q.receive(data_only = False, raw = F...
python
def receive(self, data_only = True, **options): '''Reads and (optionally) parses the response from a q service. Retrieves query result along with meta-information: >>> q.query(qconnection.MessageType.SYNC,'{x}', 10) >>> print(q.receive(data_only = False, raw = F...
['def', 'receive', '(', 'self', ',', 'data_only', '=', 'True', ',', '*', '*', 'options', ')', ':', 'result', '=', 'self', '.', '_reader', '.', 'read', '(', '*', '*', 'self', '.', '_options', '.', 'union_dict', '(', '*', '*', 'options', ')', ')', 'return', 'result', '.', 'data', 'if', 'data_only', 'else', 'result']
Reads and (optionally) parses the response from a q service. Retrieves query result along with meta-information: >>> q.query(qconnection.MessageType.SYNC,'{x}', 10) >>> print(q.receive(data_only = False, raw = False)) QMessage: message type: 2, data size: 13...
['Reads', 'and', '(', 'optionally', ')', 'parses', 'the', 'response', 'from', 'a', 'q', 'service', '.', 'Retrieves', 'query', 'result', 'along', 'with', 'meta', '-', 'information', ':', '>>>', 'q', '.', 'query', '(', 'qconnection', '.', 'MessageType', '.', 'SYNC', '{', 'x', '}', '10', ')', '>>>', 'print', '(', 'q', '.'...
train
https://github.com/exxeleron/qPython/blob/7e64a28b1e8814a8d6b9217ce79bb8de546e62f3/qpython/qconnection.py#L341-L381
9,304
CityOfZion/neo-python-core
neocore/IO/BinaryReader.py
BinaryReader.ReadByte
def ReadByte(self, do_ord=True): """ Read a single byte. Args: do_ord (bool): (default True) convert the byte to an ordinal first. Returns: bytes: a single byte if successful. 0 (int) if an exception occurred. """ try: if do_ord: ...
python
def ReadByte(self, do_ord=True): """ Read a single byte. Args: do_ord (bool): (default True) convert the byte to an ordinal first. Returns: bytes: a single byte if successful. 0 (int) if an exception occurred. """ try: if do_ord: ...
['def', 'ReadByte', '(', 'self', ',', 'do_ord', '=', 'True', ')', ':', 'try', ':', 'if', 'do_ord', ':', 'return', 'ord', '(', 'self', '.', 'stream', '.', 'read', '(', '1', ')', ')', 'return', 'self', '.', 'stream', '.', 'read', '(', '1', ')', 'except', 'Exception', 'as', 'e', ':', 'logger', '.', 'error', '(', '"ord exp...
Read a single byte. Args: do_ord (bool): (default True) convert the byte to an ordinal first. Returns: bytes: a single byte if successful. 0 (int) if an exception occurred.
['Read', 'a', 'single', 'byte', '.']
train
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryReader.py#L46-L62
9,305
Shinichi-Nakagawa/pitchpx
pitchpx/mlbam.py
MlbAm.scrape
def scrape(cls, start, end, output): """ Scrape a MLBAM Data :param start: Start Day(YYYYMMDD) :param end: End Day(YYYYMMDD) :param output: Output directory """ # Logger setting logging.basicConfig( level=logging.INFO, format="time:...
python
def scrape(cls, start, end, output): """ Scrape a MLBAM Data :param start: Start Day(YYYYMMDD) :param end: End Day(YYYYMMDD) :param output: Output directory """ # Logger setting logging.basicConfig( level=logging.INFO, format="time:...
['def', 'scrape', '(', 'cls', ',', 'start', ',', 'end', ',', 'output', ')', ':', '# Logger setting', 'logging', '.', 'basicConfig', '(', 'level', '=', 'logging', '.', 'INFO', ',', 'format', '=', '"time:%(asctime)s.%(msecs)03d"', '+', '"\\tmessage:%(message)s"', ',', 'datefmt', '=', '"%Y-%m-%d %H:%M:%S"', ')', '# valida...
Scrape a MLBAM Data :param start: Start Day(YYYYMMDD) :param end: End Day(YYYYMMDD) :param output: Output directory
['Scrape', 'a', 'MLBAM', 'Data', ':', 'param', 'start', ':', 'Start', 'Day', '(', 'YYYYMMDD', ')', ':', 'param', 'end', ':', 'End', 'Day', '(', 'YYYYMMDD', ')', ':', 'param', 'output', ':', 'Output', 'directory']
train
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/mlbam.py#L186-L212
9,306
proycon/clam
clam/common/data.py
InputTemplate.json
def json(self): """Produce a JSON representation for the web interface""" d = { 'id': self.id, 'format': self.formatclass.__name__,'label': self.label, 'mimetype': self.formatclass.mimetype, 'schema': self.formatclass.schema } if self.unique: d['unique'] = True if self.filen...
python
def json(self): """Produce a JSON representation for the web interface""" d = { 'id': self.id, 'format': self.formatclass.__name__,'label': self.label, 'mimetype': self.formatclass.mimetype, 'schema': self.formatclass.schema } if self.unique: d['unique'] = True if self.filen...
['def', 'json', '(', 'self', ')', ':', 'd', '=', '{', "'id'", ':', 'self', '.', 'id', ',', "'format'", ':', 'self', '.', 'formatclass', '.', '__name__', ',', "'label'", ':', 'self', '.', 'label', ',', "'mimetype'", ':', 'self', '.', 'formatclass', '.', 'mimetype', ',', "'schema'", ':', 'self', '.', 'formatclass', '.', ...
Produce a JSON representation for the web interface
['Produce', 'a', 'JSON', 'representation', 'for', 'the', 'web', 'interface']
train
https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/common/data.py#L1524-L1545
9,307
ponty/psidialogs
psidialogs/__init__.py
ask_folder
def ask_folder(message='Select folder.', default='', title=''): """ A dialog to get a directory name. Returns the name of a directory, or None if user chose to cancel. If the "default" argument specifies a directory name, and that directory exists, then the dialog box will start with that directory....
python
def ask_folder(message='Select folder.', default='', title=''): """ A dialog to get a directory name. Returns the name of a directory, or None if user chose to cancel. If the "default" argument specifies a directory name, and that directory exists, then the dialog box will start with that directory....
['def', 'ask_folder', '(', 'message', '=', "'Select folder.'", ',', 'default', '=', "''", ',', 'title', '=', "''", ')', ':', 'return', 'backend_api', '.', 'opendialog', '(', '"ask_folder"', ',', 'dict', '(', 'message', '=', 'message', ',', 'default', '=', 'default', ',', 'title', '=', 'title', ')', ')']
A dialog to get a directory name. Returns the name of a directory, or None if user chose to cancel. If the "default" argument specifies a directory name, and that directory exists, then the dialog box will start with that directory. :param message: message to be displayed. :param title: window titl...
['A', 'dialog', 'to', 'get', 'a', 'directory', 'name', '.', 'Returns', 'the', 'name', 'of', 'a', 'directory', 'or', 'None', 'if', 'user', 'chose', 'to', 'cancel', '.', 'If', 'the', 'default', 'argument', 'specifies', 'a', 'directory', 'name', 'and', 'that', 'directory', 'exists', 'then', 'the', 'dialog', 'box', 'will',...
train
https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L101-L113
9,308
llllllllll/codetransformer
codetransformer/utils/pretty.py
walk_code
def walk_code(co, _prefix=''): """ Traverse a code object, finding all consts which are also code objects. Yields pairs of (name, code object). """ name = _prefix + co.co_name yield name, co yield from chain.from_iterable( walk_code(c, _prefix=_extend_name(name, co)) for c i...
python
def walk_code(co, _prefix=''): """ Traverse a code object, finding all consts which are also code objects. Yields pairs of (name, code object). """ name = _prefix + co.co_name yield name, co yield from chain.from_iterable( walk_code(c, _prefix=_extend_name(name, co)) for c i...
['def', 'walk_code', '(', 'co', ',', '_prefix', '=', "''", ')', ':', 'name', '=', '_prefix', '+', 'co', '.', 'co_name', 'yield', 'name', ',', 'co', 'yield', 'from', 'chain', '.', 'from_iterable', '(', 'walk_code', '(', 'c', ',', '_prefix', '=', '_extend_name', '(', 'name', ',', 'co', ')', ')', 'for', 'c', 'in', 'co', '...
Traverse a code object, finding all consts which are also code objects. Yields pairs of (name, code object).
['Traverse', 'a', 'code', 'object', 'finding', 'all', 'consts', 'which', 'are', 'also', 'code', 'objects', '.']
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/utils/pretty.py#L149-L161
9,309
DataBiosphere/toil
src/toil/resource.py
ModuleDescriptor._resourcePath
def _resourcePath(self): """ The path to the directory that should be used when shipping this module and its siblings around as a resource. """ if self.fromVirtualEnv: return self.dirPath elif '.' in self.name: return os.path.join(self.dirPath, sel...
python
def _resourcePath(self): """ The path to the directory that should be used when shipping this module and its siblings around as a resource. """ if self.fromVirtualEnv: return self.dirPath elif '.' in self.name: return os.path.join(self.dirPath, sel...
['def', '_resourcePath', '(', 'self', ')', ':', 'if', 'self', '.', 'fromVirtualEnv', ':', 'return', 'self', '.', 'dirPath', 'elif', "'.'", 'in', 'self', '.', 'name', ':', 'return', 'os', '.', 'path', '.', 'join', '(', 'self', '.', 'dirPath', ',', 'self', '.', '_rootPackage', '(', ')', ')', 'else', ':', 'initName', '=',...
The path to the directory that should be used when shipping this module and its siblings around as a resource.
['The', 'path', 'to', 'the', 'directory', 'that', 'should', 'be', 'used', 'when', 'shipping', 'this', 'module', 'and', 'its', 'siblings', 'around', 'as', 'a', 'resource', '.']
train
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/resource.py#L543-L560
9,310
iotile/coretools
iotilecore/iotile/core/hw/update/records/reflash_tile.py
_parse_target
def _parse_target(target): """Parse a binary targeting information structure. This function only supports extracting the slot number or controller from the target and will raise an ArgumentError if more complicated targeting is desired. Args: target (bytes): The binary targeting data blob....
python
def _parse_target(target): """Parse a binary targeting information structure. This function only supports extracting the slot number or controller from the target and will raise an ArgumentError if more complicated targeting is desired. Args: target (bytes): The binary targeting data blob....
['def', '_parse_target', '(', 'target', ')', ':', 'if', 'len', '(', 'target', ')', '!=', '8', ':', 'raise', 'ArgumentError', '(', '"Invalid targeting data length"', ',', 'expected', '=', '8', ',', 'length', '=', 'len', '(', 'target', ')', ')', 'slot', ',', 'match_op', '=', 'struct', '.', 'unpack', '(', '"<B6xB"', ',', ...
Parse a binary targeting information structure. This function only supports extracting the slot number or controller from the target and will raise an ArgumentError if more complicated targeting is desired. Args: target (bytes): The binary targeting data blob. Returns: dict: The p...
['Parse', 'a', 'binary', 'targeting', 'information', 'structure', '.']
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/update/records/reflash_tile.py#L165-L188
9,311
danilobellini/audiolazy
audiolazy/lazy_stream.py
Streamix.add
def add(self, delta, data): """ Adds (enqueues) an iterable event to the mixer. Parameters ---------- delta : Time in samples since last added event. This can be zero and can be float. Use "s" object from sHz for time conversion. data : Iterable (e.g. a list, a tuple, a Stream...
python
def add(self, delta, data): """ Adds (enqueues) an iterable event to the mixer. Parameters ---------- delta : Time in samples since last added event. This can be zero and can be float. Use "s" object from sHz for time conversion. data : Iterable (e.g. a list, a tuple, a Stream...
['def', 'add', '(', 'self', ',', 'delta', ',', 'data', ')', ':', 'if', 'delta', '<', '0', ':', 'raise', 'ValueError', '(', '"Delta time should be always positive"', ')', 'self', '.', '_not_playing', '.', 'append', '(', '(', 'delta', ',', 'iter', '(', 'data', ')', ')', ')']
Adds (enqueues) an iterable event to the mixer. Parameters ---------- delta : Time in samples since last added event. This can be zero and can be float. Use "s" object from sHz for time conversion. data : Iterable (e.g. a list, a tuple, a Stream) to be "played" by the mixer at t...
['Adds', '(', 'enqueues', ')', 'an', 'iterable', 'event', 'to', 'the', 'mixer', '.']
train
https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_stream.py#L720-L742
9,312
laginha/django-mobileesp
src/django_mobileesp/mdetect.py
UAgentInfo.detectMeegoPhone
def detectMeegoPhone(self): """Return detection of a Meego phone Detects a phone running the Meego OS. """ return UAgentInfo.deviceMeego in self.__userAgent \ and UAgentInfo.mobi in self.__userAgent
python
def detectMeegoPhone(self): """Return detection of a Meego phone Detects a phone running the Meego OS. """ return UAgentInfo.deviceMeego in self.__userAgent \ and UAgentInfo.mobi in self.__userAgent
['def', 'detectMeegoPhone', '(', 'self', ')', ':', 'return', 'UAgentInfo', '.', 'deviceMeego', 'in', 'self', '.', '__userAgent', 'and', 'UAgentInfo', '.', 'mobi', 'in', 'self', '.', '__userAgent']
Return detection of a Meego phone Detects a phone running the Meego OS.
['Return', 'detection', 'of', 'a', 'Meego', 'phone']
train
https://github.com/laginha/django-mobileesp/blob/91d4babb2343b992970bdb076508d380680c8b7e/src/django_mobileesp/mdetect.py#L626-L632
9,313
monim67/django-bootstrap-datepicker-plus
bootstrap_datepicker_plus/_helpers.py
get_base_input
def get_base_input(test=False): """ Return DateTimeBaseInput class from django.forms.widgets module Return _compatibility.DateTimeBaseInput class for older django versions. """ from django.forms.widgets import DateTimeBaseInput if 'get_context' in dir(DateTimeBaseInput) and not test: # ...
python
def get_base_input(test=False): """ Return DateTimeBaseInput class from django.forms.widgets module Return _compatibility.DateTimeBaseInput class for older django versions. """ from django.forms.widgets import DateTimeBaseInput if 'get_context' in dir(DateTimeBaseInput) and not test: # ...
['def', 'get_base_input', '(', 'test', '=', 'False', ')', ':', 'from', 'django', '.', 'forms', '.', 'widgets', 'import', 'DateTimeBaseInput', 'if', "'get_context'", 'in', 'dir', '(', 'DateTimeBaseInput', ')', 'and', 'not', 'test', ':', '# django version 1.11 and above', 'base_input', '=', 'DateTimeBaseInput', 'else', '...
Return DateTimeBaseInput class from django.forms.widgets module Return _compatibility.DateTimeBaseInput class for older django versions.
['Return', 'DateTimeBaseInput', 'class', 'from', 'django', '.', 'forms', '.', 'widgets', 'module']
train
https://github.com/monim67/django-bootstrap-datepicker-plus/blob/55819bf12507c98dba91c702e224afd9bae3ef9a/bootstrap_datepicker_plus/_helpers.py#L4-L20
9,314
inveniosoftware/invenio-records-rest
invenio_records_rest/schemas/fields/datetime.py
DateString._serialize
def _serialize(self, value, attr, obj): """Serialize an ISO8601-formatted date.""" try: return super(DateString, self)._serialize( arrow.get(value).date(), attr, obj) except ParserError: return missing
python
def _serialize(self, value, attr, obj): """Serialize an ISO8601-formatted date.""" try: return super(DateString, self)._serialize( arrow.get(value).date(), attr, obj) except ParserError: return missing
['def', '_serialize', '(', 'self', ',', 'value', ',', 'attr', ',', 'obj', ')', ':', 'try', ':', 'return', 'super', '(', 'DateString', ',', 'self', ')', '.', '_serialize', '(', 'arrow', '.', 'get', '(', 'value', ')', '.', 'date', '(', ')', ',', 'attr', ',', 'obj', ')', 'except', 'ParserError', ':', 'return', 'missing']
Serialize an ISO8601-formatted date.
['Serialize', 'an', 'ISO8601', '-', 'formatted', 'date', '.']
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/schemas/fields/datetime.py#L21-L27
9,315
mabuchilab/QNET
src/qnet/utils/properties_for_args.py
properties_for_args
def properties_for_args(cls, arg_names='_arg_names'): """For a class with an attribute `arg_names` containing a list of names, add a property for every name in that list. It is assumed that there is an instance attribute ``self._<arg_name>``, which is returned by the `arg_name` property. The decorator...
python
def properties_for_args(cls, arg_names='_arg_names'): """For a class with an attribute `arg_names` containing a list of names, add a property for every name in that list. It is assumed that there is an instance attribute ``self._<arg_name>``, which is returned by the `arg_name` property. The decorator...
['def', 'properties_for_args', '(', 'cls', ',', 'arg_names', '=', "'_arg_names'", ')', ':', 'from', 'qnet', '.', 'algebra', '.', 'core', '.', 'scalar_algebra', 'import', 'Scalar', 'scalar_args', '=', 'False', 'if', 'hasattr', '(', 'cls', ',', "'_scalar_args'", ')', ':', 'scalar_args', '=', 'cls', '.', '_scalar_args', '...
For a class with an attribute `arg_names` containing a list of names, add a property for every name in that list. It is assumed that there is an instance attribute ``self._<arg_name>``, which is returned by the `arg_name` property. The decorator also adds a class attribute :attr:`_has_properties_for_a...
['For', 'a', 'class', 'with', 'an', 'attribute', 'arg_names', 'containing', 'a', 'list', 'of', 'names', 'add', 'a', 'property', 'for', 'every', 'name', 'in', 'that', 'list', '.']
train
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/utils/properties_for_args.py#L8-L36
9,316
erijo/tellcore-py
tellcore/telldus.py
Device.set_parameter
def set_parameter(self, name, value): """Set a parameter.""" self.lib.tdSetDeviceParameter(self.id, name, str(value))
python
def set_parameter(self, name, value): """Set a parameter.""" self.lib.tdSetDeviceParameter(self.id, name, str(value))
['def', 'set_parameter', '(', 'self', ',', 'name', ',', 'value', ')', ':', 'self', '.', 'lib', '.', 'tdSetDeviceParameter', '(', 'self', '.', 'id', ',', 'name', ',', 'str', '(', 'value', ')', ')']
Set a parameter.
['Set', 'a', 'parameter', '.']
train
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L341-L343
9,317
BlueBrain/NeuroM
neurom/io/datawrapper.py
DataWrapper.soma_points
def soma_points(self): '''Get the soma points''' db = self.data_block return db[db[:, COLS.TYPE] == POINT_TYPE.SOMA]
python
def soma_points(self): '''Get the soma points''' db = self.data_block return db[db[:, COLS.TYPE] == POINT_TYPE.SOMA]
['def', 'soma_points', '(', 'self', ')', ':', 'db', '=', 'self', '.', 'data_block', 'return', 'db', '[', 'db', '[', ':', ',', 'COLS', '.', 'TYPE', ']', '==', 'POINT_TYPE', '.', 'SOMA', ']']
Get the soma points
['Get', 'the', 'soma', 'points']
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L83-L86
9,318
SCIP-Interfaces/PySCIPOpt
examples/finished/read_tsplib.py
read_atsplib
def read_atsplib(filename): "basic function for reading a ATSP problem on the TSPLIB format" "NOTE: only works for explicit matrices" if filename[-3:] == ".gz": f = gzip.open(filename, 'r') data = f.readlines() else: f = open(filename, 'r') data = f.readlines() for ...
python
def read_atsplib(filename): "basic function for reading a ATSP problem on the TSPLIB format" "NOTE: only works for explicit matrices" if filename[-3:] == ".gz": f = gzip.open(filename, 'r') data = f.readlines() else: f = open(filename, 'r') data = f.readlines() for ...
['def', 'read_atsplib', '(', 'filename', ')', ':', '"NOTE: only works for explicit matrices"', 'if', 'filename', '[', '-', '3', ':', ']', '==', '".gz"', ':', 'f', '=', 'gzip', '.', 'open', '(', 'filename', ',', "'r'", ')', 'data', '=', 'f', '.', 'readlines', '(', ')', 'else', ':', 'f', '=', 'open', '(', 'filename', ','...
basic function for reading a ATSP problem on the TSPLIB format
['basic', 'function', 'for', 'reading', 'a', 'ATSP', 'problem', 'on', 'the', 'TSPLIB', 'format']
train
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/read_tsplib.py#L216-L262
9,319
MolSSI-BSE/basis_set_exchange
basis_set_exchange/curate/compare.py
_reldiff
def _reldiff(a, b): """ Computes the relative difference of two floating-point numbers rel = abs(a-b)/min(abs(a), abs(b)) If a == 0 and b == 0, then 0.0 is returned Otherwise if a or b is 0.0, inf is returned. """ a = float(a) b = float(b) aa = abs(a) ba = abs(b) if a == ...
python
def _reldiff(a, b): """ Computes the relative difference of two floating-point numbers rel = abs(a-b)/min(abs(a), abs(b)) If a == 0 and b == 0, then 0.0 is returned Otherwise if a or b is 0.0, inf is returned. """ a = float(a) b = float(b) aa = abs(a) ba = abs(b) if a == ...
['def', '_reldiff', '(', 'a', ',', 'b', ')', ':', 'a', '=', 'float', '(', 'a', ')', 'b', '=', 'float', '(', 'b', ')', 'aa', '=', 'abs', '(', 'a', ')', 'ba', '=', 'abs', '(', 'b', ')', 'if', 'a', '==', '0.0', 'and', 'b', '==', '0.0', ':', 'return', '0.0', 'elif', 'a', '==', '0', 'or', 'b', '==', '0.0', ':', 'return', 'f...
Computes the relative difference of two floating-point numbers rel = abs(a-b)/min(abs(a), abs(b)) If a == 0 and b == 0, then 0.0 is returned Otherwise if a or b is 0.0, inf is returned.
['Computes', 'the', 'relative', 'difference', 'of', 'two', 'floating', '-', 'point', 'numbers']
train
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/curate/compare.py#L9-L29
9,320
ucsb-cs-education/hairball
hairball/plugins/__init__.py
HairballPlugin.get_broadcast_events
def get_broadcast_events(cls, script): """Return a Counter of event-names that were broadcast. The Count will contain the key True if any of the broadcast blocks contain a parameter that is a variable. """ events = Counter() for name, _, block in cls.iter_blocks(script)...
python
def get_broadcast_events(cls, script): """Return a Counter of event-names that were broadcast. The Count will contain the key True if any of the broadcast blocks contain a parameter that is a variable. """ events = Counter() for name, _, block in cls.iter_blocks(script)...
['def', 'get_broadcast_events', '(', 'cls', ',', 'script', ')', ':', 'events', '=', 'Counter', '(', ')', 'for', 'name', ',', '_', ',', 'block', 'in', 'cls', '.', 'iter_blocks', '(', 'script', ')', ':', 'if', "'broadcast %s'", 'in', 'name', ':', 'if', 'isinstance', '(', 'block', '.', 'args', '[', '0', ']', ',', 'kurt', ...
Return a Counter of event-names that were broadcast. The Count will contain the key True if any of the broadcast blocks contain a parameter that is a variable.
['Return', 'a', 'Counter', 'of', 'event', '-', 'names', 'that', 'were', 'broadcast', '.']
train
https://github.com/ucsb-cs-education/hairball/blob/c6da8971f8a34e88ce401d36b51431715e1dff5b/hairball/plugins/__init__.py#L120-L134
9,321
yjzhang/uncurl_python
uncurl/nb_clustering.py
log_ncr
def log_ncr(a, b): """ Returns log(nCr(a,b)), given that b<a. Does not assume that a and b are integers (uses log-gamma). """ val = gammaln(a+1) - gammaln(a-b+1) - gammaln(b+1) return val
python
def log_ncr(a, b): """ Returns log(nCr(a,b)), given that b<a. Does not assume that a and b are integers (uses log-gamma). """ val = gammaln(a+1) - gammaln(a-b+1) - gammaln(b+1) return val
['def', 'log_ncr', '(', 'a', ',', 'b', ')', ':', 'val', '=', 'gammaln', '(', 'a', '+', '1', ')', '-', 'gammaln', '(', 'a', '-', 'b', '+', '1', ')', '-', 'gammaln', '(', 'b', '+', '1', ')', 'return', 'val']
Returns log(nCr(a,b)), given that b<a. Does not assume that a and b are integers (uses log-gamma).
['Returns', 'log', '(', 'nCr', '(', 'a', 'b', '))', 'given', 'that', 'b<a', '.', 'Does', 'not', 'assume', 'that', 'a', 'and', 'b', 'are', 'integers', '(', 'uses', 'log', '-', 'gamma', ')', '.']
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L22-L28
9,322
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/service_hooks/service_hooks_client.py
ServiceHooksClient.list_subscriptions
def list_subscriptions(self, publisher_id=None, event_type=None, consumer_id=None, consumer_action_id=None): """ListSubscriptions. Get a list of subscriptions. :param str publisher_id: ID for a subscription. :param str event_type: Maximum number of notifications to return. Default is 100...
python
def list_subscriptions(self, publisher_id=None, event_type=None, consumer_id=None, consumer_action_id=None): """ListSubscriptions. Get a list of subscriptions. :param str publisher_id: ID for a subscription. :param str event_type: Maximum number of notifications to return. Default is 100...
['def', 'list_subscriptions', '(', 'self', ',', 'publisher_id', '=', 'None', ',', 'event_type', '=', 'None', ',', 'consumer_id', '=', 'None', ',', 'consumer_action_id', '=', 'None', ')', ':', 'query_parameters', '=', '{', '}', 'if', 'publisher_id', 'is', 'not', 'None', ':', 'query_parameters', '[', "'publisherId'", ']'...
ListSubscriptions. Get a list of subscriptions. :param str publisher_id: ID for a subscription. :param str event_type: Maximum number of notifications to return. Default is 100. :param str consumer_id: ID for a consumer. :param str consumer_action_id: ID for a consumerActionId. ...
['ListSubscriptions', '.', 'Get', 'a', 'list', 'of', 'subscriptions', '.', ':', 'param', 'str', 'publisher_id', ':', 'ID', 'for', 'a', 'subscription', '.', ':', 'param', 'str', 'event_type', ':', 'Maximum', 'number', 'of', 'notifications', 'to', 'return', '.', 'Default', 'is', '100', '.', ':', 'param', 'str', 'consumer...
train
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/service_hooks/service_hooks_client.py#L325-L347
9,323
pywbem/pywbem
pywbem/cim_operations.py
WBEMConnection.IterReferenceInstancePaths
def IterReferenceInstancePaths(self, InstanceName, ResultClass=None, Role=None, FilterQueryLanguage=None, FilterQuery=None, OperationTimeout=None, ContinueOnError=None, MaxObjectCo...
python
def IterReferenceInstancePaths(self, InstanceName, ResultClass=None, Role=None, FilterQueryLanguage=None, FilterQuery=None, OperationTimeout=None, ContinueOnError=None, MaxObjectCo...
['def', 'IterReferenceInstancePaths', '(', 'self', ',', 'InstanceName', ',', 'ResultClass', '=', 'None', ',', 'Role', '=', 'None', ',', 'FilterQueryLanguage', '=', 'None', ',', 'FilterQuery', '=', 'None', ',', 'OperationTimeout', '=', 'None', ',', 'ContinueOnError', '=', 'None', ',', 'MaxObjectCount', '=', 'DEFAULT_ITE...
Retrieve the instance paths of the association instances that reference a source instance, using the Python :term:`py:generator` idiom to return the result. *New in pywbem 0.10 as experimental and finalized in 0.12.* This method uses the corresponding pull operations if supported by th...
['Retrieve', 'the', 'instance', 'paths', 'of', 'the', 'association', 'instances', 'that', 'reference', 'a', 'source', 'instance', 'using', 'the', 'Python', ':', 'term', ':', 'py', ':', 'generator', 'idiom', 'to', 'return', 'the', 'result', '.']
train
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_operations.py#L5768-L6026
9,324
FNNDSC/pfmisc
pfmisc/C_snode.py
C_snode.printPre
def printPre(self, *args): """ get/set the str_pre string. """ if len(args): self.b_printPre = args[0] else: return self.b_printPre
python
def printPre(self, *args): """ get/set the str_pre string. """ if len(args): self.b_printPre = args[0] else: return self.b_printPre
['def', 'printPre', '(', 'self', ',', '*', 'args', ')', ':', 'if', 'len', '(', 'args', ')', ':', 'self', '.', 'b_printPre', '=', 'args', '[', '0', ']', 'else', ':', 'return', 'self', '.', 'b_printPre']
get/set the str_pre string.
['get', '/', 'set', 'the', 'str_pre', 'string', '.']
train
https://github.com/FNNDSC/pfmisc/blob/960b4d6135fcc50bed0a8e55db2ab1ddad9b99d8/pfmisc/C_snode.py#L222-L229
9,325
iotile/coretools
transport_plugins/native_ble/iotile_transport_native_ble/virtual_ble.py
NativeBLEVirtualInterface._send_rpc_response
def _send_rpc_response(self, *packets): """Send an RPC response. It is executed in the baBLE working thread: should not be blocking. The RPC response is notified in one or two packets depending on whether or not response data is included. If there is a temporary error sending one of the...
python
def _send_rpc_response(self, *packets): """Send an RPC response. It is executed in the baBLE working thread: should not be blocking. The RPC response is notified in one or two packets depending on whether or not response data is included. If there is a temporary error sending one of the...
['def', '_send_rpc_response', '(', 'self', ',', '*', 'packets', ')', ':', 'if', 'len', '(', 'packets', ')', '==', '0', ':', 'return', 'handle', ',', 'payload', '=', 'packets', '[', '0', ']', 'try', ':', 'self', '.', '_send_notification', '(', 'handle', ',', 'payload', ')', 'except', 'bable_interface', '.', 'BaBLEExcept...
Send an RPC response. It is executed in the baBLE working thread: should not be blocking. The RPC response is notified in one or two packets depending on whether or not response data is included. If there is a temporary error sending one of the packets it is retried automatically. If th...
['Send', 'an', 'RPC', 'response', '.', 'It', 'is', 'executed', 'in', 'the', 'baBLE', 'working', 'thread', ':', 'should', 'not', 'be', 'blocking', '.']
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/native_ble/iotile_transport_native_ble/virtual_ble.py#L416-L444
9,326
alephdata/memorious
memorious/logic/check.py
ContextCheck.match_regexp
def match_regexp(self, value, q, strict=False): """if value matches a regexp q""" value = stringify(value) mr = re.compile(q) if value is not None: if mr.match(value): return self.shout('%r not matching the regexp %r', strict, value, q)
python
def match_regexp(self, value, q, strict=False): """if value matches a regexp q""" value = stringify(value) mr = re.compile(q) if value is not None: if mr.match(value): return self.shout('%r not matching the regexp %r', strict, value, q)
['def', 'match_regexp', '(', 'self', ',', 'value', ',', 'q', ',', 'strict', '=', 'False', ')', ':', 'value', '=', 'stringify', '(', 'value', ')', 'mr', '=', 're', '.', 'compile', '(', 'q', ')', 'if', 'value', 'is', 'not', 'None', ':', 'if', 'mr', '.', 'match', '(', 'value', ')', ':', 'return', 'self', '.', 'shout', '('...
if value matches a regexp q
['if', 'value', 'matches', 'a', 'regexp', 'q']
train
https://github.com/alephdata/memorious/blob/b4033c5064447ed5f696f9c2bbbc6c12062d2fa4/memorious/logic/check.py#L51-L58
9,327
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient.write_single_register
def write_single_register(self, reg_addr, reg_value): """Modbus function WRITE_SINGLE_REGISTER (0x06) :param reg_addr: register address (0 to 65535) :type reg_addr: int :param reg_value: register value to write :type reg_value: int :returns: True if write ok or None if f...
python
def write_single_register(self, reg_addr, reg_value): """Modbus function WRITE_SINGLE_REGISTER (0x06) :param reg_addr: register address (0 to 65535) :type reg_addr: int :param reg_value: register value to write :type reg_value: int :returns: True if write ok or None if f...
['def', 'write_single_register', '(', 'self', ',', 'reg_addr', ',', 'reg_value', ')', ':', '# check params', 'if', 'not', '(', '0', '<=', 'int', '(', 'reg_addr', ')', '<=', '65535', ')', ':', 'self', '.', '__debug_msg', '(', "'write_single_register(): reg_addr out of range'", ')', 'return', 'None', 'if', 'not', '(', '0...
Modbus function WRITE_SINGLE_REGISTER (0x06) :param reg_addr: register address (0 to 65535) :type reg_addr: int :param reg_value: register value to write :type reg_value: int :returns: True if write ok or None if fail :rtype: bool or None
['Modbus', 'function', 'WRITE_SINGLE_REGISTER', '(', '0x06', ')']
train
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L577-L617
9,328
pydata/xarray
xarray/core/utils.py
decode_numpy_dict_values
def decode_numpy_dict_values(attrs: Mapping[K, V]) -> Dict[K, V]: """Convert attribute values from numpy objects to native Python objects, for use in to_dict """ attrs = dict(attrs) for k, v in attrs.items(): if isinstance(v, np.ndarray): attrs[k] = v.tolist() elif isinst...
python
def decode_numpy_dict_values(attrs: Mapping[K, V]) -> Dict[K, V]: """Convert attribute values from numpy objects to native Python objects, for use in to_dict """ attrs = dict(attrs) for k, v in attrs.items(): if isinstance(v, np.ndarray): attrs[k] = v.tolist() elif isinst...
['def', 'decode_numpy_dict_values', '(', 'attrs', ':', 'Mapping', '[', 'K', ',', 'V', ']', ')', '->', 'Dict', '[', 'K', ',', 'V', ']', ':', 'attrs', '=', 'dict', '(', 'attrs', ')', 'for', 'k', ',', 'v', 'in', 'attrs', '.', 'items', '(', ')', ':', 'if', 'isinstance', '(', 'v', ',', 'np', '.', 'ndarray', ')', ':', 'attrs...
Convert attribute values from numpy objects to native Python objects, for use in to_dict
['Convert', 'attribute', 'values', 'from', 'numpy', 'objects', 'to', 'native', 'Python', 'objects', 'for', 'use', 'in', 'to_dict']
train
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L538-L548
9,329
Spinmob/spinmob
_pylab_colormap.py
colormap.set_image
def set_image(self, image='auto'): """ Set which pylab image to tweak. """ if image=="auto": image = _pylab.gca().images[0] self._image=image self.update_image()
python
def set_image(self, image='auto'): """ Set which pylab image to tweak. """ if image=="auto": image = _pylab.gca().images[0] self._image=image self.update_image()
['def', 'set_image', '(', 'self', ',', 'image', '=', "'auto'", ')', ':', 'if', 'image', '==', '"auto"', ':', 'image', '=', '_pylab', '.', 'gca', '(', ')', '.', 'images', '[', '0', ']', 'self', '.', '_image', '=', 'image', 'self', '.', 'update_image', '(', ')']
Set which pylab image to tweak.
['Set', 'which', 'pylab', 'image', 'to', 'tweak', '.']
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L154-L160
9,330
mosdef-hub/mbuild
mbuild/lib/recipes/tiled_compound.py
TiledCompound._add_tile
def _add_tile(self, new_tile, ijk): """Add a tile with a label indicating its tiling position. """ tile_label = "{0}_{1}".format(self.name, '-'.join(str(d) for d in ijk)) self.add(new_tile, label=tile_label, inherit_periodicity=False)
python
def _add_tile(self, new_tile, ijk): """Add a tile with a label indicating its tiling position. """ tile_label = "{0}_{1}".format(self.name, '-'.join(str(d) for d in ijk)) self.add(new_tile, label=tile_label, inherit_periodicity=False)
['def', '_add_tile', '(', 'self', ',', 'new_tile', ',', 'ijk', ')', ':', 'tile_label', '=', '"{0}_{1}"', '.', 'format', '(', 'self', '.', 'name', ',', "'-'", '.', 'join', '(', 'str', '(', 'd', ')', 'for', 'd', 'in', 'ijk', ')', ')', 'self', '.', 'add', '(', 'new_tile', ',', 'label', '=', 'tile_label', ',', 'inherit_per...
Add a tile with a label indicating its tiling position.
['Add', 'a', 'tile', 'with', 'a', 'label', 'indicating', 'its', 'tiling', 'position', '.']
train
https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/lib/recipes/tiled_compound.py#L117-L120
9,331
timothycrosley/isort
isort/isort.py
_SortImports._strip_top_comments
def _strip_top_comments(lines: Sequence[str], line_separator: str) -> str: """Strips # comments that exist at the top of the given lines""" lines = copy.copy(lines) while lines and lines[0].startswith("#"): lines = lines[1:] return line_separator.join(lines)
python
def _strip_top_comments(lines: Sequence[str], line_separator: str) -> str: """Strips # comments that exist at the top of the given lines""" lines = copy.copy(lines) while lines and lines[0].startswith("#"): lines = lines[1:] return line_separator.join(lines)
['def', '_strip_top_comments', '(', 'lines', ':', 'Sequence', '[', 'str', ']', ',', 'line_separator', ':', 'str', ')', '->', 'str', ':', 'lines', '=', 'copy', '.', 'copy', '(', 'lines', ')', 'while', 'lines', 'and', 'lines', '[', '0', ']', '.', 'startswith', '(', '"#"', ')', ':', 'lines', '=', 'lines', '[', '1', ':', '...
Strips # comments that exist at the top of the given lines
['Strips', '#', 'comments', 'that', 'exist', 'at', 'the', 'top', 'of', 'the', 'given', 'lines']
train
https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/isort.py#L124-L129
9,332
zhmcclient/python-zhmcclient
zhmcclient/_user.py
User.remove_user_role
def remove_user_role(self, user_role): """ Remove the specified User Role from this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage U...
python
def remove_user_role(self, user_role): """ Remove the specified User Role from this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage U...
['def', 'remove_user_role', '(', 'self', ',', 'user_role', ')', ':', 'body', '=', '{', "'user-role-uri'", ':', 'user_role', '.', 'uri', '}', 'self', '.', 'manager', '.', 'session', '.', 'post', '(', 'self', '.', 'uri', '+', "'/operations/remove-user-role'", ',', 'body', '=', 'body', ')']
Remove the specified User Role from this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage User Templates" task to modify a template user. Par...
['Remove', 'the', 'specified', 'User', 'Role', 'from', 'this', 'User', '.']
train
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_user.py#L301-L329
9,333
log2timeline/plaso
plaso/parsers/mediator.py
ParserMediator.ProduceExtractionWarning
def ProduceExtractionWarning(self, message, path_spec=None): """Produces an extraction warning. Args: message (str): message of the warning. path_spec (Optional[dfvfs.PathSpec]): path specification, where None will use the path specification of current file entry set in the medi...
python
def ProduceExtractionWarning(self, message, path_spec=None): """Produces an extraction warning. Args: message (str): message of the warning. path_spec (Optional[dfvfs.PathSpec]): path specification, where None will use the path specification of current file entry set in the medi...
['def', 'ProduceExtractionWarning', '(', 'self', ',', 'message', ',', 'path_spec', '=', 'None', ')', ':', 'if', 'not', 'self', '.', '_storage_writer', ':', 'raise', 'RuntimeError', '(', "'Storage writer not set.'", ')', 'if', 'not', 'path_spec', 'and', 'self', '.', '_file_entry', ':', 'path_spec', '=', 'self', '.', '_f...
Produces an extraction warning. Args: message (str): message of the warning. path_spec (Optional[dfvfs.PathSpec]): path specification, where None will use the path specification of current file entry set in the mediator. Raises: RuntimeError: when storage writer is not se...
['Produces', 'an', 'extraction', 'warning', '.']
train
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/mediator.py#L524-L548
9,334
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_http_redirect.py
brocade_http_redirect.set_http_application_url_output_status_string
def set_http_application_url_output_status_string(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") set_http_application_url = ET.Element("set_http_application_url") config = set_http_application_url output = ET.SubElement(set_http_application_url,...
python
def set_http_application_url_output_status_string(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") set_http_application_url = ET.Element("set_http_application_url") config = set_http_application_url output = ET.SubElement(set_http_application_url,...
['def', 'set_http_application_url_output_status_string', '(', 'self', ',', '*', '*', 'kwargs', ')', ':', 'config', '=', 'ET', '.', 'Element', '(', '"config"', ')', 'set_http_application_url', '=', 'ET', '.', 'Element', '(', '"set_http_application_url"', ')', 'config', '=', 'set_http_application_url', 'output', '=', 'ET...
Auto Generated Code
['Auto', 'Generated', 'Code']
train
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_http_redirect.py#L53-L64
9,335
batiste/django-page-cms
pages/managers.py
PageManager.navigation
def navigation(self): """Creates a :class:`QuerySet` of the published root pages.""" return self.on_site().filter( status=self.model.PUBLISHED).filter(parent__isnull=True)
python
def navigation(self): """Creates a :class:`QuerySet` of the published root pages.""" return self.on_site().filter( status=self.model.PUBLISHED).filter(parent__isnull=True)
['def', 'navigation', '(', 'self', ')', ':', 'return', 'self', '.', 'on_site', '(', ')', '.', 'filter', '(', 'status', '=', 'self', '.', 'model', '.', 'PUBLISHED', ')', '.', 'filter', '(', 'parent__isnull', '=', 'True', ')']
Creates a :class:`QuerySet` of the published root pages.
['Creates', 'a', ':', 'class', ':', 'QuerySet', 'of', 'the', 'published', 'root', 'pages', '.']
train
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/managers.py#L64-L67
9,336
serkanyersen/underscore.py
src/underscore.py
underscore.memoize
def memoize(self, hasher=None): """ Memoize an expensive function by storing its results. """ ns = self.Namespace() ns.memo = {} if hasher is None: hasher = lambda x: x def memoized(*args, **kwargs): key = hasher(*args) if key not in n...
python
def memoize(self, hasher=None): """ Memoize an expensive function by storing its results. """ ns = self.Namespace() ns.memo = {} if hasher is None: hasher = lambda x: x def memoized(*args, **kwargs): key = hasher(*args) if key not in n...
['def', 'memoize', '(', 'self', ',', 'hasher', '=', 'None', ')', ':', 'ns', '=', 'self', '.', 'Namespace', '(', ')', 'ns', '.', 'memo', '=', '{', '}', 'if', 'hasher', 'is', 'None', ':', 'hasher', '=', 'lambda', 'x', ':', 'x', 'def', 'memoized', '(', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'key', '=', 'hasher', ...
Memoize an expensive function by storing its results.
['Memoize', 'an', 'expensive', 'function', 'by', 'storing', 'its', 'results', '.']
train
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L773-L787
9,337
googleapis/google-cloud-python
talent/google/cloud/talent_v4beta1/gapic/company_service_client.py
CompanyServiceClient.company_path
def company_path(cls, project, company): """Return a fully-qualified company string.""" return google.api_core.path_template.expand( "projects/{project}/companies/{company}", project=project, company=company )
python
def company_path(cls, project, company): """Return a fully-qualified company string.""" return google.api_core.path_template.expand( "projects/{project}/companies/{company}", project=project, company=company )
['def', 'company_path', '(', 'cls', ',', 'project', ',', 'company', ')', ':', 'return', 'google', '.', 'api_core', '.', 'path_template', '.', 'expand', '(', '"projects/{project}/companies/{company}"', ',', 'project', '=', 'project', ',', 'company', '=', 'company', ')']
Return a fully-qualified company string.
['Return', 'a', 'fully', '-', 'qualified', 'company', 'string', '.']
train
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/talent/google/cloud/talent_v4beta1/gapic/company_service_client.py#L81-L85
9,338
liamw9534/bt-manager
bt_manager/interface.py
BTInterface.get_property
def get_property(self, name=None): """ Helper to get a property value by name or all properties as a dictionary. See also :py:meth:`set_property` :param str name: defaults to None which means all properties in the object's dictionary are returned as a dict. ...
python
def get_property(self, name=None): """ Helper to get a property value by name or all properties as a dictionary. See also :py:meth:`set_property` :param str name: defaults to None which means all properties in the object's dictionary are returned as a dict. ...
['def', 'get_property', '(', 'self', ',', 'name', '=', 'None', ')', ':', 'if', '(', 'name', ')', ':', 'return', 'self', '.', '_interface', '.', 'GetProperties', '(', ')', '[', 'name', ']', 'else', ':', 'return', 'self', '.', '_interface', '.', 'GetProperties', '(', ')']
Helper to get a property value by name or all properties as a dictionary. See also :py:meth:`set_property` :param str name: defaults to None which means all properties in the object's dictionary are returned as a dict. Otherwise, the property name key is used and its va...
['Helper', 'to', 'get', 'a', 'property', 'value', 'by', 'name', 'or', 'all', 'properties', 'as', 'a', 'dictionary', '.']
train
https://github.com/liamw9534/bt-manager/blob/51be2919394ce8134c698359649bfad09eedf4ec/bt_manager/interface.py#L170-L191
9,339
napalm-automation/napalm
napalm/nxos_ssh/nxos_ssh.py
NXOSSSHDriver.get_interfaces_ip
def get_interfaces_ip(self): """ Get interface IP details. Returns a dictionary of dictionaries. Sample output: { "Ethernet2/3": { "ipv4": { "4.4.4.4": { "prefix_length": 16 } }, ...
python
def get_interfaces_ip(self): """ Get interface IP details. Returns a dictionary of dictionaries. Sample output: { "Ethernet2/3": { "ipv4": { "4.4.4.4": { "prefix_length": 16 } }, ...
['def', 'get_interfaces_ip', '(', 'self', ')', ':', 'interfaces_ip', '=', '{', '}', 'ipv4_command', '=', '"show ip interface vrf all"', 'ipv6_command', '=', '"show ipv6 interface vrf all"', 'output_v4', '=', 'self', '.', '_send_command', '(', 'ipv4_command', ')', 'output_v6', '=', 'self', '.', '_send_command', '(', 'ip...
Get interface IP details. Returns a dictionary of dictionaries. Sample output: { "Ethernet2/3": { "ipv4": { "4.4.4.4": { "prefix_length": 16 } }, "ipv6": { "20...
['Get', 'interface', 'IP', 'details', '.', 'Returns', 'a', 'dictionary', 'of', 'dictionaries', '.']
train
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/nxos_ssh/nxos_ssh.py#L934-L1024
9,340
mikekatz04/BOWIE
bowie/plotutils/plottypes.py
Ratio.make_plot
def make_plot(self): """Creates the ratio plot. """ # sets colormap for ratio comparison plot cmap = getattr(cm, self.colormap) # set values of ratio comparison contour normval = 2.0 num_contours = 40 # must be even levels = np.linspace(-normval, normva...
python
def make_plot(self): """Creates the ratio plot. """ # sets colormap for ratio comparison plot cmap = getattr(cm, self.colormap) # set values of ratio comparison contour normval = 2.0 num_contours = 40 # must be even levels = np.linspace(-normval, normva...
['def', 'make_plot', '(', 'self', ')', ':', '# sets colormap for ratio comparison plot', 'cmap', '=', 'getattr', '(', 'cm', ',', 'self', '.', 'colormap', ')', '# set values of ratio comparison contour', 'normval', '=', '2.0', 'num_contours', '=', '40', '# must be even', 'levels', '=', 'np', '.', 'linspace', '(', '-', '...
Creates the ratio plot.
['Creates', 'the', 'ratio', 'plot', '.']
train
https://github.com/mikekatz04/BOWIE/blob/a941342a3536cb57c817a1643896d99a3f354a86/bowie/plotutils/plottypes.py#L71-L123
9,341
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/jwekey.py
JWEKey.enc_setup
def enc_setup(self, enc_alg, msg, auth_data=b'', key=None, iv=""): """ Encrypt JWE content. :param enc_alg: The JWE "enc" value specifying the encryption algorithm :param msg: The plain text message :param auth_data: Additional authenticated data :param key: Key (CEK) :r...
python
def enc_setup(self, enc_alg, msg, auth_data=b'', key=None, iv=""): """ Encrypt JWE content. :param enc_alg: The JWE "enc" value specifying the encryption algorithm :param msg: The plain text message :param auth_data: Additional authenticated data :param key: Key (CEK) :r...
['def', 'enc_setup', '(', 'self', ',', 'enc_alg', ',', 'msg', ',', 'auth_data', '=', "b''", ',', 'key', '=', 'None', ',', 'iv', '=', '""', ')', ':', 'iv', '=', 'self', '.', '_generate_iv', '(', 'enc_alg', ',', 'iv', ')', 'if', 'enc_alg', 'in', '[', '"A192GCM"', ',', '"A128GCM"', ',', '"A256GCM"', ']', ':', 'aes', '=', ...
Encrypt JWE content. :param enc_alg: The JWE "enc" value specifying the encryption algorithm :param msg: The plain text message :param auth_data: Additional authenticated data :param key: Key (CEK) :return: Tuple (ciphertext, tag), both as bytes
['Encrypt', 'JWE', 'content', '.']
train
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwekey.py#L42-L63
9,342
gwastro/pycbc
pycbc/strain/lines.py
calibration_lines
def calibration_lines(freqs, data, tref=None): """ Extract the calibration lines from strain data. Parameters ---------- freqs: list List containing the frequencies of the calibration lines. data: pycbc.types.TimeSeries Strain data to extract the calibration lines from. tref: {N...
python
def calibration_lines(freqs, data, tref=None): """ Extract the calibration lines from strain data. Parameters ---------- freqs: list List containing the frequencies of the calibration lines. data: pycbc.types.TimeSeries Strain data to extract the calibration lines from. tref: {N...
['def', 'calibration_lines', '(', 'freqs', ',', 'data', ',', 'tref', '=', 'None', ')', ':', 'if', 'tref', 'is', 'None', ':', 'tref', '=', 'float', '(', 'data', '.', 'start_time', ')', 'for', 'freq', 'in', 'freqs', ':', 'measured_line', '=', 'matching_line', '(', 'freq', ',', 'data', ',', 'tref', ',', 'bin_size', '=', '...
Extract the calibration lines from strain data. Parameters ---------- freqs: list List containing the frequencies of the calibration lines. data: pycbc.types.TimeSeries Strain data to extract the calibration lines from. tref: {None, float}, optional Reference time for the li...
['Extract', 'the', 'calibration', 'lines', 'from', 'strain', 'data', '.']
train
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/strain/lines.py#L138-L162
9,343
hydpy-dev/hydpy
hydpy/auxs/xmltools.py
XSDWriter.get_itemtypesinsertion
def get_itemtypesinsertion(cls, itemgroup, indent) -> str: """Return a string defining the required types for the given exchange item group. >>> from hydpy.auxs.xmltools import XSDWriter >>> print(XSDWriter.get_itemtypesinsertion( ... 'setitems', 1)) # doctest: +ELLIPSIS ...
python
def get_itemtypesinsertion(cls, itemgroup, indent) -> str: """Return a string defining the required types for the given exchange item group. >>> from hydpy.auxs.xmltools import XSDWriter >>> print(XSDWriter.get_itemtypesinsertion( ... 'setitems', 1)) # doctest: +ELLIPSIS ...
['def', 'get_itemtypesinsertion', '(', 'cls', ',', 'itemgroup', ',', 'indent', ')', '->', 'str', ':', 'subs', '=', '[', ']', 'for', 'modelname', 'in', 'cls', '.', 'get_modelnames', '(', ')', ':', 'subs', '.', 'append', '(', 'cls', '.', 'get_itemtypeinsertion', '(', 'itemgroup', ',', 'modelname', ',', 'indent', ')', ')'...
Return a string defining the required types for the given exchange item group. >>> from hydpy.auxs.xmltools import XSDWriter >>> print(XSDWriter.get_itemtypesinsertion( ... 'setitems', 1)) # doctest: +ELLIPSIS <complexType name="arma_v1_setitemsType"> ... ...
['Return', 'a', 'string', 'defining', 'the', 'required', 'types', 'for', 'the', 'given', 'exchange', 'item', 'group', '.']
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/xmltools.py#L1887-L1907
9,344
google/grr
grr/server/grr_response_server/signed_binary_utils.py
StreamSignedBinaryContents
def StreamSignedBinaryContents(blob_iterator, chunk_size = 1024 ): """Yields the contents of the given binary in chunks of the given size. Args: blob_iterator: An Iterator over all the binary's blobs. chunk_size: Size, in bytes, of the chunks to ...
python
def StreamSignedBinaryContents(blob_iterator, chunk_size = 1024 ): """Yields the contents of the given binary in chunks of the given size. Args: blob_iterator: An Iterator over all the binary's blobs. chunk_size: Size, in bytes, of the chunks to ...
['def', 'StreamSignedBinaryContents', '(', 'blob_iterator', ',', 'chunk_size', '=', '1024', ')', ':', 'all_blobs_read', '=', 'False', 'byte_buffer', '=', 'io', '.', 'BytesIO', '(', ')', 'while', 'not', 'all_blobs_read', 'or', 'byte_buffer', '.', 'getvalue', '(', ')', ':', 'while', 'not', 'all_blobs_read', 'and', 'byte_...
Yields the contents of the given binary in chunks of the given size. Args: blob_iterator: An Iterator over all the binary's blobs. chunk_size: Size, in bytes, of the chunks to yield.
['Yields', 'the', 'contents', 'of', 'the', 'given', 'binary', 'in', 'chunks', 'of', 'the', 'given', 'size', '.']
train
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L278-L303
9,345
maximtrp/scikit-posthocs
scikit_posthocs/_plotting.py
sign_array
def sign_array(p_values, alpha=0.05): """ Significance array Converts an array with p values to a significance array where 0 is False (not significant), 1 is True (significant), and -1 is for diagonal elements. Parameters ---------- p_values : array_like or ndarray An array, an...
python
def sign_array(p_values, alpha=0.05): """ Significance array Converts an array with p values to a significance array where 0 is False (not significant), 1 is True (significant), and -1 is for diagonal elements. Parameters ---------- p_values : array_like or ndarray An array, an...
['def', 'sign_array', '(', 'p_values', ',', 'alpha', '=', '0.05', ')', ':', 'p_values', '=', 'np', '.', 'array', '(', 'p_values', ')', 'p_values', '[', 'p_values', '>', 'alpha', ']', '=', '0', 'p_values', '[', '(', 'p_values', '<', 'alpha', ')', '&', '(', 'p_values', '>', '0', ')', ']', '=', '1', 'np', '.', 'fill_diago...
Significance array Converts an array with p values to a significance array where 0 is False (not significant), 1 is True (significant), and -1 is for diagonal elements. Parameters ---------- p_values : array_like or ndarray An array, any object exposing the array interface, containing ...
['Significance', 'array']
train
https://github.com/maximtrp/scikit-posthocs/blob/5476b09e2a325cd4e31c0b0bc6906ab5cd77fc5d/scikit_posthocs/_plotting.py#L8-L47
9,346
dslackw/slpkg
slpkg/sbo/network.py
SBoNetwork.choice_info
def choice_info(self): """View .info file """ info = ReadSBo(self.sbo_url).info(self.name, ".info") fill = self.fill_pager(info) self.pager(info + fill)
python
def choice_info(self): """View .info file """ info = ReadSBo(self.sbo_url).info(self.name, ".info") fill = self.fill_pager(info) self.pager(info + fill)
['def', 'choice_info', '(', 'self', ')', ':', 'info', '=', 'ReadSBo', '(', 'self', '.', 'sbo_url', ')', '.', 'info', '(', 'self', '.', 'name', ',', '".info"', ')', 'fill', '=', 'self', '.', 'fill_pager', '(', 'info', ')', 'self', '.', 'pager', '(', 'info', '+', 'fill', ')']
View .info file
['View', '.', 'info', 'file']
train
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/network.py#L201-L206
9,347
googleapis/google-cloud-python
bigquery_storage/google/cloud/bigquery_storage_v1beta1/reader.py
ReadRowsPage._parse_block
def _parse_block(self): """Parse metadata and rows from the block only once.""" if self._iter_rows is not None: return rows = _avro_rows(self._block, self._avro_schema) self._num_items = self._block.avro_rows.row_count self._remaining = self._block.avro_rows.row_coun...
python
def _parse_block(self): """Parse metadata and rows from the block only once.""" if self._iter_rows is not None: return rows = _avro_rows(self._block, self._avro_schema) self._num_items = self._block.avro_rows.row_count self._remaining = self._block.avro_rows.row_coun...
['def', '_parse_block', '(', 'self', ')', ':', 'if', 'self', '.', '_iter_rows', 'is', 'not', 'None', ':', 'return', 'rows', '=', '_avro_rows', '(', 'self', '.', '_block', ',', 'self', '.', '_avro_schema', ')', 'self', '.', '_num_items', '=', 'self', '.', '_block', '.', 'avro_rows', '.', 'row_count', 'self', '.', '_rema...
Parse metadata and rows from the block only once.
['Parse', 'metadata', 'and', 'rows', 'from', 'the', 'block', 'only', 'once', '.']
train
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery_storage/google/cloud/bigquery_storage_v1beta1/reader.py#L301-L309
9,348
CentOS/python-cicoclient
cicoclient/utils.py
get_dict_properties
def get_dict_properties(item, fields, mixed_case_fields=[], formatters={}): """Return a tuple containing the item properties. :param item: a single dict resource :param fields: tuple of strings with the desired field names :param mixed_case_fields: tuple of field names to preserve case :param format...
python
def get_dict_properties(item, fields, mixed_case_fields=[], formatters={}): """Return a tuple containing the item properties. :param item: a single dict resource :param fields: tuple of strings with the desired field names :param mixed_case_fields: tuple of field names to preserve case :param format...
['def', 'get_dict_properties', '(', 'item', ',', 'fields', ',', 'mixed_case_fields', '=', '[', ']', ',', 'formatters', '=', '{', '}', ')', ':', 'row', '=', '[', ']', 'for', 'field', 'in', 'fields', ':', 'if', 'field', 'in', 'mixed_case_fields', ':', 'field_name', '=', 'field', '.', 'replace', '(', "' '", ',', "'_'", ')...
Return a tuple containing the item properties. :param item: a single dict resource :param fields: tuple of strings with the desired field names :param mixed_case_fields: tuple of field names to preserve case :param formatters: dictionary mapping field names to callables to format the values
['Return', 'a', 'tuple', 'containing', 'the', 'item', 'properties', '.', ':', 'param', 'item', ':', 'a', 'single', 'dict', 'resource', ':', 'param', 'fields', ':', 'tuple', 'of', 'strings', 'with', 'the', 'desired', 'field', 'names', ':', 'param', 'mixed_case_fields', ':', 'tuple', 'of', 'field', 'names', 'to', 'preser...
train
https://github.com/CentOS/python-cicoclient/blob/ffee34f446ceb25348b13a500d5c545df202c182/cicoclient/utils.py#L21-L41
9,349
datosgobar/pydatajson
pydatajson/federation.py
restore_organization_to_ckan
def restore_organization_to_ckan(catalog, owner_org, portal_url, apikey, dataset_list=None, download_strategy=None, generate_new_access_url=None): """Restaura los datasets de la organización de un catálogo al portal pasado por parámetro. Si ha...
python
def restore_organization_to_ckan(catalog, owner_org, portal_url, apikey, dataset_list=None, download_strategy=None, generate_new_access_url=None): """Restaura los datasets de la organización de un catálogo al portal pasado por parámetro. Si ha...
['def', 'restore_organization_to_ckan', '(', 'catalog', ',', 'owner_org', ',', 'portal_url', ',', 'apikey', ',', 'dataset_list', '=', 'None', ',', 'download_strategy', '=', 'None', ',', 'generate_new_access_url', '=', 'None', ')', ':', 'push_new_themes', '(', 'catalog', ',', 'portal_url', ',', 'apikey', ')', 'restored'...
Restaura los datasets de la organización de un catálogo al portal pasado por parámetro. Si hay temas presentes en el DataJson que no están en el portal de CKAN, los genera. Args: catalog (DataJson): El catálogo de origen que se restaura. portal_url (str): La URL del portal...
['Restaura', 'los', 'datasets', 'de', 'la', 'organización', 'de', 'un', 'catálogo', 'al', 'portal', 'pasado', 'por', 'parámetro', '.', 'Si', 'hay', 'temas', 'presentes', 'en', 'el', 'DataJson', 'que', 'no', 'están', 'en', 'el', 'portal', 'de', 'CKAN', 'los', 'genera', '.']
train
https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L496-L541
9,350
orbingol/NURBS-Python
geomdl/exchange.py
import_vmesh
def import_vmesh(file): """ Imports NURBS volume(s) from volume mesh (vmesh) file(s). :param file: path to a directory containing mesh files or a single mesh file :type file: str :return: list of NURBS volumes :rtype: list :raises GeomdlException: an error occurred reading the file """ ...
python
def import_vmesh(file): """ Imports NURBS volume(s) from volume mesh (vmesh) file(s). :param file: path to a directory containing mesh files or a single mesh file :type file: str :return: list of NURBS volumes :rtype: list :raises GeomdlException: an error occurred reading the file """ ...
['def', 'import_vmesh', '(', 'file', ')', ':', 'imported_elements', '=', '[', ']', 'if', 'os', '.', 'path', '.', 'isfile', '(', 'file', ')', ':', 'imported_elements', '.', 'append', '(', 'exch', '.', 'import_vol_mesh', '(', 'file', ')', ')', 'elif', 'os', '.', 'path', '.', 'isdir', '(', 'file', ')', ':', 'files', '=', ...
Imports NURBS volume(s) from volume mesh (vmesh) file(s). :param file: path to a directory containing mesh files or a single mesh file :type file: str :return: list of NURBS volumes :rtype: list :raises GeomdlException: an error occurred reading the file
['Imports', 'NURBS', 'volume', '(', 's', ')', 'from', 'volume', 'mesh', '(', 'vmesh', ')', 'file', '(', 's', ')', '.']
train
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L826-L844
9,351
mitsei/dlkit
dlkit/services/resource.py
Bin._set_bin_view
def _set_bin_view(self, session): """Sets the underlying bin view to match current view""" if self._bin_view == FEDERATED: try: session.use_federated_bin_view() except AttributeError: pass else: try: session.use_...
python
def _set_bin_view(self, session): """Sets the underlying bin view to match current view""" if self._bin_view == FEDERATED: try: session.use_federated_bin_view() except AttributeError: pass else: try: session.use_...
['def', '_set_bin_view', '(', 'self', ',', 'session', ')', ':', 'if', 'self', '.', '_bin_view', '==', 'FEDERATED', ':', 'try', ':', 'session', '.', 'use_federated_bin_view', '(', ')', 'except', 'AttributeError', ':', 'pass', 'else', ':', 'try', ':', 'session', '.', 'use_isolated_bin_view', '(', ')', 'except', 'Attribut...
Sets the underlying bin view to match current view
['Sets', 'the', 'underlying', 'bin', 'view', 'to', 'match', 'current', 'view']
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/resource.py#L1062-L1073
9,352
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.login
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ from django.contrib.auth.views import login context = { 'title': _('Log in'), 'app_path': request.get_full_path(), REDIRECT_FIELD_NAME: req...
python
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ from django.contrib.auth.views import login context = { 'title': _('Log in'), 'app_path': request.get_full_path(), REDIRECT_FIELD_NAME: req...
['def', 'login', '(', 'self', ',', 'request', ',', 'extra_context', '=', 'None', ')', ':', 'from', 'django', '.', 'contrib', '.', 'auth', '.', 'views', 'import', 'login', 'context', '=', '{', "'title'", ':', '_', '(', "'Log in'", ')', ',', "'app_path'", ':', 'request', '.', 'get_full_path', '(', ')', ',', 'REDIRECT_FIE...
Displays the login form for the given HttpRequest.
['Displays', 'the', 'login', 'form', 'for', 'the', 'given', 'HttpRequest', '.']
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L251-L267
9,353
Holzhaus/python-cmuclmtk
cmuclmtk/__init__.py
mergeidngram
def mergeidngram(output_file, input_files, n=3, ascii_input=False, ascii_output=False): """ Takes a set of id n-gram files (in either binary (by default) or ASCII (if specified) format - note that they should all be in the same format, however) and outputs a merged id N-gram. Notes : This function ...
python
def mergeidngram(output_file, input_files, n=3, ascii_input=False, ascii_output=False): """ Takes a set of id n-gram files (in either binary (by default) or ASCII (if specified) format - note that they should all be in the same format, however) and outputs a merged id N-gram. Notes : This function ...
['def', 'mergeidngram', '(', 'output_file', ',', 'input_files', ',', 'n', '=', '3', ',', 'ascii_input', '=', 'False', ',', 'ascii_output', '=', 'False', ')', ':', 'cmd', '=', '[', "'mergeidngram'", ']', 'if', 'n', ':', 'cmd', '.', 'extend', '(', '[', "'-n'", ',', 'n', ']', ')', 'if', 'ascii_input', ':', 'cmd', '.', 'ap...
Takes a set of id n-gram files (in either binary (by default) or ASCII (if specified) format - note that they should all be in the same format, however) and outputs a merged id N-gram. Notes : This function can also be used to convert id n-gram files between ascii and binary formats.
['Takes', 'a', 'set', 'of', 'id', 'n', '-', 'gram', 'files', '(', 'in', 'either', 'binary', '(', 'by', 'default', ')', 'or', 'ASCII', '(', 'if', 'specified', ')', 'format', '-', 'note', 'that', 'they', 'should', 'all', 'be', 'in', 'the', 'same', 'format', 'however', ')', 'and', 'outputs', 'a', 'merged', 'id', 'N', '-',...
train
https://github.com/Holzhaus/python-cmuclmtk/blob/67a5c6713c497ca644ea1c697a70e8d930c9d4b4/cmuclmtk/__init__.py#L360-L392
9,354
orb-framework/orb
orb/core/query.py
Query.inverted
def inverted(self): """ Returns an inverted copy of this query. :return <orb.Query> """ out = self.copy() out.setInverted(not self.isInverted()) return out
python
def inverted(self): """ Returns an inverted copy of this query. :return <orb.Query> """ out = self.copy() out.setInverted(not self.isInverted()) return out
['def', 'inverted', '(', 'self', ')', ':', 'out', '=', 'self', '.', 'copy', '(', ')', 'out', '.', 'setInverted', '(', 'not', 'self', '.', 'isInverted', '(', ')', ')', 'return', 'out']
Returns an inverted copy of this query. :return <orb.Query>
['Returns', 'an', 'inverted', 'copy', 'of', 'this', 'query', '.']
train
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/query.py#L894-L902
9,355
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.has_sample
def has_sample(self, md5): """Checks if data store has this sample. Args: md5: The md5 digest of the required sample. Returns: True if sample with this md5 is present, else False. """ # The easiest thing is to simply get the sample and if that #...
python
def has_sample(self, md5): """Checks if data store has this sample. Args: md5: The md5 digest of the required sample. Returns: True if sample with this md5 is present, else False. """ # The easiest thing is to simply get the sample and if that #...
['def', 'has_sample', '(', 'self', ',', 'md5', ')', ':', '# The easiest thing is to simply get the sample and if that', '# succeeds than return True, else return False', 'sample', '=', 'self', '.', 'get_sample', '(', 'md5', ')', 'return', 'True', 'if', 'sample', 'else', 'False']
Checks if data store has this sample. Args: md5: The md5 digest of the required sample. Returns: True if sample with this md5 is present, else False.
['Checks', 'if', 'data', 'store', 'has', 'this', 'sample', '.']
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L265-L278
9,356
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.clean_jobs
def clean_jobs(self, recursive=False): """Clean up all the jobs associated with this object. If recursive is True this also clean jobs dispatch by this object.""" self._interface.clean_jobs(self.scatter_link, clean_all=recursive)
python
def clean_jobs(self, recursive=False): """Clean up all the jobs associated with this object. If recursive is True this also clean jobs dispatch by this object.""" self._interface.clean_jobs(self.scatter_link, clean_all=recursive)
['def', 'clean_jobs', '(', 'self', ',', 'recursive', '=', 'False', ')', ':', 'self', '.', '_interface', '.', 'clean_jobs', '(', 'self', '.', 'scatter_link', ',', 'clean_all', '=', 'recursive', ')']
Clean up all the jobs associated with this object. If recursive is True this also clean jobs dispatch by this object.
['Clean', 'up', 'all', 'the', 'jobs', 'associated', 'with', 'this', 'object', '.']
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L511-L517
9,357
tensorflow/mesh
mesh_tensorflow/ops.py
slicewise
def slicewise(tf_fn, xs, output_shape=None, output_dtype=None, splittable_dims=None, grad_function=None, name=None): """Slice-wise call to any tensorflow function. The output shape and dtype default to those of the first input. s...
python
def slicewise(tf_fn, xs, output_shape=None, output_dtype=None, splittable_dims=None, grad_function=None, name=None): """Slice-wise call to any tensorflow function. The output shape and dtype default to those of the first input. s...
['def', 'slicewise', '(', 'tf_fn', ',', 'xs', ',', 'output_shape', '=', 'None', ',', 'output_dtype', '=', 'None', ',', 'splittable_dims', '=', 'None', ',', 'grad_function', '=', 'None', ',', 'name', '=', 'None', ')', ':', 'multiple_outputs', '=', 'isinstance', '(', 'output_dtype', ',', 'list', ')', 'output_shapes', '='...
Slice-wise call to any tensorflow function. The output shape and dtype default to those of the first input. splittable_dims is a list of Dimensions which can be split while keeping the computation valid. Args: tf_fn: a function taking n tf.Tensors and returning a tf.Tensor xs: a list of n Tensors ...
['Slice', '-', 'wise', 'call', 'to', 'any', 'tensorflow', 'function', '.']
train
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1568-L1605
9,358
pyapi-gitlab/pyapi-gitlab
gitlab/base.py
Base.get
def get(self, uri, default_response=None, **kwargs): """ Call GET on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.get('/users/5') :param uri: String with the URI for ...
python
def get(self, uri, default_response=None, **kwargs): """ Call GET on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.get('/users/5') :param uri: String with the URI for ...
['def', 'get', '(', 'self', ',', 'uri', ',', 'default_response', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'url', '=', 'self', '.', 'api_url', '+', 'uri', 'response', '=', 'requests', '.', 'get', '(', 'url', ',', 'params', '=', 'kwargs', ',', 'headers', '=', 'self', '.', 'headers', ',', 'verify', '=', 'self', '.'...
Call GET on the Gitlab server >>> gitlab = Gitlab(host='http://localhost:10080', verify_ssl=False) >>> gitlab.login(user='root', password='5iveL!fe') >>> gitlab.get('/users/5') :param uri: String with the URI for the endpoint to GET from :param default_response: Return value if...
['Call', 'GET', 'on', 'the', 'Gitlab', 'server']
train
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/base.py#L55-L74
9,359
gtzampanakis/downloader
downloader.py
Downloader.open_url
def open_url(self, url, stale_after, parse_as_html = True, **kwargs): """ Download or retrieve from cache. url -- The URL to be downloaded, as a string. stale_after -- A network request for the url will be performed if the cached copy does not exist or if it exists but its age (in days) is larger ...
python
def open_url(self, url, stale_after, parse_as_html = True, **kwargs): """ Download or retrieve from cache. url -- The URL to be downloaded, as a string. stale_after -- A network request for the url will be performed if the cached copy does not exist or if it exists but its age (in days) is larger ...
['def', 'open_url', '(', 'self', ',', 'url', ',', 'stale_after', ',', 'parse_as_html', '=', 'True', ',', '*', '*', 'kwargs', ')', ':', '_LOGGER', '.', 'info', '(', "'open_url() received url: %s'", ',', 'url', ')', 'today', '=', 'datetime', '.', 'date', '.', 'today', '(', ')', 'threshold_date', '=', 'today', '-', 'datet...
Download or retrieve from cache. url -- The URL to be downloaded, as a string. stale_after -- A network request for the url will be performed if the cached copy does not exist or if it exists but its age (in days) is larger or equal to the stale_after value. A non-positive value will force re-downloa...
['Download', 'or', 'retrieve', 'from', 'cache', '.', 'url', '--', 'The', 'URL', 'to', 'be', 'downloaded', 'as', 'a', 'string', '.', 'stale_after', '--', 'A', 'network', 'request', 'for', 'the', 'url', 'will', 'be', 'performed', 'if', 'the', 'cached', 'copy', 'does', 'not', 'exist', 'or', 'if', 'it', 'exists', 'but', 'i...
train
https://github.com/gtzampanakis/downloader/blob/7354f68adc72f2bfc472f41596af6ee8b3e6ea88/downloader.py#L192-L297
9,360
Crunch-io/crunch-cube
src/cr/cube/measures/pairwise_significance.py
PairwiseSignificance.summary_pairwise_indices
def summary_pairwise_indices(self): """ndarray containing tuples of pairwise indices for the column summary.""" summary_pairwise_indices = np.empty( self.values[0].t_stats.shape[1], dtype=object ) summary_pairwise_indices[:] = [ sig.summary_pairwise_indices for si...
python
def summary_pairwise_indices(self): """ndarray containing tuples of pairwise indices for the column summary.""" summary_pairwise_indices = np.empty( self.values[0].t_stats.shape[1], dtype=object ) summary_pairwise_indices[:] = [ sig.summary_pairwise_indices for si...
['def', 'summary_pairwise_indices', '(', 'self', ')', ':', 'summary_pairwise_indices', '=', 'np', '.', 'empty', '(', 'self', '.', 'values', '[', '0', ']', '.', 't_stats', '.', 'shape', '[', '1', ']', ',', 'dtype', '=', 'object', ')', 'summary_pairwise_indices', '[', ':', ']', '=', '[', 'sig', '.', 'summary_pairwise_ind...
ndarray containing tuples of pairwise indices for the column summary.
['ndarray', 'containing', 'tuples', 'of', 'pairwise', 'indices', 'for', 'the', 'column', 'summary', '.']
train
https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/pairwise_significance.py#L60-L68
9,361
juiceinc/recipe
recipe/ingredients.py
Dimension.make_column_suffixes
def make_column_suffixes(self): """ Make sure we have the right column suffixes. These will be appended to `id` when generating the query. """ if self.column_suffixes: return self.column_suffixes if len(self.columns) == 0: return () elif len(self...
python
def make_column_suffixes(self): """ Make sure we have the right column suffixes. These will be appended to `id` when generating the query. """ if self.column_suffixes: return self.column_suffixes if len(self.columns) == 0: return () elif len(self...
['def', 'make_column_suffixes', '(', 'self', ')', ':', 'if', 'self', '.', 'column_suffixes', ':', 'return', 'self', '.', 'column_suffixes', 'if', 'len', '(', 'self', '.', 'columns', ')', '==', '0', ':', 'return', '(', ')', 'elif', 'len', '(', 'self', '.', 'columns', ')', '==', '1', ':', 'if', 'self', '.', 'formatters',...
Make sure we have the right column suffixes. These will be appended to `id` when generating the query.
['Make', 'sure', 'we', 'have', 'the', 'right', 'column', 'suffixes', '.', 'These', 'will', 'be', 'appended', 'to', 'id', 'when', 'generating', 'the', 'query', '.']
train
https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/ingredients.py#L294-L319
9,362
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_FunctionDef
def visit_FunctionDef(self, node): ''' Initialise aliasing default value before visiting. Add aliasing values for : - Pythonic - globals declarations - current function arguments ''' self.aliases = IntrinsicAliases.copy() self.aliases...
python
def visit_FunctionDef(self, node): ''' Initialise aliasing default value before visiting. Add aliasing values for : - Pythonic - globals declarations - current function arguments ''' self.aliases = IntrinsicAliases.copy() self.aliases...
['def', 'visit_FunctionDef', '(', 'self', ',', 'node', ')', ':', 'self', '.', 'aliases', '=', 'IntrinsicAliases', '.', 'copy', '(', ')', 'self', '.', 'aliases', '.', 'update', '(', '(', 'f', '.', 'name', ',', '{', 'f', '}', ')', 'for', 'f', 'in', 'self', '.', 'global_declarations', '.', 'values', '(', ')', ')', 'self',...
Initialise aliasing default value before visiting. Add aliasing values for : - Pythonic - globals declarations - current function arguments
['Initialise', 'aliasing', 'default', 'value', 'before', 'visiting', '.']
train
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L532-L600
9,363
Toilal/rebulk
rebulk/rebulk.py
Rebulk.regex
def regex(self, *pattern, **kwargs): """ Add re pattern :param pattern: :type pattern: :return: self :rtype: Rebulk """ self.pattern(self.build_re(*pattern, **kwargs)) return self
python
def regex(self, *pattern, **kwargs): """ Add re pattern :param pattern: :type pattern: :return: self :rtype: Rebulk """ self.pattern(self.build_re(*pattern, **kwargs)) return self
['def', 'regex', '(', 'self', ',', '*', 'pattern', ',', '*', '*', 'kwargs', ')', ':', 'self', '.', 'pattern', '(', 'self', '.', 'build_re', '(', '*', 'pattern', ',', '*', '*', 'kwargs', ')', ')', 'return', 'self']
Add re pattern :param pattern: :type pattern: :return: self :rtype: Rebulk
['Add', 're', 'pattern']
train
https://github.com/Toilal/rebulk/blob/7511a4671f2fd9493e3df1e5177b7656789069e8/rebulk/rebulk.py#L108-L118
9,364
tomduck/pandoc-xnos
pandocxnos/core.py
_join_strings
def _join_strings(x): """Joins adjacent Str elements found in the element list 'x'.""" for i in range(len(x)-1): # Process successive pairs of elements if x[i]['t'] == 'Str' and x[i+1]['t'] == 'Str': x[i]['c'] += x[i+1]['c'] del x[i+1] # In-place deletion of element from list ...
python
def _join_strings(x): """Joins adjacent Str elements found in the element list 'x'.""" for i in range(len(x)-1): # Process successive pairs of elements if x[i]['t'] == 'Str' and x[i+1]['t'] == 'Str': x[i]['c'] += x[i+1]['c'] del x[i+1] # In-place deletion of element from list ...
['def', '_join_strings', '(', 'x', ')', ':', 'for', 'i', 'in', 'range', '(', 'len', '(', 'x', ')', '-', '1', ')', ':', '# Process successive pairs of elements', 'if', 'x', '[', 'i', ']', '[', "'t'", ']', '==', "'Str'", 'and', 'x', '[', 'i', '+', '1', ']', '[', "'t'", ']', '==', "'Str'", ':', 'x', '[', 'i', ']', '[', "'...
Joins adjacent Str elements found in the element list 'x'.
['Joins', 'adjacent', 'Str', 'elements', 'found', 'in', 'the', 'element', 'list', 'x', '.']
train
https://github.com/tomduck/pandoc-xnos/blob/df8e162d257a548cea7eebf597efb2c21a1a4ba3/pandocxnos/core.py#L436-L443
9,365
rbuffat/pyepw
pyepw/epw.py
DataPeriod.data_period_start_day_of_week
def data_period_start_day_of_week(self, value=None): """Corresponds to IDD Field `data_period_start_day_of_week` Args: value (str): value for IDD Field `data_period_start_day_of_week` Accepted values are: - Sunday - Monday ...
python
def data_period_start_day_of_week(self, value=None): """Corresponds to IDD Field `data_period_start_day_of_week` Args: value (str): value for IDD Field `data_period_start_day_of_week` Accepted values are: - Sunday - Monday ...
['def', 'data_period_start_day_of_week', '(', 'self', ',', 'value', '=', 'None', ')', ':', 'if', 'value', 'is', 'not', 'None', ':', 'try', ':', 'value', '=', 'str', '(', 'value', ')', 'except', 'ValueError', ':', 'raise', 'ValueError', '(', "'value {} need to be of type str '", "'for field `data_period_start_day_of_wee...
Corresponds to IDD Field `data_period_start_day_of_week` Args: value (str): value for IDD Field `data_period_start_day_of_week` Accepted values are: - Sunday - Monday - Tuesday - Wednesday ...
['Corresponds', 'to', 'IDD', 'Field', 'data_period_start_day_of_week']
train
https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L5214-L5257
9,366
pyvisa/pyvisa-sim
pyvisa-sim/devices.py
Device._match_registers
def _match_registers(self, query): """Tries to match in status registers :param query: message tuple :type query: Tuple[bytes] :return: response if found or None :rtype: Tuple[bytes] | None """ if query in self._status_registers: register = self._stat...
python
def _match_registers(self, query): """Tries to match in status registers :param query: message tuple :type query: Tuple[bytes] :return: response if found or None :rtype: Tuple[bytes] | None """ if query in self._status_registers: register = self._stat...
['def', '_match_registers', '(', 'self', ',', 'query', ')', ':', 'if', 'query', 'in', 'self', '.', '_status_registers', ':', 'register', '=', 'self', '.', '_status_registers', '[', 'query', ']', 'response', '=', 'register', '.', 'value', 'logger', '.', 'debug', '(', "'Found response in status register: %s'", ',', 'repr...
Tries to match in status registers :param query: message tuple :type query: Tuple[bytes] :return: response if found or None :rtype: Tuple[bytes] | None
['Tries', 'to', 'match', 'in', 'status', 'registers']
train
https://github.com/pyvisa/pyvisa-sim/blob/9836166b6b57c165fc63a276f87fe81f106a4e26/pyvisa-sim/devices.py#L298-L313
9,367
adafruit/Adafruit_Python_PlatformDetect
adafruit_platformdetect/chip.py
Chip.id
def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements """Return a unique id for the detected chip, if any.""" # There are some times we want to trick the platform detection # say if a raspberry pi doesn't have the right ID, or for testing try: ...
python
def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements """Return a unique id for the detected chip, if any.""" # There are some times we want to trick the platform detection # say if a raspberry pi doesn't have the right ID, or for testing try: ...
['def', 'id', '(', 'self', ')', ':', '# pylint: disable=invalid-name,too-many-branches,too-many-return-statements', '# There are some times we want to trick the platform detection', "# say if a raspberry pi doesn't have the right ID, or for testing", 'try', ':', 'return', 'os', '.', 'environ', '[', "'BLINKA_FORCECHIP'"...
Return a unique id for the detected chip, if any.
['Return', 'a', 'unique', 'id', 'for', 'the', 'detected', 'chip', 'if', 'any', '.']
train
https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/cddd4d47e530026778dc4e3c3ccabad14e6eac46/adafruit_platformdetect/chip.py#L26-L70
9,368
cloudsmith-io/cloudsmith-cli
cloudsmith_cli/cli/config.py
Options.error_retry_codes
def error_retry_codes(self, value): """Set value for error_retry_codes.""" if isinstance(value, six.string_types): value = [int(x) for x in value.split(",")] self._set_option("error_retry_codes", value)
python
def error_retry_codes(self, value): """Set value for error_retry_codes.""" if isinstance(value, six.string_types): value = [int(x) for x in value.split(",")] self._set_option("error_retry_codes", value)
['def', 'error_retry_codes', '(', 'self', ',', 'value', ')', ':', 'if', 'isinstance', '(', 'value', ',', 'six', '.', 'string_types', ')', ':', 'value', '=', '[', 'int', '(', 'x', ')', 'for', 'x', 'in', 'value', '.', 'split', '(', '","', ')', ']', 'self', '.', '_set_option', '(', '"error_retry_codes"', ',', 'value', ')'...
Set value for error_retry_codes.
['Set', 'value', 'for', 'error_retry_codes', '.']
train
https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L340-L344
9,369
mikedh/trimesh
trimesh/scene/cameras.py
Camera.focal
def focal(self): """ Get the focal length in pixels for the camera. Returns ------------ focal : (2,) float Focal length in pixels """ if self._focal is None: # calculate focal length from FOV focal = [(px / 2.0) / np.tan(np.radi...
python
def focal(self): """ Get the focal length in pixels for the camera. Returns ------------ focal : (2,) float Focal length in pixels """ if self._focal is None: # calculate focal length from FOV focal = [(px / 2.0) / np.tan(np.radi...
['def', 'focal', '(', 'self', ')', ':', 'if', 'self', '.', '_focal', 'is', 'None', ':', '# calculate focal length from FOV', 'focal', '=', '[', '(', 'px', '/', '2.0', ')', '/', 'np', '.', 'tan', '(', 'np', '.', 'radians', '(', 'fov', '/', '2.0', ')', ')', 'for', 'px', ',', 'fov', 'in', 'zip', '(', 'self', '.', '_resolu...
Get the focal length in pixels for the camera. Returns ------------ focal : (2,) float Focal length in pixels
['Get', 'the', 'focal', 'length', 'in', 'pixels', 'for', 'the', 'camera', '.']
train
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/scene/cameras.py#L180-L196
9,370
matthiask/django-cte-forest
cte_forest/models.py
CTENodeManager.leaves
def leaves(self): """ Returns a :class:`QuerySet` of all leaf nodes (nodes with no children). :return: A :class:`QuerySet` of all leaf nodes (nodes with no children). """ # We need to read the _cte_node_children attribute, so ensure it exists. sel...
python
def leaves(self): """ Returns a :class:`QuerySet` of all leaf nodes (nodes with no children). :return: A :class:`QuerySet` of all leaf nodes (nodes with no children). """ # We need to read the _cte_node_children attribute, so ensure it exists. sel...
['def', 'leaves', '(', 'self', ')', ':', '# We need to read the _cte_node_children attribute, so ensure it exists.', 'self', '.', '_ensure_parameters', '(', ')', 'return', 'self', '.', 'exclude', '(', '*', '*', '{', '"%s__id__in"', '%', 'self', '.', 'model', '.', '_cte_node_children', ':', 'self', '.', 'all', '(', ')',...
Returns a :class:`QuerySet` of all leaf nodes (nodes with no children). :return: A :class:`QuerySet` of all leaf nodes (nodes with no children).
['Returns', 'a', ':', 'class', ':', 'QuerySet', 'of', 'all', 'leaf', 'nodes', '(', 'nodes', 'with', 'no', 'children', ')', '.']
train
https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/models.py#L322-L333
9,371
AdvancedClimateSystems/uModbus
scripts/examples/simple_rtu_client.py
get_serial_port
def get_serial_port(): """ Return serial.Serial instance, ready to use for RS485.""" port = Serial(port='/dev/ttyS1', baudrate=9600, parity=PARITY_NONE, stopbits=1, bytesize=8, timeout=1) fh = port.fileno() # A struct with configuration for serial port. serial_rs485 = struct.pack...
python
def get_serial_port(): """ Return serial.Serial instance, ready to use for RS485.""" port = Serial(port='/dev/ttyS1', baudrate=9600, parity=PARITY_NONE, stopbits=1, bytesize=8, timeout=1) fh = port.fileno() # A struct with configuration for serial port. serial_rs485 = struct.pack...
['def', 'get_serial_port', '(', ')', ':', 'port', '=', 'Serial', '(', 'port', '=', "'/dev/ttyS1'", ',', 'baudrate', '=', '9600', ',', 'parity', '=', 'PARITY_NONE', ',', 'stopbits', '=', '1', ',', 'bytesize', '=', '8', ',', 'timeout', '=', '1', ')', 'fh', '=', 'port', '.', 'fileno', '(', ')', '# A struct with configurat...
Return serial.Serial instance, ready to use for RS485.
['Return', 'serial', '.', 'Serial', 'instance', 'ready', 'to', 'use', 'for', 'RS485', '.']
train
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/scripts/examples/simple_rtu_client.py#L10-L21
9,372
databio/pypiper
pypiper/utils.py
add_pypiper_args
def add_pypiper_args(parser, groups=("pypiper", ), args=None, required=None, all_args=False): """ Use this to add standardized pypiper arguments to your python pipeline. There are two ways to use `add_pypiper_args`: by specifying argument groups, or by specifying individual argumen...
python
def add_pypiper_args(parser, groups=("pypiper", ), args=None, required=None, all_args=False): """ Use this to add standardized pypiper arguments to your python pipeline. There are two ways to use `add_pypiper_args`: by specifying argument groups, or by specifying individual argumen...
['def', 'add_pypiper_args', '(', 'parser', ',', 'groups', '=', '(', '"pypiper"', ',', ')', ',', 'args', '=', 'None', ',', 'required', '=', 'None', ',', 'all_args', '=', 'False', ')', ':', 'args_to_add', '=', '_determine_args', '(', 'argument_groups', '=', 'groups', ',', 'arguments', '=', 'args', ',', 'use_all_args', '=...
Use this to add standardized pypiper arguments to your python pipeline. There are two ways to use `add_pypiper_args`: by specifying argument groups, or by specifying individual arguments. Specifying argument groups will add multiple arguments to your parser; these convenient argument groupings make it ...
['Use', 'this', 'to', 'add', 'standardized', 'pypiper', 'arguments', 'to', 'your', 'python', 'pipeline', '.']
train
https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L31-L54
9,373
saltstack/salt
salt/modules/modjk.py
worker_edit
def worker_edit(worker, lbn, settings, profile='default'): ''' Edit the worker settings Note: http://tomcat.apache.org/connectors-doc/reference/status.html Data Parameters for the standard Update Action CLI Examples: .. code-block:: bash salt '*' modjk.worker_edit node1 loadbalancer1...
python
def worker_edit(worker, lbn, settings, profile='default'): ''' Edit the worker settings Note: http://tomcat.apache.org/connectors-doc/reference/status.html Data Parameters for the standard Update Action CLI Examples: .. code-block:: bash salt '*' modjk.worker_edit node1 loadbalancer1...
['def', 'worker_edit', '(', 'worker', ',', 'lbn', ',', 'settings', ',', 'profile', '=', "'default'", ')', ':', 'settings', '[', "'cmd'", ']', '=', "'update'", 'settings', '[', "'mime'", ']', '=', "'prop'", 'settings', '[', "'w'", ']', '=', 'lbn', 'settings', '[', "'sw'", ']', '=', 'worker', 'return', '_do_http', '(', '...
Edit the worker settings Note: http://tomcat.apache.org/connectors-doc/reference/status.html Data Parameters for the standard Update Action CLI Examples: .. code-block:: bash salt '*' modjk.worker_edit node1 loadbalancer1 "{'vwf': 500, 'vwd': 60}" salt '*' modjk.worker_edit node1 loa...
['Edit', 'the', 'worker', 'settings']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/modjk.py#L507-L527
9,374
jart/fabulous
fabulous/text.py
get_font_files
def get_font_files(): """Returns a list of all font files we could find Returned as a list of dir/files tuples:: get_font_files() -> {'FontName': '/abs/FontName.ttf', ...] For example:: >>> fonts = get_font_files() >>> 'NotoSans-Bold' in fonts True >>> fonts['Noto...
python
def get_font_files(): """Returns a list of all font files we could find Returned as a list of dir/files tuples:: get_font_files() -> {'FontName': '/abs/FontName.ttf', ...] For example:: >>> fonts = get_font_files() >>> 'NotoSans-Bold' in fonts True >>> fonts['Noto...
['def', 'get_font_files', '(', ')', ':', 'roots', '=', '[', "'/usr/share/fonts/truetype'", ',', '# where ubuntu puts fonts', "'/usr/share/fonts'", ',', '# where fedora puts fonts', 'os', '.', 'path', '.', 'expanduser', '(', "'~/.fonts'", ')', ',', '# custom user fonts', 'os', '.', 'path', '.', 'abspath', '(', 'os', '.'...
Returns a list of all font files we could find Returned as a list of dir/files tuples:: get_font_files() -> {'FontName': '/abs/FontName.ttf', ...] For example:: >>> fonts = get_font_files() >>> 'NotoSans-Bold' in fonts True >>> fonts['NotoSans-Bold'].endswith('/NotoSa...
['Returns', 'a', 'list', 'of', 'all', 'font', 'files', 'we', 'could', 'find']
train
https://github.com/jart/fabulous/blob/19903cf0a980b82f5928c3bec1f28b6bdd3785bd/fabulous/text.py#L180-L208
9,375
spacetelescope/drizzlepac
drizzlepac/catalogs.py
generateCatalog
def generateCatalog(wcs, mode='automatic', catalog=None, src_find_filters=None, **kwargs): """ Function which determines what type of catalog object needs to be instantiated based on what type of source selection algorithm the user specified. Parameters ---------- wcs : obj ...
python
def generateCatalog(wcs, mode='automatic', catalog=None, src_find_filters=None, **kwargs): """ Function which determines what type of catalog object needs to be instantiated based on what type of source selection algorithm the user specified. Parameters ---------- wcs : obj ...
['def', 'generateCatalog', '(', 'wcs', ',', 'mode', '=', "'automatic'", ',', 'catalog', '=', 'None', ',', 'src_find_filters', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'if', 'not', 'isinstance', '(', 'catalog', ',', 'Catalog', ')', ':', 'if', 'mode', '==', "'automatic'", ':', '# if an array is provided as the sou...
Function which determines what type of catalog object needs to be instantiated based on what type of source selection algorithm the user specified. Parameters ---------- wcs : obj WCS object generated by STWCS or PyWCS catalog : str or ndarray Filename of existing catalog or nd...
['Function', 'which', 'determines', 'what', 'type', 'of', 'catalog', 'object', 'needs', 'to', 'be', 'instantiated', 'based', 'on', 'what', 'type', 'of', 'source', 'selection', 'algorithm', 'the', 'user', 'specified', '.']
train
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/catalogs.py#L43-L76
9,376
dpkp/kafka-python
kafka/metrics/stats/sensor.py
Sensor._check_quotas
def _check_quotas(self, time_ms): """ Check if we have violated our quota for any metric that has a configured quota """ for metric in self._metrics: if metric.config and metric.config.quota: value = metric.value(time_ms) if not metric....
python
def _check_quotas(self, time_ms): """ Check if we have violated our quota for any metric that has a configured quota """ for metric in self._metrics: if metric.config and metric.config.quota: value = metric.value(time_ms) if not metric....
['def', '_check_quotas', '(', 'self', ',', 'time_ms', ')', ':', 'for', 'metric', 'in', 'self', '.', '_metrics', ':', 'if', 'metric', '.', 'config', 'and', 'metric', '.', 'config', '.', 'quota', ':', 'value', '=', 'metric', '.', 'value', '(', 'time_ms', ')', 'if', 'not', 'metric', '.', 'config', '.', 'quota', '.', 'is_a...
Check if we have violated our quota for any metric that has a configured quota
['Check', 'if', 'we', 'have', 'violated', 'our', 'quota', 'for', 'any', 'metric', 'that', 'has', 'a', 'configured', 'quota']
train
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sensor.py#L78-L91
9,377
anomaly/vishnu
vishnu/util.py
google_app_engine_ndb_delete_expired_sessions
def google_app_engine_ndb_delete_expired_sessions(dormant_for=86400, limit=500): """ Deletes expired sessions A session is expired if it expires date is set and has passed or if it has not been accessed for a given period of time. :param dormant_for: seconds since last access to delete sessions, de...
python
def google_app_engine_ndb_delete_expired_sessions(dormant_for=86400, limit=500): """ Deletes expired sessions A session is expired if it expires date is set and has passed or if it has not been accessed for a given period of time. :param dormant_for: seconds since last access to delete sessions, de...
['def', 'google_app_engine_ndb_delete_expired_sessions', '(', 'dormant_for', '=', '86400', ',', 'limit', '=', '500', ')', ':', 'from', 'vishnu', '.', 'backend', '.', 'client', '.', 'google_app_engine_ndb', 'import', 'VishnuSession', 'from', 'google', '.', 'appengine', '.', 'ext', 'import', 'ndb', 'from', 'datetime', 'i...
Deletes expired sessions A session is expired if it expires date is set and has passed or if it has not been accessed for a given period of time. :param dormant_for: seconds since last access to delete sessions, defaults to 24 hours. :type dormant_for: int :param limit: amount to delete in one call...
['Deletes', 'expired', 'sessions', 'A', 'session', 'is', 'expired', 'if', 'it', 'expires', 'date', 'is', 'set', 'and', 'has', 'passed', 'or', 'if', 'it', 'has', 'not', 'been', 'accessed', 'for', 'a', 'given', 'period', 'of', 'time', '.']
train
https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/util.py#L3-L30
9,378
python-diamond/Diamond
src/collectors/onewire/onewire.py
OneWireCollector.get_default_config
def get_default_config(self): """ Returns the default collector settings """ config = super(OneWireCollector, self).get_default_config() config.update({ 'path': 'owfs', 'owfs': '/mnt/1wire', # 'scan': {'temperature': 't'}, # 'id:24....
python
def get_default_config(self): """ Returns the default collector settings """ config = super(OneWireCollector, self).get_default_config() config.update({ 'path': 'owfs', 'owfs': '/mnt/1wire', # 'scan': {'temperature': 't'}, # 'id:24....
['def', 'get_default_config', '(', 'self', ')', ':', 'config', '=', 'super', '(', 'OneWireCollector', ',', 'self', ')', '.', 'get_default_config', '(', ')', 'config', '.', 'update', '(', '{', "'path'", ':', "'owfs'", ',', "'owfs'", ':', "'/mnt/1wire'", ',', "# 'scan': {'temperature': 't'},", "# 'id:24.BB000000': {'file...
Returns the default collector settings
['Returns', 'the', 'default', 'collector', 'settings']
train
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/onewire/onewire.py#L36-L47
9,379
googleads/googleads-python-lib
examples/adwords/v201809/advanced_operations/add_ad_customizer.py
RestrictFeedItemToAdGroup
def RestrictFeedItemToAdGroup(client, feed_item, adgroup_id): """Restricts the feed item to an ad group. Args: client: an AdWordsClient instance. feed_item: The feed item. adgroup_id: The ad group ID. """ # Get the FeedItemTargetService feed_item_target_service = client.GetService( 'FeedIte...
python
def RestrictFeedItemToAdGroup(client, feed_item, adgroup_id): """Restricts the feed item to an ad group. Args: client: an AdWordsClient instance. feed_item: The feed item. adgroup_id: The ad group ID. """ # Get the FeedItemTargetService feed_item_target_service = client.GetService( 'FeedIte...
['def', 'RestrictFeedItemToAdGroup', '(', 'client', ',', 'feed_item', ',', 'adgroup_id', ')', ':', '# Get the FeedItemTargetService', 'feed_item_target_service', '=', 'client', '.', 'GetService', '(', "'FeedItemTargetService'", ',', "'v201809'", ')', '# Optional: Restrict the first feed item to only serve with ads for ...
Restricts the feed item to an ad group. Args: client: an AdWordsClient instance. feed_item: The feed item. adgroup_id: The ad group ID.
['Restricts', 'the', 'feed', 'item', 'to', 'an', 'ad', 'group', '.']
train
https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/examples/adwords/v201809/advanced_operations/add_ad_customizer.py#L128-L158
9,380
mryellow/maze_explorer
mazeexp/engine/world.py
WorldLayer.update_visited
def update_visited(self): """ Updates exploration map visited status """ assert isinstance(self.player.cshape.center, eu.Vector2) pos = self.player.cshape.center # Helper function def set_visited(layer, cell): if cell and not cell.properties.get('visi...
python
def update_visited(self): """ Updates exploration map visited status """ assert isinstance(self.player.cshape.center, eu.Vector2) pos = self.player.cshape.center # Helper function def set_visited(layer, cell): if cell and not cell.properties.get('visi...
['def', 'update_visited', '(', 'self', ')', ':', 'assert', 'isinstance', '(', 'self', '.', 'player', '.', 'cshape', '.', 'center', ',', 'eu', '.', 'Vector2', ')', 'pos', '=', 'self', '.', 'player', '.', 'cshape', '.', 'center', '# Helper function', 'def', 'set_visited', '(', 'layer', ',', 'cell', ')', ':', 'if', 'cell'...
Updates exploration map visited status
['Updates', 'exploration', 'map', 'visited', 'status']
train
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world.py#L318-L353
9,381
JamesPHoughton/pysd
pysd/pysd.py
read_vensim
def read_vensim(mdl_file): """ Construct a model from Vensim `.mdl` file. Parameters ---------- mdl_file : <string> The relative path filename for a raw Vensim `.mdl` file Returns ------- model: a PySD class object Elements from the python model are loaded into the PySD...
python
def read_vensim(mdl_file): """ Construct a model from Vensim `.mdl` file. Parameters ---------- mdl_file : <string> The relative path filename for a raw Vensim `.mdl` file Returns ------- model: a PySD class object Elements from the python model are loaded into the PySD...
['def', 'read_vensim', '(', 'mdl_file', ')', ':', 'from', '.', 'py_backend', '.', 'vensim', '.', 'vensim2py', 'import', 'translate_vensim', 'from', '.', 'py_backend', 'import', 'functions', 'py_model_file', '=', 'translate_vensim', '(', 'mdl_file', ')', 'model', '=', 'functions', '.', 'Model', '(', 'py_model_file', ')'...
Construct a model from Vensim `.mdl` file. Parameters ---------- mdl_file : <string> The relative path filename for a raw Vensim `.mdl` file Returns ------- model: a PySD class object Elements from the python model are loaded into the PySD class and ready to run Examples ...
['Construct', 'a', 'model', 'from', 'Vensim', '.', 'mdl', 'file', '.']
train
https://github.com/JamesPHoughton/pysd/blob/bf1b1d03954e9ba5acac9ba4f1ada7cd93352eda/pysd/pysd.py#L25-L49
9,382
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_mapcube_source
def make_mapcube_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.MapCubeSource` object """ data = dict(Spatial_Filename=Spatial_Filename) if spectrum is not None: data.update(spectrum) return roi_model.MapCubeSource(name, data)
python
def make_mapcube_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.MapCubeSource` object """ data = dict(Spatial_Filename=Spatial_Filename) if spectrum is not None: data.update(spectrum) return roi_model.MapCubeSource(name, data)
['def', 'make_mapcube_source', '(', 'name', ',', 'Spatial_Filename', ',', 'spectrum', ')', ':', 'data', '=', 'dict', '(', 'Spatial_Filename', '=', 'Spatial_Filename', ')', 'if', 'spectrum', 'is', 'not', 'None', ':', 'data', '.', 'update', '(', 'spectrum', ')', 'return', 'roi_model', '.', 'MapCubeSource', '(', 'name', '...
Construct and return a `fermipy.roi_model.MapCubeSource` object
['Construct', 'and', 'return', 'a', 'fermipy', '.', 'roi_model', '.', 'MapCubeSource', 'object']
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L34-L41
9,383
mdsol/rwslib
rwslib/builders/metadata.py
TranslatedText.build
def build(self, builder): """Build XML by appending to builder""" params = {} if self.lang is not None: params["xml:lang"] = self.lang builder.start("TranslatedText", params) builder.data(self.text) builder.end("TranslatedText")
python
def build(self, builder): """Build XML by appending to builder""" params = {} if self.lang is not None: params["xml:lang"] = self.lang builder.start("TranslatedText", params) builder.data(self.text) builder.end("TranslatedText")
['def', 'build', '(', 'self', ',', 'builder', ')', ':', 'params', '=', '{', '}', 'if', 'self', '.', 'lang', 'is', 'not', 'None', ':', 'params', '[', '"xml:lang"', ']', '=', 'self', '.', 'lang', 'builder', '.', 'start', '(', '"TranslatedText"', ',', 'params', ')', 'builder', '.', 'data', '(', 'self', '.', 'text', ')', '...
Build XML by appending to builder
['Build', 'XML', 'by', 'appending', 'to', 'builder']
train
https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L250-L257
9,384
spacetelescope/synphot_refactor
synphot/units.py
spectral_density_vega
def spectral_density_vega(wav, vegaflux): """Flux equivalencies between PHOTLAM and VEGAMAG. Parameters ---------- wav : `~astropy.units.quantity.Quantity` Quantity associated with values being converted (e.g., wavelength or frequency). vegaflux : `~astropy.units.quantity.Quantity`...
python
def spectral_density_vega(wav, vegaflux): """Flux equivalencies between PHOTLAM and VEGAMAG. Parameters ---------- wav : `~astropy.units.quantity.Quantity` Quantity associated with values being converted (e.g., wavelength or frequency). vegaflux : `~astropy.units.quantity.Quantity`...
['def', 'spectral_density_vega', '(', 'wav', ',', 'vegaflux', ')', ':', 'vega_photlam', '=', 'vegaflux', '.', 'to', '(', 'PHOTLAM', ',', 'equivalencies', '=', 'u', '.', 'spectral_density', '(', 'wav', ')', ')', '.', 'value', 'def', 'converter', '(', 'x', ')', ':', '"""Set nan/inf to -99 mag."""', 'val', '=', '-', '2.5'...
Flux equivalencies between PHOTLAM and VEGAMAG. Parameters ---------- wav : `~astropy.units.quantity.Quantity` Quantity associated with values being converted (e.g., wavelength or frequency). vegaflux : `~astropy.units.quantity.Quantity` Flux of Vega at ``wav``. Returns ...
['Flux', 'equivalencies', 'between', 'PHOTLAM', 'and', 'VEGAMAG', '.']
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L64-L99
9,385
hazelcast/hazelcast-python-client
hazelcast/connection.py
ConnectionManager.get_or_connect
def get_or_connect(self, address, authenticator=None): """ Gets the existing connection for a given address. If it does not exist, the system will try to connect asynchronously. In this case, it returns a Future. When the connection is established at some point in time, it can be retriev...
python
def get_or_connect(self, address, authenticator=None): """ Gets the existing connection for a given address. If it does not exist, the system will try to connect asynchronously. In this case, it returns a Future. When the connection is established at some point in time, it can be retriev...
['def', 'get_or_connect', '(', 'self', ',', 'address', ',', 'authenticator', '=', 'None', ')', ':', 'if', 'address', 'in', 'self', '.', 'connections', ':', 'return', 'ImmediateFuture', '(', 'self', '.', 'connections', '[', 'address', ']', ')', 'else', ':', 'with', 'self', '.', '_new_connection_mutex', ':', 'if', 'addre...
Gets the existing connection for a given address. If it does not exist, the system will try to connect asynchronously. In this case, it returns a Future. When the connection is established at some point in time, it can be retrieved by using the get_connection(:class:`~hazelcast.core.Address`) or from Fu...
['Gets', 'the', 'existing', 'connection', 'for', 'a', 'given', 'address', '.', 'If', 'it', 'does', 'not', 'exist', 'the', 'system', 'will', 'try', 'to', 'connect', 'asynchronously', '.', 'In', 'this', 'case', 'it', 'returns', 'a', 'Future', '.', 'When', 'the', 'connection', 'is', 'established', 'at', 'some', 'point', '...
train
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/connection.py#L87-L121
9,386
heronotears/lazyxml
lazyxml/builder.py
Builder.check_structure
def check_structure(self, keys): r"""Check structure availability by ``attrkey`` and ``valuekey`` option. """ return set(keys) <= set([self.__options['attrkey'], self.__options['valuekey']])
python
def check_structure(self, keys): r"""Check structure availability by ``attrkey`` and ``valuekey`` option. """ return set(keys) <= set([self.__options['attrkey'], self.__options['valuekey']])
['def', 'check_structure', '(', 'self', ',', 'keys', ')', ':', 'return', 'set', '(', 'keys', ')', '<=', 'set', '(', '[', 'self', '.', '__options', '[', "'attrkey'", ']', ',', 'self', '.', '__options', '[', "'valuekey'", ']', ']', ')']
r"""Check structure availability by ``attrkey`` and ``valuekey`` option.
['r', 'Check', 'structure', 'availability', 'by', 'attrkey', 'and', 'valuekey', 'option', '.']
train
https://github.com/heronotears/lazyxml/blob/e3f1ebd3f34cfa03d022ddec90e17d60c1c81953/lazyxml/builder.py#L130-L133
9,387
materialsproject/pymatgen
pymatgen/entries/entry_tools.py
EntrySet.from_csv
def from_csv(cls, filename: str): """ Imports PDEntries from a csv. Args: filename: Filename to import from. Returns: List of Elements, List of PDEntries """ with open(filename, "r", encoding="utf-8") as f: reader = csv.reader(f, deli...
python
def from_csv(cls, filename: str): """ Imports PDEntries from a csv. Args: filename: Filename to import from. Returns: List of Elements, List of PDEntries """ with open(filename, "r", encoding="utf-8") as f: reader = csv.reader(f, deli...
['def', 'from_csv', '(', 'cls', ',', 'filename', ':', 'str', ')', ':', 'with', 'open', '(', 'filename', ',', '"r"', ',', 'encoding', '=', '"utf-8"', ')', 'as', 'f', ':', 'reader', '=', 'csv', '.', 'reader', '(', 'f', ',', 'delimiter', '=', 'unicode2str', '(', '","', ')', ',', 'quotechar', '=', 'unicode2str', '(', '"\\"...
Imports PDEntries from a csv. Args: filename: Filename to import from. Returns: List of Elements, List of PDEntries
['Imports', 'PDEntries', 'from', 'a', 'csv', '.']
train
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/entries/entry_tools.py#L259-L288
9,388
sassoo/goldman
goldman/deserializers/comma_sep.py
Parser._parse_keys
def _parse_keys(row, line_num): """ Perform some sanity checks on they keys Each key in the row should not be named None cause (that's an overrun). A key named `type` MUST be present on the row & have a string value. :param row: dict :param line_num: int """ ...
python
def _parse_keys(row, line_num): """ Perform some sanity checks on they keys Each key in the row should not be named None cause (that's an overrun). A key named `type` MUST be present on the row & have a string value. :param row: dict :param line_num: int """ ...
['def', '_parse_keys', '(', 'row', ',', 'line_num', ')', ':', 'link', '=', "'tools.ietf.org/html/rfc4180#section-2'", 'none_keys', '=', '[', 'key', 'for', 'key', 'in', 'row', '.', 'keys', '(', ')', 'if', 'key', 'is', 'None', ']', 'if', 'none_keys', ':', 'fail', '(', "'You have more fields defined on row number {} '", "...
Perform some sanity checks on they keys Each key in the row should not be named None cause (that's an overrun). A key named `type` MUST be present on the row & have a string value. :param row: dict :param line_num: int
['Perform', 'some', 'sanity', 'checks', 'on', 'they', 'keys']
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/comma_sep.py#L51-L73
9,389
FutunnOpen/futuquant
futuquant/common/sys_config.py
SysConfig.set_client_info
def set_client_info(cls, client_id, client_ver): """ .. py:function:: set_client_info(cls, client_id, client_ver) 设置调用api的客户端信息, 非必调接口 :param client_id: str, 客户端标识 :param client_ver: int, 客户端版本号 :return: None :example: .. code:: python from ...
python
def set_client_info(cls, client_id, client_ver): """ .. py:function:: set_client_info(cls, client_id, client_ver) 设置调用api的客户端信息, 非必调接口 :param client_id: str, 客户端标识 :param client_ver: int, 客户端版本号 :return: None :example: .. code:: python from ...
['def', 'set_client_info', '(', 'cls', ',', 'client_id', ',', 'client_ver', ')', ':', 'SysConfig', '.', 'CLINET_ID', '=', 'client_id', 'SysConfig', '.', 'CLIENT_VER', '=', 'client_ver']
.. py:function:: set_client_info(cls, client_id, client_ver) 设置调用api的客户端信息, 非必调接口 :param client_id: str, 客户端标识 :param client_ver: int, 客户端版本号 :return: None :example: .. code:: python from futuquant import * SysConfig.set_client_info("MyFutuQuant", ...
['..', 'py', ':', 'function', '::', 'set_client_info', '(', 'cls', 'client_id', 'client_ver', ')']
train
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/common/sys_config.py#L23-L45
9,390
dw/mitogen
mitogen/core.py
fire
def fire(obj, name, *args, **kwargs): """ Arrange for `func(*args, **kwargs)` to be invoked for every function registered for the named signal on `obj`. """ signals = vars(obj).get('_signals', {}) for func in signals.get(name, ()): func(*args, **kwargs)
python
def fire(obj, name, *args, **kwargs): """ Arrange for `func(*args, **kwargs)` to be invoked for every function registered for the named signal on `obj`. """ signals = vars(obj).get('_signals', {}) for func in signals.get(name, ()): func(*args, **kwargs)
['def', 'fire', '(', 'obj', ',', 'name', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'signals', '=', 'vars', '(', 'obj', ')', '.', 'get', '(', "'_signals'", ',', '{', '}', ')', 'for', 'func', 'in', 'signals', '.', 'get', '(', 'name', ',', '(', ')', ')', ':', 'func', '(', '*', 'args', ',', '*', '*', 'kwargs', '...
Arrange for `func(*args, **kwargs)` to be invoked for every function registered for the named signal on `obj`.
['Arrange', 'for', 'func', '(', '*', 'args', '**', 'kwargs', ')', 'to', 'be', 'invoked', 'for', 'every', 'function', 'registered', 'for', 'the', 'named', 'signal', 'on', 'obj', '.']
train
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/core.py#L400-L407
9,391
jonathf/chaospy
chaospy/distributions/operators/multiply.py
Mul._bnd
def _bnd(self, xloc, left, right, cache): """ Distribution bounds. Example: >>> print(chaospy.Uniform().range([-2, 0, 2, 4])) [[0. 0. 0. 0.] [1. 1. 1. 1.]] >>> print(Mul(chaospy.Uniform(), 2).range([-2, 0, 2, 4])) [[0. 0. 0. 0.] ...
python
def _bnd(self, xloc, left, right, cache): """ Distribution bounds. Example: >>> print(chaospy.Uniform().range([-2, 0, 2, 4])) [[0. 0. 0. 0.] [1. 1. 1. 1.]] >>> print(Mul(chaospy.Uniform(), 2).range([-2, 0, 2, 4])) [[0. 0. 0. 0.] ...
['def', '_bnd', '(', 'self', ',', 'xloc', ',', 'left', ',', 'right', ',', 'cache', ')', ':', 'left', '=', 'evaluation', '.', 'get_forward_cache', '(', 'left', ',', 'cache', ')', 'right', '=', 'evaluation', '.', 'get_forward_cache', '(', 'right', ',', 'cache', ')', 'if', 'isinstance', '(', 'left', ',', 'Dist', ')', ':',...
Distribution bounds. Example: >>> print(chaospy.Uniform().range([-2, 0, 2, 4])) [[0. 0. 0. 0.] [1. 1. 1. 1.]] >>> print(Mul(chaospy.Uniform(), 2).range([-2, 0, 2, 4])) [[0. 0. 0. 0.] [2. 2. 2. 2.]] >>> print(Mul(2, chaospy.Un...
['Distribution', 'bounds', '.']
train
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/distributions/operators/multiply.py#L110-L242
9,392
tensorflow/tensor2tensor
tensor2tensor/layers/common_layers.py
unit_targeting
def unit_targeting(w, k): """Unit-level magnitude pruning.""" k = tf.to_int32(k) w_shape = shape_list(w) size = tf.to_int32(tf.reduce_prod(w_shape[:-1])) w = tf.reshape(w, [size, w_shape[-1]]) norm = tf.norm(w, axis=0) thres = tf.contrib.framework.sort(norm, axis=0)[k] mask = to_float(thres >= norm)[No...
python
def unit_targeting(w, k): """Unit-level magnitude pruning.""" k = tf.to_int32(k) w_shape = shape_list(w) size = tf.to_int32(tf.reduce_prod(w_shape[:-1])) w = tf.reshape(w, [size, w_shape[-1]]) norm = tf.norm(w, axis=0) thres = tf.contrib.framework.sort(norm, axis=0)[k] mask = to_float(thres >= norm)[No...
['def', 'unit_targeting', '(', 'w', ',', 'k', ')', ':', 'k', '=', 'tf', '.', 'to_int32', '(', 'k', ')', 'w_shape', '=', 'shape_list', '(', 'w', ')', 'size', '=', 'tf', '.', 'to_int32', '(', 'tf', '.', 'reduce_prod', '(', 'w_shape', '[', ':', '-', '1', ']', ')', ')', 'w', '=', 'tf', '.', 'reshape', '(', 'w', ',', '[', '...
Unit-level magnitude pruning.
['Unit', '-', 'level', 'magnitude', 'pruning', '.']
train
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_layers.py#L3858-L3870
9,393
mitsei/dlkit
dlkit/json_/repository/sessions.py
CompositionAdminSession.get_composition_form_for_create
def get_composition_form_for_create(self, composition_record_types): """Gets the composition form for creating new compositions. A new form should be requested for each create transaction. arg: composition_record_types (osid.type.Type[]): array of composition record types ...
python
def get_composition_form_for_create(self, composition_record_types): """Gets the composition form for creating new compositions. A new form should be requested for each create transaction. arg: composition_record_types (osid.type.Type[]): array of composition record types ...
['def', 'get_composition_form_for_create', '(', 'self', ',', 'composition_record_types', ')', ':', '# Implemented from template for', '# osid.resource.ResourceAdminSession.get_resource_form_for_create_template', 'for', 'arg', 'in', 'composition_record_types', ':', 'if', 'not', 'isinstance', '(', 'arg', ',', 'ABCType', ...
Gets the composition form for creating new compositions. A new form should be requested for each create transaction. arg: composition_record_types (osid.type.Type[]): array of composition record types return: (osid.repository.CompositionForm) - the composition form r...
['Gets', 'the', 'composition', 'form', 'for', 'creating', 'new', 'compositions', '.']
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L3848-L3883
9,394
qacafe/cdrouter.py
cdrouter/tags.py
TagsService.get
def get(self, name): """Get a tag. :param name: Tag name as string. :return: :class:`tags.Tag <tags.Tag>` object :rtype: tags.Tag """ schema = TagSchema() resp = self.service.get_id(self.base, name) return self.service.decode(schema, resp)
python
def get(self, name): """Get a tag. :param name: Tag name as string. :return: :class:`tags.Tag <tags.Tag>` object :rtype: tags.Tag """ schema = TagSchema() resp = self.service.get_id(self.base, name) return self.service.decode(schema, resp)
['def', 'get', '(', 'self', ',', 'name', ')', ':', 'schema', '=', 'TagSchema', '(', ')', 'resp', '=', 'self', '.', 'service', '.', 'get_id', '(', 'self', '.', 'base', ',', 'name', ')', 'return', 'self', '.', 'service', '.', 'decode', '(', 'schema', ',', 'resp', ')']
Get a tag. :param name: Tag name as string. :return: :class:`tags.Tag <tags.Tag>` object :rtype: tags.Tag
['Get', 'a', 'tag', '.']
train
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/tags.py#L93-L102
9,395
Julian/jsonschema
jsonschema/_format.py
FormatChecker.checks
def checks(self, format, raises=()): """ Register a decorated function as validating a new format. Arguments: format (str): The format that the decorated function will check. raises (Exception): The exception(s) raised by the decorated...
python
def checks(self, format, raises=()): """ Register a decorated function as validating a new format. Arguments: format (str): The format that the decorated function will check. raises (Exception): The exception(s) raised by the decorated...
['def', 'checks', '(', 'self', ',', 'format', ',', 'raises', '=', '(', ')', ')', ':', 'def', '_checks', '(', 'func', ')', ':', 'self', '.', 'checkers', '[', 'format', ']', '=', '(', 'func', ',', 'raises', ')', 'return', 'func', 'return', '_checks']
Register a decorated function as validating a new format. Arguments: format (str): The format that the decorated function will check. raises (Exception): The exception(s) raised by the decorated function when an invalid instance is fou...
['Register', 'a', 'decorated', 'function', 'as', 'validating', 'a', 'new', 'format', '.']
train
https://github.com/Julian/jsonschema/blob/a72332004cdc3ba456de7918bc32059822b2f69a/jsonschema/_format.py#L42-L66
9,396
ZELLMECHANIK-DRESDEN/dclab
dclab/features/volume.py
get_volume
def get_volume(cont, pos_x, pos_y, pix): """Calculate the volume of a polygon revolved around an axis The volume estimation assumes rotational symmetry. Green`s theorem and the Gaussian divergence theorem allow to formulate the volume as a line integral. Parameters ---------- cont: ndarray...
python
def get_volume(cont, pos_x, pos_y, pix): """Calculate the volume of a polygon revolved around an axis The volume estimation assumes rotational symmetry. Green`s theorem and the Gaussian divergence theorem allow to formulate the volume as a line integral. Parameters ---------- cont: ndarray...
['def', 'get_volume', '(', 'cont', ',', 'pos_x', ',', 'pos_y', ',', 'pix', ')', ':', 'if', 'np', '.', 'isscalar', '(', 'pos_x', ')', ':', 'cont', '=', '[', 'cont', ']', 'ret_list', '=', 'False', 'else', ':', 'ret_list', '=', 'True', '# Convert input to 1D arrays', 'pos_x', '=', 'np', '.', 'atleast_1d', '(', 'pos_x', ')...
Calculate the volume of a polygon revolved around an axis The volume estimation assumes rotational symmetry. Green`s theorem and the Gaussian divergence theorem allow to formulate the volume as a line integral. Parameters ---------- cont: ndarray or list of ndarrays of shape (N,2) A 2D...
['Calculate', 'the', 'volume', 'of', 'a', 'polygon', 'revolved', 'around', 'an', 'axis']
train
https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/features/volume.py#L9-L121
9,397
pkkid/python-plexapi
plexapi/library.py
Library.search
def search(self, title=None, libtype=None, **kwargs): """ Searching within a library section is much more powerful. It seems certain attributes on the media objects can be targeted to filter this search down a bit, but I havent found the documentation for it. Example: "studi...
python
def search(self, title=None, libtype=None, **kwargs): """ Searching within a library section is much more powerful. It seems certain attributes on the media objects can be targeted to filter this search down a bit, but I havent found the documentation for it. Example: "studi...
['def', 'search', '(', 'self', ',', 'title', '=', 'None', ',', 'libtype', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'args', '=', '{', '}', 'if', 'title', ':', 'args', '[', "'title'", ']', '=', 'title', 'if', 'libtype', ':', 'args', '[', "'type'", ']', '=', 'utils', '.', 'searchType', '(', 'libtype', ')', 'for', '...
Searching within a library section is much more powerful. It seems certain attributes on the media objects can be targeted to filter this search down a bit, but I havent found the documentation for it. Example: "studio=Comedy%20Central" or "year=1999" "title=Kung Fu" all work. Other...
['Searching', 'within', 'a', 'library', 'section', 'is', 'much', 'more', 'powerful', '.', 'It', 'seems', 'certain', 'attributes', 'on', 'the', 'media', 'objects', 'can', 'be', 'targeted', 'to', 'filter', 'this', 'search', 'down', 'a', 'bit', 'but', 'I', 'havent', 'found', 'the', 'documentation', 'for', 'it', '.']
train
https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/library.py#L85-L102
9,398
chrisspen/dtree
dtree.py
Data.validate_row
def validate_row(self, row): """ Ensure each element in the row matches the schema. """ clean_row = {} if isinstance(row, (tuple, list)): assert self.header_order, "No attribute order specified." assert len(row) == len(self.header_order), \ ...
python
def validate_row(self, row): """ Ensure each element in the row matches the schema. """ clean_row = {} if isinstance(row, (tuple, list)): assert self.header_order, "No attribute order specified." assert len(row) == len(self.header_order), \ ...
['def', 'validate_row', '(', 'self', ',', 'row', ')', ':', 'clean_row', '=', '{', '}', 'if', 'isinstance', '(', 'row', ',', '(', 'tuple', ',', 'list', ')', ')', ':', 'assert', 'self', '.', 'header_order', ',', '"No attribute order specified."', 'assert', 'len', '(', 'row', ')', '==', 'len', '(', 'self', '.', 'header_or...
Ensure each element in the row matches the schema.
['Ensure', 'each', 'element', 'in', 'the', 'row', 'matches', 'the', 'schema', '.']
train
https://github.com/chrisspen/dtree/blob/9e9c9992b22ad9a7e296af7e6837666b05db43ef/dtree.py#L755-L775
9,399
ThreshingFloor/libtf
libtf/logparsers/tf_generic_log.py
TFGenericLog._extract_features
def _extract_features(self): """ Get the feature data from the log file necessary for a reduction """ for parsed_line in self.parsed_lines: result = {'raw': parsed_line} if 'ip' in parsed_line: result['ip'] = parsed_line['ip'] if r...
python
def _extract_features(self): """ Get the feature data from the log file necessary for a reduction """ for parsed_line in self.parsed_lines: result = {'raw': parsed_line} if 'ip' in parsed_line: result['ip'] = parsed_line['ip'] if r...
['def', '_extract_features', '(', 'self', ')', ':', 'for', 'parsed_line', 'in', 'self', '.', 'parsed_lines', ':', 'result', '=', '{', "'raw'", ':', 'parsed_line', '}', 'if', "'ip'", 'in', 'parsed_line', ':', 'result', '[', "'ip'", ']', '=', 'parsed_line', '[', "'ip'", ']', 'if', 'result', '[', "'ip'", ']', 'not', 'in',...
Get the feature data from the log file necessary for a reduction
['Get', 'the', 'feature', 'data', 'from', 'the', 'log', 'file', 'necessary', 'for', 'a', 'reduction']
train
https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_generic_log.py#L45-L55