repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
nerdvegas/rez
src/rez/vendor/sortedcontainers/sortedset.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/sortedcontainers/sortedset.py#L218-L234
def difference_update(self, *iterables): """ Update the set, removing elements found in keeping only elements found in any of the *iterables*. """ _set = self._set values = set(chain(*iterables)) if (4 * len(values)) > len(_set): _list = self._list ...
[ "def", "difference_update", "(", "self", ",", "*", "iterables", ")", ":", "_set", "=", "self", ".", "_set", "values", "=", "set", "(", "chain", "(", "*", "iterables", ")", ")", "if", "(", "4", "*", "len", "(", "values", ")", ")", ">", "len", "(",...
Update the set, removing elements found in keeping only elements found in any of the *iterables*.
[ "Update", "the", "set", "removing", "elements", "found", "in", "keeping", "only", "elements", "found", "in", "any", "of", "the", "*", "iterables", "*", "." ]
python
train
unistra/django-rest-framework-fine-permissions
rest_framework_fine_permissions/fields.py
https://github.com/unistra/django-rest-framework-fine-permissions/blob/71af5953648ef9f9bdfb64a4c0ed0ea62661fa61/rest_framework_fine_permissions/fields.py#L53-L71
def to_representation(self, obj): """ Represent data for the field. """ many = isinstance(obj, collections.Iterable) \ or isinstance(obj, models.Manager) \ and not isinstance(obj, dict) assert self.serializer is not None \ and issubclass(self.serializer, seri...
[ "def", "to_representation", "(", "self", ",", "obj", ")", ":", "many", "=", "isinstance", "(", "obj", ",", "collections", ".", "Iterable", ")", "or", "isinstance", "(", "obj", ",", "models", ".", "Manager", ")", "and", "not", "isinstance", "(", "obj", ...
Represent data for the field.
[ "Represent", "data", "for", "the", "field", "." ]
python
train
pybel/pybel
src/pybel/manager/cache_manager.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L741-L749
def _get_annotation_entries_from_data(self, graph: BELGraph, data: EdgeData) -> Optional[List[NamespaceEntry]]: """Get the annotation entries from an edge data dictionary.""" annotations_dict = data.get(ANNOTATIONS) if annotations_dict is not None: return [ entry ...
[ "def", "_get_annotation_entries_from_data", "(", "self", ",", "graph", ":", "BELGraph", ",", "data", ":", "EdgeData", ")", "->", "Optional", "[", "List", "[", "NamespaceEntry", "]", "]", ":", "annotations_dict", "=", "data", ".", "get", "(", "ANNOTATIONS", "...
Get the annotation entries from an edge data dictionary.
[ "Get", "the", "annotation", "entries", "from", "an", "edge", "data", "dictionary", "." ]
python
train
cherrypy/cheroot
cheroot/server.py
https://github.com/cherrypy/cheroot/blob/2af3b1798d66da697957480d3a8b4831a405770b/cheroot/server.py#L606-L634
def read_trailer_lines(self): """Read HTTP headers and yield them. Returns: Generator: yields CRLF separated lines. """ if not self.closed: raise ValueError( 'Cannot read trailers until the request body has been read.', ) whi...
[ "def", "read_trailer_lines", "(", "self", ")", ":", "if", "not", "self", ".", "closed", ":", "raise", "ValueError", "(", "'Cannot read trailers until the request body has been read.'", ",", ")", "while", "True", ":", "line", "=", "self", ".", "rfile", ".", "read...
Read HTTP headers and yield them. Returns: Generator: yields CRLF separated lines.
[ "Read", "HTTP", "headers", "and", "yield", "them", "." ]
python
train
piface/pifacecommon
pifacecommon/interrupts.py
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L309-L341
def handle_events( function_maps, event_queue, event_matches_function_map, terminate_signal): """Waits for events on the event queue and calls the registered functions. :param function_maps: A list of classes that have inheritted from :class:`FunctionMap`\ s describing what to do with e...
[ "def", "handle_events", "(", "function_maps", ",", "event_queue", ",", "event_matches_function_map", ",", "terminate_signal", ")", ":", "while", "True", ":", "# print(\"HANDLE: Waiting for events!\")", "event", "=", "event_queue", ".", "get", "(", ")", "# print(\"HANDLE...
Waits for events on the event queue and calls the registered functions. :param function_maps: A list of classes that have inheritted from :class:`FunctionMap`\ s describing what to do with events. :type function_maps: list :param event_queue: A queue to put events on. :type event_queue: :py:cla...
[ "Waits", "for", "events", "on", "the", "event", "queue", "and", "calls", "the", "registered", "functions", "." ]
python
test
allenai/allennlp
allennlp/semparse/worlds/world.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/worlds/world.py#L245-L285
def get_logical_form(self, action_sequence: List[str], add_var_function: bool = True) -> str: """ Takes an action sequence and constructs a logical form from it. This is useful if you want to get a logical form from a decoded sequence of actions ...
[ "def", "get_logical_form", "(", "self", ",", "action_sequence", ":", "List", "[", "str", "]", ",", "add_var_function", ":", "bool", "=", "True", ")", "->", "str", ":", "# Basic outline: we assume that the bracketing that we get in the RHS of each action is the", "# correc...
Takes an action sequence and constructs a logical form from it. This is useful if you want to get a logical form from a decoded sequence of actions generated by a transition based semantic parser. Parameters ---------- action_sequence : ``List[str]`` The sequence of ...
[ "Takes", "an", "action", "sequence", "and", "constructs", "a", "logical", "form", "from", "it", ".", "This", "is", "useful", "if", "you", "want", "to", "get", "a", "logical", "form", "from", "a", "decoded", "sequence", "of", "actions", "generated", "by", ...
python
train
galactics/beyond
beyond/dates/date.py
https://github.com/galactics/beyond/blob/7a7590ff0fd4c0bac3e8e383ecca03caa98e5742/beyond/dates/date.py#L367-L377
def change_scale(self, new_scale): """ Args: new_scale (str) Return: Date """ offset = self.scale.offset(self._mjd, new_scale, self.eop) result = self.datetime + timedelta(seconds=offset) return self.__class__(result, scale=new_scale)
[ "def", "change_scale", "(", "self", ",", "new_scale", ")", ":", "offset", "=", "self", ".", "scale", ".", "offset", "(", "self", ".", "_mjd", ",", "new_scale", ",", "self", ".", "eop", ")", "result", "=", "self", ".", "datetime", "+", "timedelta", "(...
Args: new_scale (str) Return: Date
[ "Args", ":", "new_scale", "(", "str", ")", "Return", ":", "Date" ]
python
train
tensorforce/tensorforce
docs/m2r.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L226-L238
def list(self, body, ordered=True): """Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. :param ordered: whether this list is ordered or not. """ mark = '#. ' if ordered else '* ' lines = body.splitlines() for i, line in enum...
[ "def", "list", "(", "self", ",", "body", ",", "ordered", "=", "True", ")", ":", "mark", "=", "'#. '", "if", "ordered", "else", "'* '", "lines", "=", "body", ".", "splitlines", "(", ")", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")",...
Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. :param ordered: whether this list is ordered or not.
[ "Rendering", "list", "tags", "like", "<ul", ">", "and", "<ol", ">", "." ]
python
valid
ambitioninc/rabbitmq-admin
rabbitmq_admin/base.py
https://github.com/ambitioninc/rabbitmq-admin/blob/ff65054115f19991da153f0e4f4e45e526545fea/rabbitmq_admin/base.py#L125-L133
def _delete(self, *args, **kwargs): """ A wrapper for deleting things :returns: The response of your delete :rtype: dict """ response = requests.delete(*args, **kwargs) response.raise_for_status()
[ "def", "_delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "requests", ".", "delete", "(", "*", "args", ",", "*", "*", "kwargs", ")", "response", ".", "raise_for_status", "(", ")" ]
A wrapper for deleting things :returns: The response of your delete :rtype: dict
[ "A", "wrapper", "for", "deleting", "things" ]
python
train
edx/auth-backends
auth_backends/backends.py
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/backends.py#L66-L77
def _map_user_details(self, response): """Maps key/values from the response to key/values in the user model. Does not transfer any key/value that is empty or not present in the response. """ dest = {} for source_key, dest_key in self.CLAIMS_TO_DETAILS_KEY_MAP.items(): ...
[ "def", "_map_user_details", "(", "self", ",", "response", ")", ":", "dest", "=", "{", "}", "for", "source_key", ",", "dest_key", "in", "self", ".", "CLAIMS_TO_DETAILS_KEY_MAP", ".", "items", "(", ")", ":", "value", "=", "response", ".", "get", "(", "sour...
Maps key/values from the response to key/values in the user model. Does not transfer any key/value that is empty or not present in the response.
[ "Maps", "key", "/", "values", "from", "the", "response", "to", "key", "/", "values", "in", "the", "user", "model", "." ]
python
train
deep-compute/deeputil
deeputil/streamcounter.py
https://github.com/deep-compute/deeputil/blob/9af5702bc3fd990688bf2aed16c20fa104be66df/deeputil/streamcounter.py#L47-L105
def add(self, item, count=1): ''' When we receive stream of data, we add them in the chunk which has limit on the no. of items that it will store. >>> s = StreamCounter(5,5) >>> data_stream = ['a','b','c','d'] >>> for item in data_stream: ... s.add(item) ...
[ "def", "add", "(", "self", ",", "item", ",", "count", "=", "1", ")", ":", "self", ".", "n_items_seen", "+=", "count", "self", ".", "n_chunk_items_seen", "+=", "count", "# get current chunk", "chunk_id", "=", "self", ".", "n_chunks", "chunk", "=", "self", ...
When we receive stream of data, we add them in the chunk which has limit on the no. of items that it will store. >>> s = StreamCounter(5,5) >>> data_stream = ['a','b','c','d'] >>> for item in data_stream: ... s.add(item) >>> s.chunk_size 5 >>> s.n_item...
[ "When", "we", "receive", "stream", "of", "data", "we", "add", "them", "in", "the", "chunk", "which", "has", "limit", "on", "the", "no", ".", "of", "items", "that", "it", "will", "store", ".", ">>>", "s", "=", "StreamCounter", "(", "5", "5", ")", ">...
python
train
rytilahti/python-songpal
songpal/device.py
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L259-L262
async def get_inputs(self) -> List[Input]: """Return list of available outputs.""" res = await self.services["avContent"]["getCurrentExternalTerminalsStatus"]() return [Input.make(services=self.services, **x) for x in res if 'meta:zone:output' not in x['meta']]
[ "async", "def", "get_inputs", "(", "self", ")", "->", "List", "[", "Input", "]", ":", "res", "=", "await", "self", ".", "services", "[", "\"avContent\"", "]", "[", "\"getCurrentExternalTerminalsStatus\"", "]", "(", ")", "return", "[", "Input", ".", "make",...
Return list of available outputs.
[ "Return", "list", "of", "available", "outputs", "." ]
python
train
DataONEorg/d1_python
lib_common/src/d1_common/checksum.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L43-L62
def create_checksum_object_from_stream( f, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM ): """Calculate the checksum of a stream. Args: f: file-like object Only requirement is a ``read()`` method that returns ``bytes``. algorithm: str Checksum algorithm, ``MD5`` or ``SH...
[ "def", "create_checksum_object_from_stream", "(", "f", ",", "algorithm", "=", "d1_common", ".", "const", ".", "DEFAULT_CHECKSUM_ALGORITHM", ")", ":", "checksum_str", "=", "calculate_checksum_on_stream", "(", "f", ",", "algorithm", ")", "checksum_pyxb", "=", "d1_common...
Calculate the checksum of a stream. Args: f: file-like object Only requirement is a ``read()`` method that returns ``bytes``. algorithm: str Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``. Returns: Populated Checksum PyXB object.
[ "Calculate", "the", "checksum", "of", "a", "stream", "." ]
python
train
JukeboxPipeline/jukeboxmaya
src/jukeboxmaya/main.py
https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/main.py#L17-L35
def load_mayaplugins(): """Loads the maya plugins (not jukebox plugins) of the pipeline :returns: None :rtype: None :raises: None """ mpp = os.environ.get('MAYA_PLUG_IN_PATH') if mpp is not None: ';'.join([mpp, MAYA_PLUGIN_PATH]) else: mpp = MAYA_PLUGIN_PATH # to si...
[ "def", "load_mayaplugins", "(", ")", ":", "mpp", "=", "os", ".", "environ", ".", "get", "(", "'MAYA_PLUG_IN_PATH'", ")", "if", "mpp", "is", "not", "None", ":", "';'", ".", "join", "(", "[", "mpp", ",", "MAYA_PLUGIN_PATH", "]", ")", "else", ":", "mpp"...
Loads the maya plugins (not jukebox plugins) of the pipeline :returns: None :rtype: None :raises: None
[ "Loads", "the", "maya", "plugins", "(", "not", "jukebox", "plugins", ")", "of", "the", "pipeline" ]
python
train
log2timeline/plaso
plaso/parsers/bsm.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/bsm.py#L218-L231
def _FormatArgToken(self, token_data): """Formats an argument token as a dictionary of values. Args: token_data (bsm_token_data_arg32|bsm_token_data_arg64): AUT_ARG32 or AUT_ARG64 token data. Returns: dict[str, str]: token values. """ return { 'string': token_data.arg...
[ "def", "_FormatArgToken", "(", "self", ",", "token_data", ")", ":", "return", "{", "'string'", ":", "token_data", ".", "argument_value", ".", "rstrip", "(", "'\\x00'", ")", ",", "'num_arg'", ":", "token_data", ".", "argument_index", ",", "'is'", ":", "token_...
Formats an argument token as a dictionary of values. Args: token_data (bsm_token_data_arg32|bsm_token_data_arg64): AUT_ARG32 or AUT_ARG64 token data. Returns: dict[str, str]: token values.
[ "Formats", "an", "argument", "token", "as", "a", "dictionary", "of", "values", "." ]
python
train
pantsbuild/pants
src/python/pants/pantsd/pants_daemon.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/pantsd/pants_daemon.py#L229-L250
def compute_invalidation_globs(bootstrap_options): """ Combine --pythonpath and --pants_config_files(pants.ini) files that are in {buildroot} dir with those invalidation_globs provided by users :param bootstrap_options: :return: A list of invalidation_globs """ buildroot = get_buildroot() ...
[ "def", "compute_invalidation_globs", "(", "bootstrap_options", ")", ":", "buildroot", "=", "get_buildroot", "(", ")", "invalidation_globs", "=", "[", "]", "globs", "=", "bootstrap_options", ".", "pythonpath", "+", "bootstrap_options", ".", "pants_config_files", "+", ...
Combine --pythonpath and --pants_config_files(pants.ini) files that are in {buildroot} dir with those invalidation_globs provided by users :param bootstrap_options: :return: A list of invalidation_globs
[ "Combine", "--", "pythonpath", "and", "--", "pants_config_files", "(", "pants", ".", "ini", ")", "files", "that", "are", "in", "{", "buildroot", "}", "dir", "with", "those", "invalidation_globs", "provided", "by", "users", ":", "param", "bootstrap_options", ":...
python
train
inasafe/inasafe
extras/data_audit.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/data_audit.py#L77-L198
def IP_verified(directory, extensions_to_ignore=None, directories_to_ignore=None, files_to_ignore=None, verbose=False): """Find and audit potential data files that might violate IP This is the public function to be used to ascertain that all d...
[ "def", "IP_verified", "(", "directory", ",", "extensions_to_ignore", "=", "None", ",", "directories_to_ignore", "=", "None", ",", "files_to_ignore", "=", "None", ",", "verbose", "=", "False", ")", ":", "# Identify data files", "oldpath", "=", "None", "all_files", ...
Find and audit potential data files that might violate IP This is the public function to be used to ascertain that all data in the specified directory tree has been audited according to the GA data IP tracking process. if IP_verified is False: # Stop and take remedial action ... el...
[ "Find", "and", "audit", "potential", "data", "files", "that", "might", "violate", "IP" ]
python
train
boriel/zxbasic
zxblex.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L448-L453
def t_preproc_ID(t): r'[_A-Za-z]+' t.value = t.value.strip() t.type = preprocessor.get(t.value.lower(), 'ID') return t
[ "def", "t_preproc_ID", "(", "t", ")", ":", "t", ".", "value", "=", "t", ".", "value", ".", "strip", "(", ")", "t", ".", "type", "=", "preprocessor", ".", "get", "(", "t", ".", "value", ".", "lower", "(", ")", ",", "'ID'", ")", "return", "t" ]
r'[_A-Za-z]+
[ "r", "[", "_A", "-", "Za", "-", "z", "]", "+" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L4506-L4520
def get_stp_mst_detail_output_msti_msti_bridge_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_stp_mst_detail = ET.Element("get_stp_mst_detail") config = get_stp_mst_detail output = ET.SubElement(get_stp_mst_detail, "output") msti ...
[ "def", "get_stp_mst_detail_output_msti_msti_bridge_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_stp_mst_detail", "=", "ET", ".", "Element", "(", "\"get_stp_mst_detail\"", ")", "config", "=...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
i3visio/osrframework
osrframework/thirdparties/pipl_com/lib/search.py
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/search.py#L532-L540
def group_records_by_domain(self): """Return the records grouped by the domain they came from. The return value is a dict, a key in this dict is a domain and the value is a list of all the records with this domain. """ key_function = lambda record: record...
[ "def", "group_records_by_domain", "(", "self", ")", ":", "key_function", "=", "lambda", "record", ":", "record", ".", "source", ".", "domain", "return", "self", ".", "group_records", "(", "key_function", ")" ]
Return the records grouped by the domain they came from. The return value is a dict, a key in this dict is a domain and the value is a list of all the records with this domain.
[ "Return", "the", "records", "grouped", "by", "the", "domain", "they", "came", "from", ".", "The", "return", "value", "is", "a", "dict", "a", "key", "in", "this", "dict", "is", "a", "domain", "and", "the", "value", "is", "a", "list", "of", "all", "the...
python
train
MaxStrange/AudioSegment
algorithms/asa.py
https://github.com/MaxStrange/AudioSegment/blob/1daefb8de626ddff3ff7016697c3ad31d262ecd6/algorithms/asa.py#L998-L1020
def _map_segmentation_mask_to_stft_domain(mask, times, frequencies, stft_times, stft_frequencies): """ Maps the given `mask`, which is in domain (`frequencies`, `times`) to the new domain (`stft_frequencies`, `stft_times`) and returns the result. """ assert mask.shape == (frequencies.shape[0], times...
[ "def", "_map_segmentation_mask_to_stft_domain", "(", "mask", ",", "times", ",", "frequencies", ",", "stft_times", ",", "stft_frequencies", ")", ":", "assert", "mask", ".", "shape", "==", "(", "frequencies", ".", "shape", "[", "0", "]", ",", "times", ".", "sh...
Maps the given `mask`, which is in domain (`frequencies`, `times`) to the new domain (`stft_frequencies`, `stft_times`) and returns the result.
[ "Maps", "the", "given", "mask", "which", "is", "in", "domain", "(", "frequencies", "times", ")", "to", "the", "new", "domain", "(", "stft_frequencies", "stft_times", ")", "and", "returns", "the", "result", "." ]
python
test
KE-works/pykechain
pykechain/models/customization.py
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/customization.py#L96-L126
def _save_customization(self, widgets): """ Save the complete customization to the activity. :param widgets: The complete set of widgets to be customized """ if len(widgets) > 0: # Get the current customization and only replace the 'ext' part of it custom...
[ "def", "_save_customization", "(", "self", ",", "widgets", ")", ":", "if", "len", "(", "widgets", ")", ">", "0", ":", "# Get the current customization and only replace the 'ext' part of it", "customization", "=", "self", ".", "activity", ".", "_json_data", ".", "get...
Save the complete customization to the activity. :param widgets: The complete set of widgets to be customized
[ "Save", "the", "complete", "customization", "to", "the", "activity", "." ]
python
train
hanguokai/youku
youku/youku_playlists.py
https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/youku_playlists.py#L21-L31
def find_playlist_by_id(self, playlist_id): """doc: http://open.youku.com/docs/doc?id=66 """ url = 'https://openapi.youku.com/v2/playlists/show.json' params = { 'client_id': self.client_id, 'playlist_id': playlist_id } r = requests.get(url, params=...
[ "def", "find_playlist_by_id", "(", "self", ",", "playlist_id", ")", ":", "url", "=", "'https://openapi.youku.com/v2/playlists/show.json'", "params", "=", "{", "'client_id'", ":", "self", ".", "client_id", ",", "'playlist_id'", ":", "playlist_id", "}", "r", "=", "r...
doc: http://open.youku.com/docs/doc?id=66
[ "doc", ":", "http", ":", "//", "open", ".", "youku", ".", "com", "/", "docs", "/", "doc?id", "=", "66" ]
python
train
google/grumpy
third_party/stdlib/optparse.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/optparse.py#L1024-L1052
def add_option(self, *args, **kwargs): """add_option(Option) add_option(opt_str, ..., kwarg=val, ...) """ if type(args[0]) in types.StringTypes: option = self.option_class(*args, **kwargs) elif len(args) == 1 and not kwargs: option = args[0] ...
[ "def", "add_option", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "type", "(", "args", "[", "0", "]", ")", "in", "types", ".", "StringTypes", ":", "option", "=", "self", ".", "option_class", "(", "*", "args", ",", "*", ...
add_option(Option) add_option(opt_str, ..., kwarg=val, ...)
[ "add_option", "(", "Option", ")", "add_option", "(", "opt_str", "...", "kwarg", "=", "val", "...", ")" ]
python
valid
tk0miya/tk.phpautodoc
src/phply/phpparse.py
https://github.com/tk0miya/tk.phpautodoc/blob/cf789f64abaf76351485cee231a075227e665fb6/src/phply/phpparse.py#L1241-L1250
def p_static_scalar_namespace_name(p): '''static_scalar : namespace_name | NS_SEPARATOR namespace_name | NAMESPACE NS_SEPARATOR namespace_name''' if len(p) == 2: p[0] = ast.Constant(p[1], lineno=p.lineno(1)) elif len(p) == 3: p[0] = ast.Constant(p[1]...
[ "def", "p_static_scalar_namespace_name", "(", "p", ")", ":", "if", "len", "(", "p", ")", "==", "2", ":", "p", "[", "0", "]", "=", "ast", ".", "Constant", "(", "p", "[", "1", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", "el...
static_scalar : namespace_name | NS_SEPARATOR namespace_name | NAMESPACE NS_SEPARATOR namespace_name
[ "static_scalar", ":", "namespace_name", "|", "NS_SEPARATOR", "namespace_name", "|", "NAMESPACE", "NS_SEPARATOR", "namespace_name" ]
python
train
LionelR/pyair
pyair/stats.py
https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/stats.py#L140-L143
def gmv(a, b): """Geometric mean variance """ return np.exp(np.square(np.log(a) - np.log(b)).mean())
[ "def", "gmv", "(", "a", ",", "b", ")", ":", "return", "np", ".", "exp", "(", "np", ".", "square", "(", "np", ".", "log", "(", "a", ")", "-", "np", ".", "log", "(", "b", ")", ")", ".", "mean", "(", ")", ")" ]
Geometric mean variance
[ "Geometric", "mean", "variance" ]
python
valid
ejeschke/ginga
ginga/rv/plugins/PlotTable.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/PlotTable.py#L237-L274
def plot_two_columns(self, reset_xlimits=False, reset_ylimits=False): """Simple line plot for two selected columns.""" self.clear_plot() if self.tab is None: # No table data to plot return plt_kw = { 'lw': self.settings.get('linewidth', 1), 'ls': se...
[ "def", "plot_two_columns", "(", "self", ",", "reset_xlimits", "=", "False", ",", "reset_ylimits", "=", "False", ")", ":", "self", ".", "clear_plot", "(", ")", "if", "self", ".", "tab", "is", "None", ":", "# No table data to plot", "return", "plt_kw", "=", ...
Simple line plot for two selected columns.
[ "Simple", "line", "plot", "for", "two", "selected", "columns", "." ]
python
train
apache/incubator-mxnet
python/mxnet/contrib/text/vocab.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/text/vocab.py#L162-L186
def to_indices(self, tokens): """Converts tokens to indices according to the vocabulary. Parameters ---------- tokens : str or list of strs A source token or tokens to be converted. Returns ------- int or list of ints A token index or a...
[ "def", "to_indices", "(", "self", ",", "tokens", ")", ":", "to_reduce", "=", "False", "if", "not", "isinstance", "(", "tokens", ",", "list", ")", ":", "tokens", "=", "[", "tokens", "]", "to_reduce", "=", "True", "indices", "=", "[", "self", ".", "tok...
Converts tokens to indices according to the vocabulary. Parameters ---------- tokens : str or list of strs A source token or tokens to be converted. Returns ------- int or list of ints A token index or a list of token indices according to the v...
[ "Converts", "tokens", "to", "indices", "according", "to", "the", "vocabulary", "." ]
python
train
h2oai/h2o-3
h2o-py/h2o/group_by.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/group_by.py#L222-L252
def get_frame(self): """ Return the resulting H2OFrame containing the result(s) of aggregation(s) of the group by. The number of rows denote the number of groups generated by the group by operation. The number of columns depend on the number of aggregations performed, the number of col...
[ "def", "get_frame", "(", "self", ")", ":", "if", "self", ".", "_res", "is", "None", ":", "aggs", "=", "[", "]", "cols_operated", "=", "[", "]", "for", "k", "in", "self", ".", "_aggs", ":", "aggs", "+=", "(", "self", ".", "_aggs", "[", "k", "]",...
Return the resulting H2OFrame containing the result(s) of aggregation(s) of the group by. The number of rows denote the number of groups generated by the group by operation. The number of columns depend on the number of aggregations performed, the number of columns specified in the col paramet...
[ "Return", "the", "resulting", "H2OFrame", "containing", "the", "result", "(", "s", ")", "of", "aggregation", "(", "s", ")", "of", "the", "group", "by", "." ]
python
test
ctuning/ck
ck/kernel.py
https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/kernel.py#L3939-L3972
def flatten_dict(i): """ Any list item is converted to @number=value Any dict item is converted to #key=value # is always added at the beginning Input: { dict - python dictionary (prefix) - prefix (for recursion) (prune_keys) - list of keys ...
[ "def", "flatten_dict", "(", "i", ")", ":", "prefix", "=", "'#'", "if", "i", ".", "get", "(", "'prefix'", ",", "''", ")", "!=", "''", ":", "prefix", "=", "str", "(", "i", "[", "'prefix'", "]", ")", "a", "=", "i", "[", "'dict'", "]", "aa", "=",...
Any list item is converted to @number=value Any dict item is converted to #key=value # is always added at the beginning Input: { dict - python dictionary (prefix) - prefix (for recursion) (prune_keys) - list of keys to prune (can have wildcards) ...
[ "Any", "list", "item", "is", "converted", "to", "@number", "=", "value", "Any", "dict", "item", "is", "converted", "to", "#key", "=", "value", "#", "is", "always", "added", "at", "the", "beginning" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py#L280-L295
def nacm_rule_list_rule_context(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm") rule_list = ET.SubElement(nacm, "rule-list") name_key = ET.SubElement(rule_...
[ "def", "nacm_rule_list_rule_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "nacm", "=", "ET", ".", "SubElement", "(", "config", ",", "\"nacm\"", ",", "xmlns", "=", "\"urn:ietf:params:x...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L3541-L3557
def dvhat(s1): """ Find the unit vector corresponding to a state vector and the derivative of the unit vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvhat_c.html :param s1: State to be normalized. :type s1: 6-Element Array of floats :return: Unit vector s1 / abs(s1), and ...
[ "def", "dvhat", "(", "s1", ")", ":", "assert", "len", "(", "s1", ")", "is", "6", "s1", "=", "stypes", ".", "toDoubleVector", "(", "s1", ")", "sout", "=", "stypes", ".", "emptyDoubleVector", "(", "6", ")", "libspice", ".", "dvhat_c", "(", "s1", ",",...
Find the unit vector corresponding to a state vector and the derivative of the unit vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvhat_c.html :param s1: State to be normalized. :type s1: 6-Element Array of floats :return: Unit vector s1 / abs(s1), and its time derivative. :r...
[ "Find", "the", "unit", "vector", "corresponding", "to", "a", "state", "vector", "and", "the", "derivative", "of", "the", "unit", "vector", "." ]
python
train
allenai/allennlp
allennlp/common/configuration.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L34-L62
def full_name(cla55: Optional[type]) -> str: """ Return the full name (including module) of the given class. """ # Special case to handle None: if cla55 is None: return "?" if issubclass(cla55, Initializer) and cla55 not in [Initializer, PretrainedModelInitializer]: init_fn = cl...
[ "def", "full_name", "(", "cla55", ":", "Optional", "[", "type", "]", ")", "->", "str", ":", "# Special case to handle None:", "if", "cla55", "is", "None", ":", "return", "\"?\"", "if", "issubclass", "(", "cla55", ",", "Initializer", ")", "and", "cla55", "n...
Return the full name (including module) of the given class.
[ "Return", "the", "full", "name", "(", "including", "module", ")", "of", "the", "given", "class", "." ]
python
train
inveniosoftware/invenio-communities
invenio_communities/models.py
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L355-L365
def delete(self): """Mark the community for deletion. :param delete_time: DateTime after which to delete the community. :type delete_time: datetime.datetime :raises: CommunitiesError """ if self.deleted_at is not None: raise CommunitiesError(community=self) ...
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "deleted_at", "is", "not", "None", ":", "raise", "CommunitiesError", "(", "community", "=", "self", ")", "else", ":", "self", ".", "deleted_at", "=", "datetime", ".", "utcnow", "(", ")" ]
Mark the community for deletion. :param delete_time: DateTime after which to delete the community. :type delete_time: datetime.datetime :raises: CommunitiesError
[ "Mark", "the", "community", "for", "deletion", "." ]
python
train
majerteam/deform_extensions
deform_extensions/__init__.py
https://github.com/majerteam/deform_extensions/blob/fdad612e4889a40f1944611264b943866a3cb96e/deform_extensions/__init__.py#L51-L62
def grouper(iterable, items, fillvalue=None): """ Collect data into fixed-length chunks or blocks e.g: grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx Got it from https://docs.python.org/2/library/itertools.html#recipes """ args = [iter(iterable)] * items return izip_longest(fillvalue=...
[ "def", "grouper", "(", "iterable", ",", "items", ",", "fillvalue", "=", "None", ")", ":", "args", "=", "[", "iter", "(", "iterable", ")", "]", "*", "items", "return", "izip_longest", "(", "fillvalue", "=", "fillvalue", ",", "*", "args", ")" ]
Collect data into fixed-length chunks or blocks e.g: grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx Got it from https://docs.python.org/2/library/itertools.html#recipes
[ "Collect", "data", "into", "fixed", "-", "length", "chunks", "or", "blocks" ]
python
train
craffel/mir_eval
mir_eval/pattern.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L64-L79
def _n_onset_midi(patterns): """Computes the number of onset_midi objects in a pattern Parameters ---------- patterns : A list of patterns using the format returned by :func:`mir_eval.io.load_patterns()` Returns ------- n_onsets : int Number of onsets within the pat...
[ "def", "_n_onset_midi", "(", "patterns", ")", ":", "return", "len", "(", "[", "o_m", "for", "pat", "in", "patterns", "for", "occ", "in", "pat", "for", "o_m", "in", "occ", "]", ")" ]
Computes the number of onset_midi objects in a pattern Parameters ---------- patterns : A list of patterns using the format returned by :func:`mir_eval.io.load_patterns()` Returns ------- n_onsets : int Number of onsets within the pattern.
[ "Computes", "the", "number", "of", "onset_midi", "objects", "in", "a", "pattern" ]
python
train
saltstack/salt
salt/modules/virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4229-L4252
def capabilities(**kwargs): ''' Return the hypervisor connection capabilities. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0...
[ "def", "capabilities", "(", "*", "*", "kwargs", ")", ":", "conn", "=", "__get_conn", "(", "*", "*", "kwargs", ")", "caps", "=", "ElementTree", ".", "fromstring", "(", "conn", ".", "getCapabilities", "(", ")", ")", "conn", ".", "close", "(", ")", "ret...
Return the hypervisor connection capabilities. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: .. code-block:: ...
[ "Return", "the", "hypervisor", "connection", "capabilities", "." ]
python
train
mattloper/chumpy
chumpy/ch.py
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/ch.py#L1088-L1110
def tree_iterator(self, visited=None, path=None): ''' Generator function that traverse the dr tree start from this node (self). ''' if visited is None: visited = set() if self not in visited: if path and isinstance(path, list): path.append...
[ "def", "tree_iterator", "(", "self", ",", "visited", "=", "None", ",", "path", "=", "None", ")", ":", "if", "visited", "is", "None", ":", "visited", "=", "set", "(", ")", "if", "self", "not", "in", "visited", ":", "if", "path", "and", "isinstance", ...
Generator function that traverse the dr tree start from this node (self).
[ "Generator", "function", "that", "traverse", "the", "dr", "tree", "start", "from", "this", "node", "(", "self", ")", "." ]
python
train
apache/spark
python/pyspark/mllib/stat/KernelDensity.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/stat/KernelDensity.py#L48-L52
def setSample(self, sample): """Set sample points from the population. Should be a RDD""" if not isinstance(sample, RDD): raise TypeError("samples should be a RDD, received %s" % type(sample)) self._sample = sample
[ "def", "setSample", "(", "self", ",", "sample", ")", ":", "if", "not", "isinstance", "(", "sample", ",", "RDD", ")", ":", "raise", "TypeError", "(", "\"samples should be a RDD, received %s\"", "%", "type", "(", "sample", ")", ")", "self", ".", "_sample", "...
Set sample points from the population. Should be a RDD
[ "Set", "sample", "points", "from", "the", "population", ".", "Should", "be", "a", "RDD" ]
python
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L267-L305
def on_touch_up(self, touch): """Delegate touch handling if possible, else select something.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return self._lasttouch = touch touch.push() touch.apply_transform_2d(self.to_local) if hasattr(self, 'p...
[ "def", "on_touch_up", "(", "self", ",", "touch", ")", ":", "if", "hasattr", "(", "self", ",", "'_lasttouch'", ")", "and", "self", ".", "_lasttouch", "==", "touch", ":", "return", "self", ".", "_lasttouch", "=", "touch", "touch", ".", "push", "(", ")", ...
Delegate touch handling if possible, else select something.
[ "Delegate", "touch", "handling", "if", "possible", "else", "select", "something", "." ]
python
train
Kortemme-Lab/klab
klab/bio/bonsai.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L63-L65
def from_non_aligned_residue_IDs(Chain, StartResidueID, EndResidueID, Sequence = None): '''A more forgiving method that does not care about the padding of the residue IDs.''' return PDBSection(Chain, PDB.ResidueID2String(StartResidueID), PDB.ResidueID2String(EndResidueID), Sequence = Sequence)
[ "def", "from_non_aligned_residue_IDs", "(", "Chain", ",", "StartResidueID", ",", "EndResidueID", ",", "Sequence", "=", "None", ")", ":", "return", "PDBSection", "(", "Chain", ",", "PDB", ".", "ResidueID2String", "(", "StartResidueID", ")", ",", "PDB", ".", "Re...
A more forgiving method that does not care about the padding of the residue IDs.
[ "A", "more", "forgiving", "method", "that", "does", "not", "care", "about", "the", "padding", "of", "the", "residue", "IDs", "." ]
python
train
belbio/bel
bel/lang/bel_specification.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/lang/bel_specification.py#L125-L143
def get_bel_versions() -> List[str]: """Get BEL Language versions supported Get the list of all BEL Language versions supported. The file this depends on is generated by belspec_yaml2json and is kept up to date using `make update_ebnf` or `make update_parsers`. You can also run `belspec_yaml2json` ...
[ "def", "get_bel_versions", "(", ")", "->", "List", "[", "str", "]", ":", "spec_dir", "=", "config", "[", "\"bel\"", "]", "[", "\"lang\"", "]", "[", "\"specifications\"", "]", "fn", "=", "f\"{spec_dir}/versions.json\"", "with", "open", "(", "fn", ",", "\"r\...
Get BEL Language versions supported Get the list of all BEL Language versions supported. The file this depends on is generated by belspec_yaml2json and is kept up to date using `make update_ebnf` or `make update_parsers`. You can also run `belspec_yaml2json` directly as it's added as a command by pip...
[ "Get", "BEL", "Language", "versions", "supported" ]
python
train
sgaynetdinov/py-vkontakte
vk/comment.py
https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/comment.py#L34-L39
def _get_comments_count(session, group_or_user_id, wall_id): """ https://vk.com/dev/wall.getComments """ response = session.fetch("wall.getComments", count=100, owner_id=group_or_user_id, post_id=wall_id) return response.get('count')
[ "def", "_get_comments_count", "(", "session", ",", "group_or_user_id", ",", "wall_id", ")", ":", "response", "=", "session", ".", "fetch", "(", "\"wall.getComments\"", ",", "count", "=", "100", ",", "owner_id", "=", "group_or_user_id", ",", "post_id", "=", "wa...
https://vk.com/dev/wall.getComments
[ "https", ":", "//", "vk", ".", "com", "/", "dev", "/", "wall", ".", "getComments" ]
python
train
uzumaxy/pyvalid
pyvalid/__accepts.py
https://github.com/uzumaxy/pyvalid/blob/74a1a64df1cc77cac55f12f0fe0f52292c6ae479/pyvalid/__accepts.py#L44-L51
def __wrap_accepted_val(self, value): """Wrap accepted value in the list if yet not wrapped. """ if isinstance(value, tuple): value = list(value) elif not isinstance(value, list): value = [value] return value
[ "def", "__wrap_accepted_val", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "tuple", ")", ":", "value", "=", "list", "(", "value", ")", "elif", "not", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[",...
Wrap accepted value in the list if yet not wrapped.
[ "Wrap", "accepted", "value", "in", "the", "list", "if", "yet", "not", "wrapped", "." ]
python
train
kensho-technologies/graphql-compiler
graphql_compiler/__init__.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/__init__.py#L103-L136
def graphql_to_gremlin(schema, graphql_query, parameters, type_equivalence_hints=None): """Compile the GraphQL input using the schema into a Gremlin query and associated metadata. Args: schema: GraphQL schema object describing the schema of the graph to be queried graphql_query: the GraphQL que...
[ "def", "graphql_to_gremlin", "(", "schema", ",", "graphql_query", ",", "parameters", ",", "type_equivalence_hints", "=", "None", ")", ":", "compilation_result", "=", "compile_graphql_to_gremlin", "(", "schema", ",", "graphql_query", ",", "type_equivalence_hints", "=", ...
Compile the GraphQL input using the schema into a Gremlin query and associated metadata. Args: schema: GraphQL schema object describing the schema of the graph to be queried graphql_query: the GraphQL query to compile to Gremlin, as a string parameters: dict, mapping argument name to its va...
[ "Compile", "the", "GraphQL", "input", "using", "the", "schema", "into", "a", "Gremlin", "query", "and", "associated", "metadata", "." ]
python
train
apache/spark
python/pyspark/sql/types.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1068-L1077
def _has_nulltype(dt): """ Return whether there is NullType in `dt` or not """ if isinstance(dt, StructType): return any(_has_nulltype(f.dataType) for f in dt.fields) elif isinstance(dt, ArrayType): return _has_nulltype((dt.elementType)) elif isinstance(dt, MapType): return _has_...
[ "def", "_has_nulltype", "(", "dt", ")", ":", "if", "isinstance", "(", "dt", ",", "StructType", ")", ":", "return", "any", "(", "_has_nulltype", "(", "f", ".", "dataType", ")", "for", "f", "in", "dt", ".", "fields", ")", "elif", "isinstance", "(", "dt...
Return whether there is NullType in `dt` or not
[ "Return", "whether", "there", "is", "NullType", "in", "dt", "or", "not" ]
python
train
androguard/androguard
androguard/core/bytecodes/dvm.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L6851-L6877
def get_raw(self): """ Get the reconstructed code as bytearray :rtype: bytearray """ code_raw = self.code.get_raw() self.insns_size = (len(code_raw) // 2) + (len(code_raw) % 2) buff = bytearray() buff += pack("<H", self.registers_size) + \ ...
[ "def", "get_raw", "(", "self", ")", ":", "code_raw", "=", "self", ".", "code", ".", "get_raw", "(", ")", "self", ".", "insns_size", "=", "(", "len", "(", "code_raw", ")", "//", "2", ")", "+", "(", "len", "(", "code_raw", ")", "%", "2", ")", "bu...
Get the reconstructed code as bytearray :rtype: bytearray
[ "Get", "the", "reconstructed", "code", "as", "bytearray" ]
python
train
mickybart/python-atlasbroker
atlasbroker/service.py
https://github.com/mickybart/python-atlasbroker/blob/5b741c1348a6d33b342e0852a8a8900fa9ebf00a/atlasbroker/service.py#L141-L156
def deprovision(self, instance_id: str, details: DeprovisionDetails, async_allowed: bool) -> DeprovisionServiceSpec: """Deprovision an instance see openbrokerapi documentation Raises: ErrInstanceDoesNotExist: Instance does not exist. """ # F...
[ "def", "deprovision", "(", "self", ",", "instance_id", ":", "str", ",", "details", ":", "DeprovisionDetails", ",", "async_allowed", ":", "bool", ")", "->", "DeprovisionServiceSpec", ":", "# Find the instance", "instance", "=", "self", ".", "_backend", ".", "find...
Deprovision an instance see openbrokerapi documentation Raises: ErrInstanceDoesNotExist: Instance does not exist.
[ "Deprovision", "an", "instance", "see", "openbrokerapi", "documentation", "Raises", ":", "ErrInstanceDoesNotExist", ":", "Instance", "does", "not", "exist", "." ]
python
train
fkarb/xltable
xltable/expression.py
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L59-L69
def value(self): """Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated. """ try: if isinstance(self.__value, Expression): return self....
[ "def", "value", "(", "self", ")", ":", "try", ":", "if", "isinstance", "(", "self", ".", "__value", ",", "Expression", ")", ":", "return", "self", ".", "__value", ".", "value", "return", "self", ".", "__value", "except", "AttributeError", ":", "return", ...
Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated.
[ "Set", "a", "calculated", "value", "for", "this", "Expression", ".", "Used", "when", "writing", "formulas", "using", "XlsxWriter", "to", "give", "cells", "an", "initial", "value", "when", "the", "sheet", "is", "loaded", "without", "being", "calculated", "." ]
python
train
numenta/nupic
src/nupic/algorithms/temporal_memory.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/temporal_memory.py#L801-L837
def _adaptSegment(cls, connections, segment, prevActiveCells, permanenceIncrement, permanenceDecrement): """ Updates synapses on segment. Strengthens active synapses; weakens inactive synapses. :param connections: (Object) Connections instance for the tm :param segment:...
[ "def", "_adaptSegment", "(", "cls", ",", "connections", ",", "segment", ",", "prevActiveCells", ",", "permanenceIncrement", ",", "permanenceDecrement", ")", ":", "# Destroying a synapse modifies the set that we're iterating through.", "synapsesToDestroy", "=", "[", "]", "fo...
Updates synapses on segment. Strengthens active synapses; weakens inactive synapses. :param connections: (Object) Connections instance for the tm :param segment: (int) Segment to adapt :param prevActiveCells: (list) Active cells in `t-1` :param permanenceIncrement: ...
[ "Updates", "synapses", "on", "segment", ".", "Strengthens", "active", "synapses", ";", "weakens", "inactive", "synapses", "." ]
python
valid
rocky/python-filecache
pyficache/main.py
https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L213-L224
def clear_file_format_cache(): """Remove syntax-formatted lines in the cache. Use this when you change the Pygments syntax or Token formatting and want to redo how files may have previously been syntax marked.""" for fname, cache_info in file_cache.items(): for format, lines in cache_info.li...
[ "def", "clear_file_format_cache", "(", ")", ":", "for", "fname", ",", "cache_info", "in", "file_cache", ".", "items", "(", ")", ":", "for", "format", ",", "lines", "in", "cache_info", ".", "lines", ".", "items", "(", ")", ":", "if", "'plain'", "==", "f...
Remove syntax-formatted lines in the cache. Use this when you change the Pygments syntax or Token formatting and want to redo how files may have previously been syntax marked.
[ "Remove", "syntax", "-", "formatted", "lines", "in", "the", "cache", ".", "Use", "this", "when", "you", "change", "the", "Pygments", "syntax", "or", "Token", "formatting", "and", "want", "to", "redo", "how", "files", "may", "have", "previously", "been", "s...
python
train
dictatorlib/dictator
dictator/__init__.py
https://github.com/dictatorlib/dictator/blob/b77b1709b6fff174f13b0f0c5dbe740b4c07d712/dictator/__init__.py#L328-L355
def iterkeys(self, match=None, count=1): """Return an iterator over the db's keys. ``match`` allows for filtering the keys by pattern. ``count`` allows for hint the minimum number of returns. >>> dc = Dictator() >>> dc['1'] = 'abc' >>> dc['2'] = 'def' >>> dc['3']...
[ "def", "iterkeys", "(", "self", ",", "match", "=", "None", ",", "count", "=", "1", ")", ":", "logger", ".", "debug", "(", "'call iterkeys %s'", ",", "match", ")", "if", "match", "is", "None", ":", "match", "=", "'*'", "for", "key", "in", "self", "....
Return an iterator over the db's keys. ``match`` allows for filtering the keys by pattern. ``count`` allows for hint the minimum number of returns. >>> dc = Dictator() >>> dc['1'] = 'abc' >>> dc['2'] = 'def' >>> dc['3'] = 'ghi' >>> itr = dc.iterkeys() >>>...
[ "Return", "an", "iterator", "over", "the", "db", "s", "keys", ".", "match", "allows", "for", "filtering", "the", "keys", "by", "pattern", ".", "count", "allows", "for", "hint", "the", "minimum", "number", "of", "returns", "." ]
python
train
sorgerlab/indra
indra/assemblers/cx/assembler.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/assembler.py#L160-L170
def save_model(self, file_name='model.cx'): """Save the assembled CX network in a file. Parameters ---------- file_name : Optional[str] The name of the file to save the CX network to. Default: model.cx """ with open(file_name, 'wt') as fh: cx_str ...
[ "def", "save_model", "(", "self", ",", "file_name", "=", "'model.cx'", ")", ":", "with", "open", "(", "file_name", ",", "'wt'", ")", "as", "fh", ":", "cx_str", "=", "self", ".", "print_cx", "(", ")", "fh", ".", "write", "(", "cx_str", ")" ]
Save the assembled CX network in a file. Parameters ---------- file_name : Optional[str] The name of the file to save the CX network to. Default: model.cx
[ "Save", "the", "assembled", "CX", "network", "in", "a", "file", "." ]
python
train
ajdavis/mongo-mockup-db
mockupdb/__init__.py
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L2000-L2012
def raise_args_err(message='bad arguments', error_class=TypeError): """Throw an error with standard message, displaying function call. >>> def f(a, *args, **kwargs): ... raise_args_err() ... >>> f(1, 2, x='y') Traceback (most recent call last): ... TypeError: bad arguments: f(1, 2, ...
[ "def", "raise_args_err", "(", "message", "=", "'bad arguments'", ",", "error_class", "=", "TypeError", ")", ":", "frame", "=", "inspect", ".", "currentframe", "(", ")", ".", "f_back", "raise", "error_class", "(", "message", "+", "': '", "+", "format_call", "...
Throw an error with standard message, displaying function call. >>> def f(a, *args, **kwargs): ... raise_args_err() ... >>> f(1, 2, x='y') Traceback (most recent call last): ... TypeError: bad arguments: f(1, 2, x='y')
[ "Throw", "an", "error", "with", "standard", "message", "displaying", "function", "call", "." ]
python
train
google/mobly
mobly/controllers/iperf_server.py
https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/iperf_server.py#L125-L145
def start(self, extra_args="", tag=""): """Starts iperf server on specified port. Args: extra_args: A string representing extra arguments to start iperf server with. tag: Appended to log file name to identify logs from different iperf runs. ...
[ "def", "start", "(", "self", ",", "extra_args", "=", "\"\"", ",", "tag", "=", "\"\"", ")", ":", "if", "self", ".", "started", ":", "return", "utils", ".", "create_dir", "(", "self", ".", "log_path", ")", "if", "tag", ":", "tag", "=", "tag", "+", ...
Starts iperf server on specified port. Args: extra_args: A string representing extra arguments to start iperf server with. tag: Appended to log file name to identify logs from different iperf runs.
[ "Starts", "iperf", "server", "on", "specified", "port", "." ]
python
train
saltstack/salt
salt/modules/keystoneng.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystoneng.py#L530-L544
def user_create(auth=None, **kwargs): ''' Create a user CLI Example: .. code-block:: bash salt '*' keystoneng.user_create name=user1 salt '*' keystoneng.user_create name=user2 password=1234 enabled=False salt '*' keystoneng.user_create name=user3 domain_id=b62e76fbeeff4e8fb770...
[ "def", "user_create", "(", "auth", "=", "None", ",", "*", "*", "kwargs", ")", ":", "cloud", "=", "get_openstack_cloud", "(", "auth", ")", "kwargs", "=", "_clean_kwargs", "(", "keep_name", "=", "True", ",", "*", "*", "kwargs", ")", "return", "cloud", "....
Create a user CLI Example: .. code-block:: bash salt '*' keystoneng.user_create name=user1 salt '*' keystoneng.user_create name=user2 password=1234 enabled=False salt '*' keystoneng.user_create name=user3 domain_id=b62e76fbeeff4e8fb77073f591cf211e
[ "Create", "a", "user" ]
python
train
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L68-L89
def _scalar_from_string( self, value: str, ) -> Union[Period, Timestamp, Timedelta, NaTType]: """ Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT...
[ "def", "_scalar_from_string", "(", "self", ",", "value", ":", "str", ",", ")", "->", "Union", "[", "Period", ",", "Timestamp", ",", "Timedelta", ",", "NaTType", "]", ":", "raise", "AbstractMethodError", "(", "self", ")" ]
Construct a scalar type from a string. Parameters ---------- value : str Returns ------- Period, Timestamp, or Timedelta, or NaT Whatever the type of ``self._scalar_type`` is. Notes ----- This should call ``self._check_compatible_wit...
[ "Construct", "a", "scalar", "type", "from", "a", "string", "." ]
python
train
KelSolaar/Manager
manager/components_manager.py
https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1270-L1298
def filter_components(self, pattern, category=None): """ Filters the Components using given regex pattern. Usage:: >>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",)) >>> manager.register_components() True >>> mana...
[ "def", "filter_components", "(", "self", ",", "pattern", ",", "category", "=", "None", ")", ":", "filtered_components", "=", "[", "]", "for", "component", ",", "profile", "in", "self", ":", "if", "category", ":", "if", "profile", ".", "category", "!=", "...
Filters the Components using given regex pattern. Usage:: >>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",)) >>> manager.register_components() True >>> manager.filter_components("\w+A$") [u'core.tests_component_a'] ...
[ "Filters", "the", "Components", "using", "given", "regex", "pattern", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_rally.py#L72-L114
def cmd_rally_add(self, args): '''handle rally add''' if len(args) < 1: alt = self.settings.rallyalt else: alt = float(args[0]) if len(args) < 2: break_alt = self.settings.rally_breakalt else: break_alt = float(args[1]) if...
[ "def", "cmd_rally_add", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "alt", "=", "self", ".", "settings", ".", "rallyalt", "else", ":", "alt", "=", "float", "(", "args", "[", "0", "]", ")", "if", "len", "(",...
handle rally add
[ "handle", "rally", "add" ]
python
train
ga4gh/ga4gh-server
ga4gh/server/backend.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L477-L485
def featureSetsGenerator(self, request): """ Returns a generator over the (featureSet, nextPageToken) pairs defined by the specified request. """ dataset = self.getDataRepository().getDataset(request.dataset_id) return self._topLevelObjectGenerator( request, d...
[ "def", "featureSetsGenerator", "(", "self", ",", "request", ")", ":", "dataset", "=", "self", ".", "getDataRepository", "(", ")", ".", "getDataset", "(", "request", ".", "dataset_id", ")", "return", "self", ".", "_topLevelObjectGenerator", "(", "request", ",",...
Returns a generator over the (featureSet, nextPageToken) pairs defined by the specified request.
[ "Returns", "a", "generator", "over", "the", "(", "featureSet", "nextPageToken", ")", "pairs", "defined", "by", "the", "specified", "request", "." ]
python
train
python/performance
performance/compare.py
https://github.com/python/performance/blob/2a9524c0a5714e85106671bc61d750e800fe17db/performance/compare.py#L106-L123
def is_significant(sample1, sample2): """Determine whether two samples differ significantly. This uses a Student's two-sample, two-tailed t-test with alpha=0.95. Args: sample1: one sample. sample2: the other sample. Returns: (significant, t_score) where significant is a bool i...
[ "def", "is_significant", "(", "sample1", ",", "sample2", ")", ":", "deg_freedom", "=", "len", "(", "sample1", ")", "+", "len", "(", "sample2", ")", "-", "2", "critical_value", "=", "tdist95conf_level", "(", "deg_freedom", ")", "t_score", "=", "tscore", "("...
Determine whether two samples differ significantly. This uses a Student's two-sample, two-tailed t-test with alpha=0.95. Args: sample1: one sample. sample2: the other sample. Returns: (significant, t_score) where significant is a bool indicating whether the two samples dif...
[ "Determine", "whether", "two", "samples", "differ", "significantly", "." ]
python
test
snare/voltron
voltron/plugin.py
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L133-L144
def valid_web_plugin(self, plugin): """ Validate a web plugin, ensuring it is a web plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, WebPlugin) and hasattr(plugin, 'plugin_type') ...
[ "def", "valid_web_plugin", "(", "self", ",", "plugin", ")", ":", "if", "(", "issubclass", "(", "plugin", ",", "WebPlugin", ")", "and", "hasattr", "(", "plugin", ",", "'plugin_type'", ")", "and", "plugin", ".", "plugin_type", "==", "'web'", "and", "hasattr"...
Validate a web plugin, ensuring it is a web plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class.
[ "Validate", "a", "web", "plugin", "ensuring", "it", "is", "a", "web", "plugin", "and", "has", "the", "necessary", "fields", "present", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/srtm.py#L111-L117
def createFileList(self): """SRTM data is split into different directories, get a list of all of them and create a dictionary for easy lookup.""" global childFileListDownload if childFileListDownload is None or not childFileListDownload.is_alive(): childFileListDownload =...
[ "def", "createFileList", "(", "self", ")", ":", "global", "childFileListDownload", "if", "childFileListDownload", "is", "None", "or", "not", "childFileListDownload", ".", "is_alive", "(", ")", ":", "childFileListDownload", "=", "multiprocessing", ".", "Process", "("...
SRTM data is split into different directories, get a list of all of them and create a dictionary for easy lookup.
[ "SRTM", "data", "is", "split", "into", "different", "directories", "get", "a", "list", "of", "all", "of", "them", "and", "create", "a", "dictionary", "for", "easy", "lookup", "." ]
python
train
Clinical-Genomics/scout
scout/utils/requests.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/utils/requests.py#L144-L179
def fetch_ensembl_genes(build='37'): """Fetch the ensembl genes Args: build(str): ['37', '38'] """ if build == '37': url = 'http://grch37.ensembl.org' else: url = 'http://www.ensembl.org' LOG.info("Fetching ensembl genes from %s", url) dataset_name = 'hsapie...
[ "def", "fetch_ensembl_genes", "(", "build", "=", "'37'", ")", ":", "if", "build", "==", "'37'", ":", "url", "=", "'http://grch37.ensembl.org'", "else", ":", "url", "=", "'http://www.ensembl.org'", "LOG", ".", "info", "(", "\"Fetching ensembl genes from %s\"", ",",...
Fetch the ensembl genes Args: build(str): ['37', '38']
[ "Fetch", "the", "ensembl", "genes", "Args", ":", "build", "(", "str", ")", ":", "[", "37", "38", "]" ]
python
test
saltstack/salt
salt/modules/solr.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solr.py#L313-L335
def _get_admin_info(command, host=None, core_name=None): ''' PRIVATE METHOD Calls the _http_request method and passes the admin command to execute and stores the data. This data is fairly static but should be refreshed periodically to make sure everything this OK. The data object will contain th...
[ "def", "_get_admin_info", "(", "command", ",", "host", "=", "None", ",", "core_name", "=", "None", ")", ":", "url", "=", "_format_url", "(", "\"admin/{0}\"", ".", "format", "(", "command", ")", ",", "host", ",", "core_name", "=", "core_name", ")", "resp"...
PRIVATE METHOD Calls the _http_request method and passes the admin command to execute and stores the data. This data is fairly static but should be refreshed periodically to make sure everything this OK. The data object will contain the JSON response. command : str The admin command to exec...
[ "PRIVATE", "METHOD", "Calls", "the", "_http_request", "method", "and", "passes", "the", "admin", "command", "to", "execute", "and", "stores", "the", "data", ".", "This", "data", "is", "fairly", "static", "but", "should", "be", "refreshed", "periodically", "to"...
python
train
SatelliteQE/nailgun
nailgun/entities.py
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entities.py#L1447-L1468
def path(self, which=None): """Extend ``nailgun.entity_mixins.Entity.path``. The format of the returned path depends on the value of ``which``: build_pxe_default /config_templates/build_pxe_default clone /config_templates/clone revision /conf...
[ "def", "path", "(", "self", ",", "which", "=", "None", ")", ":", "if", "which", "in", "(", "'build_pxe_default'", ",", "'clone'", ",", "'revision'", ")", ":", "prefix", "=", "'self'", "if", "which", "==", "'clone'", "else", "'base'", "return", "'{0}/{1}'...
Extend ``nailgun.entity_mixins.Entity.path``. The format of the returned path depends on the value of ``which``: build_pxe_default /config_templates/build_pxe_default clone /config_templates/clone revision /config_templates/revision ``super`...
[ "Extend", "nailgun", ".", "entity_mixins", ".", "Entity", ".", "path", "." ]
python
train
janpipek/physt
physt/histogram_base.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L406-L453
def merge_bins(self, amount: Optional[int] = None, *, min_frequency: Optional[float] = None, axis: Optional[AxisIdentifier] = None, inplace: bool = False) -> 'HistogramBase': """Reduce the number of bins and add their content: Parameters ---------- amount: How many ad...
[ "def", "merge_bins", "(", "self", ",", "amount", ":", "Optional", "[", "int", "]", "=", "None", ",", "*", ",", "min_frequency", ":", "Optional", "[", "float", "]", "=", "None", ",", "axis", ":", "Optional", "[", "AxisIdentifier", "]", "=", "None", ",...
Reduce the number of bins and add their content: Parameters ---------- amount: How many adjacent bins to join together. min_frequency: Try to have at least this value in each bin (this is not enforce e.g. for minima between high bins) axis: int or None On...
[ "Reduce", "the", "number", "of", "bins", "and", "add", "their", "content", ":" ]
python
train
heuer/segno
segno/encoder.py
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L919-L942
def calc_format_info(version, error, mask_pattern): """\ Returns the format information for the provided error level and mask patttern. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- Table C.1 — Valid format information bit sequences (page 80) :param int version...
[ "def", "calc_format_info", "(", "version", ",", "error", ",", "mask_pattern", ")", ":", "fmt", "=", "mask_pattern", "if", "version", ">", "0", ":", "if", "error", "==", "consts", ".", "ERROR_LEVEL_L", ":", "fmt", "+=", "0x08", "elif", "error", "==", "con...
\ Returns the format information for the provided error level and mask patttern. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- Table C.1 — Valid format information bit sequences (page 80) :param int version: Version constant :param int error: Error level consta...
[ "\\", "Returns", "the", "format", "information", "for", "the", "provided", "error", "level", "and", "mask", "patttern", "." ]
python
train
deepmipt/DeepPavlov
deeppavlov/core/data/utils.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/data/utils.py#L83-L125
def download(dest_file_path: [List[Union[str, Path]]], source_url: str, force_download=True): """Download a file from URL to one or several target locations Args: dest_file_path: path or list of paths to the file destination files (including file name) source_url: the source URL force_d...
[ "def", "download", "(", "dest_file_path", ":", "[", "List", "[", "Union", "[", "str", ",", "Path", "]", "]", "]", ",", "source_url", ":", "str", ",", "force_download", "=", "True", ")", ":", "if", "isinstance", "(", "dest_file_path", ",", "list", ")", ...
Download a file from URL to one or several target locations Args: dest_file_path: path or list of paths to the file destination files (including file name) source_url: the source URL force_download: download file if it already exists, or not
[ "Download", "a", "file", "from", "URL", "to", "one", "or", "several", "target", "locations" ]
python
test
yyuu/botornado
boto/iam/connection.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/iam/connection.py#L867-L882
def deactivate_mfa_device(self, user_name, serial_number): """ Deactivates the specified MFA device and removes it from association with the user. :type user_name: string :param user_name: The username of the user :type serial_number: string :param seria...
[ "def", "deactivate_mfa_device", "(", "self", ",", "user_name", ",", "serial_number", ")", ":", "params", "=", "{", "'UserName'", ":", "user_name", ",", "'SerialNumber'", ":", "serial_number", "}", "return", "self", ".", "get_response", "(", "'DeactivateMFADevice'"...
Deactivates the specified MFA device and removes it from association with the user. :type user_name: string :param user_name: The username of the user :type serial_number: string :param seriasl_number: The serial number which uniquely identifies ...
[ "Deactivates", "the", "specified", "MFA", "device", "and", "removes", "it", "from", "association", "with", "the", "user", "." ]
python
train
klen/muffin-admin
muffin_admin/plugin.py
https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/plugin.py#L101-L113
def register(self, *handlers, **params): """ Ensure that handler is not registered. """ for handler in handlers: if issubclass(handler, PWModel): handler = type( handler._meta.db_table.title() + 'Admin', (PWAdminHandler,), dict(model=h...
[ "def", "register", "(", "self", ",", "*", "handlers", ",", "*", "*", "params", ")", ":", "for", "handler", "in", "handlers", ":", "if", "issubclass", "(", "handler", ",", "PWModel", ")", ":", "handler", "=", "type", "(", "handler", ".", "_meta", ".",...
Ensure that handler is not registered.
[ "Ensure", "that", "handler", "is", "not", "registered", "." ]
python
train
Bogdanp/dramatiq
dramatiq/brokers/rabbitmq.py
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/brokers/rabbitmq.py#L183-L224
def declare_queue(self, queue_name): """Declare a queue. Has no effect if a queue with the given name already exists. Parameters: queue_name(str): The name of the new queue. Raises: ConnectionClosed: If the underlying channel or connection has been clos...
[ "def", "declare_queue", "(", "self", ",", "queue_name", ")", ":", "attempts", "=", "1", "while", "True", ":", "try", ":", "if", "queue_name", "not", "in", "self", ".", "queues", ":", "self", ".", "emit_before", "(", "\"declare_queue\"", ",", "queue_name", ...
Declare a queue. Has no effect if a queue with the given name already exists. Parameters: queue_name(str): The name of the new queue. Raises: ConnectionClosed: If the underlying channel or connection has been closed.
[ "Declare", "a", "queue", ".", "Has", "no", "effect", "if", "a", "queue", "with", "the", "given", "name", "already", "exists", "." ]
python
train
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L4292-L4297
def intSubset(self): """Get the internal subset of a document """ ret = libxml2mod.xmlGetIntSubset(self._o) if ret is None:raise treeError('xmlGetIntSubset() failed') __tmp = xmlDtd(_obj=ret) return __tmp
[ "def", "intSubset", "(", "self", ")", ":", "ret", "=", "libxml2mod", ".", "xmlGetIntSubset", "(", "self", ".", "_o", ")", "if", "ret", "is", "None", ":", "raise", "treeError", "(", "'xmlGetIntSubset() failed'", ")", "__tmp", "=", "xmlDtd", "(", "_obj", "...
Get the internal subset of a document
[ "Get", "the", "internal", "subset", "of", "a", "document" ]
python
train
olsoneric/pedemath
pedemath/vec3.py
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec3.py#L73-L76
def dot_v3(v, w): """Return the dotproduct of two vectors.""" return sum([x * y for x, y in zip(v, w)])
[ "def", "dot_v3", "(", "v", ",", "w", ")", ":", "return", "sum", "(", "[", "x", "*", "y", "for", "x", ",", "y", "in", "zip", "(", "v", ",", "w", ")", "]", ")" ]
Return the dotproduct of two vectors.
[ "Return", "the", "dotproduct", "of", "two", "vectors", "." ]
python
train
asobrien/randomOrg
randomorg/_rand_core.py
https://github.com/asobrien/randomOrg/blob/76c3f167c5689992d32cd1f827816254158160f7/randomorg/_rand_core.py#L111-L131
def string(num, length, digits=False, upper=True, lower=True, unique=False): """Random strings.""" function = 'strings' # Convert arguments to random.org style # for a discussion on the method see: http://bit.ly/TKGkOF digits = convert(digits) upper = convert(upper) lower = convert(lower) ...
[ "def", "string", "(", "num", ",", "length", ",", "digits", "=", "False", ",", "upper", "=", "True", ",", "lower", "=", "True", ",", "unique", "=", "False", ")", ":", "function", "=", "'strings'", "# Convert arguments to random.org style", "# for a discussion o...
Random strings.
[ "Random", "strings", "." ]
python
train
liamw9534/bt-manager
bt_manager/interface.py
https://github.com/liamw9534/bt-manager/blob/51be2919394ce8134c698359649bfad09eedf4ec/bt_manager/interface.py#L193-L211
def set_property(self, name, value): """ Helper to set a property value by name, translating to correct dbus type See also :py:meth:`get_property` :param str name: The property name in the object's dictionary whose value shall be set. :param value: Propertie...
[ "def", "set_property", "(", "self", ",", "name", ",", "value", ")", ":", "typeof", "=", "type", "(", "self", ".", "get_property", "(", "name", ")", ")", "self", ".", "_interface", ".", "SetProperty", "(", "name", ",", "translate_to_dbus_type", "(", "type...
Helper to set a property value by name, translating to correct dbus type See also :py:meth:`get_property` :param str name: The property name in the object's dictionary whose value shall be set. :param value: Properties new value to be assigned. :return: :rai...
[ "Helper", "to", "set", "a", "property", "value", "by", "name", "translating", "to", "correct", "dbus", "type" ]
python
train
chrislit/abydos
abydos/phonetic/_beider_morse.py
https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/phonetic/_beider_morse.py#L758-L786
def _language_index_from_code(self, code, name_mode): """Return the index value for a language code. This returns l_any if more than one code is specified or the code is out of bounds. Parameters ---------- code : int The language code to interpret n...
[ "def", "_language_index_from_code", "(", "self", ",", "code", ",", "name_mode", ")", ":", "if", "code", "<", "1", "or", "code", ">", "sum", "(", "_LANG_DICT", "[", "_", "]", "for", "_", "in", "BMDATA", "[", "name_mode", "]", "[", "'languages'", "]", ...
Return the index value for a language code. This returns l_any if more than one code is specified or the code is out of bounds. Parameters ---------- code : int The language code to interpret name_mode : str The name mode of the algorithm: ``gen`...
[ "Return", "the", "index", "value", "for", "a", "language", "code", "." ]
python
valid
log2timeline/dfvfs
dfvfs/vfs/apfs_container_file_system.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/apfs_container_file_system.py#L75-L92
def FileEntryExistsByPathSpec(self, path_spec): """Determines if a file entry for a path specification exists. Args: path_spec (PathSpec): a path specification. Returns: bool: True if the file entry exists. """ volume_index = apfs_helper.APFSContainerPathSpecGetVolumeIndex(path_spec) ...
[ "def", "FileEntryExistsByPathSpec", "(", "self", ",", "path_spec", ")", ":", "volume_index", "=", "apfs_helper", ".", "APFSContainerPathSpecGetVolumeIndex", "(", "path_spec", ")", "# The virtual root file has not corresponding volume index but", "# should have a location.", "if",...
Determines if a file entry for a path specification exists. Args: path_spec (PathSpec): a path specification. Returns: bool: True if the file entry exists.
[ "Determines", "if", "a", "file", "entry", "for", "a", "path", "specification", "exists", "." ]
python
train
klmitch/tendril
tendril/connection.py
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L283-L307
def framers(self, value): """ Set the framers in use for the connection. The framer states will be reset next time their respective framer is used. """ # Handle sequence values if isinstance(value, collections.Sequence): if len(value) != 2: r...
[ "def", "framers", "(", "self", ",", "value", ")", ":", "# Handle sequence values", "if", "isinstance", "(", "value", ",", "collections", ".", "Sequence", ")", ":", "if", "len", "(", "value", ")", "!=", "2", ":", "raise", "ValueError", "(", "'need exactly 2...
Set the framers in use for the connection. The framer states will be reset next time their respective framer is used.
[ "Set", "the", "framers", "in", "use", "for", "the", "connection", ".", "The", "framer", "states", "will", "be", "reset", "next", "time", "their", "respective", "framer", "is", "used", "." ]
python
train
oriontvv/pyaspeller
pyaspeller/speller.py
https://github.com/oriontvv/pyaspeller/blob/9a76d1f1fb00c7eabfa006f8e0f145f764c7a8d6/pyaspeller/speller.py#L165-L170
def dictionary(self, value): """Set dictionary""" self._dictionary = value or {} if not isinstance(self._dictionary, dict): raise BadArgumentError("dictionary must be dict: {}".format( self._dictionary))
[ "def", "dictionary", "(", "self", ",", "value", ")", ":", "self", ".", "_dictionary", "=", "value", "or", "{", "}", "if", "not", "isinstance", "(", "self", ".", "_dictionary", ",", "dict", ")", ":", "raise", "BadArgumentError", "(", "\"dictionary must be d...
Set dictionary
[ "Set", "dictionary" ]
python
test
ga4gh/ga4gh-server
ga4gh/server/datamodel/datasets.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/datasets.py#L79-L86
def addBiosample(self, biosample): """ Adds the specified biosample to this dataset. """ id_ = biosample.getId() self._biosampleIdMap[id_] = biosample self._biosampleIds.append(id_) self._biosampleNameMap[biosample.getName()] = biosample
[ "def", "addBiosample", "(", "self", ",", "biosample", ")", ":", "id_", "=", "biosample", ".", "getId", "(", ")", "self", ".", "_biosampleIdMap", "[", "id_", "]", "=", "biosample", "self", ".", "_biosampleIds", ".", "append", "(", "id_", ")", "self", "....
Adds the specified biosample to this dataset.
[ "Adds", "the", "specified", "biosample", "to", "this", "dataset", "." ]
python
train
annoviko/pyclustering
pyclustering/nnet/fsync.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/fsync.py#L268-L287
def __calculate(self, t, step, int_step): """! @brief Calculates new amplitudes for oscillators in the network in line with current step. @param[in] t (double): Time of simulation. @param[in] step (double): Step of solution at the end of which states of oscillators should b...
[ "def", "__calculate", "(", "self", ",", "t", ",", "step", ",", "int_step", ")", ":", "next_amplitudes", "=", "[", "0.0", "]", "*", "self", ".", "_num_osc", "for", "index", "in", "range", "(", "0", ",", "self", ".", "_num_osc", ",", "1", ")", ":", ...
! @brief Calculates new amplitudes for oscillators in the network in line with current step. @param[in] t (double): Time of simulation. @param[in] step (double): Step of solution at the end of which states of oscillators should be calculated. @param[in] int_step (double): S...
[ "!" ]
python
valid
OpenMath/py-openmath
openmath/convert_pickle.py
https://github.com/OpenMath/py-openmath/blob/4906aa9ccf606f533675c28823772e07c30fd220/openmath/convert_pickle.py#L167-L178
def OMSymbol(self, module, name): r""" Helper function to build an OMS object EXAMPLES:: >>> from openmath.convert_pickle import PickleConverter >>> converter = PickleConverter() >>> o = converter.OMSymbol(module="foo.bar", name="baz"); o ...
[ "def", "OMSymbol", "(", "self", ",", "module", ",", "name", ")", ":", "return", "om", ".", "OMSymbol", "(", "cdbase", "=", "self", ".", "_cdbase", ",", "cd", "=", "module", ",", "name", "=", "name", ")" ]
r""" Helper function to build an OMS object EXAMPLES:: >>> from openmath.convert_pickle import PickleConverter >>> converter = PickleConverter() >>> o = converter.OMSymbol(module="foo.bar", name="baz"); o OMSymbol(name='baz', cd='foo.bar', id=Non...
[ "r", "Helper", "function", "to", "build", "an", "OMS", "object", "EXAMPLES", "::" ]
python
test
bpsmith/tia
tia/analysis/model/pos.py
https://github.com/bpsmith/tia/blob/a7043b6383e557aeea8fc7112bbffd6e36a230e9/tia/analysis/model/pos.py#L138-L169
def plot_rets(self, ls=1, ax=None): """Plot each of the position returns :param ls: True, if positions should be broken into long/short :param ax: Axes :param regr: True, if regression line is shown """ import matplotlib.pyplot as plt from tia.util.mplot import A...
[ "def", "plot_rets", "(", "self", ",", "ls", "=", "1", ",", "ax", "=", "None", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "from", "tia", ".", "util", ".", "mplot", "import", "AxesFormat", "if", "ax", "is", "None", ":", "ax", "=", ...
Plot each of the position returns :param ls: True, if positions should be broken into long/short :param ax: Axes :param regr: True, if regression line is shown
[ "Plot", "each", "of", "the", "position", "returns" ]
python
train
AlejandroFrias/case-conversion
case_conversion/case_parse.py
https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_parse.py#L126-L138
def _simple_acronym_detection(s, i, words, *args): """Detect acronyms based on runs of upper-case letters.""" # Combine each letter into a single string. acronym = ''.join(words[s:i]) # Remove original letters in word list. for _ in xrange(s, i): del words[s] # Replace them with new wo...
[ "def", "_simple_acronym_detection", "(", "s", ",", "i", ",", "words", ",", "*", "args", ")", ":", "# Combine each letter into a single string.", "acronym", "=", "''", ".", "join", "(", "words", "[", "s", ":", "i", "]", ")", "# Remove original letters in word lis...
Detect acronyms based on runs of upper-case letters.
[ "Detect", "acronyms", "based", "on", "runs", "of", "upper", "-", "case", "letters", "." ]
python
train
Vital-Fernandez/dazer
bin/lib/CodeTools/various.py
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/CodeTools/various.py#L80-L82
def ufloatDict_stdev(self, ufloat_dict): 'This gives us a dictionary of nominal values from a dictionary of uncertainties' return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.std_dev, ufloat_dict.values())))
[ "def", "ufloatDict_stdev", "(", "self", ",", "ufloat_dict", ")", ":", "return", "OrderedDict", "(", "izip", "(", "ufloat_dict", ".", "keys", "(", ")", ",", "map", "(", "lambda", "x", ":", "x", ".", "std_dev", ",", "ufloat_dict", ".", "values", "(", ")"...
This gives us a dictionary of nominal values from a dictionary of uncertainties
[ "This", "gives", "us", "a", "dictionary", "of", "nominal", "values", "from", "a", "dictionary", "of", "uncertainties" ]
python
train
rigetti/pyquil
pyquil/quilatom.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/quilatom.py#L195-L236
def format_parameter(element): """ Formats a particular parameter. Essentially the same as built-in formatting except using 'i' instead of 'j' for the imaginary number. :param element: {int, float, long, complex, Parameter} Formats a parameter for Quil output. """ if isinstance(element, integer...
[ "def", "format_parameter", "(", "element", ")", ":", "if", "isinstance", "(", "element", ",", "integer_types", ")", "or", "isinstance", "(", "element", ",", "np", ".", "int_", ")", ":", "return", "repr", "(", "element", ")", "elif", "isinstance", "(", "e...
Formats a particular parameter. Essentially the same as built-in formatting except using 'i' instead of 'j' for the imaginary number. :param element: {int, float, long, complex, Parameter} Formats a parameter for Quil output.
[ "Formats", "a", "particular", "parameter", ".", "Essentially", "the", "same", "as", "built", "-", "in", "formatting", "except", "using", "i", "instead", "of", "j", "for", "the", "imaginary", "number", "." ]
python
train
crytic/slither
slither/detectors/statements/deprecated_calls.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/statements/deprecated_calls.py#L88-L105
def detect_deprecated_references_in_node(self, node): """ Detects if a node makes use of any deprecated standards. Returns: list of tuple: (detecting_signature, original_text, recommended_text)""" # Define our results list results = [] # If this node has an expressi...
[ "def", "detect_deprecated_references_in_node", "(", "self", ",", "node", ")", ":", "# Define our results list", "results", "=", "[", "]", "# If this node has an expression, we check the underlying expression.", "if", "node", ".", "expression", ":", "results", "+=", "self", ...
Detects if a node makes use of any deprecated standards. Returns: list of tuple: (detecting_signature, original_text, recommended_text)
[ "Detects", "if", "a", "node", "makes", "use", "of", "any", "deprecated", "standards", "." ]
python
train
proycon/clam
clam/common/client.py
https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/common/client.py#L530-L532
def upload(self,project, inputtemplate, sourcefile, **kwargs): """Alias for ``addinputfile()``""" return self.addinputfile(project, inputtemplate,sourcefile, **kwargs)
[ "def", "upload", "(", "self", ",", "project", ",", "inputtemplate", ",", "sourcefile", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "addinputfile", "(", "project", ",", "inputtemplate", ",", "sourcefile", ",", "*", "*", "kwargs", ")" ]
Alias for ``addinputfile()``
[ "Alias", "for", "addinputfile", "()" ]
python
train
ReadabilityHoldings/python-readability-api
readability/clients.py
https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L119-L126
def get_article(self, article_id): """ Get a single article represented by `article_id`. :param article_id: ID of the article to retrieve. """ url = self._generate_url('articles/{0}'.format(article_id)) return self.get(url)
[ "def", "get_article", "(", "self", ",", "article_id", ")", ":", "url", "=", "self", ".", "_generate_url", "(", "'articles/{0}'", ".", "format", "(", "article_id", ")", ")", "return", "self", ".", "get", "(", "url", ")" ]
Get a single article represented by `article_id`. :param article_id: ID of the article to retrieve.
[ "Get", "a", "single", "article", "represented", "by", "article_id", "." ]
python
train
CEA-COSMIC/ModOpt
modopt/signal/svd.py
https://github.com/CEA-COSMIC/ModOpt/blob/019b189cb897cbb4d210c44a100daaa08468830c/modopt/signal/svd.py#L63-L89
def calculate_svd(data): """Calculate Singular Value Decomposition This method calculates the Singular Value Decomposition (SVD) of the input data using SciPy. Parameters ---------- data : np.ndarray Input data array, 2D matrix Returns ------- tuple of left singular vector...
[ "def", "calculate_svd", "(", "data", ")", ":", "if", "(", "not", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", ")", "or", "(", "data", ".", "ndim", "!=", "2", ")", ":", "raise", "TypeError", "(", "'Input data must be a 2D np.ndarray.'", ")",...
Calculate Singular Value Decomposition This method calculates the Singular Value Decomposition (SVD) of the input data using SciPy. Parameters ---------- data : np.ndarray Input data array, 2D matrix Returns ------- tuple of left singular vector, singular values and right sing...
[ "Calculate", "Singular", "Value", "Decomposition" ]
python
train
SystemRDL/systemrdl-compiler
systemrdl/core/helpers.py
https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/helpers.py#L16-L27
def get_ID_text(token): """ Get the text from the ID token. Strips off leading slash escape if present """ if isinstance(token, CommonToken): text = token.text else: text = token.getText() text = text.lstrip('\\') return text
[ "def", "get_ID_text", "(", "token", ")", ":", "if", "isinstance", "(", "token", ",", "CommonToken", ")", ":", "text", "=", "token", ".", "text", "else", ":", "text", "=", "token", ".", "getText", "(", ")", "text", "=", "text", ".", "lstrip", "(", "...
Get the text from the ID token. Strips off leading slash escape if present
[ "Get", "the", "text", "from", "the", "ID", "token", ".", "Strips", "off", "leading", "slash", "escape", "if", "present" ]
python
train
olsoneric/pedemath
pedemath/vec3.py
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec3.py#L120-L125
def cross_v3(vec_a, vec_b): """Return the crossproduct between vec_a and vec_b.""" return Vec3(vec_a.y * vec_b.z - vec_a.z * vec_b.y, vec_a.z * vec_b.x - vec_a.x * vec_b.z, vec_a.x * vec_b.y - vec_a.y * vec_b.x)
[ "def", "cross_v3", "(", "vec_a", ",", "vec_b", ")", ":", "return", "Vec3", "(", "vec_a", ".", "y", "*", "vec_b", ".", "z", "-", "vec_a", ".", "z", "*", "vec_b", ".", "y", ",", "vec_a", ".", "z", "*", "vec_b", ".", "x", "-", "vec_a", ".", "x",...
Return the crossproduct between vec_a and vec_b.
[ "Return", "the", "crossproduct", "between", "vec_a", "and", "vec_b", "." ]
python
train
SCIP-Interfaces/PySCIPOpt
examples/finished/read_tsplib.py
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/read_tsplib.py#L216-L262
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", ".", "read...
basic function for reading a ATSP problem on the TSPLIB format
[ "basic", "function", "for", "reading", "a", "ATSP", "problem", "on", "the", "TSPLIB", "format" ]
python
train
probcomp/crosscat
src/LocalEngine.py
https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L322-L340
def simple_predictive_sample(self, M_c, X_L, X_D, Y, Q, seed, n=1): """Sample values from predictive distribution of the given latent state. :param Y: A list of constraints to apply when sampling. Each constraint is a triplet of (r, d, v): r is the row index, d is the column in...
[ "def", "simple_predictive_sample", "(", "self", ",", "M_c", ",", "X_L", ",", "X_D", ",", "Y", ",", "Q", ",", "seed", ",", "n", "=", "1", ")", ":", "get_next_seed", "=", "make_get_next_seed", "(", "seed", ")", "samples", "=", "_do_simple_predictive_sample",...
Sample values from predictive distribution of the given latent state. :param Y: A list of constraints to apply when sampling. Each constraint is a triplet of (r, d, v): r is the row index, d is the column index and v is the value of the constraint :type Y: list of lists ...
[ "Sample", "values", "from", "predictive", "distribution", "of", "the", "given", "latent", "state", "." ]
python
train
jpoullet2000/atlasclient
atlasclient/models.py
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/models.py#L128-L139
def create(self, **kwargs): """Create a new instance of this resource type. As a general rule, the identifier should have been provided, but in some subclasses the identifier is server-side-generated. Those classes have to overload this method to deal with that scenario. """ ...
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "primary_key", "in", "kwargs", ":", "del", "kwargs", "[", "self", ".", "primary_key", "]", "data", "=", "self", ".", "_generate_input_dict", "(", "*", "*", "kwargs", ...
Create a new instance of this resource type. As a general rule, the identifier should have been provided, but in some subclasses the identifier is server-side-generated. Those classes have to overload this method to deal with that scenario.
[ "Create", "a", "new", "instance", "of", "this", "resource", "type", "." ]
python
train
waqasbhatti/astrobase
astrobase/magnitudes.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/magnitudes.py#L221-L241
def jhk_to_rmag(jmag,hmag,kmag): '''Converts given J, H, Ks mags to an R magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted R band magnitude. ''' return convert_constants(jmag,hmag...
[ "def", "jhk_to_rmag", "(", "jmag", ",", "hmag", ",", "kmag", ")", ":", "return", "convert_constants", "(", "jmag", ",", "hmag", ",", "kmag", ",", "RJHK", ",", "RJH", ",", "RJK", ",", "RHK", ",", "RJ", ",", "RH", ",", "RK", ")" ]
Converts given J, H, Ks mags to an R magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted R band magnitude.
[ "Converts", "given", "J", "H", "Ks", "mags", "to", "an", "R", "magnitude", "value", "." ]
python
valid
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/service_endpoint/service_endpoint_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/service_endpoint/service_endpoint_client.py#L202-L218
def update_service_endpoints(self, endpoints, project): """UpdateServiceEndpoints. [Preview API] Update the service endpoints. :param [ServiceEndpoint] endpoints: Names of the service endpoints to update. :param str project: Project ID or project name :rtype: [ServiceEndpoint] ...
[ "def", "update_service_endpoints", "(", "self", ",", "endpoints", ",", "project", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'", "]", "=", "self", ".", "_serialize", ".", "url", "(", ...
UpdateServiceEndpoints. [Preview API] Update the service endpoints. :param [ServiceEndpoint] endpoints: Names of the service endpoints to update. :param str project: Project ID or project name :rtype: [ServiceEndpoint]
[ "UpdateServiceEndpoints", ".", "[", "Preview", "API", "]", "Update", "the", "service", "endpoints", ".", ":", "param", "[", "ServiceEndpoint", "]", "endpoints", ":", "Names", "of", "the", "service", "endpoints", "to", "update", ".", ":", "param", "str", "pro...
python
train
pandas-dev/pandas
pandas/io/pytables.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L4254-L4264
def get_attrs(self): """ retrieve our attributes """ self.non_index_axes = [] self.nan_rep = None self.levels = [] self.index_axes = [a.infer(self) for a in self.indexables if a.is_an_indexable] self.values_axes = [a.infer(self) ...
[ "def", "get_attrs", "(", "self", ")", ":", "self", ".", "non_index_axes", "=", "[", "]", "self", ".", "nan_rep", "=", "None", "self", ".", "levels", "=", "[", "]", "self", ".", "index_axes", "=", "[", "a", ".", "infer", "(", "self", ")", "for", "...
retrieve our attributes
[ "retrieve", "our", "attributes" ]
python
train
aiogram/aiogram
aiogram/dispatcher/filters/filters.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/filters/filters.py#L247-L263
async def check(self, *args): """ All filters must return a positive result :param args: :return: """ data = {} for target in self.targets: result = await target(*args) if not result: return False if isinstance(...
[ "async", "def", "check", "(", "self", ",", "*", "args", ")", ":", "data", "=", "{", "}", "for", "target", "in", "self", ".", "targets", ":", "result", "=", "await", "target", "(", "*", "args", ")", "if", "not", "result", ":", "return", "False", "...
All filters must return a positive result :param args: :return:
[ "All", "filters", "must", "return", "a", "positive", "result" ]
python
train