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
liftoff/pyminifier
pyminifier/minification.py
https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/minification.py#L97-L161
def remove_comments_and_docstrings(source): """ Returns *source* minus comments and docstrings. .. note:: Uses Python's built-in tokenize module to great effect. Example:: def noop(): # This is a comment ''' Does nothing. ''' pass # Don't do any...
[ "def", "remove_comments_and_docstrings", "(", "source", ")", ":", "io_obj", "=", "io", ".", "StringIO", "(", "source", ")", "out", "=", "\"\"", "prev_toktype", "=", "tokenize", ".", "INDENT", "last_lineno", "=", "-", "1", "last_col", "=", "0", "for", "tok"...
Returns *source* minus comments and docstrings. .. note:: Uses Python's built-in tokenize module to great effect. Example:: def noop(): # This is a comment ''' Does nothing. ''' pass # Don't do anything Will become:: def noop(): ...
[ "Returns", "*", "source", "*", "minus", "comments", "and", "docstrings", "." ]
python
train
37.2
Cornices/cornice.ext.swagger
cornice_swagger/swagger.py
https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L168-L186
def _ref(self, param, base_name=None): """ Store a parameter schema and return a reference to it. :param schema: Swagger parameter definition. :param base_name: Name that should be used for the reference. :rtype: dict :returns: JSON pointer to th...
[ "def", "_ref", "(", "self", ",", "param", ",", "base_name", "=", "None", ")", ":", "name", "=", "base_name", "or", "param", ".", "get", "(", "'title'", ",", "''", ")", "or", "param", ".", "get", "(", "'name'", ",", "''", ")", "pointer", "=", "sel...
Store a parameter schema and return a reference to it. :param schema: Swagger parameter definition. :param base_name: Name that should be used for the reference. :rtype: dict :returns: JSON pointer to the original parameter definition.
[ "Store", "a", "parameter", "schema", "and", "return", "a", "reference", "to", "it", "." ]
python
valid
28.789474
tonyo/pyope
pyope/util.py
https://github.com/tonyo/pyope/blob/1e9f9f15cd4b989d1bf3c607270bf6a8ae808b1e/pyope/util.py#L3-L7
def byte_to_bitstring(byte): """Convert one byte to a list of bits""" assert 0 <= byte <= 0xff bits = [int(x) for x in list(bin(byte + 0x100)[3:])] return bits
[ "def", "byte_to_bitstring", "(", "byte", ")", ":", "assert", "0", "<=", "byte", "<=", "0xff", "bits", "=", "[", "int", "(", "x", ")", "for", "x", "in", "list", "(", "bin", "(", "byte", "+", "0x100", ")", "[", "3", ":", "]", ")", "]", "return", ...
Convert one byte to a list of bits
[ "Convert", "one", "byte", "to", "a", "list", "of", "bits" ]
python
train
34.2
ejeschke/ginga
ginga/rv/plugins/Catalogs.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Catalogs.py#L1308-L1320
def select_star_cb(self, widget, res_dict): """This method is called when the user selects a star from the table. """ keys = list(res_dict.keys()) if len(keys) == 0: self.selected = [] self.replot_stars() else: idx = int(keys[0]) st...
[ "def", "select_star_cb", "(", "self", ",", "widget", ",", "res_dict", ")", ":", "keys", "=", "list", "(", "res_dict", ".", "keys", "(", ")", ")", "if", "len", "(", "keys", ")", "==", "0", ":", "self", ".", "selected", "=", "[", "]", "self", ".", ...
This method is called when the user selects a star from the table.
[ "This", "method", "is", "called", "when", "the", "user", "selects", "a", "star", "from", "the", "table", "." ]
python
train
34.384615
tcalmant/ipopo
pelix/ipopo/core.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/core.py#L1148-L1167
def get_factory_bundle(self, name): # type: (str) -> Bundle """ Retrieves the Pelix Bundle object that registered the given factory :param name: The name of a factory :return: The Bundle that registered the given factory :raise ValueError: Invalid factory """ ...
[ "def", "get_factory_bundle", "(", "self", ",", "name", ")", ":", "# type: (str) -> Bundle", "with", "self", ".", "__factories_lock", ":", "try", ":", "factory", "=", "self", ".", "__factories", "[", "name", "]", "except", "KeyError", ":", "raise", "ValueError"...
Retrieves the Pelix Bundle object that registered the given factory :param name: The name of a factory :return: The Bundle that registered the given factory :raise ValueError: Invalid factory
[ "Retrieves", "the", "Pelix", "Bundle", "object", "that", "registered", "the", "given", "factory" ]
python
train
38.6
bcbio/bcbio-nextgen
bcbio/variation/cortex.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/cortex.py#L97-L120
def _combine_variants(in_vcfs, out_file, ref_file, config): """Combine variant files, writing the header from the first non-empty input. in_vcfs is a list with each item starting with the chromosome regions, and ending with the input file. We sort by these regions to ensure the output file is in the ex...
[ "def", "_combine_variants", "(", "in_vcfs", ",", "out_file", ",", "ref_file", ",", "config", ")", ":", "in_vcfs", ".", "sort", "(", ")", "wrote_header", "=", "False", "with", "open", "(", "out_file", ",", "\"w\"", ")", "as", "out_handle", ":", "for", "in...
Combine variant files, writing the header from the first non-empty input. in_vcfs is a list with each item starting with the chromosome regions, and ending with the input file. We sort by these regions to ensure the output file is in the expected order.
[ "Combine", "variant", "files", "writing", "the", "header", "from", "the", "first", "non", "-", "empty", "input", "." ]
python
train
45.791667
Genida/dependenpy
src/dependenpy/node.py
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/node.py#L251-L260
def print_treemap(self, format=None, output=sys.stdout, **kwargs): """ Print the matrix for self's nodes. Args: format (str): output format (csv, json or text). output (file): file descriptor on which to write. """ treemap = self.as_treemap() tree...
[ "def", "print_treemap", "(", "self", ",", "format", "=", "None", ",", "output", "=", "sys", ".", "stdout", ",", "*", "*", "kwargs", ")", ":", "treemap", "=", "self", ".", "as_treemap", "(", ")", "treemap", ".", "print", "(", "format", "=", "format", ...
Print the matrix for self's nodes. Args: format (str): output format (csv, json or text). output (file): file descriptor on which to write.
[ "Print", "the", "matrix", "for", "self", "s", "nodes", "." ]
python
train
36
maljovec/topopy
topopy/ContourTree.py
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/ContourTree.py#L91-L142
def build(self, X, Y, w=None, edges=None): """ Assigns data to this object and builds the Morse-Smale Complex @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses correspond...
[ "def", "build", "(", "self", ",", "X", ",", "Y", ",", "w", "=", "None", ",", "edges", "=", "None", ")", ":", "super", "(", "ContourTree", ",", "self", ")", ".", "build", "(", "X", ",", "Y", ",", "w", ",", "edges", ")", "# Build the join and split...
Assigns data to this object and builds the Morse-Smale Complex @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses corresponding to the m samples specified by X @ In, w...
[ "Assigns", "data", "to", "this", "object", "and", "builds", "the", "Morse", "-", "Smale", "Complex" ]
python
train
38.923077
saltstack/salt
salt/states/iptables.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/iptables.py#L735-L800
def set_policy(name, table='filter', family='ipv4', **kwargs): ''' .. versionadded:: 2014.1.0 Sets the default policy for iptables firewall tables table The table that owns the chain that should be modified family Networking family, either ipv4 or ipv6 policy The requ...
[ "def", "set_policy", "(", "name", ",", "table", "=", "'filter'", ",", "family", "=", "'ipv4'", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "None", ",", "'comment'...
.. versionadded:: 2014.1.0 Sets the default policy for iptables firewall tables table The table that owns the chain that should be modified family Networking family, either ipv4 or ipv6 policy The requested table policy
[ "..", "versionadded", "::", "2014", ".", "1", ".", "0" ]
python
train
30.212121
JukeboxPipeline/jukebox-core
src/jukeboxcore/reftrack.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L1401-L1435
def get_children_to_delete(self): """Return all children that are not referenced :returns: list or :class:`Reftrack` :rtype: list :raises: None """ refobjinter = self.get_refobjinter() children = self.get_all_children() todelete = [] for c in chi...
[ "def", "get_children_to_delete", "(", "self", ")", ":", "refobjinter", "=", "self", ".", "get_refobjinter", "(", ")", "children", "=", "self", ".", "get_all_children", "(", ")", "todelete", "=", "[", "]", "for", "c", "in", "children", ":", "if", "c", "."...
Return all children that are not referenced :returns: list or :class:`Reftrack` :rtype: list :raises: None
[ "Return", "all", "children", "that", "are", "not", "referenced" ]
python
train
41.085714
ungarj/mapchete
mapchete/formats/base.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/base.py#L256-L274
def get_path(self, tile): """ Determine target file path. Parameters ---------- tile : ``BufferedTile`` must be member of output ``TilePyramid`` Returns ------- path : string """ return os.path.join(*[ self.path, ...
[ "def", "get_path", "(", "self", ",", "tile", ")", ":", "return", "os", ".", "path", ".", "join", "(", "*", "[", "self", ".", "path", ",", "str", "(", "tile", ".", "zoom", ")", ",", "str", "(", "tile", ".", "row", ")", ",", "str", "(", "tile",...
Determine target file path. Parameters ---------- tile : ``BufferedTile`` must be member of output ``TilePyramid`` Returns ------- path : string
[ "Determine", "target", "file", "path", "." ]
python
valid
21.789474
ModisWorks/modis
modis/discord_modis/modules/tableflip/api_flipcheck.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/tableflip/api_flipcheck.py#L1-L59
def flipcheck(content): """Checks a string for anger and soothes said anger Args: content (str): The message to be flipchecked Returns: putitback (str): The righted table or text """ # Prevent tampering with flip punct = """!"#$%&'*+,-./:;<=>?@[\]^_`{|}~ ━─""" tamperdict =...
[ "def", "flipcheck", "(", "content", ")", ":", "# Prevent tampering with flip", "punct", "=", "\"\"\"!\"#$%&'*+,-./:;<=>?@[\\]^_`{|}~ ━─\"\"\"", "tamperdict", "=", "str", ".", "maketrans", "(", "''", ",", "''", ",", "punct", ")", "tamperproof", "=", "content", ".", ...
Checks a string for anger and soothes said anger Args: content (str): The message to be flipchecked Returns: putitback (str): The righted table or text
[ "Checks", "a", "string", "for", "anger", "and", "soothes", "said", "anger" ]
python
train
27.254237
roboogle/gtkmvc3
gtkmvco/examples/treeview/sorting.py
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/examples/treeview/sorting.py#L87-L104
def setup_sort_column(widget, column=0, attribute=None, model=None): """ *model* is the :class:`TreeModelSort` to act on. Defaults to what is displayed. Pass this if you sort before filtering. *widget* is a clickable :class:`TreeViewColumn`. *column* is an integer addressing the column in *model* ...
[ "def", "setup_sort_column", "(", "widget", ",", "column", "=", "0", ",", "attribute", "=", "None", ",", "model", "=", "None", ")", ":", "if", "not", "attribute", ":", "attribute", "=", "widget", ".", "get_name", "(", ")", "if", "attribute", "is", "None...
*model* is the :class:`TreeModelSort` to act on. Defaults to what is displayed. Pass this if you sort before filtering. *widget* is a clickable :class:`TreeViewColumn`. *column* is an integer addressing the column in *model* that holds your objects. *attribute* is a string naming an object attrib...
[ "*", "model", "*", "is", "the", ":", "class", ":", "TreeModelSort", "to", "act", "on", ".", "Defaults", "to", "what", "is", "displayed", ".", "Pass", "this", "if", "you", "sort", "before", "filtering", "." ]
python
train
36.055556
scikit-hep/root_numpy
root_numpy/_hist.py
https://github.com/scikit-hep/root_numpy/blob/3a9bfbcf89f90dc20ca6869480a63a85e1ceebb8/root_numpy/_hist.py#L132-L260
def hist2array(hist, include_overflow=False, copy=True, return_edges=False): """Convert a ROOT histogram into a NumPy array Parameters ---------- hist : ROOT TH1, TH2, TH3, THn, or THnSparse The ROOT histogram to convert into an array include_overflow : bool, optional (default=False) ...
[ "def", "hist2array", "(", "hist", ",", "include_overflow", "=", "False", ",", "copy", "=", "True", ",", "return_edges", "=", "False", ")", ":", "import", "ROOT", "# Determine dimensionality and shape", "simple_hist", "=", "True", "if", "isinstance", "(", "hist",...
Convert a ROOT histogram into a NumPy array Parameters ---------- hist : ROOT TH1, TH2, TH3, THn, or THnSparse The ROOT histogram to convert into an array include_overflow : bool, optional (default=False) If True, the over- and underflow bins will be included in the output numpy...
[ "Convert", "a", "ROOT", "histogram", "into", "a", "NumPy", "array" ]
python
train
36.527132
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/spv.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L490-L508
def load_header_chain( cls, chain_path ): """ Load the header chain from disk. Each chain element will be a dictionary with: * """ header_parser = BlockHeaderSerializer() chain = [] height = 0 with open(chain_path, "rb") as f: h = SP...
[ "def", "load_header_chain", "(", "cls", ",", "chain_path", ")", ":", "header_parser", "=", "BlockHeaderSerializer", "(", ")", "chain", "=", "[", "]", "height", "=", "0", "with", "open", "(", "chain_path", ",", "\"rb\"", ")", "as", "f", ":", "h", "=", "...
Load the header chain from disk. Each chain element will be a dictionary with: *
[ "Load", "the", "header", "chain", "from", "disk", ".", "Each", "chain", "element", "will", "be", "a", "dictionary", "with", ":", "*" ]
python
train
23.368421
Azure/azure-cli-extensions
src/aks-preview/azext_aks_preview/_validators.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/aks-preview/azext_aks_preview/_validators.py#L71-L83
def validate_linux_host_name(namespace): """Validates a string as a legal host name component. This validation will also occur server-side in the ARM API, but that may take a minute or two before the user sees it. So it's more user-friendly to validate in the CLI pre-flight. """ # https://stack...
[ "def", "validate_linux_host_name", "(", "namespace", ")", ":", "# https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address", "rfc1123_regex", "=", "re", ".", "compile", "(", "r'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])(\\.([a-zA-Z0-9...
Validates a string as a legal host name component. This validation will also occur server-side in the ARM API, but that may take a minute or two before the user sees it. So it's more user-friendly to validate in the CLI pre-flight.
[ "Validates", "a", "string", "as", "a", "legal", "host", "name", "component", "." ]
python
train
60.461538
bear/bearlib
bearlib/logs.py
https://github.com/bear/bearlib/blob/30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd/bearlib/logs.py#L19-L60
def Logs(loggername, echo=True, debug=False, chatty=False, loglevel=logging.INFO, logfile=None, logpath=None, fileHandler=None): """Initialize logging """ log = logging.getLogger(loggername) if fileHandler is None: if logfile is None: logFilename = _ourName else: ...
[ "def", "Logs", "(", "loggername", ",", "echo", "=", "True", ",", "debug", "=", "False", ",", "chatty", "=", "False", ",", "loglevel", "=", "logging", ".", "INFO", ",", "logfile", "=", "None", ",", "logpath", "=", "None", ",", "fileHandler", "=", "Non...
Initialize logging
[ "Initialize", "logging" ]
python
train
31.952381
Mego/Seriously
seriously/probably_prime.py
https://github.com/Mego/Seriously/blob/07b256e4f35f5efec3b01434300f9ccc551b1c3e/seriously/probably_prime.py#L4-L17
def find_spelling(n): """ Finds d, r s.t. n-1 = 2^r * d """ r = 0 d = n - 1 # divmod used for large numbers quotient, remainder = divmod(d, 2) # while we can still divide 2's into n-1... while remainder != 1: r += 1 d = quotient # previous quotient before ...
[ "def", "find_spelling", "(", "n", ")", ":", "r", "=", "0", "d", "=", "n", "-", "1", "# divmod used for large numbers\r", "quotient", ",", "remainder", "=", "divmod", "(", "d", ",", "2", ")", "# while we can still divide 2's into n-1...\r", "while", "remainder", ...
Finds d, r s.t. n-1 = 2^r * d
[ "Finds", "d", "r", "s", ".", "t", ".", "n", "-", "1", "=", "2^r", "*", "d" ]
python
train
27.357143
DataBiosphere/toil
src/toil/leader.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/leader.py#L663-L681
def removeJob(self, jobBatchSystemID): """Removes a job from the system.""" assert jobBatchSystemID in self.jobBatchSystemIDToIssuedJob jobNode = self.jobBatchSystemIDToIssuedJob[jobBatchSystemID] if jobNode.preemptable: # len(jobBatchSystemIDToIssuedJob) should always be gre...
[ "def", "removeJob", "(", "self", ",", "jobBatchSystemID", ")", ":", "assert", "jobBatchSystemID", "in", "self", ".", "jobBatchSystemIDToIssuedJob", "jobNode", "=", "self", ".", "jobBatchSystemIDToIssuedJob", "[", "jobBatchSystemID", "]", "if", "jobNode", ".", "preem...
Removes a job from the system.
[ "Removes", "a", "job", "from", "the", "system", "." ]
python
train
48.421053
estnltk/estnltk
estnltk/text.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L585-L589
def analysis(self): """The list of analysis of ``words`` layer elements.""" if not self.is_tagged(ANALYSIS): self.tag_analysis() return [word[ANALYSIS] for word in self.words]
[ "def", "analysis", "(", "self", ")", ":", "if", "not", "self", ".", "is_tagged", "(", "ANALYSIS", ")", ":", "self", ".", "tag_analysis", "(", ")", "return", "[", "word", "[", "ANALYSIS", "]", "for", "word", "in", "self", ".", "words", "]" ]
The list of analysis of ``words`` layer elements.
[ "The", "list", "of", "analysis", "of", "words", "layer", "elements", "." ]
python
train
41.4
fake-name/WebRequest
WebRequest/ChromiumMixin.py
https://github.com/fake-name/WebRequest/blob/b6c94631ff88b5f81f26a9f99a2d5c706810b11f/WebRequest/ChromiumMixin.py#L295-L310
def chromiumContext(self, url, extra_tid=None): ''' Return a active chromium context, useable for manual operations directly against chromium. The WebRequest user agent and other context is synchronized into the chromium instance at startup, and changes are flushed back to the webrequest instance from chro...
[ "def", "chromiumContext", "(", "self", ",", "url", ",", "extra_tid", "=", "None", ")", ":", "assert", "url", "is", "not", "None", ",", "\"You need to pass a URL to the contextmanager, so it can dispatch to the correct tab!\"", "if", "extra_tid", "is", "True", ":", "ex...
Return a active chromium context, useable for manual operations directly against chromium. The WebRequest user agent and other context is synchronized into the chromium instance at startup, and changes are flushed back to the webrequest instance from chromium at completion.
[ "Return", "a", "active", "chromium", "context", "useable", "for", "manual", "operations", "directly", "against", "chromium", "." ]
python
train
35.1875
OSLL/jabba
jabba/analysis/parse.py
https://github.com/OSLL/jabba/blob/71c1d008ab497020fba6ffa12a600721eb3f5ef7/jabba/analysis/parse.py#L8-L31
def parse_analyzer_arguments(arguments): """ Parse string in format `function_1:param1=value:param2 function_2:param` into array of FunctionArguments """ rets = [] for argument in arguments: args = argument.split(argument_splitter) # The first one is the function name func...
[ "def", "parse_analyzer_arguments", "(", "arguments", ")", ":", "rets", "=", "[", "]", "for", "argument", "in", "arguments", ":", "args", "=", "argument", ".", "split", "(", "argument_splitter", ")", "# The first one is the function name", "func_name", "=", "args",...
Parse string in format `function_1:param1=value:param2 function_2:param` into array of FunctionArguments
[ "Parse", "string", "in", "format", "function_1", ":", "param1", "=", "value", ":", "param2", "function_2", ":", "param", "into", "array", "of", "FunctionArguments" ]
python
train
23.791667
PMEAL/OpenPNM
openpnm/core/ModelsMixin.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/core/ModelsMixin.py#L221-L279
def regenerate_models(self, propnames=None, exclude=[], deep=False): r""" Re-runs the specified model or models. Parameters ---------- propnames : string or list of strings The list of property names to be regenerated. If None are given then ALL models a...
[ "def", "regenerate_models", "(", "self", ",", "propnames", "=", "None", ",", "exclude", "=", "[", "]", ",", "deep", "=", "False", ")", ":", "# If empty list of propnames was given, do nothing and return", "if", "type", "(", "propnames", ")", "is", "list", "and",...
r""" Re-runs the specified model or models. Parameters ---------- propnames : string or list of strings The list of property names to be regenerated. If None are given then ALL models are re-run (except for those whose ``regen_mode`` is 'constant'). ...
[ "r", "Re", "-", "runs", "the", "specified", "model", "or", "models", "." ]
python
train
47.610169
kwikteam/phy
phy/cluster/supervisor.py
https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/cluster/supervisor.py#L385-L412
def _update_similarity_view(self): """Update the similarity view with matches for the specified clusters.""" if not self.similarity: return selection = self.cluster_view.selected if not len(selection): return cluster_id = selection[0] clust...
[ "def", "_update_similarity_view", "(", "self", ")", ":", "if", "not", "self", ".", "similarity", ":", "return", "selection", "=", "self", ".", "cluster_view", ".", "selected", "if", "not", "len", "(", "selection", ")", ":", "return", "cluster_id", "=", "se...
Update the similarity view with matches for the specified clusters.
[ "Update", "the", "similarity", "view", "with", "matches", "for", "the", "specified", "clusters", "." ]
python
train
48
spyder-ide/spyder
spyder/plugins/help/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L608-L613
def _update_lock_icon(self): """Update locked state icon""" icon = ima.icon('lock') if self.locked else ima.icon('lock_open') self.locked_button.setIcon(icon) tip = _("Unlock") if self.locked else _("Lock") self.locked_button.setToolTip(tip)
[ "def", "_update_lock_icon", "(", "self", ")", ":", "icon", "=", "ima", ".", "icon", "(", "'lock'", ")", "if", "self", ".", "locked", "else", "ima", ".", "icon", "(", "'lock_open'", ")", "self", ".", "locked_button", ".", "setIcon", "(", "icon", ")", ...
Update locked state icon
[ "Update", "locked", "state", "icon" ]
python
train
46.833333
quantmind/pulsar
pulsar/utils/pylib/events.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L147-L154
def bind_events(self, events): '''Register all known events found in ``events`` key-valued parameters. ''' evs = self._events if evs and events: for event in evs.values(): if event.name in events: event.bind(events[event.name])
[ "def", "bind_events", "(", "self", ",", "events", ")", ":", "evs", "=", "self", ".", "_events", "if", "evs", "and", "events", ":", "for", "event", "in", "evs", ".", "values", "(", ")", ":", "if", "event", ".", "name", "in", "events", ":", "event", ...
Register all known events found in ``events`` key-valued parameters.
[ "Register", "all", "known", "events", "found", "in", "events", "key", "-", "valued", "parameters", "." ]
python
train
37.5
Genida/archan
src/archan/plugins/checkers.py
https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/plugins/checkers.py#L30-L127
def generate_mediation_matrix(dsm): """ Generate the mediation matrix of the given matrix. Rules for mediation matrix generation: Set -1 for items NOT to be considered Set 0 for items which MUST NOT be present Set 1 for items which MUST be present Each module h...
[ "def", "generate_mediation_matrix", "(", "dsm", ")", ":", "cat", "=", "dsm", ".", "categories", "ent", "=", "dsm", ".", "entities", "size", "=", "dsm", ".", "size", "[", "0", "]", "if", "not", "cat", ":", "cat", "=", "[", "'appmodule'", "]", "*", "...
Generate the mediation matrix of the given matrix. Rules for mediation matrix generation: Set -1 for items NOT to be considered Set 0 for items which MUST NOT be present Set 1 for items which MUST be present Each module has optional dependencies to itself. - Framework...
[ "Generate", "the", "mediation", "matrix", "of", "the", "given", "matrix", "." ]
python
train
42.387755
saltstack/salt
salt/modules/win_dism.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_dism.py#L101-L139
def remove_capability(capability, image=None, restart=False): ''' Uninstall a capability Args: capability(str): The capability to be removed image (Optional[str]): The path to the root directory of an offline Windows image. If `None` is passed, the running operating system is ...
[ "def", "remove_capability", "(", "capability", ",", "image", "=", "None", ",", "restart", "=", "False", ")", ":", "if", "salt", ".", "utils", ".", "versions", ".", "version_cmp", "(", "__grains__", "[", "'osversion'", "]", ",", "'10'", ")", "==", "-", ...
Uninstall a capability Args: capability(str): The capability to be removed image (Optional[str]): The path to the root directory of an offline Windows image. If `None` is passed, the running operating system is targeted. Default is None. restart (Optional[bool]): Reb...
[ "Uninstall", "a", "capability" ]
python
train
33.384615
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L15753-L15770
def xf2rav(xform): """ This routine determines the rotation matrix and angular velocity of the rotation from a state transformation matrix. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xf2rav_c.html :param xform: state transformation matrix :type xform: list[6][6] :return: ...
[ "def", "xf2rav", "(", "xform", ")", ":", "xform", "=", "stypes", ".", "toDoubleMatrix", "(", "xform", ")", "rot", "=", "stypes", ".", "emptyDoubleMatrix", "(", ")", "av", "=", "stypes", ".", "emptyDoubleVector", "(", "3", ")", "libspice", ".", "xf2rav_c"...
This routine determines the rotation matrix and angular velocity of the rotation from a state transformation matrix. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xf2rav_c.html :param xform: state transformation matrix :type xform: list[6][6] :return: rotation associated with...
[ "This", "routine", "determines", "the", "rotation", "matrix", "and", "angular", "velocity", "of", "the", "rotation", "from", "a", "state", "transformation", "matrix", ".", "http", ":", "//", "naif", ".", "jpl", ".", "nasa", ".", "gov", "/", "pub", "/", "...
python
train
35.444444
bunq/sdk_python
bunq/sdk/json/converter.py
https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/json/converter.py#L112-L126
def deserialize(cls, cls_target, obj_raw): """ :type cls_target: T|type :type obj_raw: int|str|bool|float|list|dict|None :rtype: T """ cls._initialize() deserializer = cls._get_deserializer(cls_target) if deserializer == cls: return cls._des...
[ "def", "deserialize", "(", "cls", ",", "cls_target", ",", "obj_raw", ")", ":", "cls", ".", "_initialize", "(", ")", "deserializer", "=", "cls", ".", "_get_deserializer", "(", "cls_target", ")", "if", "deserializer", "==", "cls", ":", "return", "cls", ".", ...
:type cls_target: T|type :type obj_raw: int|str|bool|float|list|dict|None :rtype: T
[ ":", "type", "cls_target", ":", "T|type", ":", "type", "obj_raw", ":", "int|str|bool|float|list|dict|None" ]
python
train
28.133333
9seconds/pep3134
pep3134/utils.py
https://github.com/9seconds/pep3134/blob/6b6fae903bb63cb2ac24004bb2c18ebc6a7d41d0/pep3134/utils.py#L9-L44
def construct_exc_class(cls): """Constructs proxy class for the exception.""" class ProxyException(cls, BaseException): __pep3134__ = True @property def __traceback__(self): if self.__fixed_traceback__: return self.__fixed_traceback__ current_ex...
[ "def", "construct_exc_class", "(", "cls", ")", ":", "class", "ProxyException", "(", "cls", ",", "BaseException", ")", ":", "__pep3134__", "=", "True", "@", "property", "def", "__traceback__", "(", "self", ")", ":", "if", "self", ".", "__fixed_traceback__", "...
Constructs proxy class for the exception.
[ "Constructs", "proxy", "class", "for", "the", "exception", "." ]
python
train
29.222222
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L2816-L2842
def ColorfullyWrite(log: str, consoleColor: int = -1, writeToFile: bool = True, printToStdout: bool = True, logFile: str = None) -> None: """ log: str. consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`. writeToFile: bool. printToStdout: bool. ...
[ "def", "ColorfullyWrite", "(", "log", ":", "str", ",", "consoleColor", ":", "int", "=", "-", "1", ",", "writeToFile", ":", "bool", "=", "True", ",", "printToStdout", ":", "bool", "=", "True", ",", "logFile", ":", "str", "=", "None", ")", "->", "None"...
log: str. consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`. writeToFile: bool. printToStdout: bool. logFile: str, log file path. ColorfullyWrite('Hello <Color=Green>Green</Color> !!!'), color name must be in Logger.ColorNames.
[ "log", ":", "str", ".", "consoleColor", ":", "int", "a", "value", "in", "class", "ConsoleColor", "such", "as", "ConsoleColor", ".", "DarkGreen", ".", "writeToFile", ":", "bool", ".", "printToStdout", ":", "bool", ".", "logFile", ":", "str", "log", "file", ...
python
valid
43.888889
sjkingo/python-freshdesk
freshdesk/v1/api.py
https://github.com/sjkingo/python-freshdesk/blob/39edca5d86e73de5619b1d082d9d8b5c0ae626c8/freshdesk/v1/api.py#L264-L272
def _post(self, url, data={}): """Wrapper around request.post() to use the API prefix. Returns a JSON response.""" r = requests.post(self._api_prefix + url, data=json.dumps(data), headers=self.headers, auth=self.auth, allow_redirects=False, ) ...
[ "def", "_post", "(", "self", ",", "url", ",", "data", "=", "{", "}", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "_api_prefix", "+", "url", ",", "data", "=", "json", ".", "dumps", "(", "data", ")", ",", "headers", "=", "self"...
Wrapper around request.post() to use the API prefix. Returns a JSON response.
[ "Wrapper", "around", "request", ".", "post", "()", "to", "use", "the", "API", "prefix", ".", "Returns", "a", "JSON", "response", "." ]
python
train
37.444444
tensorflow/tensorboard
tensorboard/backend/event_processing/plugin_event_multiplexer.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/backend/event_processing/plugin_event_multiplexer.py#L368-L383
def Audio(self, run, tag): """Retrieve the audio events associated with a run and tag. Args: run: A string name of the run for which values are retrieved. tag: A string name of the tag for which values are retrieved. Raises: KeyError: If the run is not found, or the tag is not available ...
[ "def", "Audio", "(", "self", ",", "run", ",", "tag", ")", ":", "accumulator", "=", "self", ".", "GetAccumulator", "(", "run", ")", "return", "accumulator", ".", "Audio", "(", "tag", ")" ]
Retrieve the audio events associated with a run and tag. Args: run: A string name of the run for which values are retrieved. tag: A string name of the tag for which values are retrieved. Raises: KeyError: If the run is not found, or the tag is not available for the given run. Re...
[ "Retrieve", "the", "audio", "events", "associated", "with", "a", "run", "and", "tag", "." ]
python
train
30.0625
bennylope/django-organizations
organizations/backends/defaults.py
https://github.com/bennylope/django-organizations/blob/85f753a8f7a8f0f31636c9209fb69e7030a5c79a/organizations/backends/defaults.py#L373-L384
def send_notification(self, user, sender=None, **kwargs): """ An intermediary function for sending an notification email informing a pre-existing, active user that they have been added to a new organization. """ if not user.is_active: return False self...
[ "def", "send_notification", "(", "self", ",", "user", ",", "sender", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "user", ".", "is_active", ":", "return", "False", "self", ".", "email_message", "(", "user", ",", "self", ".", "notificati...
An intermediary function for sending an notification email informing a pre-existing, active user that they have been added to a new organization.
[ "An", "intermediary", "function", "for", "sending", "an", "notification", "email", "informing", "a", "pre", "-", "existing", "active", "user", "that", "they", "have", "been", "added", "to", "a", "new", "organization", "." ]
python
train
37.25
Cymmetria/honeycomb
honeycomb/commands/service/run.py
https://github.com/Cymmetria/honeycomb/blob/33ea91b5cf675000e4e85dd02efe580ea6e95c86/honeycomb/commands/service/run.py#L30-L88
def run(ctx, service, args, show_args, daemon, editable, integration): """Load and run a specific service.""" home = ctx.obj["HOME"] service_path = plugin_utils.get_plugin_path(home, SERVICES, service, editable) service_log_path = os.path.join(service_path, LOGS_DIR) logger.debug("running command %...
[ "def", "run", "(", "ctx", ",", "service", ",", "args", ",", "show_args", ",", "daemon", ",", "editable", ",", "integration", ")", ":", "home", "=", "ctx", ".", "obj", "[", "\"HOME\"", "]", "service_path", "=", "plugin_utils", ".", "get_plugin_path", "(",...
Load and run a specific service.
[ "Load", "and", "run", "a", "specific", "service", "." ]
python
train
44.372881
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py#L191-L208
def nacm_rule_list_rule_rule_type_notification_notification_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm") rule_list = ET.SubElement(nacm, "rule-list") ...
[ "def", "nacm_rule_list_rule_rule_type_notification_notification_name", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "nacm", "=", "ET", ".", "SubElement", "(", "config", ",", "\"nacm\"", ",", "xmln...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
48.888889
timothydmorton/VESPA
vespa/orbits/populations.py
https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/orbits/populations.py#L419-L447
def RV_timeseries(self,ts,recalc=False): """ Radial Velocity time series for star 1 at given times ts. :param ts: Times. If not ``Quantity``, assumed to be in days. :type ts: array-like or ``Quantity`` :param recalc: (optional) If ``False``,...
[ "def", "RV_timeseries", "(", "self", ",", "ts", ",", "recalc", "=", "False", ")", ":", "if", "type", "(", "ts", ")", "!=", "Quantity", ":", "ts", "*=", "u", ".", "day", "if", "not", "recalc", "and", "hasattr", "(", "self", ",", "'RV_measurements'", ...
Radial Velocity time series for star 1 at given times ts. :param ts: Times. If not ``Quantity``, assumed to be in days. :type ts: array-like or ``Quantity`` :param recalc: (optional) If ``False``, then if called with the exact same ``ts`` as las...
[ "Radial", "Velocity", "time", "series", "for", "star", "1", "at", "given", "times", "ts", "." ]
python
train
29.827586
Jammy2211/PyAutoLens
autolens/data/array/grids.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/grids.py#L391-L450
def blurring_grid_from_mask_and_psf_shape(cls, mask, psf_shape): """Setup a blurring-grid from a mask, where a blurring grid consists of all pixels that are masked, but they \ are close enough to the unmasked pixels that a fraction of their light will be blurred into those pixels \ via PSF convo...
[ "def", "blurring_grid_from_mask_and_psf_shape", "(", "cls", ",", "mask", ",", "psf_shape", ")", ":", "blurring_mask", "=", "mask", ".", "blurring_mask_for_psf_shape", "(", "psf_shape", ")", "return", "RegularGrid", ".", "from_mask", "(", "blurring_mask", ")" ]
Setup a blurring-grid from a mask, where a blurring grid consists of all pixels that are masked, but they \ are close enough to the unmasked pixels that a fraction of their light will be blurred into those pixels \ via PSF convolution. For example, if our mask is as follows: |x|x|x|x|x|...
[ "Setup", "a", "blurring", "-", "grid", "from", "a", "mask", "where", "a", "blurring", "grid", "consists", "of", "all", "pixels", "that", "are", "masked", "but", "they", "\\", "are", "close", "enough", "to", "the", "unmasked", "pixels", "that", "a", "frac...
python
valid
53.333333
Microsoft/nni
src/sdk/pynni/nni/medianstop_assessor/medianstop_assessor.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/medianstop_assessor/medianstop_assessor.py#L61-L82
def trial_end(self, trial_job_id, success): """trial_end Parameters ---------- trial_job_id: int trial job id success: bool True if succssfully finish the experiment, False otherwise """ if trial_job_id in self.running_history: ...
[ "def", "trial_end", "(", "self", ",", "trial_job_id", ",", "success", ")", ":", "if", "trial_job_id", "in", "self", ".", "running_history", ":", "if", "success", ":", "cnt", "=", "0", "history_sum", "=", "0", "self", ".", "completed_avg_history", "[", "tri...
trial_end Parameters ---------- trial_job_id: int trial job id success: bool True if succssfully finish the experiment, False otherwise
[ "trial_end", "Parameters", "----------", "trial_job_id", ":", "int", "trial", "job", "id", "success", ":", "bool", "True", "if", "succssfully", "finish", "the", "experiment", "False", "otherwise" ]
python
train
36.545455
LLNL/certipy
certipy/certipy.py
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L133-L142
def load(self): """Load from a file and return an x509 object""" private = self.is_private() with open_tls_file(self.file_path, 'r', private=private) as fh: if private: self.x509 = crypto.load_privatekey(self.encoding, fh.read()) else: sel...
[ "def", "load", "(", "self", ")", ":", "private", "=", "self", ".", "is_private", "(", ")", "with", "open_tls_file", "(", "self", ".", "file_path", ",", "'r'", ",", "private", "=", "private", ")", "as", "fh", ":", "if", "private", ":", "self", ".", ...
Load from a file and return an x509 object
[ "Load", "from", "a", "file", "and", "return", "an", "x509", "object" ]
python
train
39.8
PmagPy/PmagPy
dialogs/demag_interpretation_editor.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/demag_interpretation_editor.py#L408-L424
def update_editor(self): """ updates the logger and plot on the interpretation editor window """ self.fit_list = [] self.search_choices = [] for specimen in self.specimens_list: if specimen not in self.parent.pmag_results_data['specimens']: continue ...
[ "def", "update_editor", "(", "self", ")", ":", "self", ".", "fit_list", "=", "[", "]", "self", ".", "search_choices", "=", "[", "]", "for", "specimen", "in", "self", ".", "specimens_list", ":", "if", "specimen", "not", "in", "self", ".", "parent", ".",...
updates the logger and plot on the interpretation editor window
[ "updates", "the", "logger", "and", "plot", "on", "the", "interpretation", "editor", "window" ]
python
train
35.882353
cmbruns/pyopenvr
src/openvr/__init__.py
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L3861-L3871
def getWorkingCollisionBoundsInfo(self): """ Returns the number of Quads if the buffer points to null. Otherwise it returns Quads into the buffer up to the max specified from the working copy. """ fn = self.function_table.getWorkingCollisionBoundsInfo pQuadsBuffer = Hmd...
[ "def", "getWorkingCollisionBoundsInfo", "(", "self", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getWorkingCollisionBoundsInfo", "pQuadsBuffer", "=", "HmdQuad_t", "(", ")", "punQuadsCount", "=", "c_uint32", "(", ")", "result", "=", "fn", "(", "byre...
Returns the number of Quads if the buffer points to null. Otherwise it returns Quads into the buffer up to the max specified from the working copy.
[ "Returns", "the", "number", "of", "Quads", "if", "the", "buffer", "points", "to", "null", ".", "Otherwise", "it", "returns", "Quads", "into", "the", "buffer", "up", "to", "the", "max", "specified", "from", "the", "working", "copy", "." ]
python
train
43
pmbarrett314/curses-menu
cursesmenu/items/command_item.py
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/items/command_item.py#L27-L36
def action(self): """ This class overrides this method """ commandline = "{0} {1}".format(self.command, " ".join(self.arguments)) try: completed_process = subprocess.run(commandline, shell=True) self.exit_status = completed_process.returncode excep...
[ "def", "action", "(", "self", ")", ":", "commandline", "=", "\"{0} {1}\"", ".", "format", "(", "self", ".", "command", ",", "\" \"", ".", "join", "(", "self", ".", "arguments", ")", ")", "try", ":", "completed_process", "=", "subprocess", ".", "run", "...
This class overrides this method
[ "This", "class", "overrides", "this", "method" ]
python
test
40
monero-ecosystem/monero-python
monero/wallet.py
https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L104-L119
def confirmations(self, txn_or_pmt): """ Returns the number of confirmations for given :class:`Transaction <monero.transaction.Transaction>` or :class:`Payment <monero.transaction.Payment>` object. :rtype: int """ if isinstance(txn_or_pmt, Payment): t...
[ "def", "confirmations", "(", "self", ",", "txn_or_pmt", ")", ":", "if", "isinstance", "(", "txn_or_pmt", ",", "Payment", ")", ":", "txn", "=", "txn_or_pmt", ".", "transaction", "else", ":", "txn", "=", "txn_or_pmt", "try", ":", "return", "max", "(", "0",...
Returns the number of confirmations for given :class:`Transaction <monero.transaction.Transaction>` or :class:`Payment <monero.transaction.Payment>` object. :rtype: int
[ "Returns", "the", "number", "of", "confirmations", "for", "given", ":", "class", ":", "Transaction", "<monero", ".", "transaction", ".", "Transaction", ">", "or", ":", "class", ":", "Payment", "<monero", ".", "transaction", ".", "Payment", ">", "object", "."...
python
valid
30.5625
naphatkrit/easyci
easyci/history.py
https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L121-L138
def unstage_signature(vcs, signature): """Remove `signature` from the list of staged signatures Args: vcs (easyci.vcs.base.Vcs) signature (basestring) Raises: NotStagedError """ evidence_path = _get_staged_history_path(vcs) staged = get_staged_signatures(vcs) if sig...
[ "def", "unstage_signature", "(", "vcs", ",", "signature", ")", ":", "evidence_path", "=", "_get_staged_history_path", "(", "vcs", ")", "staged", "=", "get_staged_signatures", "(", "vcs", ")", "if", "signature", "not", "in", "staged", ":", "raise", "NotStagedErro...
Remove `signature` from the list of staged signatures Args: vcs (easyci.vcs.base.Vcs) signature (basestring) Raises: NotStagedError
[ "Remove", "signature", "from", "the", "list", "of", "staged", "signatures" ]
python
train
26.5
openego/eDisGo
edisgo/grid/network.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/network.py#L1670-L1708
def _precheck(self, curtailment_timeseries, feedin_df, curtailment_key): """ Raises an error if the curtailment at any time step exceeds the total feed-in of all generators curtailment can be distributed among at that time. Parameters ----------- curtailment_time...
[ "def", "_precheck", "(", "self", ",", "curtailment_timeseries", ",", "feedin_df", ",", "curtailment_key", ")", ":", "if", "not", "feedin_df", ".", "empty", ":", "feedin_selected_sum", "=", "feedin_df", ".", "sum", "(", "axis", "=", "1", ")", "diff", "=", "...
Raises an error if the curtailment at any time step exceeds the total feed-in of all generators curtailment can be distributed among at that time. Parameters ----------- curtailment_timeseries : :pandas:`pandas.Series<series>` Curtailment time series in kW for the te...
[ "Raises", "an", "error", "if", "the", "curtailment", "at", "any", "time", "step", "exceeds", "the", "total", "feed", "-", "in", "of", "all", "generators", "curtailment", "can", "be", "distributed", "among", "at", "that", "time", "." ]
python
train
48.615385
rr-/docstring_parser
docstring_parser/parser/google.py
https://github.com/rr-/docstring_parser/blob/389773f6790a84d33b10160589ce8591122e12bb/docstring_parser/parser/google.py#L60-L136
def parse(text: str) -> Docstring: """ Parse the Google-style docstring into its components. :returns: parsed docstring """ ret = Docstring() if not text: return ret # Clean according to PEP-0257 text = inspect.cleandoc(text) # Find first title and split on its position ...
[ "def", "parse", "(", "text", ":", "str", ")", "->", "Docstring", ":", "ret", "=", "Docstring", "(", ")", "if", "not", "text", ":", "return", "ret", "# Clean according to PEP-0257", "text", "=", "inspect", ".", "cleandoc", "(", "text", ")", "# Find first ti...
Parse the Google-style docstring into its components. :returns: parsed docstring
[ "Parse", "the", "Google", "-", "style", "docstring", "into", "its", "components", "." ]
python
train
33.272727
neurodata/ndio
ndio/remote/neurodata.py
https://github.com/neurodata/ndio/blob/792dd5816bc770b05a3db2f4327da42ff6253531/ndio/remote/neurodata.py#L470-L488
def create_token(self, token_name, project_name, dataset_name, is_public): """ Creates a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Da...
[ "def", "create_token", "(", "self", ",", "token_name", ",", "project_name", ",", "dataset_name", ",", "is_public", ")", ":", "return", "self", ".", "resources", ".", "create_token", "(", "token_name", ",", "project_name", ",", "dataset_name", ",", "is_public", ...
Creates a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on token_name (str): Token name is_public (int): 1 is public. 0 is not public Returns: bool: True if projec...
[ "Creates", "a", "token", "with", "the", "given", "parameters", ".", "Arguments", ":", "project_name", "(", "str", ")", ":", "Project", "name", "dataset_name", "(", "str", ")", ":", "Dataset", "name", "project", "is", "based", "on", "token_name", "(", "str"...
python
test
39.368421
Crunch-io/crunch-cube
src/cr/cube/distributions/wishart.py
https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/distributions/wishart.py#L89-L103
def K(self): """Normalizing constant for wishart CDF.""" K1 = np.float_power(pi, 0.5 * self.n_min * self.n_min) K1 /= ( np.float_power(2, 0.5 * self.n_min * self._n_max) * self._mgamma(0.5 * self._n_max, self.n_min) * self._mgamma(0.5 * self.n_min, self.n_min)...
[ "def", "K", "(", "self", ")", ":", "K1", "=", "np", ".", "float_power", "(", "pi", ",", "0.5", "*", "self", ".", "n_min", "*", "self", ".", "n_min", ")", "K1", "/=", "(", "np", ".", "float_power", "(", "2", ",", "0.5", "*", "self", ".", "n_mi...
Normalizing constant for wishart CDF.
[ "Normalizing", "constant", "for", "wishart", "CDF", "." ]
python
train
35.533333
spencerahill/aospy
aospy/utils/vertcoord.py
https://github.com/spencerahill/aospy/blob/2f6e775b9b9956c54af117fdcdce2c87196afb6c/aospy/utils/vertcoord.py#L66-L75
def to_pfull_from_phalf(arr, pfull_coord): """Compute data at full pressure levels from values at half levels.""" phalf_top = arr.isel(**{internal_names.PHALF_STR: slice(1, None)}) phalf_top = replace_coord(phalf_top, internal_names.PHALF_STR, internal_names.PFULL_STR, pfull_co...
[ "def", "to_pfull_from_phalf", "(", "arr", ",", "pfull_coord", ")", ":", "phalf_top", "=", "arr", ".", "isel", "(", "*", "*", "{", "internal_names", ".", "PHALF_STR", ":", "slice", "(", "1", ",", "None", ")", "}", ")", "phalf_top", "=", "replace_coord", ...
Compute data at full pressure levels from values at half levels.
[ "Compute", "data", "at", "full", "pressure", "levels", "from", "values", "at", "half", "levels", "." ]
python
train
56.3
poldracklab/niworkflows
niworkflows/viz/utils.py
https://github.com/poldracklab/niworkflows/blob/254f4b4fcc5e6ecb29d2f4602a30786b913ecce5/niworkflows/viz/utils.py#L417-L493
def compose_view(bg_svgs, fg_svgs, ref=0, out_file='report.svg'): """ Composes the input svgs into one standalone svg and inserts the CSS code for the flickering animation """ import svgutils.transform as svgt if fg_svgs is None: fg_svgs = [] # Merge SVGs and get roots svgs = b...
[ "def", "compose_view", "(", "bg_svgs", ",", "fg_svgs", ",", "ref", "=", "0", ",", "out_file", "=", "'report.svg'", ")", ":", "import", "svgutils", ".", "transform", "as", "svgt", "if", "fg_svgs", "is", "None", ":", "fg_svgs", "=", "[", "]", "# Merge SVGs...
Composes the input svgs into one standalone svg and inserts the CSS code for the flickering animation
[ "Composes", "the", "input", "svgs", "into", "one", "standalone", "svg", "and", "inserts", "the", "CSS", "code", "for", "the", "flickering", "animation" ]
python
train
29.61039
halcy/Mastodon.py
mastodon/Mastodon.py
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L65-L85
def api_version(created_ver, last_changed_ver, return_value_ver): """Version check decorator. Currently only checks Bigger Than.""" def api_min_version_decorator(function): def wrapper(function, self, *args, **kwargs): if not self.version_check_mode == "none": if self.v...
[ "def", "api_version", "(", "created_ver", ",", "last_changed_ver", ",", "return_value_ver", ")", ":", "def", "api_min_version_decorator", "(", "function", ")", ":", "def", "wrapper", "(", "function", ",", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")...
Version check decorator. Currently only checks Bigger Than.
[ "Version", "check", "decorator", ".", "Currently", "only", "checks", "Bigger", "Than", "." ]
python
train
69.857143
choderalab/pymbar
pymbar/bar.py
https://github.com/choderalab/pymbar/blob/69d1f0ff680e9ac1c6a51a5a207ea28f3ed86740/pymbar/bar.py#L54-L147
def BARzero(w_F, w_R, DeltaF): """A function that when zeroed is equivalent to the solution of the Bennett acceptance ratio. from http://journals.aps.org/prl/pdf/10.1103/PhysRevLett.91.140601 D_F = M + w_F - Delta F D_R = M + w_R - Delta F we want: \sum_N_F (1+exp(D_F))^-1 = \sum N_R N_R <...
[ "def", "BARzero", "(", "w_F", ",", "w_R", ",", "DeltaF", ")", ":", "np", ".", "seterr", "(", "over", "=", "'raise'", ")", "# raise exceptions to overflows", "w_F", "=", "np", ".", "array", "(", "w_F", ",", "np", ".", "float64", ")", "w_R", "=", "np",...
A function that when zeroed is equivalent to the solution of the Bennett acceptance ratio. from http://journals.aps.org/prl/pdf/10.1103/PhysRevLett.91.140601 D_F = M + w_F - Delta F D_R = M + w_R - Delta F we want: \sum_N_F (1+exp(D_F))^-1 = \sum N_R N_R <(1+exp(-D_R))^-1> ln \sum N_F (1+e...
[ "A", "function", "that", "when", "zeroed", "is", "equivalent", "to", "the", "solution", "of", "the", "Bennett", "acceptance", "ratio", "." ]
python
train
37.287234
jab/bidict
bidict/_base.py
https://github.com/jab/bidict/blob/1a1ba9758651aed9c4f58384eff006d2e2ad6835/bidict/_base.py#L133-L144
def _inv_cls(cls): """The inverse of this bidict type, i.e. one with *_fwdm_cls* and *_invm_cls* swapped.""" if cls._fwdm_cls is cls._invm_cls: return cls if not getattr(cls, '_inv_cls_', None): class _Inv(cls): _fwdm_cls = cls._invm_cls _i...
[ "def", "_inv_cls", "(", "cls", ")", ":", "if", "cls", ".", "_fwdm_cls", "is", "cls", ".", "_invm_cls", ":", "return", "cls", "if", "not", "getattr", "(", "cls", ",", "'_inv_cls_'", ",", "None", ")", ":", "class", "_Inv", "(", "cls", ")", ":", "_fwd...
The inverse of this bidict type, i.e. one with *_fwdm_cls* and *_invm_cls* swapped.
[ "The", "inverse", "of", "this", "bidict", "type", "i", ".", "e", ".", "one", "with", "*", "_fwdm_cls", "*", "and", "*", "_invm_cls", "*", "swapped", "." ]
python
test
39.583333
hyperledger/indy-plenum
plenum/common/transaction_store.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/transaction_store.py#L57-L71
def stop(self, timeout: int = 5) -> None: """ Try to stop the transaction store in the given timeout or raise an exception. """ self.running = False start = time.perf_counter() while True: if self.getsCounter == 0: return True ...
[ "def", "stop", "(", "self", ",", "timeout", ":", "int", "=", "5", ")", "->", "None", ":", "self", ".", "running", "=", "False", "start", "=", "time", ".", "perf_counter", "(", ")", "while", "True", ":", "if", "self", ".", "getsCounter", "==", "0", ...
Try to stop the transaction store in the given timeout or raise an exception.
[ "Try", "to", "stop", "the", "transaction", "store", "in", "the", "given", "timeout", "or", "raise", "an", "exception", "." ]
python
train
36.6
mikedh/trimesh
trimesh/nsphere.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/nsphere.py#L170-L186
def is_nsphere(points): """ Check if a list of points is an nsphere. Parameters ----------- points : (n, dimension) float Points in space Returns ----------- check : bool True if input points are on an nsphere """ center, radius, error = fit_nsphere(points) chec...
[ "def", "is_nsphere", "(", "points", ")", ":", "center", ",", "radius", ",", "error", "=", "fit_nsphere", "(", "points", ")", "check", "=", "error", "<", "tol", ".", "merge", "return", "check" ]
Check if a list of points is an nsphere. Parameters ----------- points : (n, dimension) float Points in space Returns ----------- check : bool True if input points are on an nsphere
[ "Check", "if", "a", "list", "of", "points", "is", "an", "nsphere", "." ]
python
train
20.117647
troeger/opensubmit
executor/opensubmitexec/job.py
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L152-L174
def spawn_program(self, name, arguments=[], timeout=30, exclusive=False): """Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program...
[ "def", "spawn_program", "(", "self", ",", "name", ",", "arguments", "=", "[", "]", ",", "timeout", "=", "30", ",", "exclusive", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Spawning program for interaction ...\"", ")", "if", "exclusive", ":", "k...
Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the progra...
[ "Spawns", "a", "program", "in", "the", "working", "directory", "." ]
python
train
41
tensorflow/probability
tensorflow_probability/python/distributions/hidden_markov_model.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/hidden_markov_model.py#L736-L905
def posterior_mode(self, observations, name=None): """Compute maximum likelihood sequence of hidden states. When this function is provided with a sequence of observations `x[0], ..., x[num_steps - 1]`, it returns the sequence of hidden states `z[0], ..., z[num_steps - 1]`, drawn from the underlying ...
[ "def", "posterior_mode", "(", "self", ",", "observations", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"posterior_mode\"", ")", ":", "with", "tf", ".", "control_dependencies", "(", "self", ".", "_runtime_assertio...
Compute maximum likelihood sequence of hidden states. When this function is provided with a sequence of observations `x[0], ..., x[num_steps - 1]`, it returns the sequence of hidden states `z[0], ..., z[num_steps - 1]`, drawn from the underlying Markov chain, that is most likely to yield those observat...
[ "Compute", "maximum", "likelihood", "sequence", "of", "hidden", "states", "." ]
python
test
43.823529
ministryofjustice/django-form-error-reporting
form_error_reporting.py
https://github.com/ministryofjustice/django-form-error-reporting/blob/2d08dd5cc4321e1abf49241c515ccd7050d9f828/form_error_reporting.py#L165-L177
def get_ga_client_id(self): """ Retrieve the client ID from the Google Analytics cookie, if available, and save in the current session """ request = self.get_ga_request() if not request or not hasattr(request, 'session'): return super(GARequestErrorReportingMi...
[ "def", "get_ga_client_id", "(", "self", ")", ":", "request", "=", "self", ".", "get_ga_request", "(", ")", "if", "not", "request", "or", "not", "hasattr", "(", "request", ",", "'session'", ")", ":", "return", "super", "(", "GARequestErrorReportingMixin", ","...
Retrieve the client ID from the Google Analytics cookie, if available, and save in the current session
[ "Retrieve", "the", "client", "ID", "from", "the", "Google", "Analytics", "cookie", "if", "available", "and", "save", "in", "the", "current", "session" ]
python
train
50.153846
alefnula/tea
tea/msg/mail.py
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L218-L237
def send_messages(self, messages): """Send one or more EmailMessage objects. Returns: int: Number of email messages sent. """ if not messages: return new_conn_created = self.open() if not self.connection: # We failed silentl...
[ "def", "send_messages", "(", "self", ",", "messages", ")", ":", "if", "not", "messages", ":", "return", "new_conn_created", "=", "self", ".", "open", "(", ")", "if", "not", "self", ".", "connection", ":", "# We failed silently on open(). Trying to send would be po...
Send one or more EmailMessage objects. Returns: int: Number of email messages sent.
[ "Send", "one", "or", "more", "EmailMessage", "objects", ".", "Returns", ":", "int", ":", "Number", "of", "email", "messages", "sent", "." ]
python
train
29.9
LonamiWebs/Telethon
telethon/events/common.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L242-L248
def name_inner_event(cls): """Decorator to rename cls.Event 'Event' as 'cls.Event'""" if hasattr(cls, 'Event'): cls.Event._event_name = '{}.Event'.format(cls.__name__) else: warnings.warn('Class {} does not have a inner Event'.format(cls)) return cls
[ "def", "name_inner_event", "(", "cls", ")", ":", "if", "hasattr", "(", "cls", ",", "'Event'", ")", ":", "cls", ".", "Event", ".", "_event_name", "=", "'{}.Event'", ".", "format", "(", "cls", ".", "__name__", ")", "else", ":", "warnings", ".", "warn", ...
Decorator to rename cls.Event 'Event' as 'cls.Event
[ "Decorator", "to", "rename", "cls", ".", "Event", "Event", "as", "cls", ".", "Event" ]
python
train
39.428571
senaite/senaite.core
bika/lims/browser/fields/datetimefield.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/fields/datetimefield.py#L51-L58
def set(self, instance, value, **kwargs): """ Check if value is an actual date/time value. If not, attempt to convert it to one; otherwise, set to None. Assign all properties passed as kwargs to object. """ val = get_date(instance, value) super(DateTimeField, self...
[ "def", "set", "(", "self", ",", "instance", ",", "value", ",", "*", "*", "kwargs", ")", ":", "val", "=", "get_date", "(", "instance", ",", "value", ")", "super", "(", "DateTimeField", ",", "self", ")", ".", "set", "(", "instance", ",", "val", ",", ...
Check if value is an actual date/time value. If not, attempt to convert it to one; otherwise, set to None. Assign all properties passed as kwargs to object.
[ "Check", "if", "value", "is", "an", "actual", "date", "/", "time", "value", ".", "If", "not", "attempt", "to", "convert", "it", "to", "one", ";", "otherwise", "set", "to", "None", ".", "Assign", "all", "properties", "passed", "as", "kwargs", "to", "obj...
python
train
42.875
jmcgeheeiv/pyfakefs
pyfakefs/fake_filesystem.py
https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L5114-L5224
def call(self, file_, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, open_modes=None): """Return a file-like object with the contents of the target file object. Args: file_: Path to target file or a file descrip...
[ "def", "call", "(", "self", ",", "file_", ",", "mode", "=", "'r'", ",", "buffering", "=", "-", "1", ",", "encoding", "=", "None", ",", "errors", "=", "None", ",", "newline", "=", "None", ",", "closefd", "=", "True", ",", "opener", "=", "None", ",...
Return a file-like object with the contents of the target file object. Args: file_: Path to target file or a file descriptor. mode: Additional file modes (all modes in `open()` are supported). buffering: ignored. (Used for signature compliance with __...
[ "Return", "a", "file", "-", "like", "object", "with", "the", "contents", "of", "the", "target", "file", "object", "." ]
python
train
45.576577
hazelcast/hazelcast-python-client
hazelcast/proxy/atomic_long.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_long.py#L96-L107
def get_and_alter(self, function): """ Alters the currently stored value by applying a function on it on and gets the old value. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a seri...
[ "def", "get_and_alter", "(", "self", ",", "function", ")", ":", "check_not_none", "(", "function", ",", "\"function can't be None\"", ")", "return", "self", ".", "_encode_invoke", "(", "atomic_long_get_and_alter_codec", ",", "function", "=", "self", ".", "_to_data",...
Alters the currently stored value by applying a function on it on and gets the old value. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server sid...
[ "Alters", "the", "currently", "stored", "value", "by", "applying", "a", "function", "on", "it", "on", "and", "gets", "the", "old", "value", "." ]
python
train
54.583333
twilio/twilio-python
twilio/rest/ip_messaging/v2/service/user/user_binding.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/ip_messaging/v2/service/user/user_binding.py#L189-L203
def get_instance(self, payload): """ Build an instance of UserBindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance...
[ "def", "get_instance", "(", "self", ",", "payload", ")", ":", "return", "UserBindingInstance", "(", "self", ".", "_version", ",", "payload", ",", "service_sid", "=", "self", ".", "_solution", "[", "'service_sid'", "]", ",", "user_sid", "=", "self", ".", "_...
Build an instance of UserBindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance
[ "Build", "an", "instance", "of", "UserBindingInstance" ]
python
train
34.4
docker/docker-py
docker/api/daemon.py
https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/daemon.py#L97-L152
def login(self, username, password=None, email=None, registry=None, reauth=False, dockercfg_path=None): """ Authenticate with a registry. Similar to the ``docker login`` command. Args: username (str): The registry username password (str): The plaintext pass...
[ "def", "login", "(", "self", ",", "username", ",", "password", "=", "None", ",", "email", "=", "None", ",", "registry", "=", "None", ",", "reauth", "=", "False", ",", "dockercfg_path", "=", "None", ")", ":", "# If we don't have any auth data so far, try reload...
Authenticate with a registry. Similar to the ``docker login`` command. Args: username (str): The registry username password (str): The plaintext password email (str): The email for the registry account registry (str): URL to the registry. E.g. ``...
[ "Authenticate", "with", "a", "registry", ".", "Similar", "to", "the", "docker", "login", "command", "." ]
python
train
41.446429
gem/oq-engine
openquake/calculators/extract.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L202-L218
def extract_exposure_metadata(dstore, what): """ Extract the loss categories and the tags of the exposure. Use it as /extract/exposure_metadata """ dic = {} dic1, dic2 = dstore['assetcol/tagcol'].__toh5__() dic.update(dic1) dic.update(dic2) if 'asset_risk' in dstore: dic['mul...
[ "def", "extract_exposure_metadata", "(", "dstore", ",", "what", ")", ":", "dic", "=", "{", "}", "dic1", ",", "dic2", "=", "dstore", "[", "'assetcol/tagcol'", "]", ".", "__toh5__", "(", ")", "dic", ".", "update", "(", "dic1", ")", "dic", ".", "update", ...
Extract the loss categories and the tags of the exposure. Use it as /extract/exposure_metadata
[ "Extract", "the", "loss", "categories", "and", "the", "tags", "of", "the", "exposure", ".", "Use", "it", "as", "/", "extract", "/", "exposure_metadata" ]
python
train
38.764706
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_preprovision.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_preprovision.py#L40-L51
def show_bare_metal_state_output_bare_metal_state(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") show_bare_metal_state = ET.Element("show_bare_metal_state") config = show_bare_metal_state output = ET.SubElement(show_bare_metal_state, "output") ...
[ "def", "show_bare_metal_state_output_bare_metal_state", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "show_bare_metal_state", "=", "ET", ".", "Element", "(", "\"show_bare_metal_state\"", ")", "config"...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
44.166667
scopus-api/scopus
scopus/deprecated_/scopus_author.py
https://github.com/scopus-api/scopus/blob/27ce02dd3095bfdab9d3e8475543d7c17767d1ab/scopus/deprecated_/scopus_author.py#L142-L154
def subject_areas(self): """List of tuples of author subject areas in the form (area, frequency, abbreviation, code), where frequency is the number of publications in this subject area. """ areas = self.xml.findall('subject-areas/subject-area') freqs = self.xml.findall('a...
[ "def", "subject_areas", "(", "self", ")", ":", "areas", "=", "self", ".", "xml", ".", "findall", "(", "'subject-areas/subject-area'", ")", "freqs", "=", "self", ".", "xml", ".", "findall", "(", "'author-profile/classificationgroup/'", "'classifications[@type=\"ASJC\...
List of tuples of author subject areas in the form (area, frequency, abbreviation, code), where frequency is the number of publications in this subject area.
[ "List", "of", "tuples", "of", "author", "subject", "areas", "in", "the", "form", "(", "area", "frequency", "abbreviation", "code", ")", "where", "frequency", "is", "the", "number", "of", "publications", "in", "this", "subject", "area", "." ]
python
train
52.461538
pydsigner/pygu
pygu/common.py
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/common.py#L35-L41
def hcenter_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' The same as center_blit(), but only centers horizontally. ''' loc = lambda d, s: (_vec(d.get_width() / 2, 0) - _vec(s.get_width() / 2, 0)) _blitter(loc, target, source, dest, area, special_flags)
[ "def", "hcenter_blit", "(", "target", ",", "source", ",", "dest", "=", "(", "0", ",", "0", ")", ",", "area", "=", "None", ",", "special_flags", "=", "0", ")", ":", "loc", "=", "lambda", "d", ",", "s", ":", "(", "_vec", "(", "d", ".", "get_width...
The same as center_blit(), but only centers horizontally.
[ "The", "same", "as", "center_blit", "()", "but", "only", "centers", "horizontally", "." ]
python
train
43.285714
LionelR/pyair
pyair/stats.py
https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/stats.py#L140-L143
def gmv(a, b): """Geometric mean variance """ return np.exp(np.square(np.log(a) - np.log(b)).mean())
[ "def", "gmv", "(", "a", ",", "b", ")", ":", "return", "np", ".", "exp", "(", "np", ".", "square", "(", "np", ".", "log", "(", "a", ")", "-", "np", ".", "log", "(", "b", ")", ")", ".", "mean", "(", ")", ")" ]
Geometric mean variance
[ "Geometric", "mean", "variance" ]
python
valid
27.25
72squared/redpipe
redpipe/keyspaces.py
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L597-L614
def setrange(self, name, offset, value): """ Overwrite bytes in the value of ``name`` starting at ``offset`` with ``value``. If ``offset`` plus the length of ``value`` exceeds the length of the original value, the new value will be larger than before. If ``offset`` exceed...
[ "def", "setrange", "(", "self", ",", "name", ",", "offset", ",", "value", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "setrange", "(", "self", ".", "redis_key", "(", "name", ")", ",", "offset", ",", "value", ")"...
Overwrite bytes in the value of ``name`` starting at ``offset`` with ``value``. If ``offset`` plus the length of ``value`` exceeds the length of the original value, the new value will be larger than before. If ``offset`` exceeds the length of the original value, null bytes will b...
[ "Overwrite", "bytes", "in", "the", "value", "of", "name", "starting", "at", "offset", "with", "value", ".", "If", "offset", "plus", "the", "length", "of", "value", "exceeds", "the", "length", "of", "the", "original", "value", "the", "new", "value", "will",...
python
train
42.111111
juju/charm-helpers
charmhelpers/contrib/openstack/amulet/utils.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/amulet/utils.py#L1086-L1099
def get_ceph_df(self, sentry_unit): """Return dict of ceph df json output, including ceph pool state. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :returns: Dict of ceph df output """ cmd = 'sudo ceph df --format=json' output, code = sentry_unit.run(...
[ "def", "get_ceph_df", "(", "self", ",", "sentry_unit", ")", ":", "cmd", "=", "'sudo ceph df --format=json'", "output", ",", "code", "=", "sentry_unit", ".", "run", "(", "cmd", ")", "if", "code", "!=", "0", ":", "msg", "=", "(", "'{} `{}` returned {} '", "'...
Return dict of ceph df json output, including ceph pool state. :param sentry_unit: Pointer to amulet sentry instance (juju unit) :returns: Dict of ceph df output
[ "Return", "dict", "of", "ceph", "df", "json", "output", "including", "ceph", "pool", "state", "." ]
python
train
41.142857
draperjames/qtpandas
qtpandas/models/mime.py
https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/models/mime.py#L51-L61
def data(self): """return stored data Returns: unpickled data """ try: bytestream = super(MimeData, self).data(self._mimeType).data() return pickle.loads(bytestream) except: raise
[ "def", "data", "(", "self", ")", ":", "try", ":", "bytestream", "=", "super", "(", "MimeData", ",", "self", ")", ".", "data", "(", "self", ".", "_mimeType", ")", ".", "data", "(", ")", "return", "pickle", ".", "loads", "(", "bytestream", ")", "exce...
return stored data Returns: unpickled data
[ "return", "stored", "data", "Returns", ":", "unpickled", "data" ]
python
train
24.181818
wummel/linkchecker
linkcheck/checker/urlbase.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/urlbase.py#L499-L517
def handle_exception (self): """ An exception occurred. Log it and set the cache flag. """ etype, evalue = sys.exc_info()[:2] log.debug(LOG_CHECK, "Error in %s: %s %s", self.url, etype, evalue, exception=True) # note: etype must be the exact class, not a subclass ...
[ "def", "handle_exception", "(", "self", ")", ":", "etype", ",", "evalue", "=", "sys", ".", "exc_info", "(", ")", "[", ":", "2", "]", "log", ".", "debug", "(", "LOG_CHECK", ",", "\"Error in %s: %s %s\"", ",", "self", ".", "url", ",", "etype", ",", "ev...
An exception occurred. Log it and set the cache flag.
[ "An", "exception", "occurred", ".", "Log", "it", "and", "set", "the", "cache", "flag", "." ]
python
train
43.368421
apple/turicreate
src/unity/python/turicreate/toolkits/_main.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_main.py#L25-L69
def run(toolkit_name, options, verbose=True, show_progress=False): """ Internal function to execute toolkit on the turicreate server. Parameters ---------- toolkit_name : string The name of the toolkit. options : dict A map containing the required input for the toolkit function...
[ "def", "run", "(", "toolkit_name", ",", "options", ",", "verbose", "=", "True", ",", "show_progress", "=", "False", ")", ":", "unity", "=", "glconnect", ".", "get_unity", "(", ")", "if", "(", "not", "verbose", ")", ":", "glconnect", ".", "get_server", ...
Internal function to execute toolkit on the turicreate server. Parameters ---------- toolkit_name : string The name of the toolkit. options : dict A map containing the required input for the toolkit function, for example: {'graph': g, 'reset_prob': 0.15}. verbose : bool ...
[ "Internal", "function", "to", "execute", "toolkit", "on", "the", "turicreate", "server", "." ]
python
train
25.4
programa-stic/barf-project
barf/analysis/graphs/callgraph.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/analysis/graphs/callgraph.py#L66-L80
def simple_paths_by_name(self, start_name, end_name): """Return a list of paths between start and end functions. """ cfg_start = self.find_function_by_name(start_name) cfg_end = self.find_function_by_name(end_name) if not cfg_start or not cfg_end: raise Exception("St...
[ "def", "simple_paths_by_name", "(", "self", ",", "start_name", ",", "end_name", ")", ":", "cfg_start", "=", "self", ".", "find_function_by_name", "(", "start_name", ")", "cfg_end", "=", "self", ".", "find_function_by_name", "(", "end_name", ")", "if", "not", "...
Return a list of paths between start and end functions.
[ "Return", "a", "list", "of", "paths", "between", "start", "and", "end", "functions", "." ]
python
train
40.333333
rackerlabs/simpl
simpl/config.py
https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/config.py#L511-L572
def validate_config(self, values, argv=None, strict=False): """Validate all config values through the command-line parser. This takes all supplied options (which could have been retrieved from a number of sources (such as CLI, env vars, etc...) and then validates them by running them th...
[ "def", "validate_config", "(", "self", ",", "values", ",", "argv", "=", "None", ",", "strict", "=", "False", ")", ":", "options", "=", "[", "]", "for", "option", "in", "self", ".", "_options", ":", "kwargs", "=", "option", ".", "kwargs", ".", "copy",...
Validate all config values through the command-line parser. This takes all supplied options (which could have been retrieved from a number of sources (such as CLI, env vars, etc...) and then validates them by running them through argparser (and raises SystemExit on failure). :r...
[ "Validate", "all", "config", "values", "through", "the", "command", "-", "line", "parser", "." ]
python
train
46.612903
mrstephenneal/mysql-toolkit
mysql/toolkit/commands/dump.py
https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/commands/dump.py#L86-L90
def write_text(_command, txt_file): """Dump SQL command to a text file.""" command = _command.strip() with open(txt_file, 'w') as txt: txt.writelines(command)
[ "def", "write_text", "(", "_command", ",", "txt_file", ")", ":", "command", "=", "_command", ".", "strip", "(", ")", "with", "open", "(", "txt_file", ",", "'w'", ")", "as", "txt", ":", "txt", ".", "writelines", "(", "command", ")" ]
Dump SQL command to a text file.
[ "Dump", "SQL", "command", "to", "a", "text", "file", "." ]
python
train
34.8
istresearch/scrapy-cluster
utils/scutils/redis_throttled_queue.py
https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/utils/scutils/redis_throttled_queue.py#L112-L157
def allowed(self): ''' Check to see if the pop request is allowed @return: True means the maximum was not been reached for the current time window, thus allowing what ever operation follows ''' # Expire old keys (hits) expires = time.time() - self.window ...
[ "def", "allowed", "(", "self", ")", ":", "# Expire old keys (hits)", "expires", "=", "time", ".", "time", "(", ")", "-", "self", ".", "window", "self", ".", "redis_conn", ".", "zremrangebyscore", "(", "self", ".", "window_key", ",", "'-inf'", ",", "expires...
Check to see if the pop request is allowed @return: True means the maximum was not been reached for the current time window, thus allowing what ever operation follows
[ "Check", "to", "see", "if", "the", "pop", "request", "is", "allowed" ]
python
train
38.608696
LEMS/pylems
lems/sim/build.py
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/build.py#L769-L789
def build_event_handler(self, runnable, regime, event_handler): """ Build event handler code. @param event_handler: Event handler object @type event_handler: lems.model.dynamics.EventHandler @return: Generated event handler code. @rtype: list(string) """ ...
[ "def", "build_event_handler", "(", "self", ",", "runnable", ",", "regime", ",", "event_handler", ")", ":", "if", "isinstance", "(", "event_handler", ",", "OnCondition", ")", ":", "return", "self", ".", "build_on_condition", "(", "runnable", ",", "regime", ",",...
Build event handler code. @param event_handler: Event handler object @type event_handler: lems.model.dynamics.EventHandler @return: Generated event handler code. @rtype: list(string)
[ "Build", "event", "handler", "code", "." ]
python
train
39
pyqg/pyqg
pyqg/particles.py
https://github.com/pyqg/pyqg/blob/4f41584a12bcbf8657785b8cb310fa5065ecabd1/pyqg/particles.py#L124-L135
def _distance(self, x0, y0, x1, y1): """Utitlity function to compute distance between points.""" dx = x1-x0 dy = y1-y0 # roll displacements across the borders if self.pix: dx[ dx > self.Lx/2 ] -= self.Lx dx[ dx < -self.Lx/2 ] += self.Lx if self.piy...
[ "def", "_distance", "(", "self", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "dx", "=", "x1", "-", "x0", "dy", "=", "y1", "-", "y0", "# roll displacements across the borders", "if", "self", ".", "pix", ":", "dx", "[", "dx", ">", "self", ...
Utitlity function to compute distance between points.
[ "Utitlity", "function", "to", "compute", "distance", "between", "points", "." ]
python
train
35.083333
GPflow/GPflow
gpflow/models/model.py
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/model.py#L209-L218
def predict_density(self, Xnew, Ynew): """ Compute the (log) density of the data Ynew at the points Xnew Note that this computes the log density of the data individually, ignoring correlations between them. The result is a matrix the same shape as Ynew containing the log densiti...
[ "def", "predict_density", "(", "self", ",", "Xnew", ",", "Ynew", ")", ":", "pred_f_mean", ",", "pred_f_var", "=", "self", ".", "_build_predict", "(", "Xnew", ")", "return", "self", ".", "likelihood", ".", "predict_density", "(", "pred_f_mean", ",", "pred_f_v...
Compute the (log) density of the data Ynew at the points Xnew Note that this computes the log density of the data individually, ignoring correlations between them. The result is a matrix the same shape as Ynew containing the log densities.
[ "Compute", "the", "(", "log", ")", "density", "of", "the", "data", "Ynew", "at", "the", "points", "Xnew" ]
python
train
46.4
Clinical-Genomics/scout
scout/server/blueprints/variants/controllers.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/variants/controllers.py#L421-L467
def variant_case(store, case_obj, variant_obj): """Pre-process case for the variant view. Adds information about files from case obj to variant Args: store(scout.adapter.MongoAdapter) case_obj(scout.models.Case) variant_obj(scout.models.Variant) """ case_obj['bam_files'] = ...
[ "def", "variant_case", "(", "store", ",", "case_obj", ",", "variant_obj", ")", ":", "case_obj", "[", "'bam_files'", "]", "=", "[", "]", "case_obj", "[", "'mt_bams'", "]", "=", "[", "]", "case_obj", "[", "'bai_files'", "]", "=", "[", "]", "case_obj", "[...
Pre-process case for the variant view. Adds information about files from case obj to variant Args: store(scout.adapter.MongoAdapter) case_obj(scout.models.Case) variant_obj(scout.models.Variant)
[ "Pre", "-", "process", "case", "for", "the", "variant", "view", "." ]
python
test
43.170213
chrismattmann/tika-python
tika/tika.py
https://github.com/chrismattmann/tika-python/blob/ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a/tika/tika.py#L771-L812
def main(argv=None): """Run Tika from command line according to USAGE.""" global Verbose global EncodeUtf8 global csvOutput if argv is None: argv = sys.argv if (len(argv) < 3 and not (('-h' in argv) or ('--help' in argv))): log.exception('Bad args') raise TikaException('...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "global", "Verbose", "global", "EncodeUtf8", "global", "csvOutput", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "if", "(", "len", "(", "argv", ")", "<", "3", "and", "not", "("...
Run Tika from command line according to USAGE.
[ "Run", "Tika", "from", "command", "line", "according", "to", "USAGE", "." ]
python
train
37.404762
ThreatConnect-Inc/tcex
tcex/tcex_bin_profile.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_profile.py#L817-L821
def validate_profile_exists(self): """Validate the provided profiles name exists.""" if self.args.profile_name not in self.profiles: self.handle_error('Could not find profile "{}"'.format(self.args.profile_name))
[ "def", "validate_profile_exists", "(", "self", ")", ":", "if", "self", ".", "args", ".", "profile_name", "not", "in", "self", ".", "profiles", ":", "self", ".", "handle_error", "(", "'Could not find profile \"{}\"'", ".", "format", "(", "self", ".", "args", ...
Validate the provided profiles name exists.
[ "Validate", "the", "provided", "profiles", "name", "exists", "." ]
python
train
47.4
pycontribs/pyrax
pyrax/clouddns.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddns.py#L462-L518
def _async_call(self, uri, body=None, method="GET", error_class=None, has_response=True, *args, **kwargs): """ Handles asynchronous call/responses for the DNS API. Returns the response headers and body if the call was successful. If an error status is returned, and the 'erro...
[ "def", "_async_call", "(", "self", ",", "uri", ",", "body", "=", "None", ",", "method", "=", "\"GET\"", ",", "error_class", "=", "None", ",", "has_response", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "api_methods", "=", "{", ...
Handles asynchronous call/responses for the DNS API. Returns the response headers and body if the call was successful. If an error status is returned, and the 'error_class' parameter is specified, that class of error will be raised with the details from the response. If no error class i...
[ "Handles", "asynchronous", "call", "/", "responses", "for", "the", "DNS", "API", "." ]
python
train
40.245614
buguroo/pyknow
pyknow/matchers/rete/abstract.py
https://github.com/buguroo/pyknow/blob/48818336f2e9a126f1964f2d8dc22d37ff800fe8/pyknow/matchers/rete/abstract.py#L57-L61
def activate_left(self, token): """Make a copy of the received token and call `_activate_left`.""" watchers.MATCHER.debug( "Node <%s> activated left with token %r", self, token) return self._activate_left(token.copy())
[ "def", "activate_left", "(", "self", ",", "token", ")", ":", "watchers", ".", "MATCHER", ".", "debug", "(", "\"Node <%s> activated left with token %r\"", ",", "self", ",", "token", ")", "return", "self", ".", "_activate_left", "(", "token", ".", "copy", "(", ...
Make a copy of the received token and call `_activate_left`.
[ "Make", "a", "copy", "of", "the", "received", "token", "and", "call", "_activate_left", "." ]
python
train
50
janpipek/physt
physt/histogram_base.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L652-L670
def _kwargs_from_dict(cls, a_dict: dict) -> dict: """Modify __init__ arguments from an external dictionary. Template method for from dict. Override if necessary (like it's done in Histogram1D). """ from .binnings import BinningBase kwargs = { "binnings": [Bin...
[ "def", "_kwargs_from_dict", "(", "cls", ",", "a_dict", ":", "dict", ")", "->", "dict", ":", "from", ".", "binnings", "import", "BinningBase", "kwargs", "=", "{", "\"binnings\"", ":", "[", "BinningBase", ".", "from_dict", "(", "binning_data", ")", "for", "b...
Modify __init__ arguments from an external dictionary. Template method for from dict. Override if necessary (like it's done in Histogram1D).
[ "Modify", "__init__", "arguments", "from", "an", "external", "dictionary", "." ]
python
train
41.210526
influxdata/influxdb-python
examples/tutorial_server_data.py
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_server_data.py#L19-L74
def main(host='localhost', port=8086, nb_day=15): """Instantiate a connection to the backend.""" nb_day = 15 # number of day to generate time series timeinterval_min = 5 # create an event every x minutes total_minutes = 1440 * nb_day total_records = int(total_minutes / timeinterval_min) now = ...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ",", "nb_day", "=", "15", ")", ":", "nb_day", "=", "15", "# number of day to generate time series", "timeinterval_min", "=", "5", "# create an event every x minutes", "total_minutes", "=", "...
Instantiate a connection to the backend.
[ "Instantiate", "a", "connection", "to", "the", "backend", "." ]
python
train
32.660714
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L377-L389
def add_private_note(self, private_notes, source=None): """Add private notes. :param private_notes: hidden notes for the current document :type private_notes: string :param source: source for the given private notes :type source: string """ self._append_to('_pri...
[ "def", "add_private_note", "(", "self", ",", "private_notes", ",", "source", "=", "None", ")", ":", "self", ".", "_append_to", "(", "'_private_notes'", ",", "self", ".", "_sourced_dict", "(", "source", ",", "value", "=", "private_notes", ",", ")", ")" ]
Add private notes. :param private_notes: hidden notes for the current document :type private_notes: string :param source: source for the given private notes :type source: string
[ "Add", "private", "notes", "." ]
python
train
31.076923
StackStorm/pybind
pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/lsp/secondary_path/lsp_secpath_auto_bandwidth/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/lsp/secondary_path/lsp_secpath_auto_bandwidth/__init__.py#L99-L120
def _set_lsp_secpath_autobw_template(self, v, load=False): """ Setter method for lsp_secpath_autobw_template, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/lsp/secondary_path/lsp_secpath_auto_bandwidth/lsp_secpath_autobw_template (leafref) If this variable is read-only (config: false) ...
[ "def", "_set_lsp_secpath_autobw_template", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "...
Setter method for lsp_secpath_autobw_template, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/lsp/secondary_path/lsp_secpath_auto_bandwidth/lsp_secpath_autobw_template (leafref) If this variable is read-only (config: false) in the source YANG file, then _set_lsp_secpath_autobw_template is c...
[ "Setter", "method", "for", "lsp_secpath_autobw_template", "mapped", "from", "YANG", "variable", "/", "mpls_config", "/", "router", "/", "mpls", "/", "mpls_cmds_holder", "/", "lsp", "/", "secondary_path", "/", "lsp_secpath_auto_bandwidth", "/", "lsp_secpath_autobw_templa...
python
train
101.727273
orbingol/NURBS-Python
geomdl/exchange.py
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L745-L773
def import_smesh(file): """ Generates NURBS surface(s) from surface mesh (smesh) file(s). *smesh* files are some text files which contain a set of NURBS surfaces. Each file in the set corresponds to one NURBS surface. Most of the time, you receive multiple *smesh* files corresponding to an complete object ...
[ "def", "import_smesh", "(", "file", ")", ":", "imported_elements", "=", "[", "]", "if", "os", ".", "path", ".", "isfile", "(", "file", ")", ":", "imported_elements", ".", "append", "(", "exch", ".", "import_surf_mesh", "(", "file", ")", ")", "elif", "o...
Generates NURBS surface(s) from surface mesh (smesh) file(s). *smesh* files are some text files which contain a set of NURBS surfaces. Each file in the set corresponds to one NURBS surface. Most of the time, you receive multiple *smesh* files corresponding to an complete object composed of several NURBS su...
[ "Generates", "NURBS", "surface", "(", "s", ")", "from", "surface", "mesh", "(", "smesh", ")", "file", "(", "s", ")", "." ]
python
train
43.586207
QunarOPS/qg.core
qg/core/gettextutils.py
https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L163-L188
def translate(self, desired_locale=None): """Translate this message to the desired locale. :param desired_locale: The desired locale to translate the message to, if no locale is provided the message will be translated to the system's default...
[ "def", "translate", "(", "self", ",", "desired_locale", "=", "None", ")", ":", "translated_message", "=", "Message", ".", "_translate_msgid", "(", "self", ".", "msgid", ",", "self", ".", "domain", ",", "desired_locale", ")", "if", "self", ".", "params", "i...
Translate this message to the desired locale. :param desired_locale: The desired locale to translate the message to, if no locale is provided the message will be translated to the system's default locale. :returns: the translated message in...
[ "Translate", "this", "message", "to", "the", "desired", "locale", "." ]
python
train
45.038462
bspaans/python-mingus
mingus/extra/tablature.py
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L424-L431
def _get_qsize(tuning, width): """Return a reasonable quarter note size for 'tuning' and 'width'.""" names = [x.to_shorthand() for x in tuning.tuning] basesize = len(max(names)) + 3 barsize = ((width - basesize) - 2) - 1 # x * 4 + 0.5x - barsize = 0 4.5x = barsize x = barsize / 4.5 return max(0...
[ "def", "_get_qsize", "(", "tuning", ",", "width", ")", ":", "names", "=", "[", "x", ".", "to_shorthand", "(", ")", "for", "x", "in", "tuning", ".", "tuning", "]", "basesize", "=", "len", "(", "max", "(", "names", ")", ")", "+", "3", "barsize", "=...
Return a reasonable quarter note size for 'tuning' and 'width'.
[ "Return", "a", "reasonable", "quarter", "note", "size", "for", "tuning", "and", "width", "." ]
python
train
41.75
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1716-L1756
def draw_rubberband(self, event, x0, y0, x1, y1): 'adapted from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744' canvas = self.canvas dc =wx.ClientDC(canvas) # Set logical function to XOR for rubberbanding dc.SetLogicalFunction(wx.XOR) # Set dc brush and ...
[ "def", "draw_rubberband", "(", "self", ",", "event", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "canvas", "=", "self", ".", "canvas", "dc", "=", "wx", ".", "ClientDC", "(", "canvas", ")", "# Set logical function to XOR for rubberbanding", "dc", ...
adapted from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744
[ "adapted", "from", "http", ":", "//", "aspn", ".", "activestate", ".", "com", "/", "ASPN", "/", "Cookbook", "/", "Python", "/", "Recipe", "/", "189744" ]
python
train
30.585366
mitsei/dlkit
dlkit/json_/relationship/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/relationship/managers.py#L645-L662
def get_family_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the family lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyLookupSession) - a ``FamilyLookupSession`` raise: NullArgument - ``proxy`` is ``...
[ "def", "get_family_lookup_session", "(", "self", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_family_lookup", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "FamilyLookupSe...
Gets the ``OsidSession`` associated with the family lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyLookupSession) - a ``FamilyLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to comp...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "family", "lookup", "service", "." ]
python
train
44.166667
amol-/tgext.mailer
tgext/mailer/mailer.py
https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/mailer.py#L40-L48
def _send(self, message, fail_silently=False): """Save message to a file for debugging """ seeds = '1234567890qwertyuiopasdfghjklzxcvbnm' file_part1 = datetime.now().strftime('%Y%m%d%H%M%S') file_part2 = ''.join(sample(seeds, 4)) filename = join(self.tld, '%s_%s.msg' % (f...
[ "def", "_send", "(", "self", ",", "message", ",", "fail_silently", "=", "False", ")", ":", "seeds", "=", "'1234567890qwertyuiopasdfghjklzxcvbnm'", "file_part1", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y%m%d%H%M%S'", ")", "file_part2", "...
Save message to a file for debugging
[ "Save", "message", "to", "a", "file", "for", "debugging" ]
python
train
47
Unity-Technologies/ml-agents
ml-agents/mlagents/trainers/ppo/policy.py
https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/ppo/policy.py#L63-L87
def evaluate(self, brain_info): """ Evaluates policy for the agent experiences provided. :param brain_info: BrainInfo object containing inputs. :return: Outputs from network as defined by self.inference_dict. """ feed_dict = {self.model.batch_size: len(brain_info.vector_o...
[ "def", "evaluate", "(", "self", ",", "brain_info", ")", ":", "feed_dict", "=", "{", "self", ".", "model", ".", "batch_size", ":", "len", "(", "brain_info", ".", "vector_observations", ")", ",", "self", ".", "model", ".", "sequence_length", ":", "1", "}",...
Evaluates policy for the agent experiences provided. :param brain_info: BrainInfo object containing inputs. :return: Outputs from network as defined by self.inference_dict.
[ "Evaluates", "policy", "for", "the", "agent", "experiences", "provided", ".", ":", "param", "brain_info", ":", "BrainInfo", "object", "containing", "inputs", ".", ":", "return", ":", "Outputs", "from", "network", "as", "defined", "by", "self", ".", "inference_...
python
train
50.72