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
ChargePoint/pydnp3
examples/master.py
https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master.py#L247-L256
def collection_callback(result=None): """ :type result: opendnp3.CommandPointResult """ print("Header: {0} | Index: {1} | State: {2} | Status: {3}".format( result.headerIndex, result.index, opendnp3.CommandPointStateToString(result.state), opendnp3.CommandStatusToString...
[ "def", "collection_callback", "(", "result", "=", "None", ")", ":", "print", "(", "\"Header: {0} | Index: {1} | State: {2} | Status: {3}\"", ".", "format", "(", "result", ".", "headerIndex", ",", "result", ".", "index", ",", "opendnp3", ".", "CommandPointStateToStri...
:type result: opendnp3.CommandPointResult
[ ":", "type", "result", ":", "opendnp3", ".", "CommandPointResult" ]
python
valid
33.3
rigetti/pyquil
pyquil/pyqvm.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/pyqvm.py#L319-L333
def find_label(self, label: Label): """ Helper function that iterates over the program and looks for a JumpTarget that has a Label matching the input label. :param label: Label object to search for in program :return: Program index where ``label`` is found """ fo...
[ "def", "find_label", "(", "self", ",", "label", ":", "Label", ")", ":", "for", "index", ",", "action", "in", "enumerate", "(", "self", ".", "program", ")", ":", "if", "isinstance", "(", "action", ",", "JumpTarget", ")", ":", "if", "label", "==", "act...
Helper function that iterates over the program and looks for a JumpTarget that has a Label matching the input label. :param label: Label object to search for in program :return: Program index where ``label`` is found
[ "Helper", "function", "that", "iterates", "over", "the", "program", "and", "looks", "for", "a", "JumpTarget", "that", "has", "a", "Label", "matching", "the", "input", "label", "." ]
python
train
39.666667
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L2335-L2361
def wallet_contains(self, wallet, account): """ Check whether **wallet** contains **account** :param wallet: Wallet to check contains **account** :type wallet: str :param account: Account to check exists in **wallet** :type account: str :raises: :py:exc:`nano.r...
[ "def", "wallet_contains", "(", "self", ",", "wallet", ",", "account", ")", ":", "wallet", "=", "self", ".", "_process_value", "(", "wallet", ",", "'wallet'", ")", "account", "=", "self", ".", "_process_value", "(", "account", ",", "'account'", ")", "payloa...
Check whether **wallet** contains **account** :param wallet: Wallet to check contains **account** :type wallet: str :param account: Account to check exists in **wallet** :type account: str :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.wallet_contains( ... ...
[ "Check", "whether", "**", "wallet", "**", "contains", "**", "account", "**" ]
python
train
30.703704
googleapis/google-cloud-python
logging/google/cloud/logging/entries.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/entries.py#L287-L292
def to_api_repr(self): """API repr (JSON format) for entry. """ info = super(TextEntry, self).to_api_repr() info["textPayload"] = self.payload return info
[ "def", "to_api_repr", "(", "self", ")", ":", "info", "=", "super", "(", "TextEntry", ",", "self", ")", ".", "to_api_repr", "(", ")", "info", "[", "\"textPayload\"", "]", "=", "self", ".", "payload", "return", "info" ]
API repr (JSON format) for entry.
[ "API", "repr", "(", "JSON", "format", ")", "for", "entry", "." ]
python
train
31.5
DataDog/integrations-core
network/datadog_checks/network/network.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/network/datadog_checks/network/network.py#L733-L742
def _check_psutil(self, instance): """ Gather metrics about connections states and interfaces counters using psutil facilities """ custom_tags = instance.get('tags', []) if self._collect_cx_state: self._cx_state_psutil(tags=custom_tags) self._cx_count...
[ "def", "_check_psutil", "(", "self", ",", "instance", ")", ":", "custom_tags", "=", "instance", ".", "get", "(", "'tags'", ",", "[", "]", ")", "if", "self", ".", "_collect_cx_state", ":", "self", ".", "_cx_state_psutil", "(", "tags", "=", "custom_tags", ...
Gather metrics about connections states and interfaces counters using psutil facilities
[ "Gather", "metrics", "about", "connections", "states", "and", "interfaces", "counters", "using", "psutil", "facilities" ]
python
train
33.9
h2oai/h2o-3
h2o-bindings/bin/pymagic.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-bindings/bin/pymagic.py#L24-L32
def locate_files(root_dir): """Find all python files in the given directory and all subfolders.""" all_files = [] root_dir = os.path.abspath(root_dir) for dir_name, subdirs, files in os.walk(root_dir): for f in files: if f.endswith(".py"): all_files.append(os.path.joi...
[ "def", "locate_files", "(", "root_dir", ")", ":", "all_files", "=", "[", "]", "root_dir", "=", "os", ".", "path", ".", "abspath", "(", "root_dir", ")", "for", "dir_name", ",", "subdirs", ",", "files", "in", "os", ".", "walk", "(", "root_dir", ")", ":...
Find all python files in the given directory and all subfolders.
[ "Find", "all", "python", "files", "in", "the", "given", "directory", "and", "all", "subfolders", "." ]
python
test
38.666667
mayfield/shellish
shellish/rendering/html.py
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/html.py#L223-L226
def htmlprint(*values, plain=None, **options): """ Convert HTML to VTML and then print it. Follows same semantics as vtmlprint. """ print(*[htmlrender(x, plain=plain) for x in values], **options)
[ "def", "htmlprint", "(", "*", "values", ",", "plain", "=", "None", ",", "*", "*", "options", ")", ":", "print", "(", "*", "[", "htmlrender", "(", "x", ",", "plain", "=", "plain", ")", "for", "x", "in", "values", "]", ",", "*", "*", "options", "...
Convert HTML to VTML and then print it. Follows same semantics as vtmlprint.
[ "Convert", "HTML", "to", "VTML", "and", "then", "print", "it", ".", "Follows", "same", "semantics", "as", "vtmlprint", "." ]
python
train
51
hearsaycorp/normalize
normalize/selector.py
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/selector.py#L837-L862
def delete(self, obj, force=False): """Deletes all of the fields at the specified locations. args: ``obj=``\ *OBJECT* the object to remove the fields from ``force=``\ *BOOL* if True, missing attributes do not raise errors. Otherwise, ...
[ "def", "delete", "(", "self", ",", "obj", ",", "force", "=", "False", ")", ":", "# TODO: this could be a whole lot more efficient!", "if", "not", "force", ":", "for", "fs", "in", "self", ":", "try", ":", "fs", ".", "get", "(", "obj", ")", "except", "Fiel...
Deletes all of the fields at the specified locations. args: ``obj=``\ *OBJECT* the object to remove the fields from ``force=``\ *BOOL* if True, missing attributes do not raise errors. Otherwise, the first failure raises an exception wit...
[ "Deletes", "all", "of", "the", "fields", "at", "the", "specified", "locations", "." ]
python
train
29.846154
mohamedattahri/PyXMLi
pyxmli/__init__.py
https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/__init__.py#L1289-L1298
def compute_discounts(self, precision=None): ''' Returns the total amount of discounts for this line with a specific number of decimals. @param precision:int number of decimal places @return: Decimal ''' gross = self.compute_gross(precision) return min(gro...
[ "def", "compute_discounts", "(", "self", ",", "precision", "=", "None", ")", ":", "gross", "=", "self", ".", "compute_gross", "(", "precision", ")", "return", "min", "(", "gross", ",", "sum", "(", "[", "d", ".", "compute", "(", "gross", ",", "precision...
Returns the total amount of discounts for this line with a specific number of decimals. @param precision:int number of decimal places @return: Decimal
[ "Returns", "the", "total", "amount", "of", "discounts", "for", "this", "line", "with", "a", "specific", "number", "of", "decimals", "." ]
python
train
39.5
openbermuda/ripl
ripl/md2py.py
https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/md2py.py#L57-L116
def generate_records(self, infile): """ Process a file of rest and yield dictionaries """ state = 0 record = {} for item in self.generate_lines(infile): line = item['line'] heading = item['heading'] # any Markdown heading is just a capt...
[ "def", "generate_records", "(", "self", ",", "infile", ")", ":", "state", "=", "0", "record", "=", "{", "}", "for", "item", "in", "self", ".", "generate_lines", "(", "infile", ")", ":", "line", "=", "item", "[", "'line'", "]", "heading", "=", "item",...
Process a file of rest and yield dictionaries
[ "Process", "a", "file", "of", "rest", "and", "yield", "dictionaries" ]
python
train
24.133333
secdev/scapy
scapy/packet.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1761-L1849
def ls(obj=None, case_sensitive=False, verbose=False): """List available layers, or infos on a given layer class or name. params: - obj: Packet / packet name to use - case_sensitive: if obj is a string, is it case sensitive? - verbose """ is_string = isinstance(obj, six.string_types) ...
[ "def", "ls", "(", "obj", "=", "None", ",", "case_sensitive", "=", "False", ",", "verbose", "=", "False", ")", ":", "is_string", "=", "isinstance", "(", "obj", ",", "six", ".", "string_types", ")", "if", "obj", "is", "None", "or", "is_string", ":", "t...
List available layers, or infos on a given layer class or name. params: - obj: Packet / packet name to use - case_sensitive: if obj is a string, is it case sensitive? - verbose
[ "List", "available", "layers", "or", "infos", "on", "a", "given", "layer", "class", "or", "name", ".", "params", ":", "-", "obj", ":", "Packet", "/", "packet", "name", "to", "use", "-", "case_sensitive", ":", "if", "obj", "is", "a", "string", "is", "...
python
train
47.033708
kowalpy/Robot-Framework-FTP-Library
FtpLibrary.py
https://github.com/kowalpy/Robot-Framework-FTP-Library/blob/90794be0a12af489ac98e8ae3b4ff450c83e2f3d/FtpLibrary.py#L119-L160
def ftp_connect(self, host, user='anonymous', password='anonymous@', port=21, timeout=30, connId='default'): """ Constructs FTP object, opens a connection and login. Call this function before any other (otherwise raises exception). Returns server output. Parameters: -...
[ "def", "ftp_connect", "(", "self", ",", "host", ",", "user", "=", "'anonymous'", ",", "password", "=", "'anonymous@'", ",", "port", "=", "21", ",", "timeout", "=", "30", ",", "connId", "=", "'default'", ")", ":", "if", "connId", "in", "self", ".", "f...
Constructs FTP object, opens a connection and login. Call this function before any other (otherwise raises exception). Returns server output. Parameters: - host - server host address - user(optional) - FTP user name. If not given, 'anonymous' is used. - passwo...
[ "Constructs", "FTP", "object", "opens", "a", "connection", "and", "login", ".", "Call", "this", "function", "before", "any", "other", "(", "otherwise", "raises", "exception", ")", ".", "Returns", "server", "output", ".", "Parameters", ":", "-", "host", "-", ...
python
train
50.238095
svasilev94/GraphLibrary
graphlibrary/first_search.py
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/first_search.py#L54-L92
def DFS(G): """ Algorithm for depth-first searching the vertices of a graph. """ if not G.vertices: raise GraphInsertError("This graph have no vertices.") color = {} pred = {} reach = {} finish = {} def DFSvisit(G, current, time): color[current] = 'grey' ...
[ "def", "DFS", "(", "G", ")", ":", "if", "not", "G", ".", "vertices", ":", "raise", "GraphInsertError", "(", "\"This graph have no vertices.\"", ")", "color", "=", "{", "}", "pred", "=", "{", "}", "reach", "=", "{", "}", "finish", "=", "{", "}", "def"...
Algorithm for depth-first searching the vertices of a graph.
[ "Algorithm", "for", "depth", "-", "first", "searching", "the", "vertices", "of", "a", "graph", "." ]
python
train
29.615385
belbio/bel
bel/nanopub/nanopubs.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/nanopub/nanopubs.py#L108-L138
def bel_edges( self, nanopub: Mapping[str, Any], namespace_targets: Mapping[str, List[str]] = {}, rules: List[str] = [], orthologize_target: str = None, ) -> List[Mapping[str, Any]]: """Create BEL Edges from BEL nanopub Args: nanopub (Mapping[str,...
[ "def", "bel_edges", "(", "self", ",", "nanopub", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "namespace_targets", ":", "Mapping", "[", "str", ",", "List", "[", "str", "]", "]", "=", "{", "}", ",", "rules", ":", "List", "[", "str", "]", "=",...
Create BEL Edges from BEL nanopub Args: nanopub (Mapping[str, Any]): bel nanopub namespace_targets (Mapping[str, List[str]]): what namespaces to canonicalize rules (List[str]): which computed edge rules to process, default is all, look at BEL Specification yam...
[ "Create", "BEL", "Edges", "from", "BEL", "nanopub" ]
python
train
38.419355
loli/medpy
medpy/metric/histogram.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L139-L190
def chebyshev(h1, h2): # 12 us @array, 36 us @list \w 100 bins r""" Chebyshev distance. Also Tchebychev distance, Maximum or :math:`L_{\infty}` metric; equal to Minowski distance with :math:`p=+\infty`. For the case of :math:`p=-\infty`, use `chebyshev_neg`. The Chebyshev distance between ...
[ "def", "chebyshev", "(", "h1", ",", "h2", ")", ":", "# 12 us @array, 36 us @list \\w 100 bins", "h1", ",", "h2", "=", "__prepare_histogram", "(", "h1", ",", "h2", ")", "return", "max", "(", "scipy", ".", "absolute", "(", "h1", "-", "h2", ")", ")" ]
r""" Chebyshev distance. Also Tchebychev distance, Maximum or :math:`L_{\infty}` metric; equal to Minowski distance with :math:`p=+\infty`. For the case of :math:`p=-\infty`, use `chebyshev_neg`. The Chebyshev distance between two histograms :math:`H` and :math:`H'` of size :math:`m` is de...
[ "r", "Chebyshev", "distance", ".", "Also", "Tchebychev", "distance", "Maximum", "or", ":", "math", ":", "L_", "{", "\\", "infty", "}", "metric", ";", "equal", "to", "Minowski", "distance", "with", ":", "math", ":", "p", "=", "+", "\\", "infty", ".", ...
python
train
23.615385
vtkiorg/vtki
vtki/plotting.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/plotting.py#L1546-L1557
def _update_axes_color(self, color): """Internal helper to set the axes label color""" prop_x = self.axes_actor.GetXAxisCaptionActor2D().GetCaptionTextProperty() prop_y = self.axes_actor.GetYAxisCaptionActor2D().GetCaptionTextProperty() prop_z = self.axes_actor.GetZAxisCaptionActor2D().G...
[ "def", "_update_axes_color", "(", "self", ",", "color", ")", ":", "prop_x", "=", "self", ".", "axes_actor", ".", "GetXAxisCaptionActor2D", "(", ")", ".", "GetCaptionTextProperty", "(", ")", "prop_y", "=", "self", ".", "axes_actor", ".", "GetYAxisCaptionActor2D",...
Internal helper to set the axes label color
[ "Internal", "helper", "to", "set", "the", "axes", "label", "color" ]
python
train
49.166667
JustinLovinger/optimal
optimal/common.py
https://github.com/JustinLovinger/optimal/blob/ab48a4961697338cc32d50e3a6b06ac989e39c3f/optimal/common.py#L42-L46
def make_population(population_size, solution_generator, *args, **kwargs): """Make a population with the supplied generator.""" return [ solution_generator(*args, **kwargs) for _ in range(population_size) ]
[ "def", "make_population", "(", "population_size", ",", "solution_generator", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "[", "solution_generator", "(", "*", "args", ",", "*", "*", "kwargs", ")", "for", "_", "in", "range", "(", "popula...
Make a population with the supplied generator.
[ "Make", "a", "population", "with", "the", "supplied", "generator", "." ]
python
train
44.4
fhcrc/taxtastic
taxtastic/taxtable.py
https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/taxtable.py#L130-L141
def depth_first_iter(self, self_first=True): """ Iterate over nodes below this node, optionally yielding children before self. """ if self_first: yield self for child in list(self.children): for i in child.depth_first_iter(self_first): ...
[ "def", "depth_first_iter", "(", "self", ",", "self_first", "=", "True", ")", ":", "if", "self_first", ":", "yield", "self", "for", "child", "in", "list", "(", "self", ".", "children", ")", ":", "for", "i", "in", "child", ".", "depth_first_iter", "(", "...
Iterate over nodes below this node, optionally yielding children before self.
[ "Iterate", "over", "nodes", "below", "this", "node", "optionally", "yielding", "children", "before", "self", "." ]
python
train
30.833333
gem/oq-engine
openquake/hazardlib/gsim/sharma_2009.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sharma_2009.py#L167-L174
def get_site_type_dummy_variables(self, sites): """ Binary rock/soil classification dummy variable based on sites.vs30. "``S`` is 1 for a rock site and 0 otherwise" (p. 1201). """ is_rock = np.array(sites.vs30 > self.NEHRP_BC_BOUNDARY) return is_rock
[ "def", "get_site_type_dummy_variables", "(", "self", ",", "sites", ")", ":", "is_rock", "=", "np", ".", "array", "(", "sites", ".", "vs30", ">", "self", ".", "NEHRP_BC_BOUNDARY", ")", "return", "is_rock" ]
Binary rock/soil classification dummy variable based on sites.vs30. "``S`` is 1 for a rock site and 0 otherwise" (p. 1201).
[ "Binary", "rock", "/", "soil", "classification", "dummy", "variable", "based", "on", "sites", ".", "vs30", "." ]
python
train
36.5
senaite/senaite.core
bika/lims/content/analysisprofile.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/analysisprofile.py#L212-L235
def remove_service(self, service): """Removes the service passed in from the services offered by the current Profile. If the Analysis Service passed in is not assigned to this Analysis Profile, returns False. :param service: the service to be removed from this Analysis Profile :t...
[ "def", "remove_service", "(", "self", ",", "service", ")", ":", "obj", "=", "api", ".", "get_object", "(", "service", ")", "uid", "=", "api", ".", "get_uid", "(", "obj", ")", "# Remove the service from the referenced services", "services", "=", "self", ".", ...
Removes the service passed in from the services offered by the current Profile. If the Analysis Service passed in is not assigned to this Analysis Profile, returns False. :param service: the service to be removed from this Analysis Profile :type service: AnalysisService :return: ...
[ "Removes", "the", "service", "passed", "in", "from", "the", "services", "offered", "by", "the", "current", "Profile", ".", "If", "the", "Analysis", "Service", "passed", "in", "is", "not", "assigned", "to", "this", "Analysis", "Profile", "returns", "False", "...
python
train
40.916667
gabstopper/smc-python
smc/base/model.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/base/model.py#L506-L520
def get(cls, name, raise_exc=True): """ Get the element by name. Does an exact match by element type. :param str name: name of element :param bool raise_exc: optionally disable exception. :raises ElementNotFound: if element does not exist :rtype: Element ...
[ "def", "get", "(", "cls", ",", "name", ",", "raise_exc", "=", "True", ")", ":", "element", "=", "cls", ".", "objects", ".", "filter", "(", "name", ",", "exact_match", "=", "True", ")", ".", "first", "(", ")", "if", "name", "is", "not", "None", "e...
Get the element by name. Does an exact match by element type. :param str name: name of element :param bool raise_exc: optionally disable exception. :raises ElementNotFound: if element does not exist :rtype: Element
[ "Get", "the", "element", "by", "name", ".", "Does", "an", "exact", "match", "by", "element", "type", ".", ":", "param", "str", "name", ":", "name", "of", "element", ":", "param", "bool", "raise_exc", ":", "optionally", "disable", "exception", ".", ":", ...
python
train
40.466667
Rockhopper-Technologies/enlighten
enlighten/_counter.py
https://github.com/Rockhopper-Technologies/enlighten/blob/857855f940e6c1bb84d0be849b999a18fff5bf5a/enlighten/_counter.py#L509-L518
def clear(self, flush=True): """ Args: flush(bool): Flush stream after clearing progress bar (Default:True) Clear progress bar """ if self.enabled: self.manager.write(flush=flush, position=self.position)
[ "def", "clear", "(", "self", ",", "flush", "=", "True", ")", ":", "if", "self", ".", "enabled", ":", "self", ".", "manager", ".", "write", "(", "flush", "=", "flush", ",", "position", "=", "self", ".", "position", ")" ]
Args: flush(bool): Flush stream after clearing progress bar (Default:True) Clear progress bar
[ "Args", ":", "flush", "(", "bool", ")", ":", "Flush", "stream", "after", "clearing", "progress", "bar", "(", "Default", ":", "True", ")" ]
python
train
26
AoiKuiyuyou/AoikLiveReload
tools/waf/aoikwafutil.py
https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/tools/waf/aoikwafutil.py#L1373-L1485
def build_ctx(pythonpath=None): """ Decorator that makes decorated function use BuildContext instead of \ Context instance. BuildContext instance has more methods. :param pythonpath: Path or list of paths to add to environment variable PYTHONPATH. Each path can be absolute path, or relative pat...
[ "def", "build_ctx", "(", "pythonpath", "=", "None", ")", ":", "# If argument `pythonpath` is string", "if", "isinstance", "(", "pythonpath", ",", "str", ")", ":", "# Create paths list containing the string", "path_s", "=", "[", "pythonpath", "]", "# If argument `pythonp...
Decorator that makes decorated function use BuildContext instead of \ Context instance. BuildContext instance has more methods. :param pythonpath: Path or list of paths to add to environment variable PYTHONPATH. Each path can be absolute path, or relative path relative to top directory. ...
[ "Decorator", "that", "makes", "decorated", "function", "use", "BuildContext", "instead", "of", "\\", "Context", "instance", ".", "BuildContext", "instance", "has", "more", "methods", "." ]
python
train
31.389381
saltstack/salt
salt/utils/stringutils.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/stringutils.py#L540-L572
def get_context(template, line, num_lines=5, marker=None): ''' Returns debugging context around a line in a given string Returns:: string ''' template_lines = template.splitlines() num_template_lines = len(template_lines) # In test mode, a single line template would return a crazy line num...
[ "def", "get_context", "(", "template", ",", "line", ",", "num_lines", "=", "5", ",", "marker", "=", "None", ")", ":", "template_lines", "=", "template", ".", "splitlines", "(", ")", "num_template_lines", "=", "len", "(", "template_lines", ")", "# In test mod...
Returns debugging context around a line in a given string Returns:: string
[ "Returns", "debugging", "context", "around", "a", "line", "in", "a", "given", "string" ]
python
train
31.272727
aws/aws-encryption-sdk-python
src/aws_encryption_sdk/streaming_client.py
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L494-L527
def _prep_non_framed(self): """Prepare the opening data for a non-framed message.""" try: plaintext_length = self.stream_length self.__unframed_plaintext_cache = self.source_stream except NotSupportedError: # We need to know the plaintext length before we can ...
[ "def", "_prep_non_framed", "(", "self", ")", ":", "try", ":", "plaintext_length", "=", "self", ".", "stream_length", "self", ".", "__unframed_plaintext_cache", "=", "self", ".", "source_stream", "except", "NotSupportedError", ":", "# We need to know the plaintext length...
Prepare the opening data for a non-framed message.
[ "Prepare", "the", "opening", "data", "for", "a", "non", "-", "framed", "message", "." ]
python
train
45.647059
happyleavesaoc/python-firetv
firetv/__main__.py
https://github.com/happyleavesaoc/python-firetv/blob/3dd953376c0d5af502e775ae14ed0afe03224781/firetv/__main__.py#L117-L125
def list_devices(): """ List devices via HTTP GET. """ output = {} for device_id, device in devices.items(): output[device_id] = { 'host': device.host, 'state': device.state } return jsonify(devices=output)
[ "def", "list_devices", "(", ")", ":", "output", "=", "{", "}", "for", "device_id", ",", "device", "in", "devices", ".", "items", "(", ")", ":", "output", "[", "device_id", "]", "=", "{", "'host'", ":", "device", ".", "host", ",", "'state'", ":", "d...
List devices via HTTP GET.
[ "List", "devices", "via", "HTTP", "GET", "." ]
python
train
28.222222
coursera-dl/coursera-dl
coursera/api.py
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1526-L1561
def _extract_links_from_asset_tags_in_text(self, text): """ Scan the text and extract asset tags and links to corresponding files. @param text: Page text. @type text: str @return: @see CourseraOnDemand._extract_links_from_text """ # Extract asset tags fr...
[ "def", "_extract_links_from_asset_tags_in_text", "(", "self", ",", "text", ")", ":", "# Extract asset tags from instructions text", "asset_tags_map", "=", "self", ".", "_extract_asset_tags", "(", "text", ")", "ids", "=", "list", "(", "iterkeys", "(", "asset_tags_map", ...
Scan the text and extract asset tags and links to corresponding files. @param text: Page text. @type text: str @return: @see CourseraOnDemand._extract_links_from_text
[ "Scan", "the", "text", "and", "extract", "asset", "tags", "and", "links", "to", "corresponding", "files", "." ]
python
train
35.25
theno/fabsetup
fabsetup/fabfile/setup/service/__init__.py
https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/service/__init__.py#L237-L268
def lms(): '''Install and start a Logitech Media Server (lms). More infos: * http://wiki.slimdevices.com/index.php/Logitech_Media_Server * http://wiki.slimdevices.com/index.php/DebianPackage * http://www.mysqueezebox.com/download * XSqueeze on Kodi: * http://kodi.wiki/view/Add-on:XSq...
[ "def", "lms", "(", ")", ":", "# cf. http://wiki.slimdevices.com/index.php/DebianPackage#installing_7.9.0", "cmds", "=", "'''\\\nurl=\"http://www.mysqueezebox.com/update/?version=7.9.0&revision=1&geturl=1&os=deb\"\nlatest_lms=$(wget -q -O - \"$url\")\nmkdir -p ~/.logitech_media_server_sources\ncd ~/....
Install and start a Logitech Media Server (lms). More infos: * http://wiki.slimdevices.com/index.php/Logitech_Media_Server * http://wiki.slimdevices.com/index.php/DebianPackage * http://www.mysqueezebox.com/download * XSqueeze on Kodi: * http://kodi.wiki/view/Add-on:XSqueeze * htt...
[ "Install", "and", "start", "a", "Logitech", "Media", "Server", "(", "lms", ")", "." ]
python
train
37.65625
guma44/GEOparse
GEOparse/GEOTypes.py
https://github.com/guma44/GEOparse/blob/7ee8d5b8678d780382a6bf884afa69d2033f5ca0/GEOparse/GEOTypes.py#L897-L964
def download_SRA(self, email, directory='series', filterby=None, nproc=1, **kwargs): """Download SRA files for each GSM in series. .. warning:: Do not use parallel option (nproc > 1) in the interactive shell. For more details see `this issue <https://stacko...
[ "def", "download_SRA", "(", "self", ",", "email", ",", "directory", "=", "'series'", ",", "filterby", "=", "None", ",", "nproc", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "directory", "==", "'series'", ":", "dirpath", "=", "os", ".", "path",...
Download SRA files for each GSM in series. .. warning:: Do not use parallel option (nproc > 1) in the interactive shell. For more details see `this issue <https://stackoverflow.com/questions/23641475/multiprocessing-working-in-python-but-not-in-ipython/23641560#23641560>`_ ...
[ "Download", "SRA", "files", "for", "each", "GSM", "in", "series", "." ]
python
train
42.132353
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L102-L147
def analyze_event_rate(scan_base, combine_n_readouts=1000, time_line_absolute=True, output_pdf=None, output_file=None): ''' Determines the number of events as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The number of events is taken from the meta data i...
[ "def", "analyze_event_rate", "(", "scan_base", ",", "combine_n_readouts", "=", "1000", ",", "time_line_absolute", "=", "True", ",", "output_pdf", "=", "None", ",", "output_file", "=", "None", ")", ":", "time_stamp", "=", "[", "]", "rate", "=", "[", "]", "s...
Determines the number of events as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The number of events is taken from the meta data info and stored into a pdf file. Parameters ---------- scan_base: list of str scan base names (e.g.: ['...
[ "Determines", "the", "number", "of", "events", "as", "a", "function", "of", "time", ".", "Therefore", "the", "data", "of", "a", "fixed", "number", "of", "read", "outs", "are", "combined", "(", "combine_n_readouts", ")", ".", "The", "number", "of", "events"...
python
train
57.586957
gem/oq-engine
openquake/risklib/scientific.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L935-L977
def classical_damage( fragility_functions, hazard_imls, hazard_poes, investigation_time, risk_investigation_time): """ :param fragility_functions: a list of fragility functions for each damage state :param hazard_imls: Intensity Measure Levels :param hazard_poes: ...
[ "def", "classical_damage", "(", "fragility_functions", ",", "hazard_imls", ",", "hazard_poes", ",", "investigation_time", ",", "risk_investigation_time", ")", ":", "spi", "=", "fragility_functions", ".", "steps_per_interval", "if", "spi", "and", "spi", ">", "1", ":"...
:param fragility_functions: a list of fragility functions for each damage state :param hazard_imls: Intensity Measure Levels :param hazard_poes: hazard curve :param investigation_time: hazard investigation time :param risk_investigation_time: risk investigation ti...
[ ":", "param", "fragility_functions", ":", "a", "list", "of", "fragility", "functions", "for", "each", "damage", "state", ":", "param", "hazard_imls", ":", "Intensity", "Measure", "Levels", ":", "param", "hazard_poes", ":", "hazard", "curve", ":", "param", "inv...
python
train
41.790698
pydata/xarray
xarray/core/computation.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/computation.py#L104-L117
def to_gufunc_string(self): """Create an equivalent signature string for a NumPy gufunc. Unlike __str__, handles dimensions that don't map to Python identifiers. """ all_dims = self.all_core_dims dims_map = dict(zip(sorted(all_dims), range(len(all_dims)))) input_...
[ "def", "to_gufunc_string", "(", "self", ")", ":", "all_dims", "=", "self", ".", "all_core_dims", "dims_map", "=", "dict", "(", "zip", "(", "sorted", "(", "all_dims", ")", ",", "range", "(", "len", "(", "all_dims", ")", ")", ")", ")", "input_core_dims", ...
Create an equivalent signature string for a NumPy gufunc. Unlike __str__, handles dimensions that don't map to Python identifiers.
[ "Create", "an", "equivalent", "signature", "string", "for", "a", "NumPy", "gufunc", "." ]
python
train
48.5
saltstack/salt
salt/modules/aws_sqs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aws_sqs.py#L217-L264
def delete_queue(name, region, opts=None, user=None): ''' Deletes a queue in the region. name Name of the SQS queue to deletes region Name of the region to delete the queue from opts : None Any additional options to add to the command line user : None Run hg as...
[ "def", "delete_queue", "(", "name", ",", "region", ",", "opts", "=", "None", ",", "user", "=", "None", ")", ":", "queues", "=", "list_queues", "(", "region", ",", "opts", ",", "user", ")", "url_map", "=", "_parse_queue_list", "(", "queues", ")", "log",...
Deletes a queue in the region. name Name of the SQS queue to deletes region Name of the region to delete the queue from opts : None Any additional options to add to the command line user : None Run hg as a user other than what the minion runs as CLI Example: ...
[ "Deletes", "a", "queue", "in", "the", "region", "." ]
python
train
21.291667
danilobellini/audiolazy
examples/pi.py
https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/examples/pi.py#L24-L38
def mgl_seq(x): """ Sequence whose sum is the Madhava-Gregory-Leibniz series. [x, -x^3/3, x^5/5, -x^7/7, x^9/9, -x^11/11, ...] Returns ------- An endless sequence that has the property ``atan(x) = sum(mgl_seq(x))``. Usually you would use the ``atan()`` function, not this one. """ odd_num...
[ "def", "mgl_seq", "(", "x", ")", ":", "odd_numbers", "=", "thub", "(", "count", "(", "start", "=", "1", ",", "step", "=", "2", ")", ",", "2", ")", "return", "Stream", "(", "1", ",", "-", "1", ")", "*", "x", "**", "odd_numbers", "/", "odd_number...
Sequence whose sum is the Madhava-Gregory-Leibniz series. [x, -x^3/3, x^5/5, -x^7/7, x^9/9, -x^11/11, ...] Returns ------- An endless sequence that has the property ``atan(x) = sum(mgl_seq(x))``. Usually you would use the ``atan()`` function, not this one.
[ "Sequence", "whose", "sum", "is", "the", "Madhava", "-", "Gregory", "-", "Leibniz", "series", "." ]
python
train
26.666667
telefonicaid/fiware-sdc
python-sdcclient/utils/rest_client_utils.py
https://github.com/telefonicaid/fiware-sdc/blob/d2d5f87fc574caf6bcc49594bbcb31f620ba8c51/python-sdcclient/utils/rest_client_utils.py#L116-L127
def launch_request(self, uri_pattern, body, method, headers=None, parameters=None, **kwargs): """ Launch HTTP request to the API with given arguments :param uri_pattern: string pattern of the full API url with keyword arguments (format string syntax) :param body: Raw Body content (string...
[ "def", "launch_request", "(", "self", ",", "uri_pattern", ",", "body", ",", "method", ",", "headers", "=", "None", ",", "parameters", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_call_api", "(", "uri_pattern", ",", "method", ...
Launch HTTP request to the API with given arguments :param uri_pattern: string pattern of the full API url with keyword arguments (format string syntax) :param body: Raw Body content (string) (Plain/XML/JSON to be sent) :param method: HTTP ver to be used in the request [GET | POST | PUT | DELETE...
[ "Launch", "HTTP", "request", "to", "the", "API", "with", "given", "arguments", ":", "param", "uri_pattern", ":", "string", "pattern", "of", "the", "full", "API", "url", "with", "keyword", "arguments", "(", "format", "string", "syntax", ")", ":", "param", "...
python
train
67.75
TUT-ARG/sed_eval
evaluators/sound_event_eval.py
https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/evaluators/sound_event_eval.py#L94-L144
def main(argv): """Main """ parameters = process_arguments(argv) file_list = sed_eval.io.load_file_pair_list(parameters['file_list']) path = os.path.dirname(parameters['file_list']) data = [] all_data = dcase_util.containers.MetaDataContainer() for file_pair in file_list: refer...
[ "def", "main", "(", "argv", ")", ":", "parameters", "=", "process_arguments", "(", "argv", ")", "file_list", "=", "sed_eval", ".", "io", ".", "load_file_pair_list", "(", "parameters", "[", "'file_list'", "]", ")", "path", "=", "os", ".", "path", ".", "di...
Main
[ "Main" ]
python
train
31.745098
collectiveacuity/labPack
labpack/platforms/heroku.py
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L187-L237
def access(self, app_subdomain): ''' a method to validate user can access app ''' title = '%s.access' % self.__class__.__name__ # validate input input_fields = { 'app_subdomain': app_subdomain } for key, value in input_fields.items(): ...
[ "def", "access", "(", "self", ",", "app_subdomain", ")", ":", "title", "=", "'%s.access'", "%", "self", ".", "__class__", ".", "__name__", "# validate input\r", "input_fields", "=", "{", "'app_subdomain'", ":", "app_subdomain", "}", "for", "key", ",", "value",...
a method to validate user can access app
[ "a", "method", "to", "validate", "user", "can", "access", "app" ]
python
train
38.137255
pyusb/pyusb
usb/legacy.py
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L154-L164
def interruptWrite(self, endpoint, buffer, timeout = 100): r"""Perform a interrupt write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. ...
[ "def", "interruptWrite", "(", "self", ",", "endpoint", ",", "buffer", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "write", "(", "endpoint", ",", "buffer", ",", "timeout", ")" ]
r"""Perform a interrupt write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. timeout: operation timeout in milliseconds. (default...
[ "r", "Perform", "a", "interrupt", "write", "request", "to", "the", "endpoint", "specified", "." ]
python
train
45.545455
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7278-L7293
def flattened(self): """return flattened data ``(x, f)`` such that for the sweep through coordinate ``i`` we have for data point ``j`` that ``f[i][j] == func(x[i][j])`` """ flatx = {} flatf = {} for i in self.res: if isinstance(i, int): flatx[...
[ "def", "flattened", "(", "self", ")", ":", "flatx", "=", "{", "}", "flatf", "=", "{", "}", "for", "i", "in", "self", ".", "res", ":", "if", "isinstance", "(", "i", ",", "int", ")", ":", "flatx", "[", "i", "]", "=", "[", "]", "flatf", "[", "...
return flattened data ``(x, f)`` such that for the sweep through coordinate ``i`` we have for data point ``j`` that ``f[i][j] == func(x[i][j])``
[ "return", "flattened", "data", "(", "x", "f", ")", "such", "that", "for", "the", "sweep", "through", "coordinate", "i", "we", "have", "for", "data", "point", "j", "that", "f", "[", "i", "]", "[", "j", "]", "==", "func", "(", "x", "[", "i", "]", ...
python
train
34.6875
marcomusy/vtkplotter
vtkplotter/utils.py
https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/utils.py#L229-L233
def cart2pol(x, y): """Cartesian to Polar coordinates conversion.""" theta = np.arctan2(y, x) rho = np.hypot(x, y) return theta, rho
[ "def", "cart2pol", "(", "x", ",", "y", ")", ":", "theta", "=", "np", ".", "arctan2", "(", "y", ",", "x", ")", "rho", "=", "np", ".", "hypot", "(", "x", ",", "y", ")", "return", "theta", ",", "rho" ]
Cartesian to Polar coordinates conversion.
[ "Cartesian", "to", "Polar", "coordinates", "conversion", "." ]
python
train
28.8
spyder-ide/spyder
spyder/app/restart.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/restart.py#L106-L109
def _show_message(self, text): """Show message on splash screen.""" self.splash.showMessage(text, Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.white))
[ "def", "_show_message", "(", "self", ",", "text", ")", ":", "self", ".", "splash", ".", "showMessage", "(", "text", ",", "Qt", ".", "AlignBottom", "|", "Qt", ".", "AlignCenter", "|", "Qt", ".", "AlignAbsolute", ",", "QColor", "(", "Qt", ".", "white", ...
Show message on splash screen.
[ "Show", "message", "on", "splash", "screen", "." ]
python
train
53.75
mcs07/ChemDataExtractor
chemdataextractor/nlp/tag.py
https://github.com/mcs07/ChemDataExtractor/blob/349a3bea965f2073141d62043b89319222e46af1/chemdataextractor/nlp/tag.py#L153-L168
def update(self, truth, guess, features): """Update the feature weights.""" def upd_feat(c, f, w, v): param = (f, c) self._totals[param] += (self.i - self._tstamps[param]) * w self._tstamps[param] = self.i self.weights[f][c] = w + v self.i += 1 ...
[ "def", "update", "(", "self", ",", "truth", ",", "guess", ",", "features", ")", ":", "def", "upd_feat", "(", "c", ",", "f", ",", "w", ",", "v", ")", ":", "param", "=", "(", "f", ",", "c", ")", "self", ".", "_totals", "[", "param", "]", "+=", ...
Update the feature weights.
[ "Update", "the", "feature", "weights", "." ]
python
train
36
outini/python-pylls
pylls/cachet.py
https://github.com/outini/python-pylls/blob/f9fa220594bc1974469097d9bad690a42d0d0f0f/pylls/cachet.py#L479-L493
def create(self, email, verify=None, components=None): """Create a new subscriber :param str email: Email address to subscribe :param bool verify: Whether to send verification email :param list components: Components ID list, defaults to all :return: Created subscriber data (:cl...
[ "def", "create", "(", "self", ",", "email", ",", "verify", "=", "None", ",", "components", "=", "None", ")", ":", "data", "=", "ApiParams", "(", ")", "data", "[", "'email'", "]", "=", "email", "data", "[", "'verify'", "]", "=", "verify", "data", "[...
Create a new subscriber :param str email: Email address to subscribe :param bool verify: Whether to send verification email :param list components: Components ID list, defaults to all :return: Created subscriber data (:class:`dict`) .. seealso:: https://docs.cachethq.io/referen...
[ "Create", "a", "new", "subscriber" ]
python
train
39.133333
KoffeinFlummi/Chronyk
chronyk/chronyk.py
https://github.com/KoffeinFlummi/Chronyk/blob/5a9f3518d2e831884dea7e8c077d6e7350df2fbe/chronyk/chronyk.py#L112-L128
def guesstype(timestr): """Tries to guess whether a string represents a time or a time delta and returns the appropriate object. :param timestr (required) The string to be analyzed """ timestr_full = " {} ".format(timestr) if timestr_full.find(" in ") != -1 or timestr_full.find(" ago ")...
[ "def", "guesstype", "(", "timestr", ")", ":", "timestr_full", "=", "\" {} \"", ".", "format", "(", "timestr", ")", "if", "timestr_full", ".", "find", "(", "\" in \"", ")", "!=", "-", "1", "or", "timestr_full", ".", "find", "(", "\" ago \"", ")", "!=", ...
Tries to guess whether a string represents a time or a time delta and returns the appropriate object. :param timestr (required) The string to be analyzed
[ "Tries", "to", "guess", "whether", "a", "string", "represents", "a", "time", "or", "a", "time", "delta", "and", "returns", "the", "appropriate", "object", "." ]
python
train
32.470588
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py#L589-L606
def _fw_delete(self, drvr_name, data): """Firewall Delete routine. This function calls routines to remove FW from fabric and device. It also updates its local cache. """ fw_id = data.get('firewall_id') tenant_id = self.tenant_db.get_fw_tenant(fw_id) if tenant_id...
[ "def", "_fw_delete", "(", "self", ",", "drvr_name", ",", "data", ")", ":", "fw_id", "=", "data", ".", "get", "(", "'firewall_id'", ")", "tenant_id", "=", "self", ".", "tenant_db", ".", "get_fw_tenant", "(", "fw_id", ")", "if", "tenant_id", "not", "in", ...
Firewall Delete routine. This function calls routines to remove FW from fabric and device. It also updates its local cache.
[ "Firewall", "Delete", "routine", "." ]
python
train
34.777778
brainiak/brainiak
brainiak/reprsimil/brsa.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/reprsimil/brsa.py#L796-L853
def transform(self, X, y=None, scan_onsets=None): """ Use the model to estimate the time course of response to each condition (ts), and the time course unrelated to task (ts0) which is spread across the brain. This is equivalent to "decoding" the design matrix and ...
[ "def", "transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "scan_onsets", "=", "None", ")", ":", "assert", "X", ".", "ndim", "==", "2", "and", "X", ".", "shape", "[", "1", "]", "==", "self", ".", "beta_", ".", "shape", "[", "1", "...
Use the model to estimate the time course of response to each condition (ts), and the time course unrelated to task (ts0) which is spread across the brain. This is equivalent to "decoding" the design matrix and nuisance regressors from a new dataset different from the ...
[ "Use", "the", "model", "to", "estimate", "the", "time", "course", "of", "response", "to", "each", "condition", "(", "ts", ")", "and", "the", "time", "course", "unrelated", "to", "task", "(", "ts0", ")", "which", "is", "spread", "across", "the", "brain", ...
python
train
51.568966
alefnula/tea
tea/logger/win_handlers.py
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/logger/win_handlers.py#L42-L55
def emit(self, record): """Emit a record. Output the record to the file, catering for rollover as described in doRollover(). """ try: if self.shouldRollover(record): self.doRollover() FileHandler.emit(self, record) except (Keyboard...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "if", "self", ".", "shouldRollover", "(", "record", ")", ":", "self", ".", "doRollover", "(", ")", "FileHandler", ".", "emit", "(", "self", ",", "record", ")", "except", "(", "KeyboardI...
Emit a record. Output the record to the file, catering for rollover as described in doRollover().
[ "Emit", "a", "record", "." ]
python
train
29.357143
quantumlib/Cirq
cirq/value/value_equality.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/value/value_equality.py#L135-L223
def value_equality(cls: type = None, *, unhashable: bool = False, distinct_child_types: bool = False, manual_cls: bool = False, approximate: bool = False ) -> Union[Callable[[type], type], type]: """Impl...
[ "def", "value_equality", "(", "cls", ":", "type", "=", "None", ",", "*", ",", "unhashable", ":", "bool", "=", "False", ",", "distinct_child_types", ":", "bool", "=", "False", ",", "manual_cls", ":", "bool", "=", "False", ",", "approximate", ":", "bool", ...
Implements __eq__/__ne__/__hash__ via a _value_equality_values_ method. _value_equality_values_ is a method that the decorated class must implement. _value_equality_approximate_values_ is a method that the decorated class might implement if special support for approximate equality is required. This is...
[ "Implements", "__eq__", "/", "__ne__", "/", "__hash__", "via", "a", "_value_equality_values_", "method", "." ]
python
train
54.044944
pytorch/vision
torchvision/models/alexnet.py
https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/alexnet.py#L51-L61
def alexnet(pretrained=False, **kwargs): r"""AlexNet model architecture from the `"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = AlexNet(**kwargs) if pretrained: model.load_sta...
[ "def", "alexnet", "(", "pretrained", "=", "False", ",", "*", "*", "kwargs", ")", ":", "model", "=", "AlexNet", "(", "*", "*", "kwargs", ")", "if", "pretrained", ":", "model", ".", "load_state_dict", "(", "model_zoo", ".", "load_url", "(", "model_urls", ...
r"""AlexNet model architecture from the `"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
[ "r", "AlexNet", "model", "architecture", "from", "the", "One", "weird", "trick", "...", "<https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1404", ".", "5997", ">", "_", "paper", "." ]
python
test
34.272727
nickw444/flask-ldap3-login
flask_ldap3_login/__init__.py
https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L705-L736
def connection(self): """ Convenience property for externally accessing an authenticated connection to the server. This connection is automatically handled by the appcontext, so you do not have to perform an unbind. Returns: ldap3.Connection: A bound ldap3.Connection...
[ "def", "connection", "(", "self", ")", ":", "ctx", "=", "stack", ".", "top", "if", "ctx", "is", "None", ":", "raise", "Exception", "(", "\"Working outside of the Flask application \"", "\"context. If you wish to make a connection outside of a flask\"", "\" application conte...
Convenience property for externally accessing an authenticated connection to the server. This connection is automatically handled by the appcontext, so you do not have to perform an unbind. Returns: ldap3.Connection: A bound ldap3.Connection Raises: ldap3.core.ex...
[ "Convenience", "property", "for", "externally", "accessing", "an", "authenticated", "connection", "to", "the", "server", ".", "This", "connection", "is", "automatically", "handled", "by", "the", "appcontext", "so", "you", "do", "not", "have", "to", "perform", "a...
python
test
44.1875
tjcsl/cslbot
cslbot/commands/wtf.py
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/wtf.py#L24-L34
def cmd(send, msg, _): """Tells you what acronyms mean. Syntax: {command} <term> """ try: answer = subprocess.check_output(['wtf', msg], stderr=subprocess.STDOUT) send(answer.decode().strip().replace('\n', ' or ').replace('fuck', 'fsck')) except subprocess.CalledProcessError as ex:...
[ "def", "cmd", "(", "send", ",", "msg", ",", "_", ")", ":", "try", ":", "answer", "=", "subprocess", ".", "check_output", "(", "[", "'wtf'", ",", "msg", "]", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", "send", "(", "answer", ".", "decode",...
Tells you what acronyms mean. Syntax: {command} <term>
[ "Tells", "you", "what", "acronyms", "mean", "." ]
python
train
33.454545
NLeSC/noodles
noodles/lib/thread_pool.py
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/lib/thread_pool.py#L35-L71
def thread_pool(*workers, results=None, end_of_queue=EndOfQueue): """Returns a |pull| object, call it ``r``, starting a thread for each given worker. Each thread pulls from the source that ``r`` is connected to, and the returned results are pushed to a |Queue|. ``r`` yields from the other end of the s...
[ "def", "thread_pool", "(", "*", "workers", ",", "results", "=", "None", ",", "end_of_queue", "=", "EndOfQueue", ")", ":", "if", "results", "is", "None", ":", "results", "=", "Queue", "(", "end_of_queue", "=", "end_of_queue", ")", "count", "=", "thread_coun...
Returns a |pull| object, call it ``r``, starting a thread for each given worker. Each thread pulls from the source that ``r`` is connected to, and the returned results are pushed to a |Queue|. ``r`` yields from the other end of the same |Queue|. The target function for each thread is |patch|, which c...
[ "Returns", "a", "|pull|", "object", "call", "it", "r", "starting", "a", "thread", "for", "each", "given", "worker", ".", "Each", "thread", "pulls", "from", "the", "source", "that", "r", "is", "connected", "to", "and", "the", "returned", "results", "are", ...
python
train
33.405405
wummel/linkchecker
linkcheck/logger/__init__.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/logger/__init__.py#L230-L245
def start_fileoutput (self): """Start output to configured file.""" path = os.path.dirname(self.filename) try: if path and not os.path.isdir(path): os.makedirs(path) self.fd = self.create_fd() self.close_fd = True except IOError: ...
[ "def", "start_fileoutput", "(", "self", ")", ":", "path", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "filename", ")", "try", ":", "if", "path", "and", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "os", ".", "maked...
Start output to configured file.
[ "Start", "output", "to", "configured", "file", "." ]
python
train
37.3125
MonashBI/arcana
arcana/data/file_format.py
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/file_format.py#L304-L315
def set_converter(self, file_format, converter): """ Register a Converter and the FileFormat that it is able to convert from Parameters ---------- converter : Converter The converter to register file_format : FileFormat The file format that can be...
[ "def", "set_converter", "(", "self", ",", "file_format", ",", "converter", ")", ":", "self", ".", "_converters", "[", "file_format", ".", "name", "]", "=", "(", "file_format", ",", "converter", ")" ]
Register a Converter and the FileFormat that it is able to convert from Parameters ---------- converter : Converter The converter to register file_format : FileFormat The file format that can be converted into this format
[ "Register", "a", "Converter", "and", "the", "FileFormat", "that", "it", "is", "able", "to", "convert", "from" ]
python
train
34.833333
romanz/trezor-agent
libagent/gpg/agent.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/gpg/agent.py#L216-L219
def set_hash(self, algo, digest): """Set algorithm ID and hexadecimal digest for next operation.""" self.algo = algo self.digest = digest
[ "def", "set_hash", "(", "self", ",", "algo", ",", "digest", ")", ":", "self", ".", "algo", "=", "algo", "self", ".", "digest", "=", "digest" ]
Set algorithm ID and hexadecimal digest for next operation.
[ "Set", "algorithm", "ID", "and", "hexadecimal", "digest", "for", "next", "operation", "." ]
python
train
39.5
hsolbrig/PyShEx
pyshex/shape_expressions_language/p5_context.py
https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_context.py#L356-L378
def start_evaluating(self, n: Node, s: ShExJ.shapeExpr) -> Optional[bool]: """Indicate that we are beginning to evaluate n according to shape expression s. If we are already in the process of evaluating (n,s), as indicated self.evaluating, we return our current guess as to the result. :...
[ "def", "start_evaluating", "(", "self", ",", "n", ":", "Node", ",", "s", ":", "ShExJ", ".", "shapeExpr", ")", "->", "Optional", "[", "bool", "]", ":", "if", "not", "s", ".", "id", ":", "s", ".", "id", "=", "str", "(", "BNode", "(", ")", ")", ...
Indicate that we are beginning to evaluate n according to shape expression s. If we are already in the process of evaluating (n,s), as indicated self.evaluating, we return our current guess as to the result. :param n: Node to be evaluated :param s: expression for node evaluation ...
[ "Indicate", "that", "we", "are", "beginning", "to", "evaluate", "n", "according", "to", "shape", "expression", "s", ".", "If", "we", "are", "already", "in", "the", "process", "of", "evaluating", "(", "n", "s", ")", "as", "indicated", "self", ".", "evalua...
python
train
40.347826
quantmind/pulsar
pulsar/apps/http/plugins.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/http/plugins.py#L230-L245
def on_headers(self, response, exc=None): '''Websocket upgrade as ``on_headers`` event.''' if response.status_code == 101: connection = response.connection request = response.request handler = request.websocket_handler if not handler: hand...
[ "def", "on_headers", "(", "self", ",", "response", ",", "exc", "=", "None", ")", ":", "if", "response", ".", "status_code", "==", "101", ":", "connection", "=", "response", ".", "connection", "request", "=", "response", ".", "request", "handler", "=", "r...
Websocket upgrade as ``on_headers`` event.
[ "Websocket", "upgrade", "as", "on_headers", "event", "." ]
python
train
42.9375
Dentosal/python-sc2
sc2/position.py
https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/position.py#L267-L272
def center(a: Union[Set["Point2"], List["Point2"]]) -> "Point2": """ Returns the central point for points in list """ s = Point2((0, 0)) for p in a: s += p return s / len(a)
[ "def", "center", "(", "a", ":", "Union", "[", "Set", "[", "\"Point2\"", "]", ",", "List", "[", "\"Point2\"", "]", "]", ")", "->", "\"Point2\"", ":", "s", "=", "Point2", "(", "(", "0", ",", "0", ")", ")", "for", "p", "in", "a", ":", "s", "+=",...
Returns the central point for points in list
[ "Returns", "the", "central", "point", "for", "points", "in", "list" ]
python
train
35.333333
Neurita/boyle
boyle/nifti/check.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/nifti/check.py#L172-L217
def have_same_affine(one_img, another_img, only_check_3d=False): """Return True if the affine matrix of one_img is close to the affine matrix of another_img. False otherwise. Parameters ---------- one_img: nibabel.Nifti1Image another_img: nibabel.Nifti1Image only_check_3d: bool If...
[ "def", "have_same_affine", "(", "one_img", ",", "another_img", ",", "only_check_3d", "=", "False", ")", ":", "img1", "=", "check_img", "(", "one_img", ")", "img2", "=", "check_img", "(", "another_img", ")", "ndim1", "=", "len", "(", "img1", ".", "shape", ...
Return True if the affine matrix of one_img is close to the affine matrix of another_img. False otherwise. Parameters ---------- one_img: nibabel.Nifti1Image another_img: nibabel.Nifti1Image only_check_3d: bool If True will extract only the 3D part of the affine matrices when they hav...
[ "Return", "True", "if", "the", "affine", "matrix", "of", "one_img", "is", "close", "to", "the", "affine", "matrix", "of", "another_img", ".", "False", "otherwise", "." ]
python
valid
24.76087
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L3042-L3057
def dskobj(dsk): """ Find the set of body ID codes of all objects for which topographic data are provided in a specified DSK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskobj_c.html :param dsk: Name of DSK file. :type dsk: str :return: Set of ID codes of obje...
[ "def", "dskobj", "(", "dsk", ")", ":", "dsk", "=", "stypes", ".", "stringToCharP", "(", "dsk", ")", "bodids", "=", "stypes", ".", "SPICEINT_CELL", "(", "10000", ")", "libspice", ".", "dskobj_c", "(", "dsk", ",", "ctypes", ".", "byref", "(", "bodids", ...
Find the set of body ID codes of all objects for which topographic data are provided in a specified DSK file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dskobj_c.html :param dsk: Name of DSK file. :type dsk: str :return: Set of ID codes of objects in DSK file. :rtype: ...
[ "Find", "the", "set", "of", "body", "ID", "codes", "of", "all", "objects", "for", "which", "topographic", "data", "are", "provided", "in", "a", "specified", "DSK", "file", ".", "https", ":", "//", "naif", ".", "jpl", ".", "nasa", ".", "gov", "/", "pu...
python
train
32.75
UDST/pandana
pandana/loaders/pandash5.py
https://github.com/UDST/pandana/blob/961a7ef8d3b0144b190cb60bbd61845fca6fb314/pandana/loaders/pandash5.py#L30-L53
def network_to_pandas_hdf5(network, filename, rm_nodes=None): """ Save a Network's data to a Pandas HDFStore. Parameters ---------- network : pandana.Network filename : str rm_nodes : array_like A list, array, Index, or Series of node IDs that should *not* be saved as part o...
[ "def", "network_to_pandas_hdf5", "(", "network", ",", "filename", ",", "rm_nodes", "=", "None", ")", ":", "if", "rm_nodes", "is", "not", "None", ":", "nodes", ",", "edges", "=", "remove_nodes", "(", "network", ",", "rm_nodes", ")", "else", ":", "nodes", ...
Save a Network's data to a Pandas HDFStore. Parameters ---------- network : pandana.Network filename : str rm_nodes : array_like A list, array, Index, or Series of node IDs that should *not* be saved as part of the Network.
[ "Save", "a", "Network", "s", "data", "to", "a", "Pandas", "HDFStore", "." ]
python
test
29.708333
saltstack/salt
salt/fileserver/svnfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/svnfs.py#L667-L718
def file_hash(load, fnd): ''' Return a file hash, the hash type is set in the master config file ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if not all(x in load for x in ('path', 'saltenv')): return '' saltenv = load['saltenv'] if ...
[ "def", "file_hash", "(", "load", ",", "fnd", ")", ":", "if", "'env'", "in", "load", ":", "# \"env\" is not supported; Use \"saltenv\".", "load", ".", "pop", "(", "'env'", ")", "if", "not", "all", "(", "x", "in", "load", "for", "x", "in", "(", "'path'", ...
Return a file hash, the hash type is set in the master config file
[ "Return", "a", "file", "hash", "the", "hash", "type", "is", "set", "in", "the", "master", "config", "file" ]
python
train
35.038462
pywbem/pywbem
pywbem/cim_obj.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L466-L577
def _mof_escaped(strvalue): # Note: This is a raw docstring because it shows many backslashes, and # that avoids having to double them. r""" Return a MOF-escaped string from the input string. Parameters: strvalue (:term:`unicode string`): The string value. Must not be `None`. Special...
[ "def", "_mof_escaped", "(", "strvalue", ")", ":", "# Note: This is a raw docstring because it shows many backslashes, and", "# that avoids having to double them.", "escaped_str", "=", "strvalue", "# Escape backslash (\\)", "escaped_str", "=", "escaped_str", ".", "replace", "(", "...
r""" Return a MOF-escaped string from the input string. Parameters: strvalue (:term:`unicode string`): The string value. Must not be `None`. Special characters must not be backslash-escaped. Details on backslash-escaping: `DSP0004` defines that the character repertoire for MOF string c...
[ "r", "Return", "a", "MOF", "-", "escaped", "string", "from", "the", "input", "string", "." ]
python
train
41.392857
ihmeuw/vivarium
src/vivarium/framework/population.py
https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/population.py#L99-L150
def update(self, pop: Union[pd.DataFrame, pd.Series]): """Update the simulation's state to match ``pop`` Parameters ---------- pop : The data which should be copied into the simulation's state. If ``pop`` is a DataFrame only those columns included in the view...
[ "def", "update", "(", "self", ",", "pop", ":", "Union", "[", "pd", ".", "DataFrame", ",", "pd", ".", "Series", "]", ")", ":", "if", "not", "pop", ".", "empty", ":", "if", "isinstance", "(", "pop", ",", "pd", ".", "Series", ")", ":", "if", "pop"...
Update the simulation's state to match ``pop`` Parameters ---------- pop : The data which should be copied into the simulation's state. If ``pop`` is a DataFrame only those columns included in the view's columns will be used. If ``pop`` is a Series it must have a nam...
[ "Update", "the", "simulation", "s", "state", "to", "match", "pop" ]
python
train
48.076923
numenta/htmresearch
htmresearch/frameworks/layers/l2_l4_network_creation.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/layers/l2_l4_network_creation.py#L185-L293
def createL4L2Column(network, networkConfig, suffix=""): """ Create a a single column containing one L4 and one L2. networkConfig is a dict that must contain the following keys (additional keys ok): { "enableFeedback": True, "externalInputSize": 1024, "sensorInputSize": 1024, "L4Re...
[ "def", "createL4L2Column", "(", "network", ",", "networkConfig", ",", "suffix", "=", "\"\"", ")", ":", "externalInputName", "=", "\"externalInput\"", "+", "suffix", "sensorInputName", "=", "\"sensorInput\"", "+", "suffix", "L4ColumnName", "=", "\"L4Column\"", "+", ...
Create a a single column containing one L4 and one L2. networkConfig is a dict that must contain the following keys (additional keys ok): { "enableFeedback": True, "externalInputSize": 1024, "sensorInputSize": 1024, "L4RegionType": "py.ApicalTMPairRegion", "L4Params": { <...
[ "Create", "a", "a", "single", "column", "containing", "one", "L4", "and", "one", "L2", "." ]
python
train
36.073394
gatkin/declxml
declxml.py
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L287-L311
def parse_from_string( root_processor, # type: RootProcessor xml_string # type: Text ): # type: (...) -> Any """ Parse the XML string using the processor starting from the root of the document. :param xml_string: XML string to parse. See also :func:`declxml.parse_from_file` "...
[ "def", "parse_from_string", "(", "root_processor", ",", "# type: RootProcessor", "xml_string", "# type: Text", ")", ":", "# type: (...) -> Any", "if", "not", "_is_valid_root_processor", "(", "root_processor", ")", ":", "raise", "InvalidRootProcessor", "(", "'Invalid root pr...
Parse the XML string using the processor starting from the root of the document. :param xml_string: XML string to parse. See also :func:`declxml.parse_from_file`
[ "Parse", "the", "XML", "string", "using", "the", "processor", "starting", "from", "the", "root", "of", "the", "document", "." ]
python
train
31.96
f213/rumetr-client
rumetr/roometr.py
https://github.com/f213/rumetr-client/blob/5180152bcb2eed8246b88035db7c0bb1fe603166/rumetr/roometr.py#L95-L102
def post(self, url: str, data: str, expected_status_code=201): """ Do a POST request """ r = requests.post(self._format_url(url), json=data, headers=self.headers, timeout=TIMEOUT) self._check_response(r, expected_status_code) return r.json()
[ "def", "post", "(", "self", ",", "url", ":", "str", ",", "data", ":", "str", ",", "expected_status_code", "=", "201", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "_format_url", "(", "url", ")", ",", "json", "=", "data", ",", "h...
Do a POST request
[ "Do", "a", "POST", "request" ]
python
train
35.375
horazont/aioxmpp
aioxmpp/stream.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1738-L1789
def unregister_presence_callback(self, type_, from_): """ Unregister a callback previously registered with :meth:`register_presence_callback`. :param type_: Presence type to listen for. :type type_: :class:`~.PresenceType` :param from_: Sender JID to listen for, or :data...
[ "def", "unregister_presence_callback", "(", "self", ",", "type_", ",", "from_", ")", ":", "type_", "=", "self", ".", "_coerce_enum", "(", "type_", ",", "structs", ".", "PresenceType", ")", "warnings", ".", "warn", "(", "\"unregister_presence_callback is deprecated...
Unregister a callback previously registered with :meth:`register_presence_callback`. :param type_: Presence type to listen for. :type type_: :class:`~.PresenceType` :param from_: Sender JID to listen for, or :data:`None` for a wildcard match. :type from_: :...
[ "Unregister", "a", "callback", "previously", "registered", "with", ":", "meth", ":", "register_presence_callback", "." ]
python
train
39.961538
webrecorder/pywb
pywb/apps/frontendapp.py
https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/apps/frontendapp.py#L517-L526
def create_app(cls, port): """Create a new instance of FrontEndApp that listens on port with a hostname of 0.0.0.0 :param int port: The port FrontEndApp is to listen on :return: A new instance of FrontEndApp wrapped in GeventServer :rtype: GeventServer """ app = FrontEnd...
[ "def", "create_app", "(", "cls", ",", "port", ")", ":", "app", "=", "FrontEndApp", "(", ")", "app_server", "=", "GeventServer", "(", "app", ",", "port", "=", "port", ",", "hostname", "=", "'0.0.0.0'", ")", "return", "app_server" ]
Create a new instance of FrontEndApp that listens on port with a hostname of 0.0.0.0 :param int port: The port FrontEndApp is to listen on :return: A new instance of FrontEndApp wrapped in GeventServer :rtype: GeventServer
[ "Create", "a", "new", "instance", "of", "FrontEndApp", "that", "listens", "on", "port", "with", "a", "hostname", "of", "0", ".", "0", ".", "0", ".", "0" ]
python
train
41.2
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/nbformat/v1/nbbase.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/nbformat/v1/nbbase.py#L55-L61
def new_text_cell(text=None): """Create a new text cell.""" cell = NotebookNode() if text is not None: cell.text = unicode(text) cell.cell_type = u'text' return cell
[ "def", "new_text_cell", "(", "text", "=", "None", ")", ":", "cell", "=", "NotebookNode", "(", ")", "if", "text", "is", "not", "None", ":", "cell", ".", "text", "=", "unicode", "(", "text", ")", "cell", ".", "cell_type", "=", "u'text'", "return", "cel...
Create a new text cell.
[ "Create", "a", "new", "text", "cell", "." ]
python
test
26.714286
SignalN/language
language/ngrams.py
https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L131-L145
def __similarity(s1, s2, ngrams_fn, n=3): """ The fraction of n-grams matching between two sequences Args: s1: a string s2: another string n: an int for the n in n-gram Returns: float: the fraction of n-grams matching """ ngrams1, ngr...
[ "def", "__similarity", "(", "s1", ",", "s2", ",", "ngrams_fn", ",", "n", "=", "3", ")", ":", "ngrams1", ",", "ngrams2", "=", "set", "(", "ngrams_fn", "(", "s1", ",", "n", "=", "n", ")", ")", ",", "set", "(", "ngrams_fn", "(", "s2", ",", "n", ...
The fraction of n-grams matching between two sequences Args: s1: a string s2: another string n: an int for the n in n-gram Returns: float: the fraction of n-grams matching
[ "The", "fraction", "of", "n", "-", "grams", "matching", "between", "two", "sequences" ]
python
train
31
zyga/morris
morris/__init__.py
https://github.com/zyga/morris/blob/7cd6da662c8c95b93b5fb8bb25eae8686becf31a/morris/__init__.py#L694-L706
def fire(self, args, kwargs): """ Fire this signal with the specified arguments and keyword arguments. Typically this is used by using :meth:`__call__()` on this object which is more natural as it does all the argument packing/unpacking transparently. """ for inf...
[ "def", "fire", "(", "self", ",", "args", ",", "kwargs", ")", ":", "for", "info", "in", "self", ".", "_listeners", "[", ":", "]", ":", "if", "info", ".", "pass_signal", ":", "info", ".", "listener", "(", "*", "args", ",", "signal", "=", "self", ",...
Fire this signal with the specified arguments and keyword arguments. Typically this is used by using :meth:`__call__()` on this object which is more natural as it does all the argument packing/unpacking transparently.
[ "Fire", "this", "signal", "with", "the", "specified", "arguments", "and", "keyword", "arguments", "." ]
python
train
37.692308
angr/angr
angr/storage/paged_memory.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/storage/paged_memory.py#L738-L749
def store_memory_object(self, mo, overwrite=True): """ This function optimizes a large store by storing a single reference to the :class:`SimMemoryObject` instead of one for each byte. :param memory_object: the memory object to store """ for p in self._containing_pages_...
[ "def", "store_memory_object", "(", "self", ",", "mo", ",", "overwrite", "=", "True", ")", ":", "for", "p", "in", "self", ".", "_containing_pages_mo", "(", "mo", ")", ":", "self", ".", "_apply_object_to_page", "(", "p", ",", "mo", ",", "overwrite", "=", ...
This function optimizes a large store by storing a single reference to the :class:`SimMemoryObject` instead of one for each byte. :param memory_object: the memory object to store
[ "This", "function", "optimizes", "a", "large", "store", "by", "storing", "a", "single", "reference", "to", "the", ":", "class", ":", "SimMemoryObject", "instead", "of", "one", "for", "each", "byte", "." ]
python
train
37.583333
snare/voltron
voltron/core.py
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L174-L191
def stop(self): """ Stop the server. """ log.debug("Stopping listeners") self.queue_lock.acquire() for s in self.listeners: log.debug("Stopping {}".format(s)) s.shutdown() s.socket.close() self.cancel_queue() for t in se...
[ "def", "stop", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Stopping listeners\"", ")", "self", ".", "queue_lock", ".", "acquire", "(", ")", "for", "s", "in", "self", ".", "listeners", ":", "log", ".", "debug", "(", "\"Stopping {}\"", ".", "form...
Stop the server.
[ "Stop", "the", "server", "." ]
python
train
28.5
SHTOOLS/SHTOOLS
pyshtools/shclasses/shtensor.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shtensor.py#L1394-L1450
def plot_eigh2(self, colorbar=True, cb_orientation='vertical', cb_label=None, ax=None, show=True, fname=None, **kwargs): """ Plot the second eigenvalue of the horizontal tensor. Usage ----- x.plot_eigh2([tick_interval, xlabel, ylabel, ax, colorbar, ...
[ "def", "plot_eigh2", "(", "self", ",", "colorbar", "=", "True", ",", "cb_orientation", "=", "'vertical'", ",", "cb_label", "=", "None", ",", "ax", "=", "None", ",", "show", "=", "True", ",", "fname", "=", "None", ",", "*", "*", "kwargs", ")", ":", ...
Plot the second eigenvalue of the horizontal tensor. Usage ----- x.plot_eigh2([tick_interval, xlabel, ylabel, ax, colorbar, cb_orientation, cb_label, show, fname]) Parameters ---------- tick_interval : list or tuple, optional, default = [30, 30] ...
[ "Plot", "the", "second", "eigenvalue", "of", "the", "horizontal", "tensor", "." ]
python
train
40.526316
lowandrew/OLCTools
sipprCommon/objectprep.py
https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/sipprCommon/objectprep.py#L11-L33
def objectprep(self): """ Creates fastq files from an in-progress Illumina MiSeq run or create an object and moves files appropriately """ # Create .fastq files if necessary. Otherwise create the metadata object if self.bcltofastq: if self.customsamplesheet: ...
[ "def", "objectprep", "(", "self", ")", ":", "# Create .fastq files if necessary. Otherwise create the metadata object", "if", "self", ".", "bcltofastq", ":", "if", "self", ".", "customsamplesheet", ":", "assert", "os", ".", "path", ".", "isfile", "(", "self", ".", ...
Creates fastq files from an in-progress Illumina MiSeq run or create an object and moves files appropriately
[ "Creates", "fastq", "files", "from", "an", "in", "-", "progress", "Illumina", "MiSeq", "run", "or", "create", "an", "object", "and", "moves", "files", "appropriately" ]
python
train
50.869565
datakortet/dkfileutils
tasks.py
https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/tasks.py#L127-L143
def watch(ctx): """Automatically run build whenever a relevant file changes. """ watcher = Watcher(ctx) watcher.watch_directory( path='{pkg.source_less}', ext='.less', action=lambda e: build(ctx, less=True) ) watcher.watch_directory( path='{pkg.source_js}', ext='.jsx', ...
[ "def", "watch", "(", "ctx", ")", ":", "watcher", "=", "Watcher", "(", "ctx", ")", "watcher", ".", "watch_directory", "(", "path", "=", "'{pkg.source_less}'", ",", "ext", "=", "'.less'", ",", "action", "=", "lambda", "e", ":", "build", "(", "ctx", ",", ...
Automatically run build whenever a relevant file changes.
[ "Automatically", "run", "build", "whenever", "a", "relevant", "file", "changes", "." ]
python
train
29
tylerbutler/engineer
engineer/devtools/theme_tools.py
https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/devtools/theme_tools.py#L47-L65
def list_theme(): """List all available Engineer themes.""" from engineer.themes import ThemeManager themes = ThemeManager.themes() col1, col2 = map(max, zip(*[(len(t.id) + 2, len(t.root_path) + 2) for t in themes.itervalues()])) themes = ThemeManager.themes_by_finder() for finder in sorted(th...
[ "def", "list_theme", "(", ")", ":", "from", "engineer", ".", "themes", "import", "ThemeManager", "themes", "=", "ThemeManager", ".", "themes", "(", ")", "col1", ",", "col2", "=", "map", "(", "max", ",", "zip", "(", "*", "[", "(", "len", "(", "t", "...
List all available Engineer themes.
[ "List", "all", "available", "Engineer", "themes", "." ]
python
train
39.105263
chrisrink10/basilisp
src/basilisp/lang/reader.py
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/reader.py#L736-L760
def _expand_syntax_quote( ctx: ReaderContext, form: IterableLispForm ) -> Iterable[LispForm]: """Expand syntax quoted forms to handle unquoting and unquote-splicing. The unquoted form (unquote x) becomes: (list x) The unquote-spliced form (unquote-splicing x) becomes x All other f...
[ "def", "_expand_syntax_quote", "(", "ctx", ":", "ReaderContext", ",", "form", ":", "IterableLispForm", ")", "->", "Iterable", "[", "LispForm", "]", ":", "expanded", "=", "[", "]", "for", "elem", "in", "form", ":", "if", "_is_unquote", "(", "elem", ")", "...
Expand syntax quoted forms to handle unquoting and unquote-splicing. The unquoted form (unquote x) becomes: (list x) The unquote-spliced form (unquote-splicing x) becomes x All other forms are recursively processed as by _process_syntax_quoted_form and are returned as: (list f...
[ "Expand", "syntax", "quoted", "forms", "to", "handle", "unquoting", "and", "unquote", "-", "splicing", "." ]
python
test
29.16
peterpakos/ppipa
ppipa/freeipaserver.py
https://github.com/peterpakos/ppipa/blob/cc7565fe9afa079437cccfaf8d6b8c3da3f080ee/ppipa/freeipaserver.py#L88-L95
def _search(self, base, fltr, attrs=None, scope=ldap.SCOPE_SUBTREE): """Perform LDAP search""" try: results = self._conn.search_s(base, scope, fltr, attrs) except Exception as e: log.exception(self._get_ldap_msg(e)) results = False return results
[ "def", "_search", "(", "self", ",", "base", ",", "fltr", ",", "attrs", "=", "None", ",", "scope", "=", "ldap", ".", "SCOPE_SUBTREE", ")", ":", "try", ":", "results", "=", "self", ".", "_conn", ".", "search_s", "(", "base", ",", "scope", ",", "fltr"...
Perform LDAP search
[ "Perform", "LDAP", "search" ]
python
train
38.375
eternnoir/pyTelegramBotAPI
telebot/__init__.py
https://github.com/eternnoir/pyTelegramBotAPI/blob/47b53b88123097f1b9562a6cd5d4e080b86185d1/telebot/__init__.py#L838-L847
def kick_chat_member(self, chat_id, user_id, until_date=None): """ Use this method to kick a user from a group or a supergroup. :param chat_id: Int or string : Unique identifier for the target group or username of the target supergroup :param user_id: Int : Unique identifier of the targe...
[ "def", "kick_chat_member", "(", "self", ",", "chat_id", ",", "user_id", ",", "until_date", "=", "None", ")", ":", "return", "apihelper", ".", "kick_chat_member", "(", "self", ".", "token", ",", "chat_id", ",", "user_id", ",", "until_date", ")" ]
Use this method to kick a user from a group or a supergroup. :param chat_id: Int or string : Unique identifier for the target group or username of the target supergroup :param user_id: Int : Unique identifier of the target user :param until_date: Date when the user will be unbanned, unix time. I...
[ "Use", "this", "method", "to", "kick", "a", "user", "from", "a", "group", "or", "a", "supergroup", ".", ":", "param", "chat_id", ":", "Int", "or", "string", ":", "Unique", "identifier", "for", "the", "target", "group", "or", "username", "of", "the", "t...
python
train
66.2
learningequality/ricecooker
ricecooker/utils/downloader.py
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/utils/downloader.py#L129-L253
def download_static_assets(doc, destination, base_url, request_fn=make_request, url_blacklist=[], js_middleware=None, css_middleware=None, derive_filename=_derive_filename): """ Download all static assets referenced from an HTML page. The goal is to easily create HTML5 apps! Downloads JS, CS...
[ "def", "download_static_assets", "(", "doc", ",", "destination", ",", "base_url", ",", "request_fn", "=", "make_request", ",", "url_blacklist", "=", "[", "]", ",", "js_middleware", "=", "None", ",", "css_middleware", "=", "None", ",", "derive_filename", "=", "...
Download all static assets referenced from an HTML page. The goal is to easily create HTML5 apps! Downloads JS, CSS, images, and audio clips. Args: doc: The HTML page source as a string or BeautifulSoup instance. destination: The folder to download the static assets to! base_url: Th...
[ "Download", "all", "static", "assets", "referenced", "from", "an", "HTML", "page", ".", "The", "goal", "is", "to", "easily", "create", "HTML5", "apps!", "Downloads", "JS", "CSS", "images", "and", "audio", "clips", "." ]
python
train
39.776
wmayner/pyphi
pyphi/examples.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/examples.py#L24-L99
def basic_network(cm=False): """A 3-node network of logic gates. Diagram:: +~~~~~~~~+ +~~~~>| A |<~~~~+ | | (OR) +~~~+ | | +~~~~~~~~+ | | | | | | v | +~+~~~~~~+ +~~~~~+~+ ...
[ "def", "basic_network", "(", "cm", "=", "False", ")", ":", "tpm", "=", "np", ".", "array", "(", "[", "[", "0", ",", "0", ",", "0", "]", ",", "[", "0", ",", "0", ",", "1", "]", ",", "[", "1", ",", "0", ",", "1", "]", ",", "[", "1", ","...
A 3-node network of logic gates. Diagram:: +~~~~~~~~+ +~~~~>| A |<~~~~+ | | (OR) +~~~+ | | +~~~~~~~~+ | | | | | | v | +~+~~~~~~+ +~~~~~+~+ | B |<~~~~~~+ C | |...
[ "A", "3", "-", "node", "network", "of", "logic", "gates", "." ]
python
train
26.092105
uber/rides-python-sdk
uber_rides/auth.py
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L423-L444
def get_session(self): """Create Session to store credentials. Returns (Session) A Session object with OAuth 2.0 credentials. """ response = _request_access_token( grant_type=auth.CLIENT_CREDENTIALS_GRANT, client_id=self.client_id, ...
[ "def", "get_session", "(", "self", ")", ":", "response", "=", "_request_access_token", "(", "grant_type", "=", "auth", ".", "CLIENT_CREDENTIALS_GRANT", ",", "client_id", "=", "self", ".", "client_id", ",", "client_secret", "=", "self", ".", "client_secret", ",",...
Create Session to store credentials. Returns (Session) A Session object with OAuth 2.0 credentials.
[ "Create", "Session", "to", "store", "credentials", "." ]
python
train
31.181818
doloopwhile/pyjq
pyjq.py
https://github.com/doloopwhile/pyjq/blob/003144e636af20e20862d4a191f05ec9ed9017b7/pyjq.py#L69-L74
def one(script, value=None, vars={}, url=None, opener=default_opener, library_paths=[]): """ Transform object by jq script, returning the first result. Raise ValueError unless results does not include exactly one element. """ return compile(script, vars, library_paths).one(_get_value(value, url, ope...
[ "def", "one", "(", "script", ",", "value", "=", "None", ",", "vars", "=", "{", "}", ",", "url", "=", "None", ",", "opener", "=", "default_opener", ",", "library_paths", "=", "[", "]", ")", ":", "return", "compile", "(", "script", ",", "vars", ",", ...
Transform object by jq script, returning the first result. Raise ValueError unless results does not include exactly one element.
[ "Transform", "object", "by", "jq", "script", "returning", "the", "first", "result", ".", "Raise", "ValueError", "unless", "results", "does", "not", "include", "exactly", "one", "element", "." ]
python
train
53.333333
synw/dataswim
dataswim/data/clean.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/clean.py#L88-L103
def fill_nan(self, val: str, *cols): """ Fill NaN values with new values in the main dataframe :param val: new value :type val: str :param \*cols: names of the colums :type \*cols: str, at least one :example: ``ds.fill_nan("new value", "mycol1", "mycol2")`` ...
[ "def", "fill_nan", "(", "self", ",", "val", ":", "str", ",", "*", "cols", ")", ":", "df", "=", "self", ".", "_fill_nan", "(", "val", ",", "*", "cols", ")", "if", "df", "is", "not", "None", ":", "self", ".", "df", "=", "df", "else", ":", "self...
Fill NaN values with new values in the main dataframe :param val: new value :type val: str :param \*cols: names of the colums :type \*cols: str, at least one :example: ``ds.fill_nan("new value", "mycol1", "mycol2")``
[ "Fill", "NaN", "values", "with", "new", "values", "in", "the", "main", "dataframe" ]
python
train
29.125
sassoo/goldman
goldman/resources/oauth_ropc.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/resources/oauth_ropc.py#L52-L97
def on_post(self, req, resp): """ Validate the access token request for spec compliance The spec also dictates the JSON based error response on failure & is handled in this responder. """ grant_type = req.get_param('grant_type') password = req.get_param('password') ...
[ "def", "on_post", "(", "self", ",", "req", ",", "resp", ")", ":", "grant_type", "=", "req", ".", "get_param", "(", "'grant_type'", ")", "password", "=", "req", ".", "get_param", "(", "'password'", ")", "username", "=", "req", ".", "get_param", "(", "'u...
Validate the access token request for spec compliance The spec also dictates the JSON based error response on failure & is handled in this responder.
[ "Validate", "the", "access", "token", "request", "for", "spec", "compliance" ]
python
train
40.282609
gem/oq-engine
openquake/commonlib/shapefileparser.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L428-L456
def extract_source_planes_strikes_dips(src): """ Extract strike and dip angles for source defined by multiple planes. """ if "characteristicFaultSource" not in src.tag: strikes = dict([(key, None) for key, _ in PLANES_STRIKES_PARAM]) dips = dict([(key, None) for key, _ in PLANES_DIPS_PAR...
[ "def", "extract_source_planes_strikes_dips", "(", "src", ")", ":", "if", "\"characteristicFaultSource\"", "not", "in", "src", ".", "tag", ":", "strikes", "=", "dict", "(", "[", "(", "key", ",", "None", ")", "for", "key", ",", "_", "in", "PLANES_STRIKES_PARAM...
Extract strike and dip angles for source defined by multiple planes.
[ "Extract", "strike", "and", "dip", "angles", "for", "source", "defined", "by", "multiple", "planes", "." ]
python
train
40.275862
genialis/resolwe
resolwe/elastic/lookup.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/lookup.py#L134-L142
def get_lookup(self, operator): """Look up a lookup. :param operator: Name of the lookup operator """ try: return self._lookups[operator] except KeyError: raise NotImplementedError("Lookup operator '{}' is not supported".format(operator))
[ "def", "get_lookup", "(", "self", ",", "operator", ")", ":", "try", ":", "return", "self", ".", "_lookups", "[", "operator", "]", "except", "KeyError", ":", "raise", "NotImplementedError", "(", "\"Lookup operator '{}' is not supported\"", ".", "format", "(", "op...
Look up a lookup. :param operator: Name of the lookup operator
[ "Look", "up", "a", "lookup", "." ]
python
train
32.777778
greenbender/pynntp
nntp/nntp.py
https://github.com/greenbender/pynntp/blob/991a76331cdf5d8f9dbf5b18f6e29adc80749a2f/nntp/nntp.py#L1110-L1128
def xzhdr(self, header, msgid_range=None): """XZHDR command. Args: msgid_range: A message-id as a string, or an article number as an integer, or a tuple of specifying a range of article numbers in the form (first, [last]) - if last is omitted then all article...
[ "def", "xzhdr", "(", "self", ",", "header", ",", "msgid_range", "=", "None", ")", ":", "args", "=", "header", "if", "msgid_range", "is", "not", "None", ":", "args", "+=", "\" \"", "+", "utils", ".", "unparse_msgid_range", "(", "msgid_range", ")", "code",...
XZHDR command. Args: msgid_range: A message-id as a string, or an article number as an integer, or a tuple of specifying a range of article numbers in the form (first, [last]) - if last is omitted then all articles after first are included. A msgid_ra...
[ "XZHDR", "command", "." ]
python
test
39
gmr/queries
queries/pool.py
https://github.com/gmr/queries/blob/a68855013dc6aaf9ed7b6909a4701f8da8796a0a/queries/pool.py#L524-L535
def get(cls, pid, session): """Get an idle, unused connection from the pool. Once a connection has been retrieved, it will be marked as in-use until it is freed. :param str pid: The pool ID :param queries.Session session: The session to assign to the connection :rtype: psycopg2....
[ "def", "get", "(", "cls", ",", "pid", ",", "session", ")", ":", "with", "cls", ".", "_lock", ":", "cls", ".", "_ensure_pool_exists", "(", "pid", ")", "return", "cls", ".", "_pools", "[", "pid", "]", ".", "get", "(", "session", ")" ]
Get an idle, unused connection from the pool. Once a connection has been retrieved, it will be marked as in-use until it is freed. :param str pid: The pool ID :param queries.Session session: The session to assign to the connection :rtype: psycopg2.extensions.connection
[ "Get", "an", "idle", "unused", "connection", "from", "the", "pool", ".", "Once", "a", "connection", "has", "been", "retrieved", "it", "will", "be", "marked", "as", "in", "-", "use", "until", "it", "is", "freed", "." ]
python
train
38
ajenhl/tacl
tacl/data_store.py
https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/data_store.py#L101-L114
def _add_temporary_results(self, results, label): """Adds `results` to a temporary table with `label`. :param results: results file :type results: `File` :param label: label to be associated with results :type label: `str` """ NGRAM, SIZE, NAME, SIGLUM, COUNT, L...
[ "def", "_add_temporary_results", "(", "self", ",", "results", ",", "label", ")", ":", "NGRAM", ",", "SIZE", ",", "NAME", ",", "SIGLUM", ",", "COUNT", ",", "LABEL", "=", "constants", ".", "QUERY_FIELDNAMES", "reader", "=", "csv", ".", "DictReader", "(", "...
Adds `results` to a temporary table with `label`. :param results: results file :type results: `File` :param label: label to be associated with results :type label: `str`
[ "Adds", "results", "to", "a", "temporary", "table", "with", "label", "." ]
python
train
41.214286
petl-developers/petl
petl/transform/intervals.py
https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/transform/intervals.py#L14-L38
def tupletree(table, start='start', stop='stop', value=None): """ Construct an interval tree for the given table, where each node in the tree is a row of the table. """ import intervaltree tree = intervaltree.IntervalTree() it = iter(table) hdr = next(it) flds = list(map(text_type,...
[ "def", "tupletree", "(", "table", ",", "start", "=", "'start'", ",", "stop", "=", "'stop'", ",", "value", "=", "None", ")", ":", "import", "intervaltree", "tree", "=", "intervaltree", ".", "IntervalTree", "(", ")", "it", "=", "iter", "(", "table", ")",...
Construct an interval tree for the given table, where each node in the tree is a row of the table.
[ "Construct", "an", "interval", "tree", "for", "the", "given", "table", "where", "each", "node", "in", "the", "tree", "is", "a", "row", "of", "the", "table", "." ]
python
train
32.64
itamarst/crochet
crochet/_shutdown.py
https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/crochet/_shutdown.py#L40-L44
def register(self, f, *args, **kwargs): """ Register a function and arguments to be called later. """ self._functions.append(lambda: f(*args, **kwargs))
[ "def", "register", "(", "self", ",", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_functions", ".", "append", "(", "lambda", ":", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
Register a function and arguments to be called later.
[ "Register", "a", "function", "and", "arguments", "to", "be", "called", "later", "." ]
python
train
36
dadadel/pyment
pyment/docstring.py
https://github.com/dadadel/pyment/blob/3d1bdf87d083ff56230bd0bf7c5252e20552b7b6/pyment/docstring.py#L362-L371
def get_list_key(self, data, key, header_lines=2): """Get the list of a key elements. Each element is a tuple (key=None, description, type=None). Note that the tuple's element can differ depending on the key. :param data: the data to proceed :param key: the key """ ...
[ "def", "get_list_key", "(", "self", ",", "data", ",", "key", ",", "header_lines", "=", "2", ")", ":", "return", "super", "(", "NumpydocTools", ",", "self", ")", ".", "get_list_key", "(", "data", ",", "key", ",", "header_lines", "=", "header_lines", ")" ]
Get the list of a key elements. Each element is a tuple (key=None, description, type=None). Note that the tuple's element can differ depending on the key. :param data: the data to proceed :param key: the key
[ "Get", "the", "list", "of", "a", "key", "elements", ".", "Each", "element", "is", "a", "tuple", "(", "key", "=", "None", "description", "type", "=", "None", ")", ".", "Note", "that", "the", "tuple", "s", "element", "can", "differ", "depending", "on", ...
python
train
39.9
dnanexus/dx-toolkit
src/python/dxpy/bindings/__init__.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/__init__.py#L596-L622
def clone(self, project, folder="/", **kwargs): ''' :param project: Destination project ID :type project: string :param folder: Folder route to which to move the object :type folder: string :raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the obje...
[ "def", "clone", "(", "self", ",", "project", ",", "folder", "=", "\"/\"", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_proj", "is", "None", ":", "raise", "DXError", "(", "\"Clone called when a project ID was not associated with this object handler\"", ...
:param project: Destination project ID :type project: string :param folder: Folder route to which to move the object :type folder: string :raises: :exc:`~dxpy.exceptions.DXError` if no project is associated with the object :returns: An object handler for the new cloned object ...
[ ":", "param", "project", ":", "Destination", "project", "ID", ":", "type", "project", ":", "string", ":", "param", "folder", ":", "Folder", "route", "to", "which", "to", "move", "the", "object", ":", "type", "folder", ":", "string", ":", "raises", ":", ...
python
train
40.074074
push-things/django-th
django_th/publish.py
https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/django_th/publish.py#L26-L35
def update_trigger(self, service): """ update the date when occurs the trigger :param service: service object to update """ now = arrow.utcnow().to(settings.TIME_ZONE).format('YYYY-MM-DD HH:mm:ssZZ') TriggerService.objects.filter(id=service.id).update(date_trigger...
[ "def", "update_trigger", "(", "self", ",", "service", ")", ":", "now", "=", "arrow", ".", "utcnow", "(", ")", ".", "to", "(", "settings", ".", "TIME_ZONE", ")", ".", "format", "(", "'YYYY-MM-DD HH:mm:ssZZ'", ")", "TriggerService", ".", "objects", ".", "f...
update the date when occurs the trigger :param service: service object to update
[ "update", "the", "date", "when", "occurs", "the", "trigger", ":", "param", "service", ":", "service", "object", "to", "update" ]
python
train
53.8
HewlettPackard/python-hpOneView
hpOneView/resources/networking/fabrics.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/fabrics.py#L107-L121
def get_reserved_vlan_range(self, id_or_uri): """ Gets the reserved vlan ID range for the fabric. Note: This method is only available on HPE Synergy. Args: id_or_uri: ID or URI of fabric. Returns: dict: vlan-pool """ uri = se...
[ "def", "get_reserved_vlan_range", "(", "self", ",", "id_or_uri", ")", ":", "uri", "=", "self", ".", "_client", ".", "build_uri", "(", "id_or_uri", ")", "+", "\"/reserved-vlan-range\"", "return", "self", ".", "_client", ".", "get", "(", "uri", ")" ]
Gets the reserved vlan ID range for the fabric. Note: This method is only available on HPE Synergy. Args: id_or_uri: ID or URI of fabric. Returns: dict: vlan-pool
[ "Gets", "the", "reserved", "vlan", "ID", "range", "for", "the", "fabric", "." ]
python
train
26.6
aws/aws-encryption-sdk-python
src/aws_encryption_sdk/internal/formatting/encryption_context.py
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L29-L47
def assemble_content_aad(message_id, aad_content_string, seq_num, length): """Assembles the Body AAD string for a message body structure. :param message_id: Message ID :type message_id: str :param aad_content_string: ContentAADString object for frame type :type aad_content_string: aws_encryption_sd...
[ "def", "assemble_content_aad", "(", "message_id", ",", "aad_content_string", ",", "seq_num", ",", "length", ")", ":", "if", "not", "isinstance", "(", "aad_content_string", ",", "aws_encryption_sdk", ".", "identifiers", ".", "ContentAADString", ")", ":", "raise", "...
Assembles the Body AAD string for a message body structure. :param message_id: Message ID :type message_id: str :param aad_content_string: ContentAADString object for frame type :type aad_content_string: aws_encryption_sdk.identifiers.ContentAADString :param seq_num: Sequence number of frame :t...
[ "Assembles", "the", "Body", "AAD", "string", "for", "a", "message", "body", "structure", "." ]
python
train
48.315789
materialsproject/pymatgen
pymatgen/io/abinit/flows.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L332-L338
def pickle_loads(cls, s): """Reconstruct the flow from a string.""" strio = StringIO() strio.write(s) strio.seek(0) flow = pmg_pickle_load(strio) return flow
[ "def", "pickle_loads", "(", "cls", ",", "s", ")", ":", "strio", "=", "StringIO", "(", ")", "strio", ".", "write", "(", "s", ")", "strio", ".", "seek", "(", "0", ")", "flow", "=", "pmg_pickle_load", "(", "strio", ")", "return", "flow" ]
Reconstruct the flow from a string.
[ "Reconstruct", "the", "flow", "from", "a", "string", "." ]
python
train
28.428571