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
edoburu/django-tag-parser
tag_parser/basetags.py
https://github.com/edoburu/django-tag-parser/blob/c24256cfdd0248434f2e3df3444ed9f945d4181f/tag_parser/basetags.py#L148-L158
def render(self, context): """ The default Django render() method for the tag. This method resolves the filter expressions, and calls :func:`render_tag`. """ # Resolve token kwargs tag_args = [expr.resolve(context) for expr in self.args] if self.compile_args else self.ar...
[ "def", "render", "(", "self", ",", "context", ")", ":", "# Resolve token kwargs", "tag_args", "=", "[", "expr", ".", "resolve", "(", "context", ")", "for", "expr", "in", "self", ".", "args", "]", "if", "self", ".", "compile_args", "else", "self", ".", ...
The default Django render() method for the tag. This method resolves the filter expressions, and calls :func:`render_tag`.
[ "The", "default", "Django", "render", "()", "method", "for", "the", "tag", "." ]
python
test
47.454545
jonathf/chaospy
chaospy/distributions/operators/tan.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/distributions/operators/tan.py#L39-L42
def _pdf(self, x, dist, cache): """Probability density function.""" return evaluation.evaluate_density( dist, numpy.arctan(x), cache=cache)/(1+x*x)
[ "def", "_pdf", "(", "self", ",", "x", ",", "dist", ",", "cache", ")", ":", "return", "evaluation", ".", "evaluate_density", "(", "dist", ",", "numpy", ".", "arctan", "(", "x", ")", ",", "cache", "=", "cache", ")", "/", "(", "1", "+", "x", "*", ...
Probability density function.
[ "Probability", "density", "function", "." ]
python
train
43
Azure/blobxfer
blobxfer/operations/synccopy.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/synccopy.py#L517-L532
def _finalize_nonblock_blob(self, sd, metadata, digest): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, dict, # str) -> None """Finalize Non-Block blob :param SyncCopy self: this :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor :param dic...
[ "def", "_finalize_nonblock_blob", "(", "self", ",", "sd", ",", "metadata", ",", "digest", ")", ":", "# type: (SyncCopy, blobxfer.models.synccopy.Descriptor, dict,", "# str) -> None", "# set md5 page blob property if required", "if", "(", "blobxfer", ".", "util", ".", ...
Finalize Non-Block blob :param SyncCopy self: this :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor :param dict metadata: metadata dict :param str digest: md5 digest
[ "Finalize", "Non", "-", "Block", "blob", ":", "param", "SyncCopy", "self", ":", "this", ":", "param", "blobxfer", ".", "models", ".", "synccopy", ".", "Descriptor", "sd", ":", "synccopy", "descriptor", ":", "param", "dict", "metadata", ":", "metadata", "di...
python
train
44.9375
tyiannak/pyAudioAnalysis
pyAudioAnalysis/audioFeatureExtraction.py
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L889-L928
def mtFeatureExtractionToFile(fileName, midTermSize, midTermStep, shortTermSize, shortTermStep, outPutFile, storeStFeatures=False, storeToCSV=False, PLOT=False): """ This function is used as a wrapper to: a) read the content of a WAV file b) perform mid-term feature extract...
[ "def", "mtFeatureExtractionToFile", "(", "fileName", ",", "midTermSize", ",", "midTermStep", ",", "shortTermSize", ",", "shortTermStep", ",", "outPutFile", ",", "storeStFeatures", "=", "False", ",", "storeToCSV", "=", "False", ",", "PLOT", "=", "False", ")", ":"...
This function is used as a wrapper to: a) read the content of a WAV file b) perform mid-term feature extraction on that signal c) write the mid-term feature sequences to a numpy file
[ "This", "function", "is", "used", "as", "a", "wrapper", "to", ":", "a", ")", "read", "the", "content", "of", "a", "WAV", "file", "b", ")", "perform", "mid", "-", "term", "feature", "extraction", "on", "that", "signal", "c", ")", "write", "the", "mid"...
python
train
45.725
fhs/pyhdf
pyhdf/SD.py
https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2959-L3018
def getscale(self): """Obtain the scale values along a dimension. Args:: no argument Returns:: list with the scale values; the list length is equal to the dimension length; the element type is equal to the dimension data type, as set when the 'setdimsc...
[ "def", "getscale", "(", "self", ")", ":", "# Get dimension info. If data_type is 0, no scale have been set", "# on the dimension.", "status", ",", "dim_name", ",", "dim_size", ",", "data_type", ",", "n_attrs", "=", "_C", ".", "SDdiminfo", "(", "self", ".", "_id", ")...
Obtain the scale values along a dimension. Args:: no argument Returns:: list with the scale values; the list length is equal to the dimension length; the element type is equal to the dimension data type, as set when the 'setdimscale()' method was called. ...
[ "Obtain", "the", "scale", "values", "along", "a", "dimension", "." ]
python
train
31.7
Capitains/MyCapytain
MyCapytain/resources/prototypes/cts/inventory.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/cts/inventory.py#L461-L466
def lang(self): """ Languages this text is in :return: List of available languages """ return str(self.graph.value(self.asNode(), DC.language))
[ "def", "lang", "(", "self", ")", ":", "return", "str", "(", "self", ".", "graph", ".", "value", "(", "self", ".", "asNode", "(", ")", ",", "DC", ".", "language", ")", ")" ]
Languages this text is in :return: List of available languages
[ "Languages", "this", "text", "is", "in" ]
python
train
28.5
grahambell/pymoc
lib/pymoc/io/json.py
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/io/json.py#L42-L55
def read_moc_json(moc, filename=None, file=None): """Read JSON encoded data into a MOC. Either a filename, or an open file object can be specified. """ if file is not None: obj = _read_json(file) else: with open(filename, 'rb') as f: obj = _read_json(f) for (order,...
[ "def", "read_moc_json", "(", "moc", ",", "filename", "=", "None", ",", "file", "=", "None", ")", ":", "if", "file", "is", "not", "None", ":", "obj", "=", "_read_json", "(", "file", ")", "else", ":", "with", "open", "(", "filename", ",", "'rb'", ")"...
Read JSON encoded data into a MOC. Either a filename, or an open file object can be specified.
[ "Read", "JSON", "encoded", "data", "into", "a", "MOC", "." ]
python
train
25.714286
supercoderz/pyflightdata
pyflightdata/flightdata.py
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L172-L191
def get_fleet(self, airline_key): """Get the fleet for a particular airline. Given a airline code form the get_airlines() method output, this method returns the fleet for the airline. Args: airline_key (str): The code for the airline on flightradar24 Returns: A...
[ "def", "get_fleet", "(", "self", ",", "airline_key", ")", ":", "url", "=", "AIRLINE_FLEET_BASE", ".", "format", "(", "airline_key", ")", "return", "self", ".", "_fr24", ".", "get_airline_fleet_data", "(", "url", ",", "self", ".", "AUTH_TOKEN", "!=", "''", ...
Get the fleet for a particular airline. Given a airline code form the get_airlines() method output, this method returns the fleet for the airline. Args: airline_key (str): The code for the airline on flightradar24 Returns: A list of dicts, one for each aircraft in the ...
[ "Get", "the", "fleet", "for", "a", "particular", "airline", "." ]
python
train
34.9
gbiggs/rtctree
rtctree/ports.py
https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/ports.py#L83-L123
def connect(self, dests=[], name=None, id='', props={}): '''Connect this port to other ports. After the connection has been made, a delayed reparse of the connections for this and the destination port will be triggered. @param dests A list of the destination Port objects. Must be provi...
[ "def", "connect", "(", "self", ",", "dests", "=", "[", "]", ",", "name", "=", "None", ",", "id", "=", "''", ",", "props", "=", "{", "}", ")", ":", "with", "self", ".", "_mutex", ":", "if", "self", ".", "porttype", "==", "'DataInPort'", "or", "s...
Connect this port to other ports. After the connection has been made, a delayed reparse of the connections for this and the destination port will be triggered. @param dests A list of the destination Port objects. Must be provided. @param name The name of the connection. If None, a suit...
[ "Connect", "this", "port", "to", "other", "ports", "." ]
python
train
55
Woile/commitizen
commitizen/config.py
https://github.com/Woile/commitizen/blob/bc54b9a4b6ad281620179a1ed417c01addde55f6/commitizen/config.py#L54-L78
def read_raw_parser_conf(data: str) -> dict: """We expect to have a section like this ``` [commitizen] name = cz_jira files = [ "commitizen/__version__.py", "pyproject.toml" ] # this tab at the end is important ``` """ config = configparser.ConfigParser(allow_no...
[ "def", "read_raw_parser_conf", "(", "data", ":", "str", ")", "->", "dict", ":", "config", "=", "configparser", ".", "ConfigParser", "(", "allow_no_value", "=", "True", ")", "config", ".", "read_string", "(", "data", ")", "try", ":", "_data", ":", "dict", ...
We expect to have a section like this ``` [commitizen] name = cz_jira files = [ "commitizen/__version__.py", "pyproject.toml" ] # this tab at the end is important ```
[ "We", "expect", "to", "have", "a", "section", "like", "this" ]
python
train
23.84
materialsproject/pymatgen-db
matgendb/vv/report.py
https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/vv/report.py#L449-L465
def result_subsets(self, rs): """Break a result set into subsets with the same keys. :param rs: Result set, rows of a result as a list of dicts :type rs: list of dict :return: A set with distinct keys (tuples), and a dict, by these tuples, of max. widths for each column """ ...
[ "def", "result_subsets", "(", "self", ",", "rs", ")", ":", "keyset", ",", "maxwid", "=", "set", "(", ")", ",", "{", "}", "for", "r", "in", "rs", ":", "key", "=", "tuple", "(", "sorted", "(", "r", ".", "keys", "(", ")", ")", ")", "keyset", "."...
Break a result set into subsets with the same keys. :param rs: Result set, rows of a result as a list of dicts :type rs: list of dict :return: A set with distinct keys (tuples), and a dict, by these tuples, of max. widths for each column
[ "Break", "a", "result", "set", "into", "subsets", "with", "the", "same", "keys", "." ]
python
train
40.588235
bitesofcode/projexui
projexui/widgets/xlocationwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xlocationwidget.py#L69-L77
def blockSignals( self, state ): """ Blocks the signals for this widget and its sub-parts. :param state | <bool> """ super(XLocationWidget, self).blockSignals(state) self._locationEdit.blockSignals(state) self._locationButton.blockSignals(sta...
[ "def", "blockSignals", "(", "self", ",", "state", ")", ":", "super", "(", "XLocationWidget", ",", "self", ")", ".", "blockSignals", "(", "state", ")", "self", ".", "_locationEdit", ".", "blockSignals", "(", "state", ")", "self", ".", "_locationButton", "."...
Blocks the signals for this widget and its sub-parts. :param state | <bool>
[ "Blocks", "the", "signals", "for", "this", "widget", "and", "its", "sub", "-", "parts", ".", ":", "param", "state", "|", "<bool", ">" ]
python
train
35
tensorpack/tensorpack
tensorpack/utils/debug.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/utils/debug.py#L8-L27
def enable_call_trace(): """ Enable trace for calls to any function. """ def tracer(frame, event, arg): if event == 'call': co = frame.f_code func_name = co.co_name if func_name == 'write' or func_name == 'print': # ignore write() calls from print stat...
[ "def", "enable_call_trace", "(", ")", ":", "def", "tracer", "(", "frame", ",", "event", ",", "arg", ")", ":", "if", "event", "==", "'call'", ":", "co", "=", "frame", ".", "f_code", "func_name", "=", "co", ".", "co_name", "if", "func_name", "==", "'wr...
Enable trace for calls to any function.
[ "Enable", "trace", "for", "calls", "to", "any", "function", "." ]
python
train
40.45
markovmodel/PyEMMA
pyemma/_base/model.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/_base/model.py#L55-L69
def _get_model_param_names(cls): r"""Get parameter names for the model""" # fetch model parameters if hasattr(cls, 'set_model_params'): # introspect the constructor arguments to find the model parameters # to represent args, varargs, kw, default = getargspec_n...
[ "def", "_get_model_param_names", "(", "cls", ")", ":", "# fetch model parameters", "if", "hasattr", "(", "cls", ",", "'set_model_params'", ")", ":", "# introspect the constructor arguments to find the model parameters", "# to represent", "args", ",", "varargs", ",", "kw", ...
r"""Get parameter names for the model
[ "r", "Get", "parameter", "names", "for", "the", "model" ]
python
train
48.6
Nachtfeuer/pipeline
spline/tools/report/collector.py
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L229-L239
def count_stages(self, matrix_name): """ Number of registered stages for given matrix name. Parameters: matrix_name (str): name of the matrix Returns: int: number of reported stages for given matrix name. """ return len(self.data[matrix_name]) if...
[ "def", "count_stages", "(", "self", ",", "matrix_name", ")", ":", "return", "len", "(", "self", ".", "data", "[", "matrix_name", "]", ")", "if", "matrix_name", "in", "self", ".", "data", "else", "0" ]
Number of registered stages for given matrix name. Parameters: matrix_name (str): name of the matrix Returns: int: number of reported stages for given matrix name.
[ "Number", "of", "registered", "stages", "for", "given", "matrix", "name", "." ]
python
train
31.090909
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L196-L199
def commit_fw_db_result(self): """Calls routine to update the FW create/delete result in DB. """ fw_dict = self.get_fw_dict() self.update_fw_db_result(fw_dict.get('fw_id'), fw_dict)
[ "def", "commit_fw_db_result", "(", "self", ")", ":", "fw_dict", "=", "self", ".", "get_fw_dict", "(", ")", "self", ".", "update_fw_db_result", "(", "fw_dict", ".", "get", "(", "'fw_id'", ")", ",", "fw_dict", ")" ]
Calls routine to update the FW create/delete result in DB.
[ "Calls", "routine", "to", "update", "the", "FW", "create", "/", "delete", "result", "in", "DB", "." ]
python
train
50.5
beetbox/audioread
audioread/macca.py
https://github.com/beetbox/audioread/blob/c8bedf7880f13a7b7488b108aaf245d648674818/audioread/macca.py#L215-L222
def _open_url(cls, url): """Given a CFURL Python object, return an opened ExtAudioFileRef. """ file_obj = ctypes.c_void_p() check(_coreaudio.ExtAudioFileOpenURL( url._obj, ctypes.byref(file_obj) )) return file_obj
[ "def", "_open_url", "(", "cls", ",", "url", ")", ":", "file_obj", "=", "ctypes", ".", "c_void_p", "(", ")", "check", "(", "_coreaudio", ".", "ExtAudioFileOpenURL", "(", "url", ".", "_obj", ",", "ctypes", ".", "byref", "(", "file_obj", ")", ")", ")", ...
Given a CFURL Python object, return an opened ExtAudioFileRef.
[ "Given", "a", "CFURL", "Python", "object", "return", "an", "opened", "ExtAudioFileRef", "." ]
python
train
33.25
apache/incubator-heron
third_party/python/cpplint/cpplint.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/third_party/python/cpplint/cpplint.py#L2089-L2113
def CheckHeaderFileIncluded(filename, include_state, error): """Logs an error if a source file does not include its header.""" # Do not check test files fileinfo = FileInfo(filename) if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): return for ext in GetHeaderExtensions(): basefilename = filename...
[ "def", "CheckHeaderFileIncluded", "(", "filename", ",", "include_state", ",", "error", ")", ":", "# Do not check test files", "fileinfo", "=", "FileInfo", "(", "filename", ")", "if", "Search", "(", "_TEST_FILE_SUFFIX", ",", "fileinfo", ".", "BaseName", "(", ")", ...
Logs an error if a source file does not include its header.
[ "Logs", "an", "error", "if", "a", "source", "file", "does", "not", "include", "its", "header", "." ]
python
valid
38.28
rocky/python-xasm
xasm/pyc_convert.py
https://github.com/rocky/python-xasm/blob/03e9576112934d00fbc70645b781ed7b3e3fcda1/xasm/pyc_convert.py#L53-L70
def transform_26_27(inst, new_inst, i, n, offset, instructions, new_asm): """Change JUMP_IF_FALSE and JUMP_IF_TRUE to POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE""" if inst.opname in ('JUMP_IF_FALSE', 'JUMP_IF_TRUE'): i += 1 assert i < n assert instructions[i].opname =...
[ "def", "transform_26_27", "(", "inst", ",", "new_inst", ",", "i", ",", "n", ",", "offset", ",", "instructions", ",", "new_asm", ")", ":", "if", "inst", ".", "opname", "in", "(", "'JUMP_IF_FALSE'", ",", "'JUMP_IF_TRUE'", ")", ":", "i", "+=", "1", "asser...
Change JUMP_IF_FALSE and JUMP_IF_TRUE to POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE
[ "Change", "JUMP_IF_FALSE", "and", "JUMP_IF_TRUE", "to", "POP_JUMP_IF_FALSE", "and", "POP_JUMP_IF_TRUE" ]
python
train
39.611111
fracpete/python-weka-wrapper3
python/weka/classifiers.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/classifiers.py#L744-L756
def kernel(self, kernel): """ Sets the kernel. :param kernel: the kernel to set :type kernel: Kernel """ result = javabridge.static_call( "weka/classifiers/KernelHelper", "setKernel", "(Ljava/lang/Object;Lweka/classifiers/functions/supportVector/K...
[ "def", "kernel", "(", "self", ",", "kernel", ")", ":", "result", "=", "javabridge", ".", "static_call", "(", "\"weka/classifiers/KernelHelper\"", ",", "\"setKernel\"", ",", "\"(Ljava/lang/Object;Lweka/classifiers/functions/supportVector/Kernel;)Z\"", ",", "self", ".", "jo...
Sets the kernel. :param kernel: the kernel to set :type kernel: Kernel
[ "Sets", "the", "kernel", "." ]
python
train
33.538462
arviz-devs/arviz
arviz/plots/plot_utils.py
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/plot_utils.py#L165-L190
def _create_axes_grid(length_plotters, rows, cols, **kwargs): """Create figure and axes for grids with multiple plots. Parameters ---------- n_items : int Number of panels required rows : int Number of rows cols : int Number of columns Returns ------- fig : ...
[ "def", "_create_axes_grid", "(", "length_plotters", ",", "rows", ",", "cols", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"constrained_layout\"", ",", "True", ")", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", "rows", ","...
Create figure and axes for grids with multiple plots. Parameters ---------- n_items : int Number of panels required rows : int Number of rows cols : int Number of columns Returns ------- fig : matplotlib figure ax : matplotlib axes
[ "Create", "figure", "and", "axes", "for", "grids", "with", "multiple", "plots", "." ]
python
train
24.615385
project-ncl/pnc-cli
pnc_cli/buildconfigurations.py
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/buildconfigurations.py#L146-L156
def update_build_configuration(id, **kwargs): """ Update an existing BuildConfiguration with new information :param id: ID of BuildConfiguration to update :param name: Name of BuildConfiguration to update :return: """ data = update_build_configuration_raw(id, **kwargs) if data: ...
[ "def", "update_build_configuration", "(", "id", ",", "*", "*", "kwargs", ")", ":", "data", "=", "update_build_configuration_raw", "(", "id", ",", "*", "*", "kwargs", ")", "if", "data", ":", "return", "utils", ".", "format_json", "(", "data", ")" ]
Update an existing BuildConfiguration with new information :param id: ID of BuildConfiguration to update :param name: Name of BuildConfiguration to update :return:
[ "Update", "an", "existing", "BuildConfiguration", "with", "new", "information" ]
python
train
30.909091
diging/tethne
tethne/analyze/corpus.py
https://github.com/diging/tethne/blob/ba10eeb264b7a3f2dbcce71cfd5cb2d6bbf7055f/tethne/analyze/corpus.py#L227-L326
def sigma(G, corpus, featureset_name, B=None, **kwargs): """ Calculate sigma (from `Chen 2009 <http://arxiv.org/pdf/0904.1439.pdf>`_) for all of the nodes in a :class:`.GraphCollection`\. You can set parameters for burstness estimation using ``kwargs``: ========= ================================...
[ "def", "sigma", "(", "G", ",", "corpus", ",", "featureset_name", ",", "B", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'date'", "not", "in", "corpus", ".", "indices", ":", "corpus", ".", "index", "(", "'date'", ")", "# Calculate burstness if...
Calculate sigma (from `Chen 2009 <http://arxiv.org/pdf/0904.1439.pdf>`_) for all of the nodes in a :class:`.GraphCollection`\. You can set parameters for burstness estimation using ``kwargs``: ========= =============================================================== Parameter Description =====...
[ "Calculate", "sigma", "(", "from", "Chen", "2009", "<http", ":", "//", "arxiv", ".", "org", "/", "pdf", "/", "0904", ".", "1439", ".", "pdf", ">", "_", ")", "for", "all", "of", "the", "nodes", "in", "a", ":", "class", ":", ".", "GraphCollection", ...
python
train
38.53
hobson/pug-invest
pug/invest/sandbox/sim.py
https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/sandbox/sim.py#L263-L273
def symbol_bollinger(symbol='GOOG', start=datetime.datetime(2008, 1, 1), end=datetime.datetime(2009, 12, 31), price_type='close', cleaner=clean_dataframe, window=20, sigma=1.): """Calculate the Bolinger indicator value >>> symbol_bollinger("goog", '2008-1-1', '2008-2-1')[-1] # doctest: +ELLIPSIS, +NOR...
[ "def", "symbol_bollinger", "(", "symbol", "=", "'GOOG'", ",", "start", "=", "datetime", ".", "datetime", "(", "2008", ",", "1", ",", "1", ")", ",", "end", "=", "datetime", ".", "datetime", "(", "2009", ",", "12", ",", "31", ")", ",", "price_type", ...
Calculate the Bolinger indicator value >>> symbol_bollinger("goog", '2008-1-1', '2008-2-1')[-1] # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE -1.8782...
[ "Calculate", "the", "Bolinger", "indicator", "value" ]
python
train
52.545455
vertexproject/synapse
synapse/lib/link.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/link.py#L39-L47
async def unixlisten(path, onlink): ''' Start an PF_UNIX server listening on the given path. ''' info = {'path': path, 'unix': True} async def onconn(reader, writer): link = await Link.anit(reader, writer, info=info) link.schedCoro(onlink(link)) return await asyncio.start_unix_se...
[ "async", "def", "unixlisten", "(", "path", ",", "onlink", ")", ":", "info", "=", "{", "'path'", ":", "path", ",", "'unix'", ":", "True", "}", "async", "def", "onconn", "(", "reader", ",", "writer", ")", ":", "link", "=", "await", "Link", ".", "anit...
Start an PF_UNIX server listening on the given path.
[ "Start", "an", "PF_UNIX", "server", "listening", "on", "the", "given", "path", "." ]
python
train
37.222222
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L1652-L1658
def set_comment(self, format, *args): """ Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted. """ return lib.zconfig_set_comment(self._as_parameter_, format, *args)
[ "def", "set_comment", "(", "self", ",", "format", ",", "*", "args", ")", ":", "return", "lib", ".", "zconfig_set_comment", "(", "self", ".", "_as_parameter_", ",", "format", ",", "*", "args", ")" ]
Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted.
[ "Add", "comment", "to", "config", "item", "before", "saving", "to", "disk", ".", "You", "can", "add", "as", "many", "comment", "lines", "as", "you", "like", ".", "If", "you", "use", "a", "null", "format", "all", "comments", "are", "deleted", "." ]
python
train
41
pgmpy/pgmpy
pgmpy/inference/ExactInference.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L533-L627
def _query(self, variables, operation, evidence=None, joint=True): """ This is a generalized query method that can be used for both query and map query. Parameters ---------- variables: list list of variables for which you want to compute the probability oper...
[ "def", "_query", "(", "self", ",", "variables", ",", "operation", ",", "evidence", "=", "None", ",", "joint", "=", "True", ")", ":", "is_calibrated", "=", "self", ".", "_is_converged", "(", "operation", "=", "operation", ")", "# Calibrate the junction tree if ...
This is a generalized query method that can be used for both query and map query. Parameters ---------- variables: list list of variables for which you want to compute the probability operation: str ('marginalize' | 'maximize') The operation to do for passing mes...
[ "This", "is", "a", "generalized", "query", "method", "that", "can", "be", "used", "for", "both", "query", "and", "map", "query", "." ]
python
train
48.326316
cmbruns/pyopenvr
src/openvr/__init__.py
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L4188-L4193
def getCurrentFadeColor(self, bBackground): """Get current fade color value.""" fn = self.function_table.getCurrentFadeColor result = fn(bBackground) return result
[ "def", "getCurrentFadeColor", "(", "self", ",", "bBackground", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getCurrentFadeColor", "result", "=", "fn", "(", "bBackground", ")", "return", "result" ]
Get current fade color value.
[ "Get", "current", "fade", "color", "value", "." ]
python
train
31.833333
google/grr
grr/client/grr_response_client/client_utils_common.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L35-L86
def Execute(cmd, args, time_limit=-1, bypass_whitelist=False, daemon=False, use_client_context=False, cwd=None): """Executes commands on the client. This function is the only place where commands will be executed by the GRR client. This make...
[ "def", "Execute", "(", "cmd", ",", "args", ",", "time_limit", "=", "-", "1", ",", "bypass_whitelist", "=", "False", ",", "daemon", "=", "False", ",", "use_client_context", "=", "False", ",", "cwd", "=", "None", ")", ":", "if", "not", "bypass_whitelist", ...
Executes commands on the client. This function is the only place where commands will be executed by the GRR client. This makes sure that all issued commands are compared to a white list and no malicious commands are issued on the client machine. Args: cmd: The command to be executed. args: List of arg...
[ "Executes", "commands", "on", "the", "client", "." ]
python
train
38.019231
CivicSpleen/ambry
ambry/orm/database.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L482-L531
def dataset(self, ref, load_all=False, exception=True): """Return a dataset, given a vid or id :param ref: Vid or id for a dataset. If an id is provided, will it will return the one with the largest revision number :param load_all: Use a query that eagerly loads everything. :re...
[ "def", "dataset", "(", "self", ",", "ref", ",", "load_all", "=", "False", ",", "exception", "=", "True", ")", ":", "ref", "=", "str", "(", "ref", ")", "try", ":", "ds", "=", "self", ".", "session", ".", "query", "(", "Dataset", ")", ".", "filter"...
Return a dataset, given a vid or id :param ref: Vid or id for a dataset. If an id is provided, will it will return the one with the largest revision number :param load_all: Use a query that eagerly loads everything. :return: :class:`ambry.orm.Dataset`
[ "Return", "a", "dataset", "given", "a", "vid", "or", "id" ]
python
train
29.88
bitesofcode/projexui
projexui/widgets/xorbbrowserwidget/xorbbrowserfactory.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbbrowserfactory.py#L77-L92
def createCard( self, parent, record ): """ Creates a new widget that will represent the card view for the inpued record. :param parent | <QWidget> record | <orb.Table> :return <QWidget> || None """ cls = se...
[ "def", "createCard", "(", "self", ",", "parent", ",", "record", ")", ":", "cls", "=", "self", ".", "cardClass", "(", "record", ")", "if", "(", "cls", ")", ":", "card", "=", "cls", "(", "parent", ")", "card", ".", "setRecord", "(", "record", ")", ...
Creates a new widget that will represent the card view for the inpued record. :param parent | <QWidget> record | <orb.Table> :return <QWidget> || None
[ "Creates", "a", "new", "widget", "that", "will", "represent", "the", "card", "view", "for", "the", "inpued", "record", ".", ":", "param", "parent", "|", "<QWidget", ">", "record", "|", "<orb", ".", "Table", ">", ":", "return", "<QWidget", ">", "||", "N...
python
train
28.75
bokeh/bokeh
bokeh/core/property/descriptors.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/descriptors.py#L671-L697
def _get(self, obj): ''' Internal implementation of instance attribute access for the ``BasicPropertyDescriptor`` getter. If the value has not been explicitly set by a user, return that value. Otherwise, return the default. Args: obj (HasProps) : the instance to get...
[ "def", "_get", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_property_values'", ")", ":", "raise", "RuntimeError", "(", "\"Cannot get a property value '%s' from a %s instance before HasProps.__init__\"", "%", "(", "self", ".", "name"...
Internal implementation of instance attribute access for the ``BasicPropertyDescriptor`` getter. If the value has not been explicitly set by a user, return that value. Otherwise, return the default. Args: obj (HasProps) : the instance to get a value of this property for ...
[ "Internal", "implementation", "of", "instance", "attribute", "access", "for", "the", "BasicPropertyDescriptor", "getter", "." ]
python
train
35.296296
nateshmbhat/pyttsx3
pyttsx3/driver.py
https://github.com/nateshmbhat/pyttsx3/blob/0f304bff4812d50937393f1e3d7f89c9862a1623/pyttsx3/driver.py#L178-L187
def save_to_file(self, text, filename, name): ''' Called by the engine to push a say command onto the queue. @param text: Text to speak @type text: unicode @param name: Name to associate with the utterance @type name: str ''' self._push(self._driver.save_...
[ "def", "save_to_file", "(", "self", ",", "text", ",", "filename", ",", "name", ")", ":", "self", ".", "_push", "(", "self", ".", "_driver", ".", "save_to_file", ",", "(", "text", ",", "filename", ")", ",", "name", ")" ]
Called by the engine to push a say command onto the queue. @param text: Text to speak @type text: unicode @param name: Name to associate with the utterance @type name: str
[ "Called", "by", "the", "engine", "to", "push", "a", "say", "command", "onto", "the", "queue", "." ]
python
train
34.3
push-things/django-th
th_trello/my_trello.py
https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/th_trello/my_trello.py#L89-L153
def save_data(self, trigger_id, **data): """ let's save the data :param trigger_id: trigger ID from which to save data :param data: the data to check to be used and save :type trigger_id: int :type data: dict :return: the status of the sa...
[ "def", "save_data", "(", "self", ",", "trigger_id", ",", "*", "*", "data", ")", ":", "data", "[", "'output_format'", "]", "=", "'md'", "title", ",", "content", "=", "super", "(", "ServiceTrello", ",", "self", ")", ".", "save_data", "(", "trigger_id", "...
let's save the data :param trigger_id: trigger ID from which to save data :param data: the data to check to be used and save :type trigger_id: int :type data: dict :return: the status of the save statement :rtype: boolean
[ "let", "s", "save", "the", "data" ]
python
train
40.138462
grahambell/pymoc
lib/pymoc/util/tool.py
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/util/tool.py#L273-L288
def intersection(self): """Compute the intersection with the given MOC. This command takes the name of a MOC file and forms the intersection of the running MOC with that file. :: pymoctool a.fits --intersection b.fits --output intersection.fits """ if self...
[ "def", "intersection", "(", "self", ")", ":", "if", "self", ".", "moc", "is", "None", ":", "raise", "CommandError", "(", "'No MOC information present for intersection'", ")", "filename", "=", "self", ".", "params", ".", "pop", "(", ")", "self", ".", "moc", ...
Compute the intersection with the given MOC. This command takes the name of a MOC file and forms the intersection of the running MOC with that file. :: pymoctool a.fits --intersection b.fits --output intersection.fits
[ "Compute", "the", "intersection", "with", "the", "given", "MOC", "." ]
python
train
31.1875
gem/oq-engine
openquake/hazardlib/gsim/cauzzi_2014.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L401-L419
def _compute_mean(self, C, rup, dists, sites, imt): """ Returns the mean ground motion acceleration and velocity """ mean = (self._get_magnitude_scaling_term(C, rup.mag) + self._get_distance_scaling_term(C, rup.mag, dists.rrup) + self._get_site_amplificati...
[ "def", "_compute_mean", "(", "self", ",", "C", ",", "rup", ",", "dists", ",", "sites", ",", "imt", ")", ":", "mean", "=", "(", "self", ".", "_get_magnitude_scaling_term", "(", "C", ",", "rup", ".", "mag", ")", "+", "self", ".", "_get_distance_scaling_t...
Returns the mean ground motion acceleration and velocity
[ "Returns", "the", "mean", "ground", "motion", "acceleration", "and", "velocity" ]
python
train
43.315789
CitrineInformatics/pif-dft
dfttopif/parsers/pwscf.py
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L114-L122
def _is_converged(self): '''Determine if calculation converged; for a relaxation (static) run we look for ionic (electronic) convergence in the output''' if self.is_relaxed(): # relaxation run case return self._get_line(['End of', 'Geometry Optimization'], self.outputf, r...
[ "def", "_is_converged", "(", "self", ")", ":", "if", "self", ".", "is_relaxed", "(", ")", ":", "# relaxation run case", "return", "self", ".", "_get_line", "(", "[", "'End of'", ",", "'Geometry Optimization'", "]", ",", "self", ".", "outputf", ",", "return_s...
Determine if calculation converged; for a relaxation (static) run we look for ionic (electronic) convergence in the output
[ "Determine", "if", "calculation", "converged", ";", "for", "a", "relaxation", "(", "static", ")", "run", "we", "look", "for", "ionic", "(", "electronic", ")", "convergence", "in", "the", "output" ]
python
train
53
peterwittek/ncpol2sdpa
ncpol2sdpa/nc_utils.py
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/nc_utils.py#L398-L434
def generate_operators(name, n_vars=1, hermitian=None, commutative=False): """Generates a number of commutative or noncommutative operators :param name: The prefix in the symbolic representation of the noncommuting variables. This will be suffixed by a number from 0 to n_vars-...
[ "def", "generate_operators", "(", "name", ",", "n_vars", "=", "1", ",", "hermitian", "=", "None", ",", "commutative", "=", "False", ")", ":", "variables", "=", "[", "]", "for", "i", "in", "range", "(", "n_vars", ")", ":", "if", "n_vars", ">", "1", ...
Generates a number of commutative or noncommutative operators :param name: The prefix in the symbolic representation of the noncommuting variables. This will be suffixed by a number from 0 to n_vars-1 if n_vars > 1. :type name: str. :param n_vars: The number of variables. ...
[ "Generates", "a", "number", "of", "commutative", "or", "noncommutative", "operators" ]
python
train
36
stormpath/stormpath-django
django_stormpath/backends.py
https://github.com/stormpath/stormpath-django/blob/af60eb5da2115d94ac313613c5d4e6b9f3d16157/django_stormpath/backends.py#L22-L36
def _stormpath_authenticate(self, username, password): """Check if Stormpath authentication works :param username: Can be actual username or email :param password: Account password Returns an account object if successful or None otherwise. """ APPLICATION = get_applicat...
[ "def", "_stormpath_authenticate", "(", "self", ",", "username", ",", "password", ")", ":", "APPLICATION", "=", "get_application", "(", ")", "try", ":", "result", "=", "APPLICATION", ".", "authenticate_account", "(", "username", ",", "password", ")", "return", ...
Check if Stormpath authentication works :param username: Can be actual username or email :param password: Account password Returns an account object if successful or None otherwise.
[ "Check", "if", "Stormpath", "authentication", "works" ]
python
train
33.866667
peterwittek/ncpol2sdpa
ncpol2sdpa/physics_utils.py
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/physics_utils.py#L17-L44
def get_neighbors(index, lattice_length, width=0, periodic=False): """Get the forward neighbors of a site in a lattice. :param index: Linear index of operator. :type index: int. :param lattice_length: The size of the 2D lattice in either dimension :type lattice_length: int. :param width: Option...
[ "def", "get_neighbors", "(", "index", ",", "lattice_length", ",", "width", "=", "0", ",", "periodic", "=", "False", ")", ":", "if", "width", "==", "0", ":", "width", "=", "lattice_length", "neighbors", "=", "[", "]", "coords", "=", "divmod", "(", "inde...
Get the forward neighbors of a site in a lattice. :param index: Linear index of operator. :type index: int. :param lattice_length: The size of the 2D lattice in either dimension :type lattice_length: int. :param width: Optional parameter to define width. :type width: int. :param periodic: O...
[ "Get", "the", "forward", "neighbors", "of", "a", "site", "in", "a", "lattice", "." ]
python
train
34.607143
HewlettPackard/python-hpOneView
hpOneView/oneview_client.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L446-L456
def server_hardware_types(self): """ Gets the ServerHardwareTypes API client. Returns: ServerHardwareTypes: """ if not self.__server_hardware_types: self.__server_hardware_types = ServerHardwareTypes( self.__connection) return self...
[ "def", "server_hardware_types", "(", "self", ")", ":", "if", "not", "self", ".", "__server_hardware_types", ":", "self", ".", "__server_hardware_types", "=", "ServerHardwareTypes", "(", "self", ".", "__connection", ")", "return", "self", ".", "__server_hardware_type...
Gets the ServerHardwareTypes API client. Returns: ServerHardwareTypes:
[ "Gets", "the", "ServerHardwareTypes", "API", "client", "." ]
python
train
30.363636
google/transitfeed
kmlwriter.py
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L675-L695
def _CreateShapePointFolder(self, shapes_folder, shape): """Create a KML Folder containing all the shape points in a shape. The folder contains placemarks for each shapepoint. Args: shapes_folder: A KML Shape Folder ElementTree.Element instance shape: The shape to plot. Returns: The...
[ "def", "_CreateShapePointFolder", "(", "self", ",", "shapes_folder", ",", "shape", ")", ":", "folder_name", "=", "shape", ".", "shape_id", "+", "' Shape Points'", "folder", "=", "self", ".", "_CreateFolder", "(", "shapes_folder", ",", "folder_name", ",", "visibl...
Create a KML Folder containing all the shape points in a shape. The folder contains placemarks for each shapepoint. Args: shapes_folder: A KML Shape Folder ElementTree.Element instance shape: The shape to plot. Returns: The Folder ElementTree.Element instance or None.
[ "Create", "a", "KML", "Folder", "containing", "all", "the", "shape", "points", "in", "a", "shape", "." ]
python
train
36.952381
gtaylor/python-route53
route53/connection.py
https://github.com/gtaylor/python-route53/blob/b9fc7e258a79551c9ed61e4a71668b7f06f9e774/route53/connection.py#L53-L111
def _do_autopaginating_api_call(self, path, params, method, parser_func, next_marker_xpath, next_marker_param_name, next_type_xpath=None, parser_kwargs=None): """ Given an API method, the arguments passed to it, and a function to hand parsing off to, loop through the record sets ...
[ "def", "_do_autopaginating_api_call", "(", "self", ",", "path", ",", "params", ",", "method", ",", "parser_func", ",", "next_marker_xpath", ",", "next_marker_param_name", ",", "next_type_xpath", "=", "None", ",", "parser_kwargs", "=", "None", ")", ":", "if", "no...
Given an API method, the arguments passed to it, and a function to hand parsing off to, loop through the record sets in the API call until all records have been yielded. :param str method: The API method on the endpoint. :param dict params: The kwargs from the top-level API method. ...
[ "Given", "an", "API", "method", "the", "arguments", "passed", "to", "it", "and", "a", "function", "to", "hand", "parsing", "off", "to", "loop", "through", "the", "record", "sets", "in", "the", "API", "call", "until", "all", "records", "have", "been", "yi...
python
test
45.644068
has2k1/plotnine
plotnine/themes/themeable.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/themeable.py#L129-L138
def merge(self, other): """ Merge properties of other into self Raises ValueError if any them are a blank """ if self.is_blank() or other.is_blank(): raise ValueError('Cannot merge if there is a blank.') else: self.properties.update(other.properti...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "if", "self", ".", "is_blank", "(", ")", "or", "other", ".", "is_blank", "(", ")", ":", "raise", "ValueError", "(", "'Cannot merge if there is a blank.'", ")", "else", ":", "self", ".", "properties", "...
Merge properties of other into self Raises ValueError if any them are a blank
[ "Merge", "properties", "of", "other", "into", "self" ]
python
train
31.4
klen/makesite
makesite/site.py
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L75-L98
def paste_template(self, template_name, template=None, deploy_dir=None): " Paste template. " LOGGER.debug("Paste template: %s" % template_name) deploy_dir = deploy_dir or self.deploy_dir template = template or self._get_template_path(template_name) self.read([op.join(template, s...
[ "def", "paste_template", "(", "self", ",", "template_name", ",", "template", "=", "None", ",", "deploy_dir", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"Paste template: %s\"", "%", "template_name", ")", "deploy_dir", "=", "deploy_dir", "or", "self",...
Paste template.
[ "Paste", "template", "." ]
python
train
40
hollenstein/maspy
maspy/auxiliary.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/auxiliary.py#L733-L803
def returnSplineList(dependentVar, independentVar, subsetPercentage=0.4, cycles=10, minKnotPoints=10, initialKnots=200, splineOrder=2, terminalExpansion=0.1 ): """ #TODO: docstring Note: Expects sorted arrays. :param dependentVar: #TODO: docst...
[ "def", "returnSplineList", "(", "dependentVar", ",", "independentVar", ",", "subsetPercentage", "=", "0.4", ",", "cycles", "=", "10", ",", "minKnotPoints", "=", "10", ",", "initialKnots", "=", "200", ",", "splineOrder", "=", "2", ",", "terminalExpansion", "=",...
#TODO: docstring Note: Expects sorted arrays. :param dependentVar: #TODO: docstring :param independentVar: #TODO: docstring :param subsetPercentage: #TODO: docstring :param cycles: #TODO: docstring :param minKnotPoints: #TODO: docstring :param initialKnots: #TODO: docstring :param spli...
[ "#TODO", ":", "docstring" ]
python
train
40.732394
kashifrazzaqui/again
again/statemachine.py
https://github.com/kashifrazzaqui/again/blob/09cfbda7650d44447dbb0b27780835e9236741ea/again/statemachine.py#L147-L160
def consume(self, event): """ process the current event, setup new state and teardown current state """ future_states = self.can(event) new_state = future_states[0] if len(future_states) > 1: new_state = self.choose(event) event.execute() self...
[ "def", "consume", "(", "self", ",", "event", ")", ":", "future_states", "=", "self", ".", "can", "(", "event", ")", "new_state", "=", "future_states", "[", "0", "]", "if", "len", "(", "future_states", ")", ">", "1", ":", "new_state", "=", "self", "."...
process the current event, setup new state and teardown current state
[ "process", "the", "current", "event", "setup", "new", "state", "and", "teardown", "current", "state" ]
python
train
29.5
cloudendpoints/endpoints-python
endpoints/api_config.py
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L102-L116
def _Enum(docstring, *names): """Utility to generate enum classes used by annotations. Args: docstring: Docstring for the generated enum class. *names: Enum names. Returns: A class that contains enum names as attributes. """ enums = dict(zip(names, range(len(names)))) reverse = dict((value, ke...
[ "def", "_Enum", "(", "docstring", ",", "*", "names", ")", ":", "enums", "=", "dict", "(", "zip", "(", "names", ",", "range", "(", "len", "(", "names", ")", ")", ")", ")", "reverse", "=", "dict", "(", "(", "value", ",", "key", ")", "for", "key",...
Utility to generate enum classes used by annotations. Args: docstring: Docstring for the generated enum class. *names: Enum names. Returns: A class that contains enum names as attributes.
[ "Utility", "to", "generate", "enum", "classes", "used", "by", "annotations", "." ]
python
train
30.2
Pixelapse/pyglass
pyglass/quicklook/api.py
https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/quicklook/api.py#L24-L44
def preview(src_path): ''' Generates a preview of src_path in the requested format. :returns: A list of preview paths, one for each page. Blank list if unsupported. ''' preview = embedded_preview(src_path) if not is_valid_preview(preview): preview = generator_preview(src_path) if not is_valid_preview(...
[ "def", "preview", "(", "src_path", ")", ":", "preview", "=", "embedded_preview", "(", "src_path", ")", "if", "not", "is_valid_preview", "(", "preview", ")", ":", "preview", "=", "generator_preview", "(", "src_path", ")", "if", "not", "is_valid_preview", "(", ...
Generates a preview of src_path in the requested format. :returns: A list of preview paths, one for each page. Blank list if unsupported.
[ "Generates", "a", "preview", "of", "src_path", "in", "the", "requested", "format", ".", ":", "returns", ":", "A", "list", "of", "preview", "paths", "one", "for", "each", "page", ".", "Blank", "list", "if", "unsupported", "." ]
python
train
28.857143
mwgielen/jackal
jackal/scripts/eternalblue.py
https://github.com/mwgielen/jackal/blob/7fe62732eb5194b7246215d5277fb37c398097bf/jackal/scripts/eternalblue.py#L123-L134
def detect_os(self, ip): """ Runs the checker.py scripts to detect the os. """ process = subprocess.run(['python2', os.path.join(self.datadir, 'MS17-010', 'checker.py'), str(ip)], stdout=subprocess.PIPE) out = process.stdout.decode('utf-8').split('\n') system_os = '' ...
[ "def", "detect_os", "(", "self", ",", "ip", ")", ":", "process", "=", "subprocess", ".", "run", "(", "[", "'python2'", ",", "os", ".", "path", ".", "join", "(", "self", ".", "datadir", ",", "'MS17-010'", ",", "'checker.py'", ")", ",", "str", "(", "...
Runs the checker.py scripts to detect the os.
[ "Runs", "the", "checker", ".", "py", "scripts", "to", "detect", "the", "os", "." ]
python
valid
40.5
tundish/turberfield-dialogue
turberfield/dialogue/player.py
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/player.py#L45-L95
def rehearse( folders, references, handler, repeat=0, roles=1, strict=False, loop=None ): """Cast a set of objects into a sequence of scene scripts. Deliver the performance. :param folders: A sequence of :py:class:`turberfield.dialogue.model.SceneScript.Folder` objects. :param reference...
[ "def", "rehearse", "(", "folders", ",", "references", ",", "handler", ",", "repeat", "=", "0", ",", "roles", "=", "1", ",", "strict", "=", "False", ",", "loop", "=", "None", ")", ":", "if", "isinstance", "(", "folders", ",", "SceneScript", ".", "Fold...
Cast a set of objects into a sequence of scene scripts. Deliver the performance. :param folders: A sequence of :py:class:`turberfield.dialogue.model.SceneScript.Folder` objects. :param references: A sequence of Python objects. :param handler: A callable object. This will be invoked with every event...
[ "Cast", "a", "set", "of", "objects", "into", "a", "sequence", "of", "scene", "scripts", ".", "Deliver", "the", "performance", "." ]
python
train
33.411765
aiven/pghoard
pghoard/rohmu/encryptor.py
https://github.com/aiven/pghoard/blob/2994165d4ef3ff7a5669a2527346bcbfb5b3bd8a/pghoard/rohmu/encryptor.py#L101-L109
def write(self, data): """Encrypt and write the given bytes""" self._check_not_closed() if not data: return 0 enc_data = self.encryptor.update(data) self.next_fp.write(enc_data) self.offset += len(data) return len(data)
[ "def", "write", "(", "self", ",", "data", ")", ":", "self", ".", "_check_not_closed", "(", ")", "if", "not", "data", ":", "return", "0", "enc_data", "=", "self", ".", "encryptor", ".", "update", "(", "data", ")", "self", ".", "next_fp", ".", "write",...
Encrypt and write the given bytes
[ "Encrypt", "and", "write", "the", "given", "bytes" ]
python
train
31
proteanhq/protean
src/protean/impl/repository/dict_repo.py
https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/impl/repository/dict_repo.py#L134-L146
def _set_auto_fields(self, model_obj): """Set the values of the auto field using counter""" for field_name, field_obj in \ self.entity_cls.meta_.auto_fields: counter_key = f'{self.schema_name}_{field_name}' if not (field_name in model_obj and model_obj[field_name]...
[ "def", "_set_auto_fields", "(", "self", ",", "model_obj", ")", ":", "for", "field_name", ",", "field_obj", "in", "self", ".", "entity_cls", ".", "meta_", ".", "auto_fields", ":", "counter_key", "=", "f'{self.schema_name}_{field_name}'", "if", "not", "(", "field_...
Set the values of the auto field using counter
[ "Set", "the", "values", "of", "the", "auto", "field", "using", "counter" ]
python
train
48.692308
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L7644-L7687
def kxtrct(keywd, terms, nterms, instring, termlen=_default_len_out, stringlen=_default_len_out, substrlen=_default_len_out): """ Locate a keyword in a string and extract the substring from the beginning of the first word following the keyword to the beginning of the first subsequent recognized terminat...
[ "def", "kxtrct", "(", "keywd", ",", "terms", ",", "nterms", ",", "instring", ",", "termlen", "=", "_default_len_out", ",", "stringlen", "=", "_default_len_out", ",", "substrlen", "=", "_default_len_out", ")", ":", "assert", "nterms", "<=", "len", "(", "terms...
Locate a keyword in a string and extract the substring from the beginning of the first word following the keyword to the beginning of the first subsequent recognized terminator of a list. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kxtrct_c.html :param keywd: Word that marks the beginning ...
[ "Locate", "a", "keyword", "in", "a", "string", "and", "extract", "the", "substring", "from", "the", "beginning", "of", "the", "first", "word", "following", "the", "keyword", "to", "the", "beginning", "of", "the", "first", "subsequent", "recognized", "terminato...
python
train
44.159091
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py#L789-L801
def qos_rcv_queue_multicast_threshold_traffic_class4(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") qos = ET.SubElement(config, "qos", xmlns="urn:brocade.com:mgmt:brocade-qos") rcv_queue = ET.SubElement(qos, "rcv-queue") multicast = ET.SubElemen...
[ "def", "qos_rcv_queue_multicast_threshold_traffic_class4", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "qos", "=", "ET", ".", "SubElement", "(", "config", ",", "\"qos\"", ",", "xmlns", "=", "...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
46.846154
ajenhl/tacl
tacl/data_store.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/data_store.py#L471-L499
def _get_text_id(self, witness): """Returns the database ID of the Text record for `witness`. This may require creating such a record. If `text`\'s checksum does not match an existing record's checksum, the record's checksum is updated and all associated TextNGram and TextHasNG...
[ "def", "_get_text_id", "(", "self", ",", "witness", ")", ":", "name", ",", "siglum", "=", "witness", ".", "get_names", "(", ")", "text_record", "=", "self", ".", "_conn", ".", "execute", "(", "constants", ".", "SELECT_TEXT_SQL", ",", "[", "name", ",", ...
Returns the database ID of the Text record for `witness`. This may require creating such a record. If `text`\'s checksum does not match an existing record's checksum, the record's checksum is updated and all associated TextNGram and TextHasNGram records are deleted. :param wit...
[ "Returns", "the", "database", "ID", "of", "the", "Text", "record", "for", "witness", "." ]
python
train
42.448276
tensorflow/tensor2tensor
tensor2tensor/utils/diet.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/diet.py#L177-L225
def update_variable(self, var, grad_var): """Update the variable and its slots.""" params = self.params global_step = tf.to_float(self.global_step) + 1 # compute learning rate lrate = params.learning_rate if params.learning_rate_decay_scheme == "noam": lrate *= tf.minimum(global_step * pa...
[ "def", "update_variable", "(", "self", ",", "var", ",", "grad_var", ")", ":", "params", "=", "self", ".", "params", "global_step", "=", "tf", ".", "to_float", "(", "self", ".", "global_step", ")", "+", "1", "# compute learning rate", "lrate", "=", "params"...
Update the variable and its slots.
[ "Update", "the", "variable", "and", "its", "slots", "." ]
python
train
45.22449
KrzyHonk/bpmn-python
bpmn_python/bpmn_diagram_metrics.py
https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_metrics.py#L221-L232
def NOAJS_metric(bpmn_graph): """ Returns the value of the NOAJS metric (Number of Activities, joins and splits) for the BPMNDiagramGraph instance. :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model. """ activities_count = all_activities_count(bpmn_graph) gateways_c...
[ "def", "NOAJS_metric", "(", "bpmn_graph", ")", ":", "activities_count", "=", "all_activities_count", "(", "bpmn_graph", ")", "gateways_count", "=", "all_gateways_count", "(", "bpmn_graph", ")", "return", "activities_count", "+", "gateways_count" ]
Returns the value of the NOAJS metric (Number of Activities, joins and splits) for the BPMNDiagramGraph instance. :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.
[ "Returns", "the", "value", "of", "the", "NOAJS", "metric", "(", "Number", "of", "Activities", "joins", "and", "splits", ")", "for", "the", "BPMNDiagramGraph", "instance", "." ]
python
train
32.666667
slarse/clanimtk
clanimtk/util.py
https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/util.py#L94-L116
def concatechain(*generators: types.FrameGenerator, separator: str = ''): """Return a generator that in each iteration takes one value from each of the supplied generators, joins them together with the specified separator and yields the result. Stops as soon as any iterator raises StopIteration and retu...
[ "def", "concatechain", "(", "*", "generators", ":", "types", ".", "FrameGenerator", ",", "separator", ":", "str", "=", "''", ")", ":", "while", "True", ":", "try", ":", "next_", "=", "[", "next", "(", "gen", ")", "for", "gen", "in", "generators", "]"...
Return a generator that in each iteration takes one value from each of the supplied generators, joins them together with the specified separator and yields the result. Stops as soon as any iterator raises StopIteration and returns the value contained in it. Primarily created for chaining string generat...
[ "Return", "a", "generator", "that", "in", "each", "iteration", "takes", "one", "value", "from", "each", "of", "the", "supplied", "generators", "joins", "them", "together", "with", "the", "specified", "separator", "and", "yields", "the", "result", ".", "Stops",...
python
train
43.913043
manolomartinez/greg
greg/classes.py
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L202-L217
def will_tag(self): """ Check whether the feed should be tagged """ wanttags = self.retrieve_config('Tag', 'no') if wanttags == 'yes': if aux.staggerexists: willtag = True else: willtag = False print(("You wa...
[ "def", "will_tag", "(", "self", ")", ":", "wanttags", "=", "self", ".", "retrieve_config", "(", "'Tag'", ",", "'no'", ")", "if", "wanttags", "==", "'yes'", ":", "if", "aux", ".", "staggerexists", ":", "willtag", "=", "True", "else", ":", "willtag", "="...
Check whether the feed should be tagged
[ "Check", "whether", "the", "feed", "should", "be", "tagged" ]
python
train
35.1875
mixmastamyk/console
console/core.py
https://github.com/mixmastamyk/console/blob/afe6c95d5a7b83d85376f450454e3769e4a5c3d0/console/core.py#L468-L478
def set_output(self, outfile): ''' Set's the output file, currently only useful with context-managers. Note: This function is experimental and may not last. ''' if self._orig_stdout: # restore Usted sys.stdout = self._orig_stdout self._stream = ...
[ "def", "set_output", "(", "self", ",", "outfile", ")", ":", "if", "self", ".", "_orig_stdout", ":", "# restore Usted", "sys", ".", "stdout", "=", "self", ".", "_orig_stdout", "self", ".", "_stream", "=", "outfile", "sys", ".", "stdout", "=", "_LineWriter",...
Set's the output file, currently only useful with context-managers. Note: This function is experimental and may not last.
[ "Set", "s", "the", "output", "file", "currently", "only", "useful", "with", "context", "-", "managers", "." ]
python
train
34.909091
pytroll/pyorbital
pyorbital/astronomy.py
https://github.com/pytroll/pyorbital/blob/647007934dc827a4c698629cf32a84a5167844b2/pyorbital/astronomy.py#L134-L144
def cos_zen(utc_time, lon, lat): """Cosine of the sun-zenith angle for *lon*, *lat* at *utc_time*. utc_time: datetime.datetime instance of the UTC time lon and lat in degrees. """ lon = np.deg2rad(lon) lat = np.deg2rad(lat) r_a, dec = sun_ra_dec(utc_time) h__ = _local_hour_angle(utc_tim...
[ "def", "cos_zen", "(", "utc_time", ",", "lon", ",", "lat", ")", ":", "lon", "=", "np", ".", "deg2rad", "(", "lon", ")", "lat", "=", "np", ".", "deg2rad", "(", "lat", ")", "r_a", ",", "dec", "=", "sun_ra_dec", "(", "utc_time", ")", "h__", "=", "...
Cosine of the sun-zenith angle for *lon*, *lat* at *utc_time*. utc_time: datetime.datetime instance of the UTC time lon and lat in degrees.
[ "Cosine", "of", "the", "sun", "-", "zenith", "angle", "for", "*", "lon", "*", "*", "lat", "*", "at", "*", "utc_time", "*", ".", "utc_time", ":", "datetime", ".", "datetime", "instance", "of", "the", "UTC", "time", "lon", "and", "lat", "in", "degrees"...
python
train
36.636364
hvac/hvac
hvac/api/auth_methods/okta.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/auth_methods/okta.py#L15-L57
def configure(self, org_name, api_token=None, base_url='okta.com', ttl=None, max_ttl=None, bypass_okta_mfa=False, mount_point=DEFAULT_MOUNT_POINT): """Configure the connection parameters for Okta. This path honors the distinction between the create and update capabilities inside ACL p...
[ "def", "configure", "(", "self", ",", "org_name", ",", "api_token", "=", "None", ",", "base_url", "=", "'okta.com'", ",", "ttl", "=", "None", ",", "max_ttl", "=", "None", ",", "bypass_okta_mfa", "=", "False", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ...
Configure the connection parameters for Okta. This path honors the distinction between the create and update capabilities inside ACL policies. Supported methods: POST: /auth/{mount_point}/config. Produces: 204 (empty body) :param org_name: Name of the organization to be used in t...
[ "Configure", "the", "connection", "parameters", "for", "Okta", "." ]
python
train
47.372093
tetframework/Tonnikala
tonnikala/runtime/debug.py
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/runtime/debug.py#L162-L201
def translate_exception(exc_info, initial_skip=0): """If passed an exc_info it will automatically rewrite the exceptions all the way down to the correct line numbers and frames. """ tb = exc_info[2] frames = [] # skip some internal frames if wanted for x in range(initial_skip): if t...
[ "def", "translate_exception", "(", "exc_info", ",", "initial_skip", "=", "0", ")", ":", "tb", "=", "exc_info", "[", "2", "]", "frames", "=", "[", "]", "# skip some internal frames if wanted", "for", "x", "in", "range", "(", "initial_skip", ")", ":", "if", ...
If passed an exc_info it will automatically rewrite the exceptions all the way down to the correct line numbers and frames.
[ "If", "passed", "an", "exc_info", "it", "will", "automatically", "rewrite", "the", "exceptions", "all", "the", "way", "down", "to", "the", "correct", "line", "numbers", "and", "frames", "." ]
python
train
35.675
pypyr/pypyr-cli
pypyr/context.py
https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L405-L441
def get_formatted_as_type(self, value, default=None, out_type=str): """Return formatted value for input value, returns as out_type. Caveat emptor: if out_type is bool and value a string, return will be True if str is 'True'. It will be False for all other cases. Args: ...
[ "def", "get_formatted_as_type", "(", "self", ",", "value", ",", "default", "=", "None", ",", "out_type", "=", "str", ")", ":", "if", "value", "is", "None", ":", "value", "=", "default", "if", "isinstance", "(", "value", ",", "SpecialTagDirective", ")", "...
Return formatted value for input value, returns as out_type. Caveat emptor: if out_type is bool and value a string, return will be True if str is 'True'. It will be False for all other cases. Args: value: the value to format default: if value is None, set to thi...
[ "Return", "formatted", "value", "for", "input", "value", "returns", "as", "out_type", "." ]
python
train
37.648649
ska-sa/katcp-python
katcp/fake_clients.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L16-L59
def fake_KATCP_client_resource_factory( KATCPClientResourceClass, fake_options, resource_spec, *args, **kwargs): """Create a fake KATCPClientResource-like class and a fake-manager Parameters ---------- KATCPClientResourceClass : class Subclass of :class:`katcp.resource_client.KATCPClien...
[ "def", "fake_KATCP_client_resource_factory", "(", "KATCPClientResourceClass", ",", "fake_options", ",", "resource_spec", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO Implement allow_any_request functionality. When True, any unknown request (even", "# if there is n...
Create a fake KATCPClientResource-like class and a fake-manager Parameters ---------- KATCPClientResourceClass : class Subclass of :class:`katcp.resource_client.KATCPClientResource` fake_options : dict Options for the faking process. Keys: allow_any_request : bool, default F...
[ "Create", "a", "fake", "KATCPClientResource", "-", "like", "class", "and", "a", "fake", "-", "manager" ]
python
train
47.340909
trustar/trustar-python
trustar/models/report.py
https://github.com/trustar/trustar-python/blob/707d51adc58d68aed7de12a4ca37949cb75cf122/trustar/models/report.py#L94-L123
def to_dict(self, remove_nones=False): """ Creates a dictionary representation of the object. :param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``. :return: A dictionary representation of the report. """ if remove...
[ "def", "to_dict", "(", "self", ",", "remove_nones", "=", "False", ")", ":", "if", "remove_nones", ":", "report_dict", "=", "super", "(", ")", ".", "to_dict", "(", "remove_nones", "=", "True", ")", "else", ":", "report_dict", "=", "{", "'title'", ":", "...
Creates a dictionary representation of the object. :param remove_nones: Whether ``None`` values should be filtered out of the dictionary. Defaults to ``False``. :return: A dictionary representation of the report.
[ "Creates", "a", "dictionary", "representation", "of", "the", "object", "." ]
python
train
34.466667
CalebBell/ht
ht/conduction.py
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conduction.py#L234-L269
def k_to_R_value(k, SI=True): r'''Returns the R-value of a substance given its thermal conductivity, Will return R-value in SI units unless SI is false. SI units are m^2 K/(W*inch); Imperial units of R-value are ft^2 deg F*h/(BTU*inch). Parameters ---------- k : float Thermal conductivi...
[ "def", "k_to_R_value", "(", "k", ",", "SI", "=", "True", ")", ":", "r", "=", "k_to_thermal_resistivity", "(", "k", ")", "if", "SI", ":", "return", "r", "*", "inch", "else", ":", "return", "r", "/", "(", "foot", "**", "2", "*", "degree_Fahrenheit", ...
r'''Returns the R-value of a substance given its thermal conductivity, Will return R-value in SI units unless SI is false. SI units are m^2 K/(W*inch); Imperial units of R-value are ft^2 deg F*h/(BTU*inch). Parameters ---------- k : float Thermal conductivity of a substance [W/m/K] SI :...
[ "r", "Returns", "the", "R", "-", "value", "of", "a", "substance", "given", "its", "thermal", "conductivity", "Will", "return", "R", "-", "value", "in", "SI", "units", "unless", "SI", "is", "false", ".", "SI", "units", "are", "m^2", "K", "/", "(", "W"...
python
train
28.638889
explosion/spaCy
spacy/_ml.py
https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/_ml.py#L84-L99
def with_cpu(ops, model): """Wrap a model that should run on CPU, transferring inputs and outputs as necessary.""" model.to_cpu() def with_cpu_forward(inputs, drop=0.0): cpu_outputs, backprop = model.begin_update(_to_cpu(inputs), drop=drop) gpu_outputs = _to_device(ops, cpu_outputs) ...
[ "def", "with_cpu", "(", "ops", ",", "model", ")", ":", "model", ".", "to_cpu", "(", ")", "def", "with_cpu_forward", "(", "inputs", ",", "drop", "=", "0.0", ")", ":", "cpu_outputs", ",", "backprop", "=", "model", ".", "begin_update", "(", "_to_cpu", "("...
Wrap a model that should run on CPU, transferring inputs and outputs as necessary.
[ "Wrap", "a", "model", "that", "should", "run", "on", "CPU", "transferring", "inputs", "and", "outputs", "as", "necessary", "." ]
python
train
33.875
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L321-L331
def bookmarks_index_changed(self): """Update the UI when the bookmarks combobox has changed.""" index = self.bookmarks_list.currentIndex() if index >= 0: self.tool.reset() rectangle = self.bookmarks_list.itemData(index) self.tool.set_rectangle(rectangle) ...
[ "def", "bookmarks_index_changed", "(", "self", ")", ":", "index", "=", "self", ".", "bookmarks_list", ".", "currentIndex", "(", ")", "if", "index", ">=", "0", ":", "self", ".", "tool", ".", "reset", "(", ")", "rectangle", "=", "self", ".", "bookmarks_lis...
Update the UI when the bookmarks combobox has changed.
[ "Update", "the", "UI", "when", "the", "bookmarks", "combobox", "has", "changed", "." ]
python
train
41.090909
apache/incubator-mxnet
python/mxnet/contrib/autograd.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/autograd.py#L195-L230
def grad(func, argnum=None): """Return function that computes gradient of arguments. Parameters ---------- func: a python function The forward (loss) function. argnum: an int or a list of int The index of argument to calculate gradient for. Returns ------- grad_func: a ...
[ "def", "grad", "(", "func", ",", "argnum", "=", "None", ")", ":", "grad_with_loss_func", "=", "grad_and_loss", "(", "func", ",", "argnum", ")", "@", "functools", ".", "wraps", "(", "grad_with_loss_func", ")", "def", "wrapped", "(", "*", "args", ")", ":",...
Return function that computes gradient of arguments. Parameters ---------- func: a python function The forward (loss) function. argnum: an int or a list of int The index of argument to calculate gradient for. Returns ------- grad_func: a python function A function t...
[ "Return", "function", "that", "computes", "gradient", "of", "arguments", "." ]
python
train
28.777778
Azure/azure-uamqp-python
uamqp/message.py
https://github.com/Azure/azure-uamqp-python/blob/b67e4fcaf2e8a337636947523570239c10a58ae2/uamqp/message.py#L495-L525
def gather(self): """Return all the messages represented by this object. This will convert the batch data into individual Message objects, which may be one or more if multi_messages is set to `True`. :rtype: list[~uamqp.message.Message] """ if self._multi_messages: ...
[ "def", "gather", "(", "self", ")", ":", "if", "self", ".", "_multi_messages", ":", "return", "self", ".", "_multi_message_generator", "(", ")", "new_message", "=", "self", ".", "_create_batch_message", "(", ")", "message_size", "=", "new_message", ".", "get_me...
Return all the messages represented by this object. This will convert the batch data into individual Message objects, which may be one or more if multi_messages is set to `True`. :rtype: list[~uamqp.message.Message]
[ "Return", "all", "the", "messages", "represented", "by", "this", "object", ".", "This", "will", "convert", "the", "batch", "data", "into", "individual", "Message", "objects", "which", "may", "be", "one", "or", "more", "if", "multi_messages", "is", "set", "to...
python
train
47.516129
dbtsai/python-mimeparse
mimeparse.py
https://github.com/dbtsai/python-mimeparse/blob/cf605c0994149b1a1936b3a8a597203fe3fbb62e/mimeparse.py#L155-L184
def best_match(supported, header): """Return mime-type with the highest quality ('q') from list of candidates. Takes a list of supported mime-types and finds the best match for all the media-ranges listed in header. The value of header must be a string that conforms to the format of the HTTP Accept: he...
[ "def", "best_match", "(", "supported", ",", "header", ")", ":", "split_header", "=", "_filter_blank", "(", "header", ".", "split", "(", "','", ")", ")", "parsed_header", "=", "[", "parse_media_range", "(", "r", ")", "for", "r", "in", "split_header", "]", ...
Return mime-type with the highest quality ('q') from list of candidates. Takes a list of supported mime-types and finds the best match for all the media-ranges listed in header. The value of header must be a string that conforms to the format of the HTTP Accept: header. The value of 'supported' is a li...
[ "Return", "mime", "-", "type", "with", "the", "highest", "quality", "(", "q", ")", "from", "list", "of", "candidates", "." ]
python
train
36.3
unbservices/clams
clams/__init__.py
https://github.com/unbservices/clams/blob/2ae0a36eb8f82a153d27f74ef37688f976952789/clams/__init__.py#L360-L363
def _attach_arguments(self): """Add the registered arguments to the parser.""" for arg in self.arguments: self.parser.add_argument(*arg[0], **arg[1])
[ "def", "_attach_arguments", "(", "self", ")", ":", "for", "arg", "in", "self", ".", "arguments", ":", "self", ".", "parser", ".", "add_argument", "(", "*", "arg", "[", "0", "]", ",", "*", "*", "arg", "[", "1", "]", ")" ]
Add the registered arguments to the parser.
[ "Add", "the", "registered", "arguments", "to", "the", "parser", "." ]
python
train
43.5
angr/angr
angr/analyses/reassembler.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/reassembler.py#L1223-L1236
def desymbolize(self): """ We believe this was a pointer and symbolized it before. Now we want to desymbolize it. The following actions are performed: - Reload content from memory - Mark the sort as 'unknown' :return: None """ self.sort = 'unknown' ...
[ "def", "desymbolize", "(", "self", ")", ":", "self", ".", "sort", "=", "'unknown'", "content", "=", "self", ".", "binary", ".", "fast_memory_load", "(", "self", ".", "addr", ",", "self", ".", "size", ",", "bytes", ")", "self", ".", "content", "=", "[...
We believe this was a pointer and symbolized it before. Now we want to desymbolize it. The following actions are performed: - Reload content from memory - Mark the sort as 'unknown' :return: None
[ "We", "believe", "this", "was", "a", "pointer", "and", "symbolized", "it", "before", ".", "Now", "we", "want", "to", "desymbolize", "it", "." ]
python
train
29.5
pkgw/pwkit
pwkit/fk10.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L808-L835
def find_rt_coefficients_tot_intens(self, depth0=None): """Figure out total-intensity emission and absorption coefficients for the current parameters. **Argument** *depth0* (default None) A first guess to use for a good integration depth, in cm. If None, the most re...
[ "def", "find_rt_coefficients_tot_intens", "(", "self", ",", "depth0", "=", "None", ")", ":", "j_O", ",", "alpha_O", ",", "j_X", ",", "alpha_X", "=", "self", ".", "find_rt_coefficients", "(", "depth0", "=", "depth0", ")", "j_I", "=", "j_O", "+", "j_X", "a...
Figure out total-intensity emission and absorption coefficients for the current parameters. **Argument** *depth0* (default None) A first guess to use for a good integration depth, in cm. If None, the most recent value is used. **Return value** A tuple ``(j...
[ "Figure", "out", "total", "-", "intensity", "emission", "and", "absorption", "coefficients", "for", "the", "current", "parameters", "." ]
python
train
34.928571
GNS3/gns3-server
gns3server/controller/project.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L730-L833
def open(self): """ Load topology elements """ if self._status == "opened": return self.reset() self._loading = True self._status = "opened" path = self._topology_file() if not os.path.exists(path): self._loading = False ...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "_status", "==", "\"opened\"", ":", "return", "self", ".", "reset", "(", ")", "self", ".", "_loading", "=", "True", "self", ".", "_status", "=", "\"opened\"", "path", "=", "self", ".", "_topolo...
Load topology elements
[ "Load", "topology", "elements" ]
python
train
41.740385
OCHA-DAP/hdx-python-utilities
src/hdx/utilities/loader.py
https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/loader.py#L113-L129
def load_file_to_str(path): # type: (str) -> str """ Load file into a string removing newlines Args: path (str): Path to file Returns: str: String contents of file """ with open(path, 'rt') as f: string = f.read().replace(linesep, '') if not string: rai...
[ "def", "load_file_to_str", "(", "path", ")", ":", "# type: (str) -> str", "with", "open", "(", "path", ",", "'rt'", ")", "as", "f", ":", "string", "=", "f", ".", "read", "(", ")", ".", "replace", "(", "linesep", ",", "''", ")", "if", "not", "string",...
Load file into a string removing newlines Args: path (str): Path to file Returns: str: String contents of file
[ "Load", "file", "into", "a", "string", "removing", "newlines" ]
python
train
21.294118
7sDream/zhihu-py3
zhihu/answer.py
https://github.com/7sDream/zhihu-py3/blob/bcb4aa8325f8b54d3b44bd0bdc959edd9761fcfc/zhihu/answer.py#L362-L374
def refresh(self): """刷新 Answer object 的属性. 例如赞同数增加了, 先调用 ``refresh()`` 再访问 upvote_num属性, 可获得更新后的赞同数. :return: None """ super().refresh() self._html = None self._upvote_num = None self._content = None self._collect_num = None ...
[ "def", "refresh", "(", "self", ")", ":", "super", "(", ")", ".", "refresh", "(", ")", "self", ".", "_html", "=", "None", "self", ".", "_upvote_num", "=", "None", "self", ".", "_content", "=", "None", "self", ".", "_collect_num", "=", "None", "self", ...
刷新 Answer object 的属性. 例如赞同数增加了, 先调用 ``refresh()`` 再访问 upvote_num属性, 可获得更新后的赞同数. :return: None
[ "刷新", "Answer", "object", "的属性", ".", "例如赞同数增加了", "先调用", "refresh", "()", "再访问", "upvote_num属性", "可获得更新后的赞同数", ".", ":", "return", ":", "None" ]
python
train
25.923077
pyviz/holoviews
holoviews/core/options.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/options.py#L1252-L1266
def transfer_options(cls, obj, new_obj, backend=None): """ Transfers options for all backends from one object to another. Drops any options defined in the supplied drop list. """ backend = cls.current_backend if backend is None else backend type_name = type(new_obj).__nam...
[ "def", "transfer_options", "(", "cls", ",", "obj", ",", "new_obj", ",", "backend", "=", "None", ")", ":", "backend", "=", "cls", ".", "current_backend", "if", "backend", "is", "None", "else", "backend", "type_name", "=", "type", "(", "new_obj", ")", ".",...
Transfers options for all backends from one object to another. Drops any options defined in the supplied drop list.
[ "Transfers", "options", "for", "all", "backends", "from", "one", "object", "to", "another", ".", "Drops", "any", "options", "defined", "in", "the", "supplied", "drop", "list", "." ]
python
train
50.533333
debrouwere/google-analytics
googleanalytics/commands/query.py
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/commands/query.py#L102-L130
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
[ "def", "query", "(", "scope", ",", "blueprint", ",", "debug", ",", "output", ",", "with_metadata", ",", "realtime", ",", "*", "*", "description", ")", ":", "if", "realtime", ":", "description", "[", "'type'", "]", "=", "'realtime'", "if", "blueprint", ":...
e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensions pagepath \ --debug
[ "e", ".", "g", "." ]
python
train
29
google/grumpy
third_party/stdlib/getopt.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/getopt.py#L51-L92
def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the ...
[ "def", "getopt", "(", "args", ",", "shortopts", ",", "longopts", "=", "[", "]", ")", ":", "opts", "=", "[", "]", "if", "type", "(", "longopts", ")", "==", "type", "(", "\"\"", ")", ":", "longopts", "=", "[", "longopts", "]", "else", ":", "longopt...
getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to ...
[ "getopt", "(", "args", "options", "[", "long_options", "]", ")", "-", ">", "opts", "args" ]
python
valid
43.809524
saltstack/salt
salt/modules/system.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L337-L405
def set_system_date_time(years=None, months=None, days=None, hours=None, minutes=None, seconds=None, utc_offset=None): ''' Set the system date and time. Each argu...
[ "def", "set_system_date_time", "(", "years", "=", "None", ",", "months", "=", "None", ",", "days", "=", "None", ",", "hours", "=", "None", ",", "minutes", "=", "None", ",", "seconds", "=", "None", ",", "utc_offset", "=", "None", ")", ":", "# Get the cu...
Set the system date and time. Each argument is an element of the date, but not required. If an element is not passed, the current system value for that element will be used. For example, if you don't pass the year, the current system year will be used. (Used by set_system_date and set_system_time) ...
[ "Set", "the", "system", "date", "and", "time", ".", "Each", "argument", "is", "an", "element", "of", "the", "date", "but", "not", "required", ".", "If", "an", "element", "is", "not", "passed", "the", "current", "system", "value", "for", "that", "element"...
python
train
34.681159
ic-labs/django-icekit
icekit/abstract_models.py
https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit/abstract_models.py#L32-L37
def save(self, *args, **kwargs): """ Update ``self.modified``. """ self.modified = timezone.now() super(AbstractBaseModel, self).save(*args, **kwargs)
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "modified", "=", "timezone", ".", "now", "(", ")", "super", "(", "AbstractBaseModel", ",", "self", ")", ".", "save", "(", "*", "args", ",", "*", "*", ...
Update ``self.modified``.
[ "Update", "self", ".", "modified", "." ]
python
train
30.833333
wandb/client
wandb/vendor/prompt_toolkit/layout/containers.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/layout/containers.py#L1414-L1506
def _scroll_when_linewrapping(self, ui_content, width, height, cli): """ Scroll to make sure the cursor position is visible and that we maintain the requested scroll offset. Set `self.horizontal_scroll/vertical_scroll`. """ scroll_offsets_bottom = self.scroll_offsets.bot...
[ "def", "_scroll_when_linewrapping", "(", "self", ",", "ui_content", ",", "width", ",", "height", ",", "cli", ")", ":", "scroll_offsets_bottom", "=", "self", ".", "scroll_offsets", ".", "bottom", "scroll_offsets_top", "=", "self", ".", "scroll_offsets", ".", "top...
Scroll to make sure the cursor position is visible and that we maintain the requested scroll offset. Set `self.horizontal_scroll/vertical_scroll`.
[ "Scroll", "to", "make", "sure", "the", "cursor", "position", "is", "visible", "and", "that", "we", "maintain", "the", "requested", "scroll", "offset", "." ]
python
train
45.709677
hoh/Hereby
hereby.py
https://github.com/hoh/Hereby/blob/a5f8bcdcb667e1fe1e64f542162e15ec31741505/hereby.py#L38-L40
def abspath(self, path): """Return absolute path for a path relative to the current file.""" return os.path.abspath(os.path.join(os.path.dirname(self.path), path))
[ "def", "abspath", "(", "self", ",", "path", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "path", ")", ",", "path", ")", ")" ]
Return absolute path for a path relative to the current file.
[ "Return", "absolute", "path", "for", "a", "path", "relative", "to", "the", "current", "file", "." ]
python
train
59
fermiPy/fermipy
fermipy/gtanalysis.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2569-L2717
def profile(self, name, parName, logemin=None, logemax=None, reoptimize=False, xvals=None, npts=None, savestate=True, **kwargs): """Profile the likelihood for the given source and parameter. Parameters ---------- name : str Source name. ...
[ "def", "profile", "(", "self", ",", "name", ",", "parName", ",", "logemin", "=", "None", ",", "logemax", "=", "None", ",", "reoptimize", "=", "False", ",", "xvals", "=", "None", ",", "npts", "=", "None", ",", "savestate", "=", "True", ",", "*", "*"...
Profile the likelihood for the given source and parameter. Parameters ---------- name : str Source name. parName : str Parameter name. reoptimize : bool Re-fit nuisance parameters at each step in the scan. Note that enabling this o...
[ "Profile", "the", "likelihood", "for", "the", "given", "source", "and", "parameter", "." ]
python
train
34.369128
tanghaibao/goatools
goatools/go_enrichment.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_enrichment.py#L307-L319
def get_results_msg(self, results, study): """Return summary for GOEA results.""" # To convert msg list to string: "\n".join(msg) msg = [] if results: fmt = "{M:6,} GO terms are associated with {N:6,} of {NT:6,}" stu_items, num_gos_stu = self.get_item_cnt(results,...
[ "def", "get_results_msg", "(", "self", ",", "results", ",", "study", ")", ":", "# To convert msg list to string: \"\\n\".join(msg)", "msg", "=", "[", "]", "if", "results", ":", "fmt", "=", "\"{M:6,} GO terms are associated with {N:6,} of {NT:6,}\"", "stu_items", ",", "n...
Return summary for GOEA results.
[ "Return", "summary", "for", "GOEA", "results", "." ]
python
train
55.307692
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1273-L1342
def reindex_similar(self, other, n_sphere=4): """Reindex ``other`` to be similarly indexed as ``self``. Returns a reindexed copy of ``other`` that minimizes the distance for each atom to itself in the same chemical environemt from ``self`` to ``other``. Read more about the defin...
[ "def", "reindex_similar", "(", "self", ",", "other", ",", "n_sphere", "=", "4", ")", ":", "def", "make_subset_similar", "(", "m1", ",", "subset1", ",", "m2", ",", "subset2", ",", "index_dct", ")", ":", "\"\"\"Changes index_dct INPLACE\"\"\"", "coords", "=", ...
Reindex ``other`` to be similarly indexed as ``self``. Returns a reindexed copy of ``other`` that minimizes the distance for each atom to itself in the same chemical environemt from ``self`` to ``other``. Read more about the definition of the chemical environment in :func:`Carte...
[ "Reindex", "other", "to", "be", "similarly", "indexed", "as", "self", "." ]
python
train
43
dcos/shakedown
shakedown/dcos/file.py
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L69-L78
def copy_file_to_master( file_path, remote_path='.', username=None, key_path=None ): """ Copy a file to the Mesos master """ return copy_file(shakedown.master_ip(), file_path, remote_path, username, key_path)
[ "def", "copy_file_to_master", "(", "file_path", ",", "remote_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ")", ":", "return", "copy_file", "(", "shakedown", ".", "master_ip", "(", ")", ",", "file_path", ",", "remote_path", ...
Copy a file to the Mesos master
[ "Copy", "a", "file", "to", "the", "Mesos", "master" ]
python
train
24.4
thriftrw/thriftrw-python
thriftrw/compile/compiler.py
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/compiler.py#L164-L278
def compile(self, name, contents, path=None): """Compile the given Thrift document into a Python module. The generated module contains, .. py:attribute:: __services__ A collection of generated classes for all services defined in the thrift file. .. version...
[ "def", "compile", "(", "self", ",", "name", ",", "contents", ",", "path", "=", "None", ")", ":", "assert", "name", "if", "path", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "path", "in", "self", ".", "_module_specs"...
Compile the given Thrift document into a Python module. The generated module contains, .. py:attribute:: __services__ A collection of generated classes for all services defined in the thrift file. .. versionchanged:: 1.0 Renamed from ``services`` ...
[ "Compile", "the", "given", "Thrift", "document", "into", "a", "Python", "module", "." ]
python
train
30.521739
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/jar.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/jar.py#L92-L197
def Jar(env, target = None, source = [], *args, **kw): """ A pseudo-Builder wrapper around the separate Jar sources{File,Dir} Builders. """ # jar target should not be a list so assume they passed # no target and want implicit target to be made and the arg # was actaully the list of sources ...
[ "def", "Jar", "(", "env", ",", "target", "=", "None", ",", "source", "=", "[", "]", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "# jar target should not be a list so assume they passed", "# no target and want implicit target to be made and the arg", "# was actaul...
A pseudo-Builder wrapper around the separate Jar sources{File,Dir} Builders.
[ "A", "pseudo", "-", "Builder", "wrapper", "around", "the", "separate", "Jar", "sources", "{", "File", "Dir", "}", "Builders", "." ]
python
train
46.40566
ishepard/pydriller
pydriller/git_repository.py
https://github.com/ishepard/pydriller/blob/71facb32afa085d5ddf0081beba34d00d57b8080/pydriller/git_repository.py#L102-L109
def get_commit(self, commit_id: str) -> Commit: """ Get the specified commit. :param str commit_id: hash of the commit to analyze :return: Commit """ return Commit(self.repo.commit(commit_id), self.path, self.main_branch)
[ "def", "get_commit", "(", "self", ",", "commit_id", ":", "str", ")", "->", "Commit", ":", "return", "Commit", "(", "self", ".", "repo", ".", "commit", "(", "commit_id", ")", ",", "self", ".", "path", ",", "self", ".", "main_branch", ")" ]
Get the specified commit. :param str commit_id: hash of the commit to analyze :return: Commit
[ "Get", "the", "specified", "commit", "." ]
python
train
32.875
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L145-L191
def dump(node): """ Dump initialized object structure to yaml """ from qubell.api.private.platform import Auth, QubellPlatform from qubell.api.private.organization import Organization from qubell.api.private.application import Application from qubell.api.private.instance import Instance fro...
[ "def", "dump", "(", "node", ")", ":", "from", "qubell", ".", "api", ".", "private", ".", "platform", "import", "Auth", ",", "QubellPlatform", "from", "qubell", ".", "api", ".", "private", ".", "organization", "import", "Organization", "from", "qubell", "."...
Dump initialized object structure to yaml
[ "Dump", "initialized", "object", "structure", "to", "yaml" ]
python
train
41.744681
AmesCornish/buttersink
buttersink/ioctl.py
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/ioctl.py#L259-L263
def read(self, structure): """ Read and advance. """ start = self.offset self.skip(structure.size) return structure.read(self.buf, start)
[ "def", "read", "(", "self", ",", "structure", ")", ":", "start", "=", "self", ".", "offset", "self", ".", "skip", "(", "structure", ".", "size", ")", "return", "structure", ".", "read", "(", "self", ".", "buf", ",", "start", ")" ]
Read and advance.
[ "Read", "and", "advance", "." ]
python
train
33
vladcalin/gemstone
gemstone/core/microservice.py
https://github.com/vladcalin/gemstone/blob/325a49d17621b9d45ffd2b5eca6f0de284de8ba4/gemstone/core/microservice.py#L385-L393
def _add_extra_handlers(self, handlers): """ Adds the extra handler (defined by the user) :param handlers: a list of :py:class:`tornado.web.RequestHandler` instances. :return: """ extra_handlers = [(h[0], h[1], {"microservice": self}) for h in self.extra_handlers] ...
[ "def", "_add_extra_handlers", "(", "self", ",", "handlers", ")", ":", "extra_handlers", "=", "[", "(", "h", "[", "0", "]", ",", "h", "[", "1", "]", ",", "{", "\"microservice\"", ":", "self", "}", ")", "for", "h", "in", "self", ".", "extra_handlers", ...
Adds the extra handler (defined by the user) :param handlers: a list of :py:class:`tornado.web.RequestHandler` instances. :return:
[ "Adds", "the", "extra", "handler", "(", "defined", "by", "the", "user", ")" ]
python
train
38.333333
rodluger/everest
everest/basecamp.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L52-L55
def unmasked(self, depth=0.01): """Return the unmasked overfitting metric for a given transit depth.""" return 1 - (np.hstack(self._O2) + np.hstack(self._O3) / depth) / np.hstack(self._O1)
[ "def", "unmasked", "(", "self", ",", "depth", "=", "0.01", ")", ":", "return", "1", "-", "(", "np", ".", "hstack", "(", "self", ".", "_O2", ")", "+", "np", ".", "hstack", "(", "self", ".", "_O3", ")", "/", "depth", ")", "/", "np", ".", "hstac...
Return the unmasked overfitting metric for a given transit depth.
[ "Return", "the", "unmasked", "overfitting", "metric", "for", "a", "given", "transit", "depth", "." ]
python
train
55.25
klahnakoski/mo-logs
mo_logs/startup.py
https://github.com/klahnakoski/mo-logs/blob/0971277ac9caf28a755b766b70621916957d4fea/mo_logs/startup.py#L60-L87
def read_settings(filename=None, defs=None): """ :param filename: Force load a file :param defs: arguments you want to accept :param default_filename: A config file from an environment variable (a fallback config file, if no other provided) :return: """ # READ SETTINGS defs = listwrap(de...
[ "def", "read_settings", "(", "filename", "=", "None", ",", "defs", "=", "None", ")", ":", "# READ SETTINGS", "defs", "=", "listwrap", "(", "defs", ")", "defs", ".", "append", "(", "{", "\"name\"", ":", "[", "\"--config\"", ",", "\"--settings\"", ",", "\"...
:param filename: Force load a file :param defs: arguments you want to accept :param default_filename: A config file from an environment variable (a fallback config file, if no other provided) :return:
[ ":", "param", "filename", ":", "Force", "load", "a", "file", ":", "param", "defs", ":", "arguments", "you", "want", "to", "accept", ":", "param", "default_filename", ":", "A", "config", "file", "from", "an", "environment", "variable", "(", "a", "fallback",...
python
train
33.892857
gwastro/pycbc
pycbc/inference/io/base_mcmc.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/io/base_mcmc.py#L148-L181
def write_acls(self, acls): """Writes the given autocorrelation lengths. The ACL of each parameter is saved to ``[sampler_group]/acls/{param}']``. The maximum over all the parameters is saved to the file's 'acl' attribute. Parameters ---------- acls : dict ...
[ "def", "write_acls", "(", "self", ",", "acls", ")", ":", "group", "=", "self", ".", "sampler_group", "+", "'/acls/{}'", "# write the individual acls", "for", "param", "in", "acls", ":", "try", ":", "# we need to use the write_direct function because it's", "# apparent...
Writes the given autocorrelation lengths. The ACL of each parameter is saved to ``[sampler_group]/acls/{param}']``. The maximum over all the parameters is saved to the file's 'acl' attribute. Parameters ---------- acls : dict A dictionary of ACLs keyed by t...
[ "Writes", "the", "given", "autocorrelation", "lengths", "." ]
python
train
37.117647
Yelp/kafka-utils
kafka_utils/kafka_cluster_manager/cluster_info/cluster_topology.py
https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_cluster_manager/cluster_info/cluster_topology.py#L178-L233
def update_cluster_topology(self, assignment): """Modify the cluster-topology with given assignment. Change the replica set of partitions as in given assignment. :param assignment: dict representing actions to be used to update the current cluster-topology :raises: InvalidBroke...
[ "def", "update_cluster_topology", "(", "self", ",", "assignment", ")", ":", "try", ":", "for", "partition_name", ",", "replica_ids", "in", "six", ".", "iteritems", "(", "assignment", ")", ":", "try", ":", "new_replicas", "=", "[", "self", ".", "brokers", "...
Modify the cluster-topology with given assignment. Change the replica set of partitions as in given assignment. :param assignment: dict representing actions to be used to update the current cluster-topology :raises: InvalidBrokerIdError when broker-id is invalid :raises: Invali...
[ "Modify", "the", "cluster", "-", "topology", "with", "given", "assignment", "." ]
python
train
43.732143