repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
Microsoft/nni
tools/nni_trial_tool/url_utils.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_trial_tool/url_utils.py#L27-L29
def gen_send_version_url(ip, port): '''Generate send error url''' return '{0}:{1}{2}{3}/{4}/{5}'.format(BASE_URL.format(ip), port, API_ROOT_URL, VERSION_API, NNI_EXP_ID, NNI_TRIAL_JOB_ID)
[ "def", "gen_send_version_url", "(", "ip", ",", "port", ")", ":", "return", "'{0}:{1}{2}{3}/{4}/{5}'", ".", "format", "(", "BASE_URL", ".", "format", "(", "ip", ")", ",", "port", ",", "API_ROOT_URL", ",", "VERSION_API", ",", "NNI_EXP_ID", ",", "NNI_TRIAL_JOB_ID...
Generate send error url
[ "Generate", "send", "error", "url" ]
python
train
64.333333
apache/spark
python/pyspark/sql/group.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/group.py#L195-L221
def pivot(self, pivot_col, values=None): """ Pivots a column of the current :class:`DataFrame` and perform the specified aggregation. There are two versions of pivot function: one that requires the caller to specify the list of distinct values to pivot on, and one that does not. The latt...
[ "def", "pivot", "(", "self", ",", "pivot_col", ",", "values", "=", "None", ")", ":", "if", "values", "is", "None", ":", "jgd", "=", "self", ".", "_jgd", ".", "pivot", "(", "pivot_col", ")", "else", ":", "jgd", "=", "self", ".", "_jgd", ".", "pivo...
Pivots a column of the current :class:`DataFrame` and perform the specified aggregation. There are two versions of pivot function: one that requires the caller to specify the list of distinct values to pivot on, and one that does not. The latter is more concise but less efficient, because Spark ...
[ "Pivots", "a", "column", "of", "the", "current", ":", "class", ":", "DataFrame", "and", "perform", "the", "specified", "aggregation", ".", "There", "are", "two", "versions", "of", "pivot", "function", ":", "one", "that", "requires", "the", "caller", "to", ...
python
train
54.444444
portfors-lab/sparkle
sparkle/tools/audiotools.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/audiotools.py#L399-L427
def calibrate_signal(signal, resp, fs, frange): """Given original signal and recording, spits out a calibrated signal""" # remove dc offset from recorded response (synthesized orignal shouldn't have one) dc = np.mean(resp) resp = resp - dc npts = len(signal) f0 = np.ceil(frange[0] / (float(fs) ...
[ "def", "calibrate_signal", "(", "signal", ",", "resp", ",", "fs", ",", "frange", ")", ":", "# remove dc offset from recorded response (synthesized orignal shouldn't have one)", "dc", "=", "np", ".", "mean", "(", "resp", ")", "resp", "=", "resp", "-", "dc", "npts",...
Given original signal and recording, spits out a calibrated signal
[ "Given", "original", "signal", "and", "recording", "spits", "out", "a", "calibrated", "signal" ]
python
train
25.517241
djgagne/hagelslag
hagelslag/processing/TrackProcessing.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/TrackProcessing.py#L541-L575
def calc_track_errors(model_tracks, obs_tracks, track_pairings): """ Calculates spatial and temporal translation errors between matched forecast and observed tracks. Args: model_tracks: List of model track STObjects obs_tracks: List of observed track STObjects ...
[ "def", "calc_track_errors", "(", "model_tracks", ",", "obs_tracks", ",", "track_pairings", ")", ":", "columns", "=", "[", "'obs_track_id'", ",", "'translation_error_x'", ",", "'translation_error_y'", ",", "'start_time_difference'", ",", "'end_time_difference'", ",", "]"...
Calculates spatial and temporal translation errors between matched forecast and observed tracks. Args: model_tracks: List of model track STObjects obs_tracks: List of observed track STObjects track_pairings: List of tuples pairing forecast and observed tracks. ...
[ "Calculates", "spatial", "and", "temporal", "translation", "errors", "between", "matched", "forecast", "and", "observed", "tracks", "." ]
python
train
50.2
chaoss/grimoirelab-perceval
perceval/backends/core/gerrit.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/gerrit.py#L495-L522
def setup_cmd_parser(cls): """Returns the Gerrit argument parser.""" parser = BackendCommandArgumentParser(cls.BACKEND.CATEGORIES, from_date=True, archive=True) # Gerrit options group = parser.p...
[ "def", "setup_cmd_parser", "(", "cls", ")", ":", "parser", "=", "BackendCommandArgumentParser", "(", "cls", ".", "BACKEND", ".", "CATEGORIES", ",", "from_date", "=", "True", ",", "archive", "=", "True", ")", "# Gerrit options", "group", "=", "parser", ".", "...
Returns the Gerrit argument parser.
[ "Returns", "the", "Gerrit", "argument", "parser", "." ]
python
test
48.035714
pycontribs/jira
jira/client.py
https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L1849-L1857
def add_watcher(self, issue, watcher): """Add a user to an issue's watchers list. :param issue: ID or key of the issue affected :param watcher: username of the user to add to the watchers list """ url = self._get_url('issue/' + str(issue) + '/watchers') self._session.pos...
[ "def", "add_watcher", "(", "self", ",", "issue", ",", "watcher", ")", ":", "url", "=", "self", ".", "_get_url", "(", "'issue/'", "+", "str", "(", "issue", ")", "+", "'/watchers'", ")", "self", ".", "_session", ".", "post", "(", "url", ",", "data", ...
Add a user to an issue's watchers list. :param issue: ID or key of the issue affected :param watcher: username of the user to add to the watchers list
[ "Add", "a", "user", "to", "an", "issue", "s", "watchers", "list", "." ]
python
train
39.666667
HydrelioxGitHub/pybbox
pybbox/__init__.py
https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L102-L113
def get_all_connected_devices(self): """ Get all info about devices connected to the box :return: a list with each device info :rtype: list """ self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE) self.bbox...
[ "def", "get_all_connected_devices", "(", "self", ")", ":", "self", ".", "bbox_auth", ".", "set_access", "(", "BboxConstant", ".", "AUTHENTICATION_LEVEL_PUBLIC", ",", "BboxConstant", ".", "AUTHENTICATION_LEVEL_PRIVATE", ")", "self", ".", "bbox_url", ".", "set_api_name"...
Get all info about devices connected to the box :return: a list with each device info :rtype: list
[ "Get", "all", "info", "about", "devices", "connected", "to", "the", "box", ":", "return", ":", "a", "list", "with", "each", "device", "info", ":", "rtype", ":", "list" ]
python
train
46.916667
robmarkcole/HASS-data-detective
detective/core.py
https://github.com/robmarkcole/HASS-data-detective/blob/f67dfde9dd63a3af411944d1857b0835632617c5/detective/core.py#L82-L104
def fetch_entities(self): """Fetch entities for which we have data.""" query = text( """ SELECT entity_id FROM states GROUP BY entity_id """ ) response = self.perform_query(query) # Parse the domains from the entities. ...
[ "def", "fetch_entities", "(", "self", ")", ":", "query", "=", "text", "(", "\"\"\"\n SELECT entity_id\n FROM states\n GROUP BY entity_id\n \"\"\"", ")", "response", "=", "self", ".", "perform_query", "(", "query", ")", "# Parse the ...
Fetch entities for which we have data.
[ "Fetch", "entities", "for", "which", "we", "have", "data", "." ]
python
train
28.478261
bitlabstudio/django-calendarium
calendarium/utils.py
https://github.com/bitlabstudio/django-calendarium/blob/cabe69eff965dff80893012fb4dfe724e995807a/calendarium/utils.py#L28-L40
def monday_of_week(year, week): """ Returns a datetime for the monday of the given week of the given year. """ str_time = time.strptime('{0} {1} 1'.format(year, week), '%Y %W %w') date = timezone.datetime(year=str_time.tm_year, month=str_time.tm_mon, day=str_time.tm_mda...
[ "def", "monday_of_week", "(", "year", ",", "week", ")", ":", "str_time", "=", "time", ".", "strptime", "(", "'{0} {1} 1'", ".", "format", "(", "year", ",", "week", ")", ",", "'%Y %W %w'", ")", "date", "=", "timezone", ".", "datetime", "(", "year", "=",...
Returns a datetime for the monday of the given week of the given year.
[ "Returns", "a", "datetime", "for", "the", "monday", "of", "the", "given", "week", "of", "the", "given", "year", "." ]
python
train
42.307692
tonioo/sievelib
sievelib/commands.py
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L1086-L1108
def get_command_instance(name, parent=None, checkexists=True): """Try to guess and create the appropriate command instance Given a command name (encountered by the parser), construct the associated class name and, if known, return a new instance. If the command is not known or has not been loaded usin...
[ "def", "get_command_instance", "(", "name", ",", "parent", "=", "None", ",", "checkexists", "=", "True", ")", ":", "cname", "=", "\"%sCommand\"", "%", "name", ".", "lower", "(", ")", ".", "capitalize", "(", ")", "gl", "=", "globals", "(", ")", "conditi...
Try to guess and create the appropriate command instance Given a command name (encountered by the parser), construct the associated class name and, if known, return a new instance. If the command is not known or has not been loaded using require, an UnknownCommand exception is raised. :param name...
[ "Try", "to", "guess", "and", "create", "the", "appropriate", "command", "instance" ]
python
train
34.782609
digidotcom/python-streamexpect
streamexpect.py
https://github.com/digidotcom/python-streamexpect/blob/9ab894506ffd679b37230e935158ff3b0aa170ab/streamexpect.py#L316-L336
def search(self, buf): """Search the provided buffer for a match to any sub-searchers. Search the provided buffer for a match to any of this collection's sub-searchers. If a single matching sub-searcher is found, returns that sub-searcher's *match* object. If multiple matches are found,...
[ "def", "search", "(", "self", ",", "buf", ")", ":", "self", ".", "_check_type", "(", "buf", ")", "best_match", "=", "None", "best_index", "=", "sys", ".", "maxsize", "for", "searcher", "in", "self", ":", "match", "=", "searcher", ".", "search", "(", ...
Search the provided buffer for a match to any sub-searchers. Search the provided buffer for a match to any of this collection's sub-searchers. If a single matching sub-searcher is found, returns that sub-searcher's *match* object. If multiple matches are found, the match with the smalle...
[ "Search", "the", "provided", "buffer", "for", "a", "match", "to", "any", "sub", "-", "searchers", "." ]
python
train
40.904762
mlperf/training
translation/tensorflow/transformer/translate.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/translate.py#L140-L152
def translate_text(estimator, subtokenizer, txt): """Translate a single string.""" encoded_txt = _encode_and_add_eos(txt, subtokenizer) def input_fn(): ds = tf.data.Dataset.from_tensors(encoded_txt) ds = ds.batch(_DECODE_BATCH_SIZE) return ds predictions = estimator.predict(input_fn) translation...
[ "def", "translate_text", "(", "estimator", ",", "subtokenizer", ",", "txt", ")", ":", "encoded_txt", "=", "_encode_and_add_eos", "(", "txt", ",", "subtokenizer", ")", "def", "input_fn", "(", ")", ":", "ds", "=", "tf", ".", "data", ".", "Dataset", ".", "f...
Translate a single string.
[ "Translate", "a", "single", "string", "." ]
python
train
35.461538
f3at/feat
src/feat/common/enum.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/common/enum.py#L70-L85
def get(cls, key): """ str, int or Enum => Enum """ if isinstance(key, Enum) and not isinstance(key, cls): raise TypeError("Cannot type cast between enums") if isinstance(key, int): if not int(key) in cls._values: raise KeyError("There is n...
[ "def", "get", "(", "cls", ",", "key", ")", ":", "if", "isinstance", "(", "key", ",", "Enum", ")", "and", "not", "isinstance", "(", "key", ",", "cls", ")", ":", "raise", "TypeError", "(", "\"Cannot type cast between enums\"", ")", "if", "isinstance", "(",...
str, int or Enum => Enum
[ "str", "int", "or", "Enum", "=", ">", "Enum" ]
python
train
41.1875
fermiPy/fermipy
fermipy/sourcefind_utils.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind_utils.py#L12-L150
def fit_error_ellipse(tsmap, xy=None, dpix=3, zmin=None): """Fit a positional uncertainty ellipse from a TS map. The fit will be performed over pixels in the vicinity of the peak pixel with D < dpix OR z > zmin where D is the distance from the peak pixel in pixel coordinates and z is the difference in ...
[ "def", "fit_error_ellipse", "(", "tsmap", ",", "xy", "=", "None", ",", "dpix", "=", "3", ",", "zmin", "=", "None", ")", ":", "if", "xy", "is", "None", ":", "ix", ",", "iy", "=", "np", ".", "unravel_index", "(", "np", ".", "argmax", "(", "tsmap", ...
Fit a positional uncertainty ellipse from a TS map. The fit will be performed over pixels in the vicinity of the peak pixel with D < dpix OR z > zmin where D is the distance from the peak pixel in pixel coordinates and z is the difference in amplitude from the peak pixel. Parameters ----------...
[ "Fit", "a", "positional", "uncertainty", "ellipse", "from", "a", "TS", "map", ".", "The", "fit", "will", "be", "performed", "over", "pixels", "in", "the", "vicinity", "of", "the", "peak", "pixel", "with", "D", "<", "dpix", "OR", "z", ">", "zmin", "wher...
python
train
33.676259
PGower/PyCanvas
pycanvas/apis/files.py
https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/files.py#L1339-L1363
def remove_usage_rights_courses(self, file_ids, course_id, folder_ids=None): """ Remove usage rights. Removes copyright and license information associated with one or more files """ path = {} data = {} params = {} # REQUIRED - PATH - course_id ...
[ "def", "remove_usage_rights_courses", "(", "self", ",", "file_ids", ",", "course_id", ",", "folder_ids", "=", "None", ")", ":", "path", "=", "{", "}", "data", "=", "{", "}", "params", "=", "{", "}", "# REQUIRED - PATH - course_id\r", "\"\"\"ID\"\"\"", "path", ...
Remove usage rights. Removes copyright and license information associated with one or more files
[ "Remove", "usage", "rights", ".", "Removes", "copyright", "and", "license", "information", "associated", "with", "one", "or", "more", "files" ]
python
train
41.44
Bystroushaak/pyDHTMLParser
src/dhtmlparser/__init__.py
https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/__init__.py#L153-L183
def _indexOfEndTag(istack): """ Go through `istack` and search endtag. Element at first index is considered as opening tag. Args: istack (list): List of :class:`.HTMLElement` objects. Returns: int: Index of end tag or 0 if not found. """ if len(istack) <= 0: return ...
[ "def", "_indexOfEndTag", "(", "istack", ")", ":", "if", "len", "(", "istack", ")", "<=", "0", ":", "return", "0", "if", "not", "istack", "[", "0", "]", ".", "isOpeningTag", "(", ")", ":", "return", "0", "cnt", "=", "0", "opener", "=", "istack", "...
Go through `istack` and search endtag. Element at first index is considered as opening tag. Args: istack (list): List of :class:`.HTMLElement` objects. Returns: int: Index of end tag or 0 if not found.
[ "Go", "through", "istack", "and", "search", "endtag", ".", "Element", "at", "first", "index", "is", "considered", "as", "opening", "tag", "." ]
python
train
21.935484
collectiveacuity/labPack
labpack/platforms/docker.py
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/docker.py#L118-L156
def _validate_virtualbox(self): ''' a method to validate that virtualbox is running on Win 7/8 machines :return: boolean indicating whether virtualbox is running ''' # validate operating system if self.localhost.os.sysname != 'Windows': return Fal...
[ "def", "_validate_virtualbox", "(", "self", ")", ":", "# validate operating system\r", "if", "self", ".", "localhost", ".", "os", ".", "sysname", "!=", "'Windows'", ":", "return", "False", "win_release", "=", "float", "(", "self", ".", "localhost", ".", "os", ...
a method to validate that virtualbox is running on Win 7/8 machines :return: boolean indicating whether virtualbox is running
[ "a", "method", "to", "validate", "that", "virtualbox", "is", "running", "on", "Win", "7", "/", "8", "machines", ":", "return", ":", "boolean", "indicating", "whether", "virtualbox", "is", "running" ]
python
train
44.102564
sosy-lab/benchexec
benchexec/tablegenerator/__init__.py
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/tablegenerator/__init__.py#L765-L769
def set_relative_path(self, common_prefix, base_dir): """ generate output representation of rows """ self.short_filename = self.filename.replace(common_prefix, '', 1)
[ "def", "set_relative_path", "(", "self", ",", "common_prefix", ",", "base_dir", ")", ":", "self", ".", "short_filename", "=", "self", ".", "filename", ".", "replace", "(", "common_prefix", ",", "''", ",", "1", ")" ]
generate output representation of rows
[ "generate", "output", "representation", "of", "rows" ]
python
train
38.8
cloudboss/friend
friend/strings.py
https://github.com/cloudboss/friend/blob/3357e6ec849552e3ae9ed28017ff0926e4006e4e/friend/strings.py#L64-L73
def random_hex(length): """ Return a random hex string. :param int length: The length of string to return :returns: A random string :rtype: str """ charset = ''.join(set(string.hexdigits.lower())) return random_string(length, charset)
[ "def", "random_hex", "(", "length", ")", ":", "charset", "=", "''", ".", "join", "(", "set", "(", "string", ".", "hexdigits", ".", "lower", "(", ")", ")", ")", "return", "random_string", "(", "length", ",", "charset", ")" ]
Return a random hex string. :param int length: The length of string to return :returns: A random string :rtype: str
[ "Return", "a", "random", "hex", "string", "." ]
python
train
25.8
Miserlou/Zappa
zappa/core.py
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3010-L3049
def fetch_logs(self, lambda_name, filter_pattern='', limit=10000, start_time=0): """ Fetch the CloudWatch logs for a given Lambda name. """ log_name = '/aws/lambda/' + lambda_name streams = self.logs_client.describe_log_streams( logGroupName=log_name, desc...
[ "def", "fetch_logs", "(", "self", ",", "lambda_name", ",", "filter_pattern", "=", "''", ",", "limit", "=", "10000", ",", "start_time", "=", "0", ")", ":", "log_name", "=", "'/aws/lambda/'", "+", "lambda_name", "streams", "=", "self", ".", "logs_client", "....
Fetch the CloudWatch logs for a given Lambda name.
[ "Fetch", "the", "CloudWatch", "logs", "for", "a", "given", "Lambda", "name", "." ]
python
train
35.725
log2timeline/plaso
docs/conf.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/docs/conf.py#L388-L407
def find_and_replace(self, node): """Parses URIs containing .md and replaces them with their HTML page. Args: node(node): docutils node. Returns: node: docutils node. """ if isinstance(node, nodes.reference) and 'refuri' in node: reference_uri = node['refuri'] if referenc...
[ "def", "find_and_replace", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "nodes", ".", "reference", ")", "and", "'refuri'", "in", "node", ":", "reference_uri", "=", "node", "[", "'refuri'", "]", "if", "reference_uri", ".", "en...
Parses URIs containing .md and replaces them with their HTML page. Args: node(node): docutils node. Returns: node: docutils node.
[ "Parses", "URIs", "containing", ".", "md", "and", "replaces", "them", "with", "their", "HTML", "page", "." ]
python
train
33.4
python-openxml/python-docx
docx/image/jpeg.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/jpeg.py#L166-L180
def iter_markers(self): """ Generate a (marker_code, segment_offset) 2-tuple for each marker in the JPEG *stream*, in the order they occur in the stream. """ marker_finder = _MarkerFinder.from_stream(self._stream) start = 0 marker_code = None while marker_...
[ "def", "iter_markers", "(", "self", ")", ":", "marker_finder", "=", "_MarkerFinder", ".", "from_stream", "(", "self", ".", "_stream", ")", "start", "=", "0", "marker_code", "=", "None", "while", "marker_code", "!=", "JPEG_MARKER_CODE", ".", "EOI", ":", "mark...
Generate a (marker_code, segment_offset) 2-tuple for each marker in the JPEG *stream*, in the order they occur in the stream.
[ "Generate", "a", "(", "marker_code", "segment_offset", ")", "2", "-", "tuple", "for", "each", "marker", "in", "the", "JPEG", "*", "stream", "*", "in", "the", "order", "they", "occur", "in", "the", "stream", "." ]
python
train
39.733333
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/models/images.py#L63-L103
def save(self, chunk_size=DEFAULT_DATA_CHUNK_SIZE, named=False): """ Get a tarball of an image. Similar to the ``docker save`` command. Args: chunk_size (int): The generator will return up to that much data per iteration, but may return less. If ``None``, data will b...
[ "def", "save", "(", "self", ",", "chunk_size", "=", "DEFAULT_DATA_CHUNK_SIZE", ",", "named", "=", "False", ")", ":", "img", "=", "self", ".", "id", "if", "named", ":", "img", "=", "self", ".", "tags", "[", "0", "]", "if", "self", ".", "tags", "else...
Get a tarball of an image. Similar to the ``docker save`` command. Args: chunk_size (int): The generator will return up to that much data per iteration, but may return less. If ``None``, data will be streamed as it is received. Default: 2 MB named (str or...
[ "Get", "a", "tarball", "of", "an", "image", ".", "Similar", "to", "the", "docker", "save", "command", "." ]
python
train
39.634146
belbio/bel
bel/lang/partialparse.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/lang/partialparse.py#L365-L408
def arg_types(parsed: Parsed, errors: Errors) -> Tuple[Parsed, Errors]: """Add argument types to parsed function data structure Args: parsed: function and arg locations in BEL string errors: error messages Returns: (parsed, errors): parsed, arguments with arg types plus error messa...
[ "def", "arg_types", "(", "parsed", ":", "Parsed", ",", "errors", ":", "Errors", ")", "->", "Tuple", "[", "Parsed", ",", "Errors", "]", ":", "func_pattern", "=", "re", ".", "compile", "(", "r\"\\s*[a-zA-Z]+\\(\"", ")", "nsarg_pattern", "=", "re", ".", "co...
Add argument types to parsed function data structure Args: parsed: function and arg locations in BEL string errors: error messages Returns: (parsed, errors): parsed, arguments with arg types plus error messages
[ "Add", "argument", "types", "to", "parsed", "function", "data", "structure" ]
python
train
36.704545
spdx/tools-python
spdx/parsers/rdfbuilders.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/rdfbuilders.py#L100-L108
def set_doc_comment(self, doc, comment): """Sets document comment, Raises CardinalityError if comment already set. """ if not self.doc_comment_set: self.doc_comment_set = True doc.comment = comment else: raise CardinalityError('Document::Commen...
[ "def", "set_doc_comment", "(", "self", ",", "doc", ",", "comment", ")", ":", "if", "not", "self", ".", "doc_comment_set", ":", "self", ".", "doc_comment_set", "=", "True", "doc", ".", "comment", "=", "comment", "else", ":", "raise", "CardinalityError", "("...
Sets document comment, Raises CardinalityError if comment already set.
[ "Sets", "document", "comment", "Raises", "CardinalityError", "if", "comment", "already", "set", "." ]
python
valid
35
Cognexa/cxflow
cxflow/main_loop.py
https://github.com/Cognexa/cxflow/blob/dd609e6b0bd854424a8f86781dd77801a13038f9/cxflow/main_loop.py#L96-L100
def _create_epoch_data(self, streams: Optional[Iterable[str]]=None) -> EpochData: """Create empty epoch data double dict.""" if streams is None: streams = [self._train_stream_name] + self._extra_streams return OrderedDict([(stream_name, OrderedDict()) for stream_name in streams])
[ "def", "_create_epoch_data", "(", "self", ",", "streams", ":", "Optional", "[", "Iterable", "[", "str", "]", "]", "=", "None", ")", "->", "EpochData", ":", "if", "streams", "is", "None", ":", "streams", "=", "[", "self", ".", "_train_stream_name", "]", ...
Create empty epoch data double dict.
[ "Create", "empty", "epoch", "data", "double", "dict", "." ]
python
train
62.4
sethmlarson/virtualbox-python
virtualbox/library_ext/console.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library_ext/console.py#L122-L131
def register_on_event_source_changed(self, callback): """Set the callback function to consume on event source changed events. This occurs when a listener is added or removed. Callback receives a IEventStateChangedEvent object. Returns the callback_id """ event_type = l...
[ "def", "register_on_event_source_changed", "(", "self", ",", "callback", ")", ":", "event_type", "=", "library", ".", "VBoxEventType", ".", "on_event_source_changed", "return", "self", ".", "event_source", ".", "register_callback", "(", "callback", ",", "event_type", ...
Set the callback function to consume on event source changed events. This occurs when a listener is added or removed. Callback receives a IEventStateChangedEvent object. Returns the callback_id
[ "Set", "the", "callback", "function", "to", "consume", "on", "event", "source", "changed", "events", ".", "This", "occurs", "when", "a", "listener", "is", "added", "or", "removed", "." ]
python
train
42.8
nicolargo/glances
glances/autodiscover.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L116-L138
def add_service(self, zeroconf, srv_type, srv_name): """Method called when a new Zeroconf client is detected. Return True if the zeroconf client is a Glances server Note: the return code will never be used """ if srv_type != zeroconf_type: return False logger...
[ "def", "add_service", "(", "self", ",", "zeroconf", ",", "srv_type", ",", "srv_name", ")", ":", "if", "srv_type", "!=", "zeroconf_type", ":", "return", "False", "logger", ".", "debug", "(", "\"Check new Zeroconf server: %s / %s\"", "%", "(", "srv_type", ",", "...
Method called when a new Zeroconf client is detected. Return True if the zeroconf client is a Glances server Note: the return code will never be used
[ "Method", "called", "when", "a", "new", "Zeroconf", "client", "is", "detected", "." ]
python
train
42.391304
TangoAlpha/liffylights
liffylights.py
https://github.com/TangoAlpha/liffylights/blob/7ae9ed947ecf039734014d98b6e18de0f26fa1d3/liffylights.py#L421-L430
def probe(self, ipaddr=None): """ Probe given address for bulb. """ if ipaddr is None: # no address so use broadcast ipaddr = self._broadcast_addr cmd = {"payloadtype": PayloadType.GET, "target": ipaddr} self._send_command(cmd)
[ "def", "probe", "(", "self", ",", "ipaddr", "=", "None", ")", ":", "if", "ipaddr", "is", "None", ":", "# no address so use broadcast", "ipaddr", "=", "self", ".", "_broadcast_addr", "cmd", "=", "{", "\"payloadtype\"", ":", "PayloadType", ".", "GET", ",", "...
Probe given address for bulb.
[ "Probe", "given", "address", "for", "bulb", "." ]
python
train
29.1
osrg/ryu
ryu/services/protocols/bgp/processor.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/processor.py#L423-L448
def _cmp_by_asn(local_asn, path1, path2): """Select the path based on source (iBGP/eBGP) peer. eBGP path is preferred over iBGP. If both paths are from same kind of peers, return None. """ def get_path_source_asn(path): asn = None if path.source is None: asn = local_asn ...
[ "def", "_cmp_by_asn", "(", "local_asn", ",", "path1", ",", "path2", ")", ":", "def", "get_path_source_asn", "(", "path", ")", ":", "asn", "=", "None", "if", "path", ".", "source", "is", "None", ":", "asn", "=", "local_asn", "else", ":", "asn", "=", "...
Select the path based on source (iBGP/eBGP) peer. eBGP path is preferred over iBGP. If both paths are from same kind of peers, return None.
[ "Select", "the", "path", "based", "on", "source", "(", "iBGP", "/", "eBGP", ")", "peer", "." ]
python
train
31.192308
nezhar/updatable
updatable/__init__.py
https://github.com/nezhar/updatable/blob/654c70a40d9cabcfdd762acf82b49f66057438af/updatable/__init__.py#L65-L91
def get_pypi_package_data(package_name, version=None): """ Get package data from pypi by the package name https://wiki.python.org/moin/PyPIJSON :param package_name: string :param version: string :return: dict """ pypi_url = 'https://pypi.org/pypi' if version: package_url =...
[ "def", "get_pypi_package_data", "(", "package_name", ",", "version", "=", "None", ")", ":", "pypi_url", "=", "'https://pypi.org/pypi'", "if", "version", ":", "package_url", "=", "'%s/%s/%s/json'", "%", "(", "pypi_url", ",", "package_name", ",", "version", ",", "...
Get package data from pypi by the package name https://wiki.python.org/moin/PyPIJSON :param package_name: string :param version: string :return: dict
[ "Get", "package", "data", "from", "pypi", "by", "the", "package", "name" ]
python
train
24.851852
balloob/pychromecast
pychromecast/__init__.py
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L274-L278
def new_cast_status(self, status): """ Called when a new status received from the Chromecast. """ self.status = status if status: self.status_event.set()
[ "def", "new_cast_status", "(", "self", ",", "status", ")", ":", "self", ".", "status", "=", "status", "if", "status", ":", "self", ".", "status_event", ".", "set", "(", ")" ]
Called when a new status received from the Chromecast.
[ "Called", "when", "a", "new", "status", "received", "from", "the", "Chromecast", "." ]
python
train
37
ihgazni2/elist
elist/elist.py
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3568-L3577
def init(len,default_element=None): ''' from elist.elist import * init(5) init(5,"x") ''' rslt = [] for i in range(0,len): rslt.append(copy.deepcopy(default_element)) return(rslt)
[ "def", "init", "(", "len", ",", "default_element", "=", "None", ")", ":", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", ")", ":", "rslt", ".", "append", "(", "copy", ".", "deepcopy", "(", "default_element", ")", ")", "re...
from elist.elist import * init(5) init(5,"x")
[ "from", "elist", ".", "elist", "import", "*", "init", "(", "5", ")", "init", "(", "5", "x", ")" ]
python
valid
22.2
rgs1/zk_shell
zk_shell/xclient.py
https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/xclient.py#L22-L26
def connected_socket(address, timeout=3): """ yields a connected socket """ sock = socket.create_connection(address, timeout) yield sock sock.close()
[ "def", "connected_socket", "(", "address", ",", "timeout", "=", "3", ")", ":", "sock", "=", "socket", ".", "create_connection", "(", "address", ",", "timeout", ")", "yield", "sock", "sock", ".", "close", "(", ")" ]
yields a connected socket
[ "yields", "a", "connected", "socket" ]
python
train
32.2
jopohl/urh
src/urh/controller/MainController.py
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/MainController.py#L799-L804
def on_files_dropped_on_group(self, files, group_id: int): """ :param group_id: :type files: list of QtCore.QUrl """ self.__add_urls_to_group(files, group_id=group_id)
[ "def", "on_files_dropped_on_group", "(", "self", ",", "files", ",", "group_id", ":", "int", ")", ":", "self", ".", "__add_urls_to_group", "(", "files", ",", "group_id", "=", "group_id", ")" ]
:param group_id: :type files: list of QtCore.QUrl
[ ":", "param", "group_id", ":", ":", "type", "files", ":", "list", "of", "QtCore", ".", "QUrl" ]
python
train
33.666667
rosenbrockc/fortpy
fortpy/interop/converter.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/interop/converter.py#L74-L86
def nvalues(self): """Returns the number of values recorded on this single line. If the number is variable, it returns -1.""" if self._nvalues is None: self._nvalues = 0 for val in self.values: if type(val) == type(int): self._nvalues +...
[ "def", "nvalues", "(", "self", ")", ":", "if", "self", ".", "_nvalues", "is", "None", ":", "self", ".", "_nvalues", "=", "0", "for", "val", "in", "self", ".", "values", ":", "if", "type", "(", "val", ")", "==", "type", "(", "int", ")", ":", "se...
Returns the number of values recorded on this single line. If the number is variable, it returns -1.
[ "Returns", "the", "number", "of", "values", "recorded", "on", "this", "single", "line", ".", "If", "the", "number", "is", "variable", "it", "returns", "-", "1", "." ]
python
train
33.076923
JonLiuFYI/pkdx
pkdx/pkdx/main.py
https://github.com/JonLiuFYI/pkdx/blob/269e9814df074e0df25972fad04539a644d73a3c/pkdx/pkdx/main.py#L29-L33
def description(pokemon): """Return a description of the given Pokemon.""" r = requests.get('http://pokeapi.co/' + (pokemon.descriptions.values()[0])) desc = eval(r.text)['description'].replace('Pokmon', 'Pokémon') return desc
[ "def", "description", "(", "pokemon", ")", ":", "r", "=", "requests", ".", "get", "(", "'http://pokeapi.co/'", "+", "(", "pokemon", ".", "descriptions", ".", "values", "(", ")", "[", "0", "]", ")", ")", "desc", "=", "eval", "(", "r", ".", "text", "...
Return a description of the given Pokemon.
[ "Return", "a", "description", "of", "the", "given", "Pokemon", "." ]
python
train
47.6
knipknap/SpiffWorkflow
SpiffWorkflow/bpmn/BpmnScriptEngine.py
https://github.com/knipknap/SpiffWorkflow/blob/f0af7f59a332e0619e4f3c00a7d4a3d230760e00/SpiffWorkflow/bpmn/BpmnScriptEngine.py#L47-L52
def execute(self, task, script, **kwargs): """ Execute the script, within the context of the specified task """ locals().update(kwargs) exec(script)
[ "def", "execute", "(", "self", ",", "task", ",", "script", ",", "*", "*", "kwargs", ")", ":", "locals", "(", ")", ".", "update", "(", "kwargs", ")", "exec", "(", "script", ")" ]
Execute the script, within the context of the specified task
[ "Execute", "the", "script", "within", "the", "context", "of", "the", "specified", "task" ]
python
valid
30.5
briancappello/flask-unchained
flask_unchained/commands/new.py
https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/commands/new.py#L182-L224
def project(dest, app_bundle, force, dev, admin, api, celery, graphene, mail, oauth, security, session, sqlalchemy, webpack): """ Create a new Flask Unchained project. """ if os.path.exists(dest) and os.listdir(dest) and not force: if not click.confirm(f'WARNING: Project ...
[ "def", "project", "(", "dest", ",", "app_bundle", ",", "force", ",", "dev", ",", "admin", ",", "api", ",", "celery", ",", "graphene", ",", "mail", ",", "oauth", ",", "security", ",", "session", ",", "sqlalchemy", ",", "webpack", ")", ":", "if", "os",...
Create a new Flask Unchained project.
[ "Create", "a", "new", "Flask", "Unchained", "project", "." ]
python
train
39.860465
BernardFW/bernard
src/bernard/i18n/translator.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/translator.py#L574-L604
def unserialize(wd: WordDictionary, text: Dict): """ Transforms back a serialized value of `serialize()` """ if not isinstance(text, Mapping): raise ValueError('Text has not the right format') try: t = text['type'] if t == 'string': return text['value'] ...
[ "def", "unserialize", "(", "wd", ":", "WordDictionary", ",", "text", ":", "Dict", ")", ":", "if", "not", "isinstance", "(", "text", ",", "Mapping", ")", ":", "raise", "ValueError", "(", "'Text has not the right format'", ")", "try", ":", "t", "=", "text", ...
Transforms back a serialized value of `serialize()`
[ "Transforms", "back", "a", "serialized", "value", "of", "serialize", "()" ]
python
train
30.16129
abilian/abilian-core
abilian/core/entities.py
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/core/entities.py#L385-L423
def _indexable_roles_and_users(self): """Return a string made for indexing roles having :any:`READ` permission on this object.""" from abilian.services.indexing import indexable_role from abilian.services.security import READ, Admin, Anonymous, Creator, Owner from abilian.service...
[ "def", "_indexable_roles_and_users", "(", "self", ")", ":", "from", "abilian", ".", "services", ".", "indexing", "import", "indexable_role", "from", "abilian", ".", "services", ".", "security", "import", "READ", ",", "Admin", ",", "Anonymous", ",", "Creator", ...
Return a string made for indexing roles having :any:`READ` permission on this object.
[ "Return", "a", "string", "made", "for", "indexing", "roles", "having", ":", "any", ":", "READ", "permission", "on", "this", "object", "." ]
python
train
36.25641
PyCQA/astroid
astroid/bases.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/bases.py#L296-L321
def bool_value(self): """Infer the truth value for an Instance The truth value of an instance is determined by these conditions: * if it implements __bool__ on Python 3 or __nonzero__ on Python 2, then its bool value will be determined by calling this special metho...
[ "def", "bool_value", "(", "self", ")", ":", "context", "=", "contextmod", ".", "InferenceContext", "(", ")", "context", ".", "callcontext", "=", "contextmod", ".", "CallContext", "(", "args", "=", "[", "]", ")", "context", ".", "boundnode", "=", "self", ...
Infer the truth value for an Instance The truth value of an instance is determined by these conditions: * if it implements __bool__ on Python 3 or __nonzero__ on Python 2, then its bool value will be determined by calling this special method and checking its result. ...
[ "Infer", "the", "truth", "value", "for", "an", "Instance" ]
python
train
45.923077
satellogic/telluric
telluric/vrt.py
https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vrt.py#L192-L262
def raster_collection_vrt(fc, relative_to_vrt=True, nodata=None, mask_band=None): """Make a VRT XML document from a feature collection of GeoRaster2 objects. Parameters ---------- rasters : FeatureCollection The FeatureCollection of GeoRasters. relative_to_vrt : bool, optional If Tru...
[ "def", "raster_collection_vrt", "(", "fc", ",", "relative_to_vrt", "=", "True", ",", "nodata", "=", "None", ",", "mask_band", "=", "None", ")", ":", "def", "max_resolution", "(", ")", ":", "max_affine", "=", "max", "(", "fc", ",", "key", "=", "lambda", ...
Make a VRT XML document from a feature collection of GeoRaster2 objects. Parameters ---------- rasters : FeatureCollection The FeatureCollection of GeoRasters. relative_to_vrt : bool, optional If True the bands simple source url will be related to the VRT file nodata : int, optional ...
[ "Make", "a", "VRT", "XML", "document", "from", "a", "feature", "collection", "of", "GeoRaster2", "objects", ".", "Parameters", "----------", "rasters", ":", "FeatureCollection", "The", "FeatureCollection", "of", "GeoRasters", ".", "relative_to_vrt", ":", "bool", "...
python
train
44.802817
sibirrer/lenstronomy
lenstronomy/Util/param_util.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/param_util.py#L93-L104
def ellipticity2phi_q(e1, e2): """ :param e1: :param e2: :return: """ phi = np.arctan2(e2, e1)/2 c = np.sqrt(e1**2+e2**2) if c > 0.999: c = 0.999 q = (1-c)/(1+c) return phi, q
[ "def", "ellipticity2phi_q", "(", "e1", ",", "e2", ")", ":", "phi", "=", "np", ".", "arctan2", "(", "e2", ",", "e1", ")", "/", "2", "c", "=", "np", ".", "sqrt", "(", "e1", "**", "2", "+", "e2", "**", "2", ")", "if", "c", ">", "0.999", ":", ...
:param e1: :param e2: :return:
[ ":", "param", "e1", ":", ":", "param", "e2", ":", ":", "return", ":" ]
python
train
17.666667
chrippa/python-librtmp
librtmp/packet.py
https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/packet.py#L103-L107
def body(self): """The body of the packet.""" view = ffi.buffer(self.packet.m_body, self.packet.m_nBodySize) return view[:]
[ "def", "body", "(", "self", ")", ":", "view", "=", "ffi", ".", "buffer", "(", "self", ".", "packet", ".", "m_body", ",", "self", ".", "packet", ".", "m_nBodySize", ")", "return", "view", "[", ":", "]" ]
The body of the packet.
[ "The", "body", "of", "the", "packet", "." ]
python
train
28.8
user-cont/colin
colin/cli/colin.py
https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/cli/colin.py#L200-L214
def list_rulesets(debug): """ List available rulesets. """ try: rulesets = get_rulesets() max_len = max([len(r[0]) for r in rulesets]) for r in rulesets: click.echo('{0: <{1}} ({2})'.format(r[0], max_len, r[1])) except Exception as ex: logger.error("An err...
[ "def", "list_rulesets", "(", "debug", ")", ":", "try", ":", "rulesets", "=", "get_rulesets", "(", ")", "max_len", "=", "max", "(", "[", "len", "(", "r", "[", "0", "]", ")", "for", "r", "in", "rulesets", "]", ")", "for", "r", "in", "rulesets", ":"...
List available rulesets.
[ "List", "available", "rulesets", "." ]
python
train
28.333333
esheldon/fitsio
fitsio/header.py
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L218-L288
def clean(self, is_table=False): """ Remove reserved keywords from the header. These are keywords that the fits writer must write in order to maintain consistency between header and data. keywords -------- is_table: bool, optional Set True if this is...
[ "def", "clean", "(", "self", ",", "is_table", "=", "False", ")", ":", "rmnames", "=", "[", "'SIMPLE'", ",", "'EXTEND'", ",", "'XTENSION'", ",", "'BITPIX'", ",", "'PCOUNT'", ",", "'GCOUNT'", ",", "'THEAP'", ",", "'EXTNAME'", ",", "'BLANK'", ",", "'ZQUANTI...
Remove reserved keywords from the header. These are keywords that the fits writer must write in order to maintain consistency between header and data. keywords -------- is_table: bool, optional Set True if this is a table, so extra keywords will be cleaned
[ "Remove", "reserved", "keywords", "from", "the", "header", "." ]
python
train
31.816901
MrYsLab/pymata-aio
pymata_aio/pymata_core.py
https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_core.py#L1015-L1032
async def servo_config(self, pin, min_pulse=544, max_pulse=2400): """ Configure a pin as a servo pin. Set pulse min, max in ms. Use this method (not set_pin_mode) to configure a pin for servo operation. :param pin: Servo Pin. :param min_pulse: Min pulse width in ms. ...
[ "async", "def", "servo_config", "(", "self", ",", "pin", ",", "min_pulse", "=", "544", ",", "max_pulse", "=", "2400", ")", ":", "command", "=", "[", "pin", ",", "min_pulse", "&", "0x7f", ",", "(", "min_pulse", ">>", "7", ")", "&", "0x7f", ",", "max...
Configure a pin as a servo pin. Set pulse min, max in ms. Use this method (not set_pin_mode) to configure a pin for servo operation. :param pin: Servo Pin. :param min_pulse: Min pulse width in ms. :param max_pulse: Max pulse width in ms. :returns: No return value
[ "Configure", "a", "pin", "as", "a", "servo", "pin", ".", "Set", "pulse", "min", "max", "in", "ms", ".", "Use", "this", "method", "(", "not", "set_pin_mode", ")", "to", "configure", "a", "pin", "for", "servo", "operation", "." ]
python
train
33.166667
numenta/nupic.core
bindings/py/setup.py
https://github.com/numenta/nupic.core/blob/333290c32403ce11e7117f826a6348c3a8e6c125/bindings/py/setup.py#L133-L144
def getPlatformInfo(): """Identify platform.""" if "linux" in sys.platform: platform = "linux" elif "darwin" in sys.platform: platform = "darwin" # win32 elif sys.platform.startswith("win"): platform = "windows" else: raise Exception("Platform '%s' is unsupported!" % sys.platform) return p...
[ "def", "getPlatformInfo", "(", ")", ":", "if", "\"linux\"", "in", "sys", ".", "platform", ":", "platform", "=", "\"linux\"", "elif", "\"darwin\"", "in", "sys", ".", "platform", ":", "platform", "=", "\"darwin\"", "# win32", "elif", "sys", ".", "platform", ...
Identify platform.
[ "Identify", "platform", "." ]
python
train
26.333333
log2timeline/plaso
plaso/analyzers/manager.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/analyzers/manager.py#L13-L29
def DeregisterAnalyzer(cls, analyzer_class): """Deregisters a analyzer class. The analyzer classes are identified based on their lower case name. Args: analyzer_class (type): class object of the analyzer. Raises: KeyError: if analyzer class is not set for the corresponding name. """ ...
[ "def", "DeregisterAnalyzer", "(", "cls", ",", "analyzer_class", ")", ":", "analyzer_name", "=", "analyzer_class", ".", "NAME", ".", "lower", "(", ")", "if", "analyzer_name", "not", "in", "cls", ".", "_analyzer_classes", ":", "raise", "KeyError", "(", "'analyze...
Deregisters a analyzer class. The analyzer classes are identified based on their lower case name. Args: analyzer_class (type): class object of the analyzer. Raises: KeyError: if analyzer class is not set for the corresponding name.
[ "Deregisters", "a", "analyzer", "class", "." ]
python
train
32.294118
potash/drain
drain/step.py
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L478-L493
def _expand_inputs(step, steps=None): """ Returns the set of this step and all steps passed to the constructor (recursively). """ if steps is None: steps = set() for arg in step._kwargs.values(): if isinstance(arg, Step): _expand_inputs(arg, steps=steps) elif uti...
[ "def", "_expand_inputs", "(", "step", ",", "steps", "=", "None", ")", ":", "if", "steps", "is", "None", ":", "steps", "=", "set", "(", ")", "for", "arg", "in", "step", ".", "_kwargs", ".", "values", "(", ")", ":", "if", "isinstance", "(", "arg", ...
Returns the set of this step and all steps passed to the constructor (recursively).
[ "Returns", "the", "set", "of", "this", "step", "and", "all", "steps", "passed", "to", "the", "constructor", "(", "recursively", ")", "." ]
python
train
30
Qiskit/qiskit-terra
qiskit/circuit/instruction.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/instruction.py#L169-L192
def assemble(self): """Assemble a QasmQobjInstruction""" instruction = QasmQobjInstruction(name=self.name) # Evaluate parameters if self.params: params = [ x.evalf() if hasattr(x, 'evalf') else x for x in self.params ] params = [ ...
[ "def", "assemble", "(", "self", ")", ":", "instruction", "=", "QasmQobjInstruction", "(", "name", "=", "self", ".", "name", ")", "# Evaluate parameters", "if", "self", ".", "params", ":", "params", "=", "[", "x", ".", "evalf", "(", ")", "if", "hasattr", ...
Assemble a QasmQobjInstruction
[ "Assemble", "a", "QasmQobjInstruction" ]
python
test
41.791667
NatLibFi/Skosify
skosify/rdftools/access.py
https://github.com/NatLibFi/Skosify/blob/1d269987f10df08e706272dcf6a86aef4abebcde/skosify/rdftools/access.py#L10-L14
def find_prop_overlap(rdf, prop1, prop2): """Generate (subject,object) pairs connected by two properties.""" for s, o in sorted(rdf.subject_objects(prop1)): if (s, prop2, o) in rdf: yield (s, o)
[ "def", "find_prop_overlap", "(", "rdf", ",", "prop1", ",", "prop2", ")", ":", "for", "s", ",", "o", "in", "sorted", "(", "rdf", ".", "subject_objects", "(", "prop1", ")", ")", ":", "if", "(", "s", ",", "prop2", ",", "o", ")", "in", "rdf", ":", ...
Generate (subject,object) pairs connected by two properties.
[ "Generate", "(", "subject", "object", ")", "pairs", "connected", "by", "two", "properties", "." ]
python
train
43.6
TyVik/YaDiskClient
YaDiskClient/YaDiskClient.py
https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L173-L196
def publish(self, path): """Publish file or folder and return public url""" def parseContent(content): root = ET.fromstring(content) prop = root.find(".//d:prop", namespaces=self.namespaces) return prop.find("{urn:yandex:disk:meta}public_url").text.strip() ...
[ "def", "publish", "(", "self", ",", "path", ")", ":", "def", "parseContent", "(", "content", ")", ":", "root", "=", "ET", ".", "fromstring", "(", "content", ")", "prop", "=", "root", ".", "find", "(", "\".//d:prop\"", ",", "namespaces", "=", "self", ...
Publish file or folder and return public url
[ "Publish", "file", "or", "folder", "and", "return", "public", "url" ]
python
train
31.75
assamite/creamas
creamas/core/artifact.py
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/artifact.py#L63-L72
def add_eval(self, agent, e, fr=None): """Add or change agent's evaluation of the artifact with given framing information. :param agent: Name of the agent which did the evaluation. :param float e: Evaluation for the artifact. :param object fr: Framing information for the evaluat...
[ "def", "add_eval", "(", "self", ",", "agent", ",", "e", ",", "fr", "=", "None", ")", ":", "self", ".", "_evals", "[", "agent", ".", "name", "]", "=", "e", "self", ".", "_framings", "[", "agent", ".", "name", "]", "=", "fr" ]
Add or change agent's evaluation of the artifact with given framing information. :param agent: Name of the agent which did the evaluation. :param float e: Evaluation for the artifact. :param object fr: Framing information for the evaluation.
[ "Add", "or", "change", "agent", "s", "evaluation", "of", "the", "artifact", "with", "given", "framing", "information", "." ]
python
train
40.3
Microsoft/knack
knack/commands.py
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/commands.py#L307-L330
def command(self, name, handler_name, **kwargs): """ Register a command into the command table :param name: The name of the command :type name: str :param handler_name: The name of the handler that will be applied to the operations template :type handler_name: str :param...
[ "def", "command", "(", "self", ",", "name", ",", "handler_name", ",", "*", "*", "kwargs", ")", ":", "import", "copy", "command_name", "=", "'{} {}'", ".", "format", "(", "self", ".", "group_name", ",", "name", ")", "if", "self", ".", "group_name", "els...
Register a command into the command table :param name: The name of the command :type name: str :param handler_name: The name of the handler that will be applied to the operations template :type handler_name: str :param kwargs: Kwargs to apply to the command. ...
[ "Register", "a", "command", "into", "the", "command", "table" ]
python
train
52.958333
jmbhughes/suvi-trainer
suvitrainer/gui.py
https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/suvitrainer/gui.py#L556-L594
def setup_singlecolor(self): """ initial setup of single color options and variables""" self.singlecolorframe = tk.Frame(self.tab_configure, bg=self.single_color_theme) channel_choices = sorted(list(self.data.keys())) self.singlecolorlabel = tk.Label(self.singlecolorframe, text="single",...
[ "def", "setup_singlecolor", "(", "self", ")", ":", "self", ".", "singlecolorframe", "=", "tk", ".", "Frame", "(", "self", ".", "tab_configure", ",", "bg", "=", "self", ".", "single_color_theme", ")", "channel_choices", "=", "sorted", "(", "list", "(", "sel...
initial setup of single color options and variables
[ "initial", "setup", "of", "single", "color", "options", "and", "variables" ]
python
train
68.307692
joeferraro/mm
mm/commands/debug.py
https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/commands/debug.py#L270-L295
def execute(self): """ self.params = { "ActionScriptType" : "None", "ExecutableEntityId" : "01pd0000001yXtYAAU", "IsDumpingHeap" : True, "Iteration" : 1, "Line" : 3, ...
[ "def", "execute", "(", "self", ")", ":", "config", ".", "logger", ".", "debug", "(", "'logging self'", ")", "config", ".", "logger", ".", "debug", "(", "self", ".", "params", ")", "if", "'project_name'", "in", "self", ".", "params", ":", "self", ".", ...
self.params = { "ActionScriptType" : "None", "ExecutableEntityId" : "01pd0000001yXtYAAU", "IsDumpingHeap" : True, "Iteration" : 1, "Line" : 3, "ScopeId" : "005d00000...
[ "self", ".", "params", "=", "{", "ActionScriptType", ":", "None", "ExecutableEntityId", ":", "01pd0000001yXtYAAU", "IsDumpingHeap", ":", "True", "Iteration", ":", "1", "Line", ":", "3", "ScopeId", ":", "005d0000000xxzsAAA", "}" ]
python
train
39.923077
Azure/msrestazure-for-python
msrestazure/polling/async_arm_polling.py
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/polling/async_arm_polling.py#L57-L81
async def _poll(self): """Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation status 'Fa...
[ "async", "def", "_poll", "(", "self", ")", ":", "while", "not", "self", ".", "finished", "(", ")", ":", "await", "self", ".", "_delay", "(", ")", "await", "self", ".", "update_status", "(", ")", "if", "failed", "(", "self", ".", "_operation", ".", ...
Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation status 'Failed' or 'Cancelled'. :rai...
[ "Poll", "status", "of", "operation", "so", "long", "as", "operation", "is", "incomplete", "and", "we", "have", "an", "endpoint", "to", "query", "." ]
python
train
43.28
emencia/dr-dump
drdump/dependancies.py
https://github.com/emencia/dr-dump/blob/f03a2ed01fb82e6fe1df66f7fa82e646a3822d4b/drdump/dependancies.py#L36-L69
def get_dump_names(self, names, dumps=None): """ Find and return all dump names required (by dependancies) for a given dump names list Beware, the returned name list does not respect order, you should only use it when walking throught the "original" dict builded by OrderedDict ...
[ "def", "get_dump_names", "(", "self", ",", "names", ",", "dumps", "=", "None", ")", ":", "# Default value for dumps argument is an empty set (setting directly", "# as a python argument would result as a shared value between", "# instances)", "if", "dumps", "is", "None", ":", ...
Find and return all dump names required (by dependancies) for a given dump names list Beware, the returned name list does not respect order, you should only use it when walking throught the "original" dict builded by OrderedDict
[ "Find", "and", "return", "all", "dump", "names", "required", "(", "by", "dependancies", ")", "for", "a", "given", "dump", "names", "list" ]
python
train
36.823529
BerkeleyAutomation/perception
perception/image.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L685-L723
def focus(self, height, width, center_i=None, center_j=None): """Zero out all of the image outside of a crop box. Parameters ---------- height : int The height of the desired crop box. width : int The width of the desired crop box. center_i : in...
[ "def", "focus", "(", "self", ",", "height", ",", "width", ",", "center_i", "=", "None", ",", "center_j", "=", "None", ")", ":", "if", "center_i", "is", "None", ":", "center_i", "=", "self", ".", "height", "/", "2", "if", "center_j", "is", "None", "...
Zero out all of the image outside of a crop box. Parameters ---------- height : int The height of the desired crop box. width : int The width of the desired crop box. center_i : int The center height point of the crop box. If not specified, ...
[ "Zero", "out", "all", "of", "the", "image", "outside", "of", "a", "crop", "box", "." ]
python
train
34.692308
mdickinson/bigfloat
bigfloat/core.py
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L1236-L1286
def pow(x, y, context=None): """ Return ``x`` raised to the power ``y``. Special values are handled as described in the ISO C99 and IEEE 754-2008 standards for the pow function. * pow(±0, y) returns plus or minus infinity for y a negative odd integer. * pow(±0, y) returns plus infinity fo...
[ "def", "pow", "(", "x", ",", "y", ",", "context", "=", "None", ")", ":", "return", "_apply_function_in_current_context", "(", "BigFloat", ",", "mpfr", ".", "mpfr_pow", ",", "(", "BigFloat", ".", "_implicit_convert", "(", "x", ")", ",", "BigFloat", ".", "...
Return ``x`` raised to the power ``y``. Special values are handled as described in the ISO C99 and IEEE 754-2008 standards for the pow function. * pow(±0, y) returns plus or minus infinity for y a negative odd integer. * pow(±0, y) returns plus infinity for y negative and not an odd integer. ...
[ "Return", "x", "raised", "to", "the", "power", "y", "." ]
python
train
29.882353
grigi/talkey
talkey/base.py
https://github.com/grigi/talkey/blob/5d2d4a1f7001744c4fd9a79a883a3f2001522329/talkey/base.py#L217-L224
def configure(self, **_options): ''' Sets language-specific configuration. Raises TTSError on error. ''' language, voice, voiceinfo, options = self._configure(**_options) self.languages_options[language] = (voice, options)
[ "def", "configure", "(", "self", ",", "*", "*", "_options", ")", ":", "language", ",", "voice", ",", "voiceinfo", ",", "options", "=", "self", ".", "_configure", "(", "*", "*", "_options", ")", "self", ".", "languages_options", "[", "language", "]", "=...
Sets language-specific configuration. Raises TTSError on error.
[ "Sets", "language", "-", "specific", "configuration", "." ]
python
train
33
darkfeline/mir.anidb
mir/anidb/anime.py
https://github.com/darkfeline/mir.anidb/blob/a0d25908f85fb1ff4bc595954bfc3f223f1b5acc/mir/anidb/anime.py#L179-L182
def _unpack_episode_title(element: ET.Element): """Unpack EpisodeTitle from title XML element.""" return EpisodeTitle(title=element.text, lang=element.get(f'{XML}lang'))
[ "def", "_unpack_episode_title", "(", "element", ":", "ET", ".", "Element", ")", ":", "return", "EpisodeTitle", "(", "title", "=", "element", ".", "text", ",", "lang", "=", "element", ".", "get", "(", "f'{XML}lang'", ")", ")" ]
Unpack EpisodeTitle from title XML element.
[ "Unpack", "EpisodeTitle", "from", "title", "XML", "element", "." ]
python
train
49.5
CalebBell/fluids
fluids/optional/pychebfun.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L486-L522
def roots(self): """ Utilises Boyd's O(n^2) recursive subdivision algorithm. The chebfun is recursively subsampled until it is successfully represented to machine precision by a sequence of piecewise interpolants of degree 100 or less. A colleague matrix eigenvalue solve is then ...
[ "def", "roots", "(", "self", ")", ":", "if", "self", ".", "size", "(", ")", "==", "1", ":", "return", "np", ".", "array", "(", "[", "]", ")", "elif", "self", ".", "size", "(", ")", "<=", "100", ":", "ak", "=", "self", ".", "coefficients", "("...
Utilises Boyd's O(n^2) recursive subdivision algorithm. The chebfun is recursively subsampled until it is successfully represented to machine precision by a sequence of piecewise interpolants of degree 100 or less. A colleague matrix eigenvalue solve is then applied to each of these piec...
[ "Utilises", "Boyd", "s", "O", "(", "n^2", ")", "recursive", "subdivision", "algorithm", ".", "The", "chebfun", "is", "recursively", "subsampled", "until", "it", "is", "successfully", "represented", "to", "machine", "precision", "by", "a", "sequence", "of", "pi...
python
train
41.135135
astraw38/lint
lint/utils/git_utils.py
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/git_utils.py#L22-L38
def get_files_changed(repository, review_id): """ Get a list of files changed compared to the given review. Compares against current directory. :param repository: Git repository. Used to get remote. - By default uses first remote in list. :param review_id: Gerrit review ID. :return: List ...
[ "def", "get_files_changed", "(", "repository", ",", "review_id", ")", ":", "repository", ".", "git", ".", "fetch", "(", "[", "next", "(", "iter", "(", "repository", ".", "remotes", ")", ")", ",", "review_id", "]", ")", "files_changed", "=", "repository", ...
Get a list of files changed compared to the given review. Compares against current directory. :param repository: Git repository. Used to get remote. - By default uses first remote in list. :param review_id: Gerrit review ID. :return: List of file paths relative to current directory.
[ "Get", "a", "list", "of", "files", "changed", "compared", "to", "the", "given", "review", ".", "Compares", "against", "current", "directory", "." ]
python
train
45
jxtech/wechatpy
wechatpy/client/api/wxa.py
https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/wxa.py#L337-L355
def add_template(self, template_short_id, keyword_id_list): """ 组合模板,并将其添加至账号下的模板列表里 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR :param template_short_id: 模板标题ID :param keyword_id_list: 按照顺序排列的模板关键词列表,最多10个 :type ...
[ "def", "add_template", "(", "self", ",", "template_short_id", ",", "keyword_id_list", ")", ":", "return", "self", ".", "_post", "(", "'cgi-bin/wxopen/template/add'", ",", "data", "=", "{", "'id'", ":", "template_short_id", ",", "'keyword_id_list'", ":", "keyword_i...
组合模板,并将其添加至账号下的模板列表里 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR :param template_short_id: 模板标题ID :param keyword_id_list: 按照顺序排列的模板关键词列表,最多10个 :type keyword_id_list: list[int] :return: 模板ID
[ "组合模板,并将其添加至账号下的模板列表里", "详情请参考", "https", ":", "//", "open", ".", "weixin", ".", "qq", ".", "com", "/", "cgi", "-", "bin", "/", "showdocument?action", "=", "dir_list&id", "=", "open1500465446_j4CgR" ]
python
train
32.947368
SheffieldML/GPyOpt
GPyOpt/core/task/variables.py
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L175-L187
def round(self, value_array): """ Rounds a discrete variable by selecting the closest point in the domain Assumes an 1d array with a single element as an input. """ value = value_array[0] rounded_value = self.domain[0] for domain_value in self.domain: ...
[ "def", "round", "(", "self", ",", "value_array", ")", ":", "value", "=", "value_array", "[", "0", "]", "rounded_value", "=", "self", ".", "domain", "[", "0", "]", "for", "domain_value", "in", "self", ".", "domain", ":", "if", "np", ".", "abs", "(", ...
Rounds a discrete variable by selecting the closest point in the domain Assumes an 1d array with a single element as an input.
[ "Rounds", "a", "discrete", "variable", "by", "selecting", "the", "closest", "point", "in", "the", "domain", "Assumes", "an", "1d", "array", "with", "a", "single", "element", "as", "an", "input", "." ]
python
train
34.615385
istresearch/scrapy-cluster
crawler/crawling/spiders/lxmlhtml.py
https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/crawler/crawling/spiders/lxmlhtml.py#L18-L42
def _extract_links(self, selector, response_url, response_encoding, base_url): ''' Pretty much the same function, just added 'ignore' to to_native_str() ''' links = [] # hacky way to get the underlying lxml parsed document for el, attr, attr_val in self._iter_links(select...
[ "def", "_extract_links", "(", "self", ",", "selector", ",", "response_url", ",", "response_encoding", ",", "base_url", ")", ":", "links", "=", "[", "]", "# hacky way to get the underlying lxml parsed document", "for", "el", ",", "attr", ",", "attr_val", "in", "sel...
Pretty much the same function, just added 'ignore' to to_native_str()
[ "Pretty", "much", "the", "same", "function", "just", "added", "ignore", "to", "to_native_str", "()" ]
python
train
45.32
dwavesystems/dwavebinarycsp
dwavebinarycsp/core/constraint.py
https://github.com/dwavesystems/dwavebinarycsp/blob/d6b1e70ceaa8f451d7afaa87ea10c7fc948a64e2/dwavebinarycsp/core/constraint.py#L476-L495
def copy(self): """Create a copy. Examples: This example copies constraint :math:`a \\ne b` and tests a solution on the copied constraint. >>> import dwavebinarycsp >>> import operator >>> const = dwavebinarycsp.Constraint.from_func(operator....
[ "def", "copy", "(", "self", ")", ":", "# each object is itself immutable (except the function)", "return", "self", ".", "__class__", "(", "self", ".", "func", ",", "self", ".", "configurations", ",", "self", ".", "variables", ",", "self", ".", "vartype", ",", ...
Create a copy. Examples: This example copies constraint :math:`a \\ne b` and tests a solution on the copied constraint. >>> import dwavebinarycsp >>> import operator >>> const = dwavebinarycsp.Constraint.from_func(operator.ne, ... ...
[ "Create", "a", "copy", "." ]
python
valid
34.6
binbrain/OpenSesame
OpenSesame/searchable.py
https://github.com/binbrain/OpenSesame/blob/e32c306385012646400ecb49fc65c64b14ce3a93/OpenSesame/searchable.py#L25-L32
def _instant_search(self): """Determine possible keys after a push or pop """ _keys = [] for k,v in self.searchables.iteritems(): if self.string in v: _keys.append(k) self.candidates.append(_keys)
[ "def", "_instant_search", "(", "self", ")", ":", "_keys", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "searchables", ".", "iteritems", "(", ")", ":", "if", "self", ".", "string", "in", "v", ":", "_keys", ".", "append", "(", "k", ")", ...
Determine possible keys after a push or pop
[ "Determine", "possible", "keys", "after", "a", "push", "or", "pop" ]
python
train
32.125
saltstack/salt
salt/grains/core.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/core.py#L465-L485
def _osx_memdata(): ''' Return the memory information for BSD-like systems ''' grains = {'mem_total': 0, 'swap_total': 0} sysctl = salt.utils.path.which('sysctl') if sysctl: mem = __salt__['cmd.run']('{0} -n hw.memsize'.format(sysctl)) swap_total = __salt__['cmd.run']('{0} -n vm...
[ "def", "_osx_memdata", "(", ")", ":", "grains", "=", "{", "'mem_total'", ":", "0", ",", "'swap_total'", ":", "0", "}", "sysctl", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'sysctl'", ")", "if", "sysctl", ":", "mem", "=", "__salt__", ...
Return the memory information for BSD-like systems
[ "Return", "the", "memory", "information", "for", "BSD", "-", "like", "systems" ]
python
train
35.333333
tijme/not-your-average-web-crawler
nyawc/helpers/RandomInputHelper.py
https://github.com/tijme/not-your-average-web-crawler/blob/d77c14e1616c541bb3980f649a7e6f8ed02761fb/nyawc/helpers/RandomInputHelper.py#L207-L221
def get_random_telephonenumber(): """Get a random 10 digit phone number that complies with most of the requirements. Returns: str: The random telephone number. """ phone = [ RandomInputHelper.get_random_value(3, "123456789"), RandomInputHelper.get_r...
[ "def", "get_random_telephonenumber", "(", ")", ":", "phone", "=", "[", "RandomInputHelper", ".", "get_random_value", "(", "3", ",", "\"123456789\"", ")", ",", "RandomInputHelper", ".", "get_random_value", "(", "3", ",", "\"12345678\"", ")", ",", "\"\"", ".", "...
Get a random 10 digit phone number that complies with most of the requirements. Returns: str: The random telephone number.
[ "Get", "a", "random", "10", "digit", "phone", "number", "that", "complies", "with", "most", "of", "the", "requirements", "." ]
python
train
28.933333
davesque/django-rest-framework-simplejwt
rest_framework_simplejwt/tokens.py
https://github.com/davesque/django-rest-framework-simplejwt/blob/d6084c595aefbf97865d15254b56017e710e8e47/rest_framework_simplejwt/tokens.py#L156-L168
def for_user(cls, user): """ Returns an authorization token for the given user that will be provided after authenticating the user's credentials. """ user_id = getattr(user, api_settings.USER_ID_FIELD) if not isinstance(user_id, int): user_id = str(user_id) ...
[ "def", "for_user", "(", "cls", ",", "user", ")", ":", "user_id", "=", "getattr", "(", "user", ",", "api_settings", ".", "USER_ID_FIELD", ")", "if", "not", "isinstance", "(", "user_id", ",", "int", ")", ":", "user_id", "=", "str", "(", "user_id", ")", ...
Returns an authorization token for the given user that will be provided after authenticating the user's credentials.
[ "Returns", "an", "authorization", "token", "for", "the", "given", "user", "that", "will", "be", "provided", "after", "authenticating", "the", "user", "s", "credentials", "." ]
python
train
30.923077
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/core/read_write_functions.py
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/read_write_functions.py#L76-L92
def load_b26_file(file_name): """ loads a .b26 file into a dictionary Args: file_name: Returns: dictionary with keys instrument, scripts, probes """ # file_name = "Z:\Lab\Cantilever\Measurements\\tmp_\\a" assert os.path.exists(file_name) with open(file_name, 'r') as infile: ...
[ "def", "load_b26_file", "(", "file_name", ")", ":", "# file_name = \"Z:\\Lab\\Cantilever\\Measurements\\\\tmp_\\\\a\"", "assert", "os", ".", "path", ".", "exists", "(", "file_name", ")", "with", "open", "(", "file_name", ",", "'r'", ")", "as", "infile", ":", "data...
loads a .b26 file into a dictionary Args: file_name: Returns: dictionary with keys instrument, scripts, probes
[ "loads", "a", ".", "b26", "file", "into", "a", "dictionary" ]
python
train
21
dwavesystems/dimod
dimod/higherorder/utils.py
https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/higherorder/utils.py#L226-L249
def poly_energies(samples_like, poly): """Calculates energy of samples from a higher order polynomial. Args: sample (samples_like): A collection of raw samples. `samples_like` is an extension of NumPy's array_like structure. See :func:`.as_samples`. poly (dict): ...
[ "def", "poly_energies", "(", "samples_like", ",", "poly", ")", ":", "msg", "=", "(", "\"poly_energies is deprecated and will be removed in dimod 0.9.0.\"", "\"In the future, use BinaryPolynomial.energies\"", ")", "warnings", ".", "warn", "(", "msg", ",", "DeprecationWarning",...
Calculates energy of samples from a higher order polynomial. Args: sample (samples_like): A collection of raw samples. `samples_like` is an extension of NumPy's array_like structure. See :func:`.as_samples`. poly (dict): Polynomial as a dict of form {term: bias,...
[ "Calculates", "energy", "of", "samples", "from", "a", "higher", "order", "polynomial", "." ]
python
train
40.875
ihgazni2/edict
edict/edict.py
https://github.com/ihgazni2/edict/blob/44a08ccc10b196aa3854619b4c51ddb246778a34/edict/edict.py#L778-L787
def is_mirrable(d): ''' d = {1:'a',2:'a',3:'b'} ''' vl = list(d.values()) lngth1 = vl.__len__() uvl = elel.uniqualize(vl) lngth2 = uvl.__len__() cond = (lngth1 == lngth2) return(cond)
[ "def", "is_mirrable", "(", "d", ")", ":", "vl", "=", "list", "(", "d", ".", "values", "(", ")", ")", "lngth1", "=", "vl", ".", "__len__", "(", ")", "uvl", "=", "elel", ".", "uniqualize", "(", "vl", ")", "lngth2", "=", "uvl", ".", "__len__", "("...
d = {1:'a',2:'a',3:'b'}
[ "d", "=", "{", "1", ":", "a", "2", ":", "a", "3", ":", "b", "}" ]
python
train
21.4
wbond/certvalidator
certvalidator/__init__.py
https://github.com/wbond/certvalidator/blob/c62233a713bcc36963e9d82323ec8d84f8e01485/certvalidator/__init__.py#L140-L201
def validate_usage(self, key_usage, extended_key_usage=None, extended_optional=False): """ Validates the certificate path and that the certificate is valid for the key usage and extended key usage purposes specified. :param key_usage: A set of unicode strings of the required...
[ "def", "validate_usage", "(", "self", ",", "key_usage", ",", "extended_key_usage", "=", "None", ",", "extended_optional", "=", "False", ")", ":", "self", ".", "_validate_path", "(", ")", "validate_usage", "(", "self", ".", "_context", ",", "self", ".", "_cer...
Validates the certificate path and that the certificate is valid for the key usage and extended key usage purposes specified. :param key_usage: A set of unicode strings of the required key usage purposes. Valid values include: - "digital_signature" - "...
[ "Validates", "the", "certificate", "path", "and", "that", "the", "certificate", "is", "valid", "for", "the", "key", "usage", "and", "extended", "key", "usage", "purposes", "specified", "." ]
python
train
34.064516
mkoura/dump2polarion
dump2polarion/exporters/requirements_exporter.py
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/requirements_exporter.py#L212-L215
def write_xml(xml, output_file=None): """Outputs the XML content into a file.""" gen_filename = "requirements-{:%Y%m%d%H%M%S}.xml".format(datetime.datetime.now()) utils.write_xml(xml, output_loc=output_file, filename=gen_filename)
[ "def", "write_xml", "(", "xml", ",", "output_file", "=", "None", ")", ":", "gen_filename", "=", "\"requirements-{:%Y%m%d%H%M%S}.xml\"", ".", "format", "(", "datetime", ".", "datetime", ".", "now", "(", ")", ")", "utils", ".", "write_xml", "(", "xml", ",", ...
Outputs the XML content into a file.
[ "Outputs", "the", "XML", "content", "into", "a", "file", "." ]
python
train
62.75
Chyroc/WechatSogou
wechatsogou/structuring.py
https://github.com/Chyroc/WechatSogou/blob/2e0e9886f555fd8bcfc7ae9718ced6ce955cd24a/wechatsogou/structuring.py#L136-L215
def get_article_by_search(text): """从搜索文章获得的文本 提取章列表信息 Parameters ---------- text : str or unicode 搜索文章获得的文本 Returns ------- list[dict] { 'article': { 'title': '', # 文章标题 'url': '',...
[ "def", "get_article_by_search", "(", "text", ")", ":", "page", "=", "etree", ".", "HTML", "(", "text", ")", "lis", "=", "page", ".", "xpath", "(", "'//ul[@class=\"news-list\"]/li'", ")", "articles", "=", "[", "]", "for", "li", "in", "lis", ":", "url", ...
从搜索文章获得的文本 提取章列表信息 Parameters ---------- text : str or unicode 搜索文章获得的文本 Returns ------- list[dict] { 'article': { 'title': '', # 文章标题 'url': '', # 文章链接 'imgs': '', # ...
[ "从搜索文章获得的文本", "提取章列表信息" ]
python
train
36.675
Parsely/probably
probably/temporal_daily.py
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/temporal_daily.py#L115-L141
def warm(self, jittering_ratio=0.2): """Progressively load the previous snapshot during the day. Loading all the snapshots at once can takes a substantial amount of time. This method, if called periodically during the day will progressively load those snapshots one by one. Because many workers ...
[ "def", "warm", "(", "self", ",", "jittering_ratio", "=", "0.2", ")", ":", "if", "self", ".", "snapshot_to_load", "==", "None", ":", "last_period", "=", "self", ".", "current_period", "-", "dt", ".", "timedelta", "(", "days", "=", "self", ".", "expiration...
Progressively load the previous snapshot during the day. Loading all the snapshots at once can takes a substantial amount of time. This method, if called periodically during the day will progressively load those snapshots one by one. Because many workers are going to use this method at the same...
[ "Progressively", "load", "the", "previous", "snapshot", "during", "the", "day", "." ]
python
train
56.62963
DataONEorg/d1_python
lib_client/src/d1_client/session.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/session.py#L222-L233
def PUT(self, rest_path_list, **kwargs): """Send a PUT request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. See post() for parameters. :returns: Response object """ fields = kwargs.pop("fields", None) if fields is no...
[ "def", "PUT", "(", "self", ",", "rest_path_list", ",", "*", "*", "kwargs", ")", ":", "fields", "=", "kwargs", ".", "pop", "(", "\"fields\"", ",", "None", ")", "if", "fields", "is", "not", "None", ":", "return", "self", ".", "_send_mmp_stream", "(", "...
Send a PUT request with optional streaming multipart encoding. See requests.sessions.request for optional parameters. See post() for parameters. :returns: Response object
[ "Send", "a", "PUT", "request", "with", "optional", "streaming", "multipart", "encoding", ".", "See", "requests", ".", "sessions", ".", "request", "for", "optional", "parameters", ".", "See", "post", "()", "for", "parameters", "." ]
python
train
39.833333
pr-omethe-us/PyKED
pyked/chemked.py
https://github.com/pr-omethe-us/PyKED/blob/d9341a068c1099049a3f1de41c512591f342bf64/pyked/chemked.py#L853-L889
def get_cantera_mass_fraction(self, species_conversion=None): """Get the mass fractions in a string format suitable for input to Cantera. Arguments: species_conversion (`dict`, optional): Mapping of species identifier to a species name. This argument should be supplied when ...
[ "def", "get_cantera_mass_fraction", "(", "self", ",", "species_conversion", "=", "None", ")", ":", "if", "self", ".", "composition_type", "in", "[", "'mole fraction'", ",", "'mole percent'", "]", ":", "raise", "ValueError", "(", "'Cannot get mass fractions from the gi...
Get the mass fractions in a string format suitable for input to Cantera. Arguments: species_conversion (`dict`, optional): Mapping of species identifier to a species name. This argument should be supplied when the name of the species in the ChemKED YAML file does not...
[ "Get", "the", "mass", "fractions", "in", "a", "string", "format", "suitable", "for", "input", "to", "Cantera", "." ]
python
train
52.081081
benmontet/f3
f3/photometry.py
https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L301-L329
def do_photometry(self): """ Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data in each orientation. This function is called by other functions and generally the user will not need to interact with it directly. """ ...
[ "def", "do_photometry", "(", "self", ")", ":", "std_f", "=", "np", ".", "zeros", "(", "4", ")", "data_save", "=", "np", ".", "zeros_like", "(", "self", ".", "postcard", ")", "self", ".", "obs_flux", "=", "np", ".", "zeros_like", "(", "self", ".", "...
Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data in each orientation. This function is called by other functions and generally the user will not need to interact with it directly.
[ "Does", "photometry", "and", "estimates", "uncertainties", "by", "calculating", "the", "scatter", "around", "a", "linear", "fit", "to", "the", "data", "in", "each", "orientation", ".", "This", "function", "is", "called", "by", "other", "functions", "and", "gen...
python
valid
43.137931
openpermissions/koi
koi/keygen.py
https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/keygen.py#L137-L165
def gen_non_ca_cert(filename, dirname, days, ip_list, dns_list, ca_crt, ca_key, silent=False): """ generate a non CA key and certificate key pair signed by the private CA key and crt. :param filename: prefix for the key and cert file :param dirname: name of the directory :par...
[ "def", "gen_non_ca_cert", "(", "filename", ",", "dirname", ",", "days", ",", "ip_list", ",", "dns_list", ",", "ca_crt", ",", "ca_key", ",", "silent", "=", "False", ")", ":", "key_file", "=", "os", ".", "path", ".", "join", "(", "dirname", ",", "'{}.key...
generate a non CA key and certificate key pair signed by the private CA key and crt. :param filename: prefix for the key and cert file :param dirname: name of the directory :param days: days of the certificate being valid :ip_list: a list of ip address to be included in the certificate :dns_list...
[ "generate", "a", "non", "CA", "key", "and", "certificate", "key", "pair", "signed", "by", "the", "private", "CA", "key", "and", "crt", ".", ":", "param", "filename", ":", "prefix", "for", "the", "key", "and", "cert", "file", ":", "param", "dirname", ":...
python
train
43.344828
pytroll/satpy
satpy/config.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/config.py#L105-L115
def glob_config(pattern, *search_dirs): """Return glob results for all possible configuration locations. Note: This method does not check the configuration "base" directory if the pattern includes a subdirectory. This is done for performance since this is usually used to find *all* configs for a cert...
[ "def", "glob_config", "(", "pattern", ",", "*", "search_dirs", ")", ":", "patterns", "=", "config_search_paths", "(", "pattern", ",", "*", "search_dirs", ",", "check_exists", "=", "False", ")", "for", "pattern", "in", "patterns", ":", "for", "path", "in", ...
Return glob results for all possible configuration locations. Note: This method does not check the configuration "base" directory if the pattern includes a subdirectory. This is done for performance since this is usually used to find *all* configs for a certain component.
[ "Return", "glob", "results", "for", "all", "possible", "configuration", "locations", "." ]
python
train
45.818182
theislab/scvelo
scvelo/tools/velocity.py
https://github.com/theislab/scvelo/blob/c7a96d70edfe705e86bf364434a9527d4fd8df11/scvelo/tools/velocity.py#L104-L183
def velocity(data, vkey='velocity', mode=None, fit_offset=False, fit_offset2=False, filter_genes=False, groups=None, groupby=None, groups_for_fit=None, use_raw=False, perc=[5, 95], copy=False): """Estimates velocities in a gene-specific manner Arguments --------- data: :class:`~anndata.Ann...
[ "def", "velocity", "(", "data", ",", "vkey", "=", "'velocity'", ",", "mode", "=", "None", ",", "fit_offset", "=", "False", ",", "fit_offset2", "=", "False", ",", "filter_genes", "=", "False", ",", "groups", "=", "None", ",", "groupby", "=", "None", ","...
Estimates velocities in a gene-specific manner Arguments --------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) Name under which to refer to the computed velocities for `velocity_graph` and `velocity_embedding`. mode: `'deterministic'`, ...
[ "Estimates", "velocities", "in", "a", "gene", "-", "specific", "manner" ]
python
train
50.35
Naresh1318/crystal
crystal/sql_table_utils.py
https://github.com/Naresh1318/crystal/blob/6bb43fd1128296cc59b8ed3bc03064cc61c6bd88/crystal/sql_table_utils.py#L233-L249
def get_variables(run_name): """ Returns a dict of variables in the selected run table. :param run_name: str, required run table name :return: dict -> {<int_keys>: <variable_name>} """ conn, c = open_data_base_connection() try: # Get latest project c.execute("""SELECT variabl...
[ "def", "get_variables", "(", "run_name", ")", ":", "conn", ",", "c", "=", "open_data_base_connection", "(", ")", "try", ":", "# Get latest project", "c", ".", "execute", "(", "\"\"\"SELECT variable_name FROM {}\"\"\"", ".", "format", "(", "run_name", ")", ")", "...
Returns a dict of variables in the selected run table. :param run_name: str, required run table name :return: dict -> {<int_keys>: <variable_name>}
[ "Returns", "a", "dict", "of", "variables", "in", "the", "selected", "run", "table", ".", ":", "param", "run_name", ":", "str", "required", "run", "table", "name", ":", "return", ":", "dict", "-", ">", "{", "<int_keys", ">", ":", "<variable_name", ">", ...
python
train
36.470588
flo-compbio/genometools
genometools/ebi/uniprot_goa.py
https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ebi/uniprot_goa.py#L27-L50
def get_gaf_gene_ontology_file(path): """Extract the gene ontology file associated with a GO annotation file. Parameters ---------- path: str The path name of the GO annotation file. Returns ------- str The URL of the associated gene ontology file. """ assert isinst...
[ "def", "get_gaf_gene_ontology_file", "(", "path", ")", ":", "assert", "isinstance", "(", "path", ",", "str", ")", "version", "=", "None", "with", "misc", ".", "smart_open_read", "(", "path", ",", "encoding", "=", "'UTF-8'", ",", "try_gzip", "=", "True", ")...
Extract the gene ontology file associated with a GO annotation file. Parameters ---------- path: str The path name of the GO annotation file. Returns ------- str The URL of the associated gene ontology file.
[ "Extract", "the", "gene", "ontology", "file", "associated", "with", "a", "GO", "annotation", "file", "." ]
python
train
25.291667
SiLab-Bonn/basil
basil/HL/GPAC.py
https://github.com/SiLab-Bonn/basil/blob/99052482d9334dd1f5598eb2d2fb4d5399a32291/basil/HL/GPAC.py#L839-L856
def set_current_limit(self, channel, value, unit='A'): '''Setting current limit Note: same limit for all channels. ''' # TODO: add units / calibration if unit == 'raw': value = value elif unit == 'A': value = int(value * 1000 * self.CURRENT_LIMIT_...
[ "def", "set_current_limit", "(", "self", ",", "channel", ",", "value", ",", "unit", "=", "'A'", ")", ":", "# TODO: add units / calibration", "if", "unit", "==", "'raw'", ":", "value", "=", "value", "elif", "unit", "==", "'A'", ":", "value", "=", "int", "...
Setting current limit Note: same limit for all channels.
[ "Setting", "current", "limit" ]
python
train
37.944444
rauenzi/discordbot.py
discordbot/cogs/meta.py
https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/meta.py#L31-L41
async def join(self, ctx): """Sends you the bot invite link.""" perms = discord.Permissions.none() perms.read_messages = True perms.send_messages = True perms.manage_messages = True perms.embed_links = True perms.read_message_history = True perms.attach_fi...
[ "async", "def", "join", "(", "self", ",", "ctx", ")", ":", "perms", "=", "discord", ".", "Permissions", ".", "none", "(", ")", "perms", ".", "read_messages", "=", "True", "perms", ".", "send_messages", "=", "True", "perms", ".", "manage_messages", "=", ...
Sends you the bot invite link.
[ "Sends", "you", "the", "bot", "invite", "link", "." ]
python
train
42.090909
bukun/TorCMS
torcms/handlers/post_handler.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L575-L618
def update(self, uid): ''' in infor. ''' postinfo = MPost.get_by_uid(uid) if postinfo.kind == self.kind: pass else: return False post_data, ext_dic = self.fetch_post_data() if 'gcat0' in post_data: pass else: ...
[ "def", "update", "(", "self", ",", "uid", ")", ":", "postinfo", "=", "MPost", ".", "get_by_uid", "(", "uid", ")", "if", "postinfo", ".", "kind", "==", "self", ".", "kind", ":", "pass", "else", ":", "return", "False", "post_data", ",", "ext_dic", "=",...
in infor.
[ "in", "infor", "." ]
python
train
27.431818
BlueBrain/NeuroM
neurom/fst/_neuritefunc.py
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuritefunc.py#L79-L81
def n_leaves(neurites, neurite_type=NeuriteType.all): '''number of leaves points in a collection of neurites''' return n_sections(neurites, neurite_type=neurite_type, iterator_type=Tree.ileaf)
[ "def", "n_leaves", "(", "neurites", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "return", "n_sections", "(", "neurites", ",", "neurite_type", "=", "neurite_type", ",", "iterator_type", "=", "Tree", ".", "ileaf", ")" ]
number of leaves points in a collection of neurites
[ "number", "of", "leaves", "points", "in", "a", "collection", "of", "neurites" ]
python
train
66
ClearcodeHQ/matchbox
src/matchbox/index.py
https://github.com/ClearcodeHQ/matchbox/blob/22f5bd163ad22ceacb0fcd5d4ddae9069d1a94f4/src/matchbox/index.py#L141-L151
def add_mismatch(self, entity, *traits): """ Add a mismatching entity to the index. We do this by simply adding the mismatch to the index. :param collections.Hashable entity: an object to be mismatching the values of `traits_indexed_by` :param list traits: a list of hashable tr...
[ "def", "add_mismatch", "(", "self", ",", "entity", ",", "*", "traits", ")", ":", "for", "trait", "in", "traits", ":", "self", ".", "index", "[", "trait", "]", ".", "add", "(", "entity", ")" ]
Add a mismatching entity to the index. We do this by simply adding the mismatch to the index. :param collections.Hashable entity: an object to be mismatching the values of `traits_indexed_by` :param list traits: a list of hashable traits to index the entity with
[ "Add", "a", "mismatching", "entity", "to", "the", "index", "." ]
python
train
38.363636
hishnash/djangochannelsrestframework
djangochannelsrestframework/generics.py
https://github.com/hishnash/djangochannelsrestframework/blob/19fdec7efd785b1a94d19612a8de934e1948e344/djangochannelsrestframework/generics.py#L91-L107
def get_serializer( self, action_kwargs: Dict=None, *args, **kwargs) -> Serializer: """ Return the serializer instance that should be used for validating and deserializing input, and for serializing output. """ serializer_class = self.get_seria...
[ "def", "get_serializer", "(", "self", ",", "action_kwargs", ":", "Dict", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "Serializer", ":", "serializer_class", "=", "self", ".", "get_serializer_class", "(", "*", "*", "action_kwargs", ")"...
Return the serializer instance that should be used for validating and deserializing input, and for serializing output.
[ "Return", "the", "serializer", "instance", "that", "should", "be", "used", "for", "validating", "and", "deserializing", "input", "and", "for", "serializing", "output", "." ]
python
train
29.411765
programa-stic/barf-project
barf/core/smt/smttranslator.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/core/smt/smttranslator.py#L222-L226
def _register_name(self, name): """Get register name. """ if name not in self._var_name_mappers: self._var_name_mappers[name] = VariableNamer(name)
[ "def", "_register_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_var_name_mappers", ":", "self", ".", "_var_name_mappers", "[", "name", "]", "=", "VariableNamer", "(", "name", ")" ]
Get register name.
[ "Get", "register", "name", "." ]
python
train
35.8
teepark/junction
junction/hub.py
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/hub.py#L149-L180
def publish(self, service, routing_id, method, args=None, kwargs=None, broadcast=False, udp=False): '''Send a 1-way message :param service: the service name (the routing top level) :type service: anything hash-able :param int routing_id: the id used for routing w...
[ "def", "publish", "(", "self", ",", "service", ",", "routing_id", ",", "method", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "broadcast", "=", "False", ",", "udp", "=", "False", ")", ":", "if", "udp", ":", "func", "=", "self", ".", ...
Send a 1-way message :param service: the service name (the routing top level) :type service: anything hash-able :param int routing_id: the id used for routing within the registered handlers of the service :param string method: the method name to call :par...
[ "Send", "a", "1", "-", "way", "message" ]
python
train
44.59375
itamarst/eliot
eliot/logwriter.py
https://github.com/itamarst/eliot/blob/c03c96520c5492fadfc438b4b0f6336e2785ba2d/eliot/logwriter.py#L66-L75
def stopService(self): """ Stop the writer thread, wait for it to finish. """ Service.stopService(self) removeDestination(self) self._reactor.callFromThread(self._reactor.stop) return deferToThreadPool( self._mainReactor, self._mainReactor....
[ "def", "stopService", "(", "self", ")", ":", "Service", ".", "stopService", "(", "self", ")", "removeDestination", "(", "self", ")", "self", ".", "_reactor", ".", "callFromThread", "(", "self", ".", "_reactor", ".", "stop", ")", "return", "deferToThreadPool"...
Stop the writer thread, wait for it to finish.
[ "Stop", "the", "writer", "thread", "wait", "for", "it", "to", "finish", "." ]
python
train
34.6
log2timeline/dfvfs
dfvfs/helpers/source_scanner.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/helpers/source_scanner.py#L51-L66
def GetSubNodeByLocation(self, location): """Retrieves a sub scan node based on the location. Args: location (str): location that should match the location of the path specification of a sub scan node. Returns: SourceScanNode: sub scan node or None if not available. """ for s...
[ "def", "GetSubNodeByLocation", "(", "self", ",", "location", ")", ":", "for", "sub_node", "in", "self", ".", "sub_nodes", ":", "sub_node_location", "=", "getattr", "(", "sub_node", ".", "path_spec", ",", "'location'", ",", "None", ")", "if", "location", "=="...
Retrieves a sub scan node based on the location. Args: location (str): location that should match the location of the path specification of a sub scan node. Returns: SourceScanNode: sub scan node or None if not available.
[ "Retrieves", "a", "sub", "scan", "node", "based", "on", "the", "location", "." ]
python
train
30.25
mikedh/trimesh
trimesh/exchange/gltf.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/exchange/gltf.py#L909-L931
def _convert_camera(camera): """ Convert a trimesh camera to a GLTF camera. Parameters ------------ camera : trimesh.scene.cameras.Camera Trimesh camera object Returns ------------- gltf_camera : dict Camera represented as a GLTF dict """ result = { "name": ...
[ "def", "_convert_camera", "(", "camera", ")", ":", "result", "=", "{", "\"name\"", ":", "camera", ".", "name", ",", "\"type\"", ":", "\"perspective\"", ",", "\"perspective\"", ":", "{", "\"aspectRatio\"", ":", "camera", ".", "fov", "[", "0", "]", "/", "c...
Convert a trimesh camera to a GLTF camera. Parameters ------------ camera : trimesh.scene.cameras.Camera Trimesh camera object Returns ------------- gltf_camera : dict Camera represented as a GLTF dict
[ "Convert", "a", "trimesh", "camera", "to", "a", "GLTF", "camera", "." ]
python
train
22