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
VingtCinq/python-mailchimp
mailchimp3/entities/storeproductimages.py
https://github.com/VingtCinq/python-mailchimp/blob/1b472f1b64fdde974732ac4b7ed48908bb707260/mailchimp3/entities/storeproductimages.py#L57-L79
def all(self, store_id, product_id, get_all=False, **queryparams): """ Get information about a product’s images. :param store_id: The store id. :type store_id: :py:class:`str` :param product_id: The id for the product of a store. :type product_id: :py:class:`str` ...
[ "def", "all", "(", "self", ",", "store_id", ",", "product_id", ",", "get_all", "=", "False", ",", "*", "*", "queryparams", ")", ":", "self", ".", "store_id", "=", "store_id", "self", ".", "product_id", "=", "product_id", "self", ".", "image_id", "=", "...
Get information about a product’s images. :param store_id: The store id. :type store_id: :py:class:`str` :param product_id: The id for the product of a store. :type product_id: :py:class:`str` :param get_all: Should the query get all results :type get_all: :py:class:`boo...
[ "Get", "information", "about", "a", "product’s", "images", "." ]
python
valid
42.652174
dailymuse/oz
oz/__init__.py
https://github.com/dailymuse/oz/blob/4329f6a207dc9d2a8fbeb4d16d415dbe4570b5bd/oz/__init__.py#L106-L125
def trigger(self, name, *args, **kwargs): """ Triggers an event to run through middleware. This method will execute a chain of relevant trigger callbacks, until one of the callbacks returns the `break_trigger`. """ # Relevant middleware is cached so we don't have to redi...
[ "def", "trigger", "(", "self", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Relevant middleware is cached so we don't have to rediscover it", "# every time. Fetch the cached value if possible.", "listeners", "=", "self", ".", "_triggers", ".", "g...
Triggers an event to run through middleware. This method will execute a chain of relevant trigger callbacks, until one of the callbacks returns the `break_trigger`.
[ "Triggers", "an", "event", "to", "run", "through", "middleware", ".", "This", "method", "will", "execute", "a", "chain", "of", "relevant", "trigger", "callbacks", "until", "one", "of", "the", "callbacks", "returns", "the", "break_trigger", "." ]
python
train
31.75
karel-brinda/rnftools
rnftools/lavender/Report.py
https://github.com/karel-brinda/rnftools/blob/25510798606fbc803a622a1abfcecf06d00d47a9/rnftools/lavender/Report.py#L174-L219
def add_graph( self, y, x_label=None, y_label="", title="", x_run=None, y_run=None, svg_size_px=None, key_position="bottom right", ): """ Add a new graph to the overlap report. Args: y (str): Value plotted on y-axis. x_label ...
[ "def", "add_graph", "(", "self", ",", "y", ",", "x_label", "=", "None", ",", "y_label", "=", "\"\"", ",", "title", "=", "\"\"", ",", "x_run", "=", "None", ",", "y_run", "=", "None", ",", "svg_size_px", "=", "None", ",", "key_position", "=", "\"bottom...
Add a new graph to the overlap report. Args: y (str): Value plotted on y-axis. x_label (str): Label on x-axis. y_label (str): Label on y-axis. title (str): Title of the plot. x_run ((float,float)): x-range. y_run ((int,int)): y-rang. svg_size_px ((int,int): Size of SVG image in pixels. key_po...
[ "Add", "a", "new", "graph", "to", "the", "overlap", "report", "." ]
python
train
28.23913
Naresh1318/crystal
crystal/app.py
https://github.com/Naresh1318/crystal/blob/6bb43fd1128296cc59b8ed3bc03064cc61c6bd88/crystal/app.py#L196-L209
def delete_run(): """ Delete the selected run from the database. :return: """ assert request.method == "POST", "POST request expected received {}".format(request.method) if request.method == "POST": try: selections = json.loads(request.form["selections"]) utils.dr...
[ "def", "delete_run", "(", ")", ":", "assert", "request", ".", "method", "==", "\"POST\"", ",", "\"POST request expected received {}\"", ".", "format", "(", "request", ".", "method", ")", "if", "request", ".", "method", "==", "\"POST\"", ":", "try", ":", "sel...
Delete the selected run from the database. :return:
[ "Delete", "the", "selected", "run", "from", "the", "database", ".", ":", "return", ":" ]
python
train
38.071429
bhmm/bhmm
bhmm/api.py
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/api.py#L202-L227
def init_gaussian_hmm(observations, nstates, lag=1, reversible=True): """ Use a heuristic scheme to generate an initial model. Parameters ---------- observations : list of ndarray((T_i)) list of arrays of length T_i with observation data nstates : int The number of states. Exam...
[ "def", "init_gaussian_hmm", "(", "observations", ",", "nstates", ",", "lag", "=", "1", ",", "reversible", "=", "True", ")", ":", "from", "bhmm", ".", "init", "import", "gaussian", "if", "lag", ">", "1", ":", "observations", "=", "lag_observations", "(", ...
Use a heuristic scheme to generate an initial model. Parameters ---------- observations : list of ndarray((T_i)) list of arrays of length T_i with observation data nstates : int The number of states. Examples -------- Generate initial model for a gaussian output model. ...
[ "Use", "a", "heuristic", "scheme", "to", "generate", "an", "initial", "model", "." ]
python
train
31.230769
aleju/imgaug
imgaug/augmentables/kps.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L13-L58
def compute_geometric_median(X, eps=1e-5): """ Estimate the geometric median of points in 2D. Code from https://stackoverflow.com/a/30305181 Parameters ---------- X : (N,2) ndarray Points in 2D. Second axis must be given in xy-form. eps : float, optional Distance threshold...
[ "def", "compute_geometric_median", "(", "X", ",", "eps", "=", "1e-5", ")", ":", "y", "=", "np", ".", "mean", "(", "X", ",", "0", ")", "while", "True", ":", "D", "=", "scipy", ".", "spatial", ".", "distance", ".", "cdist", "(", "X", ",", "[", "y...
Estimate the geometric median of points in 2D. Code from https://stackoverflow.com/a/30305181 Parameters ---------- X : (N,2) ndarray Points in 2D. Second axis must be given in xy-form. eps : float, optional Distance threshold when to return the median. Returns ------- ...
[ "Estimate", "the", "geometric", "median", "of", "points", "in", "2D", "." ]
python
valid
23.195652
apache/incubator-superset
superset/utils/decorators.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/decorators.py#L35-L43
def stats_timing(stats_key, stats_logger): """Provide a transactional scope around a series of operations.""" start_ts = now_as_float() try: yield start_ts except Exception as e: raise e finally: stats_logger.timing(stats_key, now_as_float() - start_ts)
[ "def", "stats_timing", "(", "stats_key", ",", "stats_logger", ")", ":", "start_ts", "=", "now_as_float", "(", ")", "try", ":", "yield", "start_ts", "except", "Exception", "as", "e", ":", "raise", "e", "finally", ":", "stats_logger", ".", "timing", "(", "st...
Provide a transactional scope around a series of operations.
[ "Provide", "a", "transactional", "scope", "around", "a", "series", "of", "operations", "." ]
python
train
32.111111
studionow/pybrightcove
pybrightcove/video.py
https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/video.py#L747-L758
def find_by_ids(ids, _connection=None, page_size=100, page_number=0, sort_by=enums.DEFAULT_SORT_BY, sort_order=enums.DEFAULT_SORT_ORDER): """ List all videos identified by a list of Brightcove video ids """ if not isinstance(ids, (list, tuple)): err = "Video.find_by_i...
[ "def", "find_by_ids", "(", "ids", ",", "_connection", "=", "None", ",", "page_size", "=", "100", ",", "page_number", "=", "0", ",", "sort_by", "=", "enums", ".", "DEFAULT_SORT_BY", ",", "sort_order", "=", "enums", ".", "DEFAULT_SORT_ORDER", ")", ":", "if",...
List all videos identified by a list of Brightcove video ids
[ "List", "all", "videos", "identified", "by", "a", "list", "of", "Brightcove", "video", "ids" ]
python
train
50.416667
AshleySetter/frange
frange/frange/frange.py
https://github.com/AshleySetter/frange/blob/6b0412d0584fce04c870af82d3e0bf90ed60fb5b/frange/frange/frange.py#L92-L121
def drange(start, stop, step): """ A generator that yields successive samples from start (inclusive) to stop (exclusive) in step intervals. Parameters ---------- start : float starting point stop : float stopping point step : float stepping interval Yields ...
[ "def", "drange", "(", "start", ",", "stop", ",", "step", ")", ":", "x", "=", "start", "if", "step", ">", "0", ":", "while", "x", "+", "step", "<=", "stop", ":", "# produces same behaviour as numpy.arange", "yield", "x", "x", "+=", "step", "elif", "step...
A generator that yields successive samples from start (inclusive) to stop (exclusive) in step intervals. Parameters ---------- start : float starting point stop : float stopping point step : float stepping interval Yields ------ x : float next sampl...
[ "A", "generator", "that", "yields", "successive", "samples", "from", "start", "(", "inclusive", ")", "to", "stop", "(", "exclusive", ")", "in", "step", "intervals", "." ]
python
train
23.066667
miyakogi/wdom
wdom/event.py
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/event.py#L391-L399
def js_exec(self, method: str, *args: Union[int, str, bool]) -> None: """Execute ``method`` in the related node on browser. Other keyword arguments are passed to ``params`` attribute. If this node is not in any document tree (namely, this node does not have parent node), the ``method`` ...
[ "def", "js_exec", "(", "self", ",", "method", ":", "str", ",", "*", "args", ":", "Union", "[", "int", ",", "str", ",", "bool", "]", ")", "->", "None", ":", "if", "self", ".", "connected", ":", "self", ".", "ws_send", "(", "dict", "(", "method", ...
Execute ``method`` in the related node on browser. Other keyword arguments are passed to ``params`` attribute. If this node is not in any document tree (namely, this node does not have parent node), the ``method`` is not executed.
[ "Execute", "method", "in", "the", "related", "node", "on", "browser", "." ]
python
train
47.333333
saltstack/salt
salt/states/csf.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/csf.py#L261-L265
def nics_skip(name, nics, ipv6): ''' Alias for :mod:`csf.nics_skipped <salt.states.csf.nics_skipped>` ''' return nics_skipped(name, nics=nics, ipv6=ipv6)
[ "def", "nics_skip", "(", "name", ",", "nics", ",", "ipv6", ")", ":", "return", "nics_skipped", "(", "name", ",", "nics", "=", "nics", ",", "ipv6", "=", "ipv6", ")" ]
Alias for :mod:`csf.nics_skipped <salt.states.csf.nics_skipped>`
[ "Alias", "for", ":", "mod", ":", "csf", ".", "nics_skipped", "<salt", ".", "states", ".", "csf", ".", "nics_skipped", ">" ]
python
train
33
fbcotter/py3nvml
py3nvml/py3nvml.py
https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/py3nvml.py#L3869-L3903
def nvmlUnitSetLedState(unit, color): r""" /** * Set the LED state for the unit. The LED can be either green (0) or amber (1). * * For S-class products. * Requires root/admin permissions. * * This operation takes effect immediately. * * * <b>Current S-Class products ...
[ "def", "nvmlUnitSetLedState", "(", "unit", ",", "color", ")", ":", "fn", "=", "_nvmlGetFunctionPointer", "(", "\"nvmlUnitSetLedState\"", ")", "ret", "=", "fn", "(", "unit", ",", "_nvmlLedColor_t", "(", "color", ")", ")", "_nvmlCheckReturn", "(", "ret", ")", ...
r""" /** * Set the LED state for the unit. The LED can be either green (0) or amber (1). * * For S-class products. * Requires root/admin permissions. * * This operation takes effect immediately. * * * <b>Current S-Class products don't provide unique LEDs for each unit. A...
[ "r", "/", "**", "*", "Set", "the", "LED", "state", "for", "the", "unit", ".", "The", "LED", "can", "be", "either", "green", "(", "0", ")", "or", "amber", "(", "1", ")", ".", "*", "*", "For", "S", "-", "class", "products", ".", "*", "Requires", ...
python
train
42.457143
futapi/fut
fut/core.py
https://github.com/futapi/fut/blob/3792c9eee8f5884f38a02210e649c46c6c7a756d/fut/core.py#L1238-L1251
def tradeStatus(self, trade_id): """Return trade status. :params trade_id: Trade id. """ method = 'GET' url = 'trade/status' if not isinstance(trade_id, (list, tuple)): trade_id = (trade_id,) trade_id = (str(i) for i in trade_id) params = {'t...
[ "def", "tradeStatus", "(", "self", ",", "trade_id", ")", ":", "method", "=", "'GET'", "url", "=", "'trade/status'", "if", "not", "isinstance", "(", "trade_id", ",", "(", "list", ",", "tuple", ")", ")", ":", "trade_id", "=", "(", "trade_id", ",", ")", ...
Return trade status. :params trade_id: Trade id.
[ "Return", "trade", "status", "." ]
python
valid
35.428571
biolink/ontobio
ontobio/sim/api/owlsim2.py
https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/sim/api/owlsim2.py#L311-L353
def _simsearch_to_simresult(self, sim_resp: Dict, method: SimAlgorithm) -> SimResult: """ Convert owlsim json to SimResult object :param sim_resp: owlsim response from search_by_attribute_set() :param method: SimAlgorithm :return: SimResult object """ sim_ids = ...
[ "def", "_simsearch_to_simresult", "(", "self", ",", "sim_resp", ":", "Dict", ",", "method", ":", "SimAlgorithm", ")", "->", "SimResult", ":", "sim_ids", "=", "get_nodes_from_ids", "(", "sim_resp", "[", "'query_IRIs'", "]", ")", "sim_resp", "[", "'results'", "]...
Convert owlsim json to SimResult object :param sim_resp: owlsim response from search_by_attribute_set() :param method: SimAlgorithm :return: SimResult object
[ "Convert", "owlsim", "json", "to", "SimResult", "object" ]
python
train
33.744186
peerplays-network/python-peerplays
peerplays/cli/bookie.py
https://github.com/peerplays-network/python-peerplays/blob/188f04238e7e21d5f73e9b01099eea44289ef6b7/peerplays/cli/bookie.py#L98-L116
def rule(ctx, rule): """ [bookie] Show a specific rule :param str bmg: Betting market id """ rule = Rule(rule, peerplays_instance=ctx.peerplays) t = PrettyTable([ "id", "name", ]) t.align = "l" t.add_row([ rule["id"], "\n".join(["{}: {}".format(v[0], ...
[ "def", "rule", "(", "ctx", ",", "rule", ")", ":", "rule", "=", "Rule", "(", "rule", ",", "peerplays_instance", "=", "ctx", ".", "peerplays", ")", "t", "=", "PrettyTable", "(", "[", "\"id\"", ",", "\"name\"", ",", "]", ")", "t", ".", "align", "=", ...
[bookie] Show a specific rule :param str bmg: Betting market id
[ "[", "bookie", "]", "Show", "a", "specific", "rule" ]
python
train
24.315789
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/configuration_db/setup.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/setup.py#L9-L15
def package_files(directory): """Get list of data files to add to the package.""" paths = [] for (path, _, file_names) in walk(directory): for filename in file_names: paths.append(join('..', path, filename)) return paths
[ "def", "package_files", "(", "directory", ")", ":", "paths", "=", "[", "]", "for", "(", "path", ",", "_", ",", "file_names", ")", "in", "walk", "(", "directory", ")", ":", "for", "filename", "in", "file_names", ":", "paths", ".", "append", "(", "join...
Get list of data files to add to the package.
[ "Get", "list", "of", "data", "files", "to", "add", "to", "the", "package", "." ]
python
train
35.714286
bwohlberg/sporco
sporco/admm/admm.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/admm.py#L1414-L1425
def rsdl_rn(self, AX, Y): """Compute primal residual normalisation term. Overriding this method is required if methods :meth:`cnst_A`, :meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not overridden. """ if not hasattr(self, '_cnst_nrm_c'): self._cnst...
[ "def", "rsdl_rn", "(", "self", ",", "AX", ",", "Y", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_cnst_nrm_c'", ")", ":", "self", ".", "_cnst_nrm_c", "=", "np", ".", "sqrt", "(", "np", ".", "linalg", ".", "norm", "(", "self", ".", "cnst_...
Compute primal residual normalisation term. Overriding this method is required if methods :meth:`cnst_A`, :meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not overridden.
[ "Compute", "primal", "residual", "normalisation", "term", "." ]
python
train
42.75
numberoverzero/bloop
bloop/session.py
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L362-L378
def get_stream_records(self, iterator_id): """Wraps :func:`boto3.DynamoDBStreams.Client.get_records`. :param iterator_id: Iterator id. Usually :data:`Shard.iterator_id <bloop.stream.shard.Shard.iterator_id>`. :return: Dict with "Records" list (may be empty) and "NextShardIterator" str (may not...
[ "def", "get_stream_records", "(", "self", ",", "iterator_id", ")", ":", "try", ":", "return", "self", ".", "stream_client", ".", "get_records", "(", "ShardIterator", "=", "iterator_id", ")", "except", "botocore", ".", "exceptions", ".", "ClientError", "as", "e...
Wraps :func:`boto3.DynamoDBStreams.Client.get_records`. :param iterator_id: Iterator id. Usually :data:`Shard.iterator_id <bloop.stream.shard.Shard.iterator_id>`. :return: Dict with "Records" list (may be empty) and "NextShardIterator" str (may not exist). :rtype: dict :raises bloop.ex...
[ "Wraps", ":", "func", ":", "boto3", ".", "DynamoDBStreams", ".", "Client", ".", "get_records", "." ]
python
train
62.411765
liminspace/dju-image
dju_image/tools.py
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/tools.py#L50-L72
def get_profile_configs(profile=None, use_cache=True): """ Returns upload configs for profile. """ if use_cache and profile in _profile_configs_cache: return _profile_configs_cache[profile] profile_conf = None if profile is not None: try: profile_conf = dju_settings.D...
[ "def", "get_profile_configs", "(", "profile", "=", "None", ",", "use_cache", "=", "True", ")", ":", "if", "use_cache", "and", "profile", "in", "_profile_configs_cache", ":", "return", "_profile_configs_cache", "[", "profile", "]", "profile_conf", "=", "None", "i...
Returns upload configs for profile.
[ "Returns", "upload", "configs", "for", "profile", "." ]
python
train
41.173913
datastax/python-driver
cassandra/connection.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/connection.py#L1252-L1274
def service_timeouts(self): """ run callbacks on all expired timers Called from the event thread :return: next end time, or None """ queue = self._queue if self._new_timers: new_timers = self._new_timers while new_timers: he...
[ "def", "service_timeouts", "(", "self", ")", ":", "queue", "=", "self", ".", "_queue", "if", "self", ".", "_new_timers", ":", "new_timers", "=", "self", ".", "_new_timers", "while", "new_timers", ":", "heappush", "(", "queue", ",", "new_timers", ".", "pop"...
run callbacks on all expired timers Called from the event thread :return: next end time, or None
[ "run", "callbacks", "on", "all", "expired", "timers", "Called", "from", "the", "event", "thread", ":", "return", ":", "next", "end", "time", "or", "None" ]
python
train
31.652174
slackapi/python-slackclient
slack/web/client.py
https://github.com/slackapi/python-slackclient/blob/901341c0284fd81e6d2719d6a0502308760d83e4/slack/web/client.py#L1291-L1294
def users_profile_get(self, **kwargs) -> SlackResponse: """Retrieves a user's profile information.""" self._validate_xoxp_token() return self.api_call("users.profile.get", http_verb="GET", params=kwargs)
[ "def", "users_profile_get", "(", "self", ",", "*", "*", "kwargs", ")", "->", "SlackResponse", ":", "self", ".", "_validate_xoxp_token", "(", ")", "return", "self", ".", "api_call", "(", "\"users.profile.get\"", ",", "http_verb", "=", "\"GET\"", ",", "params", ...
Retrieves a user's profile information.
[ "Retrieves", "a", "user", "s", "profile", "information", "." ]
python
train
56
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1432-L1436
def p_delays_intnumber(self, p): 'delays : DELAY intnumber' p[0] = DelayStatement( IntConst(p[2], lineno=p.lineno(1)), lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_delays_intnumber", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "DelayStatement", "(", "IntConst", "(", "p", "[", "2", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", ",", "lineno", "=", "p", ".", "lineno...
delays : DELAY intnumber
[ "delays", ":", "DELAY", "intnumber" ]
python
train
39.8
lrq3000/pyFileFixity
pyFileFixity/lib/tqdm/tqdm.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/tqdm/tqdm.py#L20-L26
def format_sizeof(num, suffix='bytes'): '''Readable size format, courtesy of Sridhar Ratnakumar''' for unit in ['','K','M','G','T','P','E','Z']: if abs(num) < 1000.0: return "%3.1f%s%s" % (num, unit, suffix) num /= 1000.0 return "%.1f%s%s" % (num, 'Y', suffix)
[ "def", "format_sizeof", "(", "num", ",", "suffix", "=", "'bytes'", ")", ":", "for", "unit", "in", "[", "''", ",", "'K'", ",", "'M'", ",", "'G'", ",", "'T'", ",", "'P'", ",", "'E'", ",", "'Z'", "]", ":", "if", "abs", "(", "num", ")", "<", "100...
Readable size format, courtesy of Sridhar Ratnakumar
[ "Readable", "size", "format", "courtesy", "of", "Sridhar", "Ratnakumar" ]
python
train
42
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/fixer_util.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/fixer_util.py#L250-L258
def find_indentation(node): """Find the indentation of *node*.""" while node is not None: if node.type == syms.suite and len(node.children) > 2: indent = node.children[1] if indent.type == token.INDENT: return indent.value node = node.parent return u""
[ "def", "find_indentation", "(", "node", ")", ":", "while", "node", "is", "not", "None", ":", "if", "node", ".", "type", "==", "syms", ".", "suite", "and", "len", "(", "node", ".", "children", ")", ">", "2", ":", "indent", "=", "node", ".", "childre...
Find the indentation of *node*.
[ "Find", "the", "indentation", "of", "*", "node", "*", "." ]
python
train
34.666667
spyder-ide/conda-manager
conda_manager/api/manager_api.py
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L143-L149
def _repo_url_to_path(self, repo): """Convert a `repo` url to a file path for local storage.""" repo = repo.replace('http://', '') repo = repo.replace('https://', '') repo = repo.replace('/', '_') return os.sep.join([self._data_directory, repo])
[ "def", "_repo_url_to_path", "(", "self", ",", "repo", ")", ":", "repo", "=", "repo", ".", "replace", "(", "'http://'", ",", "''", ")", "repo", "=", "repo", ".", "replace", "(", "'https://'", ",", "''", ")", "repo", "=", "repo", ".", "replace", "(", ...
Convert a `repo` url to a file path for local storage.
[ "Convert", "a", "repo", "url", "to", "a", "file", "path", "for", "local", "storage", "." ]
python
train
40
usc-isi-i2/dig-extractor
digExtractor/extractor_processor.py
https://github.com/usc-isi-i2/dig-extractor/blob/87c138e0300d77e35ebeb5f5e9488c3d71e60eb3/digExtractor/extractor_processor.py#L150-L158
def set_input_fields(self, input_fields): """Given a scalar or ordered list of strings generate JSONPaths that describe how to access the values necessary for the Extractor """ if not (isinstance(input_fields, basestring) or isinstance(input_fields, types.ListType)): ...
[ "def", "set_input_fields", "(", "self", ",", "input_fields", ")", ":", "if", "not", "(", "isinstance", "(", "input_fields", ",", "basestring", ")", "or", "isinstance", "(", "input_fields", ",", "types", ".", "ListType", ")", ")", ":", "raise", "ValueError", ...
Given a scalar or ordered list of strings generate JSONPaths that describe how to access the values necessary for the Extractor
[ "Given", "a", "scalar", "or", "ordered", "list", "of", "strings", "generate", "JSONPaths", "that", "describe", "how", "to", "access", "the", "values", "necessary", "for", "the", "Extractor" ]
python
train
51.888889
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4522-L4530
def merge(self, dict_=None): """not is use so far, see check()""" if dict_ is None and hasattr(self, '__dict__'): dict_ = self.__dict__ # doesn't work anymore as we have _lock attribute if dict_ is None: return self self.update(dict_) return ...
[ "def", "merge", "(", "self", ",", "dict_", "=", "None", ")", ":", "if", "dict_", "is", "None", "and", "hasattr", "(", "self", ",", "'__dict__'", ")", ":", "dict_", "=", "self", ".", "__dict__", "# doesn't work anymore as we have _lock attribute", "if", "dict...
not is use so far, see check()
[ "not", "is", "use", "so", "far", "see", "check", "()" ]
python
train
35.111111
ssato/python-anyconfig
src/anyconfig/processors.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L321-L334
def findall(self, obj, forced_type=None, cls=anyconfig.models.processor.Processor): """ :param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to f...
[ "def", "findall", "(", "self", ",", "obj", ",", "forced_type", "=", "None", ",", "cls", "=", "anyconfig", ".", "models", ".", "processor", ".", "Processor", ")", ":", "return", "[", "p", "(", ")", "for", "p", "in", "findall", "(", "obj", ",", "self...
:param obj: a file path, file, file-like object, pathlib.Path object or an 'anyconfig.globals.IOInfo' (namedtuple) object :param forced_type: Forced processor type to find :param cls: A class object to compare with 'ptype' :return: A list of instances of processor classe...
[ ":", "param", "obj", ":", "a", "file", "path", "file", "file", "-", "like", "object", "pathlib", ".", "Path", "object", "or", "an", "anyconfig", ".", "globals", ".", "IOInfo", "(", "namedtuple", ")", "object", ":", "param", "forced_type", ":", "Forced", ...
python
train
47.214286
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L365-L420
def _populate_bookmarks_list(self): """Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are re...
[ "def", "_populate_bookmarks_list", "(", "self", ")", ":", "# Connect to the QGIS sqlite database and check if the table exists.", "# noinspection PyArgumentList", "db_file_path", "=", "QgsApplication", ".", "qgisUserDatabaseFilePath", "(", ")", "db", "=", "sqlite3", ".", "conne...
Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are reprojected to mapcanvas crs.
[ "Read", "the", "sqlite", "database", "and", "populate", "the", "bookmarks", "list", "." ]
python
train
37.017857
apache/incubator-superset
superset/connectors/sqla/models.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L933-L952
def import_obj(cls, i_datasource, import_time=None): """Imports the datasource from the object to the database. Metrics and columns and datasource will be overrided if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata is...
[ "def", "import_obj", "(", "cls", ",", "i_datasource", ",", "import_time", "=", "None", ")", ":", "def", "lookup_sqlatable", "(", "table", ")", ":", "return", "db", ".", "session", ".", "query", "(", "SqlaTable", ")", ".", "join", "(", "Database", ")", ...
Imports the datasource from the object to the database. Metrics and columns and datasource will be overrided if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata isn't copies over.
[ "Imports", "the", "datasource", "from", "the", "object", "to", "the", "database", "." ]
python
train
46.6
openpermissions/koi
koi/utils.py
https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/utils.py#L52-L65
def stringify(*args): """ Joins args to build a string, unless there's one arg and it's a function, then acts a decorator. """ if (len(args) == 1) and callable(args[0]): func = args[0] @wraps(func) def _inner(*args, **kwargs): return "".join([str(i) for i in func...
[ "def", "stringify", "(", "*", "args", ")", ":", "if", "(", "len", "(", "args", ")", "==", "1", ")", "and", "callable", "(", "args", "[", "0", "]", ")", ":", "func", "=", "args", "[", "0", "]", "@", "wraps", "(", "func", ")", "def", "_inner", ...
Joins args to build a string, unless there's one arg and it's a function, then acts a decorator.
[ "Joins", "args", "to", "build", "a", "string", "unless", "there", "s", "one", "arg", "and", "it", "s", "a", "function", "then", "acts", "a", "decorator", "." ]
python
train
28.928571
tuomas2/automate
src/automate/statusobject.py
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L591-L605
def deactivate_program(self, program): """ Called by program, when it is deactivated. """ self.logger.debug("deactivate_program %s", program) with self._program_lock: self.logger.debug("deactivate_program got through %s", program) if program not in se...
[ "def", "deactivate_program", "(", "self", ",", "program", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"deactivate_program %s\"", ",", "program", ")", "with", "self", ".", "_program_lock", ":", "self", ".", "logger", ".", "debug", "(", "\"deactivate...
Called by program, when it is deactivated.
[ "Called", "by", "program", "when", "it", "is", "deactivated", "." ]
python
train
37.866667
fedora-infra/fmn.rules
fmn/rules/taskotron.py
https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/taskotron.py#L15-L33
def taskotron_task(config, message, task=None): """ Particular taskotron task With this rule, you can limit messages to only those of particular `taskotron <https://taskotron.fedoraproject.org/>`_ task. You can specify several tasks by separating them with a comma ',', i.e.: ``dist.depcheck,dist.r...
[ "def", "taskotron_task", "(", "config", ",", "message", ",", "task", "=", "None", ")", ":", "# We only operate on taskotron messages, first off.", "if", "not", "taskotron_result_new", "(", "config", ",", "message", ")", ":", "return", "False", "if", "not", "task",...
Particular taskotron task With this rule, you can limit messages to only those of particular `taskotron <https://taskotron.fedoraproject.org/>`_ task. You can specify several tasks by separating them with a comma ',', i.e.: ``dist.depcheck,dist.rpmlint``.
[ "Particular", "taskotron", "task" ]
python
train
32.263158
lark-parser/lark
examples/standalone/json_parser.py
https://github.com/lark-parser/lark/blob/a798dec77907e74520dd7e90c7b6a4acc680633a/examples/standalone/json_parser.py#L61-L85
def match_examples(self, parse_fn, examples): """ Given a parser instance and a dictionary mapping some label with some malformed syntax examples, it'll return the label for the example that bests matches the current error. """ assert self.state is not None, "Not supporte...
[ "def", "match_examples", "(", "self", ",", "parse_fn", ",", "examples", ")", ":", "assert", "self", ".", "state", "is", "not", "None", ",", "\"Not supported for this exception\"", "candidate", "=", "None", "for", "label", ",", "example", "in", "examples", ".",...
Given a parser instance and a dictionary mapping some label with some malformed syntax examples, it'll return the label for the example that bests matches the current error.
[ "Given", "a", "parser", "instance", "and", "a", "dictionary", "mapping", "some", "label", "with", "some", "malformed", "syntax", "examples", "it", "ll", "return", "the", "label", "for", "the", "example", "that", "bests", "matches", "the", "current", "error", ...
python
train
39.52
psss/did
did/plugins/trac.py
https://github.com/psss/did/blob/04e4ee6f1aa14c0cae3ba9f9803871f3f98279cb/did/plugins/trac.py#L96-L103
def history(self, user=None): """ Return relevant who-did-what logs from the ticket history """ for event in self.changelog: when, who, what, old, new, ignore = event if (when >= self.options.since.date and when <= self.options.until.date): if ...
[ "def", "history", "(", "self", ",", "user", "=", "None", ")", ":", "for", "event", "in", "self", ".", "changelog", ":", "when", ",", "who", ",", "what", ",", "old", ",", "new", ",", "ignore", "=", "event", "if", "(", "when", ">=", "self", ".", ...
Return relevant who-did-what logs from the ticket history
[ "Return", "relevant", "who", "-", "did", "-", "what", "logs", "from", "the", "ticket", "history" ]
python
train
50.25
nuSTORM/gnomon
gnomon/Graph.py
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/Graph.py#L42-L69
def CreateDirectedEdges(self, points, gr, layer_width): """ Take each key (ie. point) in the graph and for that point create an edge to every point downstream of it where the weight of the edge is the tuple (distance, angle) """ for z0, x0, Q0 in points: for z...
[ "def", "CreateDirectedEdges", "(", "self", ",", "points", ",", "gr", ",", "layer_width", ")", ":", "for", "z0", ",", "x0", ",", "Q0", "in", "points", ":", "for", "z1", ",", "x1", ",", "Q1", "in", "points", ":", "dz", "=", "z1", "-", "z0", "# no f...
Take each key (ie. point) in the graph and for that point create an edge to every point downstream of it where the weight of the edge is the tuple (distance, angle)
[ "Take", "each", "key", "(", "ie", ".", "point", ")", "in", "the", "graph", "and", "for", "that", "point", "create", "an", "edge", "to", "every", "point", "downstream", "of", "it", "where", "the", "weight", "of", "the", "edge", "is", "the", "tuple", "...
python
train
39.357143
jopohl/urh
src/urh/models/ProtocolTreeItem.py
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeItem.py#L106-L114
def child(self, number): """ :type number: int :rtype: ProtocolTreeItem """ if number < self.childCount(): return self.__childItems[number] else: return False
[ "def", "child", "(", "self", ",", "number", ")", ":", "if", "number", "<", "self", ".", "childCount", "(", ")", ":", "return", "self", ".", "__childItems", "[", "number", "]", "else", ":", "return", "False" ]
:type number: int :rtype: ProtocolTreeItem
[ ":", "type", "number", ":", "int", ":", "rtype", ":", "ProtocolTreeItem" ]
python
train
24.666667
scanny/python-pptx
pptx/text/text.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/text.py#L217-L229
def _best_fit_font_size(self, family, max_size, bold, italic, font_file): """ Return the largest integer point size not greater than *max_size* that allows all the text in this text frame to fit inside its extents when rendered using the font described by *family*, *bold*, and *i...
[ "def", "_best_fit_font_size", "(", "self", ",", "family", ",", "max_size", ",", "bold", ",", "italic", ",", "font_file", ")", ":", "if", "font_file", "is", "None", ":", "font_file", "=", "FontFiles", ".", "find", "(", "family", ",", "bold", ",", "italic"...
Return the largest integer point size not greater than *max_size* that allows all the text in this text frame to fit inside its extents when rendered using the font described by *family*, *bold*, and *italic*. If *font_file* is specified, it is used to calculate the fit, whether or not i...
[ "Return", "the", "largest", "integer", "point", "size", "not", "greater", "than", "*", "max_size", "*", "that", "allows", "all", "the", "text", "in", "this", "text", "frame", "to", "fit", "inside", "its", "extents", "when", "rendered", "using", "the", "fon...
python
train
50.769231
kyper-data/python-highcharts
highcharts/highcharts/highcharts.py
https://github.com/kyper-data/python-highcharts/blob/a4c488ae5c2e125616efad5a722f3dfd8a9bc450/highcharts/highcharts/highcharts.py#L339-L371
def buildhtmlheader(self): """generate HTML header content""" if self.drilldown_flag: self.add_JSsource('http://code.highcharts.com/modules/drilldown.js') if self.offline: opener = urllib.request.build_opener() opener.addheaders = [('User-Agent', '...
[ "def", "buildhtmlheader", "(", "self", ")", ":", "if", "self", ".", "drilldown_flag", ":", "self", ".", "add_JSsource", "(", "'http://code.highcharts.com/modules/drilldown.js'", ")", "if", "self", ".", "offline", ":", "opener", "=", "urllib", ".", "request", "."...
generate HTML header content
[ "generate", "HTML", "header", "content" ]
python
train
31.484848
influxdata/influxdb-python
influxdb/client.py
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L454-L514
def write_points(self, points, time_precision=None, database=None, retention_policy=None, tags=None, batch_size=None, protocol='json', consistency=None ...
[ "def", "write_points", "(", "self", ",", "points", ",", "time_precision", "=", "None", ",", "database", "=", "None", ",", "retention_policy", "=", "None", ",", "tags", "=", "None", ",", "batch_size", "=", "None", ",", "protocol", "=", "'json'", ",", "con...
Write to multiple time series names. :param points: the list of points to be written in the database :type points: list of dictionaries, each dictionary represents a point :type points: (if protocol is 'json') list of dicts, where each dict represents...
[ "Write", "to", "multiple", "time", "series", "names", "." ]
python
train
47.836066
portfoliome/foil
foil/parsers.py
https://github.com/portfoliome/foil/blob/b66d8cf4ab048a387d8c7a033b47e922ed6917d6/foil/parsers.py#L121-L135
def parse_broken_json(json_text: str) -> dict: """ Parses broken JSON that the standard Python JSON module cannot parse. Ex: {success:true} Keys do not contain quotes and the JSON cannot be parsed using the regular json encoder. YAML happens to be a superset of JSON and can parse json without quot...
[ "def", "parse_broken_json", "(", "json_text", ":", "str", ")", "->", "dict", ":", "# Add spacing between Key and Value to prevent parsing error", "json_text", "=", "json_text", ".", "replace", "(", "\":\"", ",", "\": \"", ")", "json_dict", "=", "yaml", ".", "load", ...
Parses broken JSON that the standard Python JSON module cannot parse. Ex: {success:true} Keys do not contain quotes and the JSON cannot be parsed using the regular json encoder. YAML happens to be a superset of JSON and can parse json without quotes.
[ "Parses", "broken", "JSON", "that", "the", "standard", "Python", "JSON", "module", "cannot", "parse", "." ]
python
train
32.466667
philklei/tahoma-api
tahoma_api/tahoma_api.py
https://github.com/philklei/tahoma-api/blob/fc84f6ba3b673d0cd0e9e618777834a74a3c7b64/tahoma_api/tahoma_api.py#L749-L765
def set_active_state(self, name, value): """Set active state.""" if name not in self.__active_states.keys(): raise ValueError("Can not set unknown state '" + name + "'") if (isinstance(self.__active_states[name], int) and isinstance(value, str)): # we get...
[ "def", "set_active_state", "(", "self", ",", "name", ",", "value", ")", ":", "if", "name", "not", "in", "self", ".", "__active_states", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "\"Can not set unknown state '\"", "+", "name", "+", "\"'\"", ")...
Set active state.
[ "Set", "active", "state", "." ]
python
train
43.882353
michaeljoseph/remarkable
remarkable/cli.py
https://github.com/michaeljoseph/remarkable/blob/321f8f7d58fe2ad0c48233980cedda18c5abad55/remarkable/cli.py#L56-L95
def render_template_directory(deck, arguments): """Render a template directory""" output_directory = dir_name_from_title(deck.title) if os.path.exists(output_directory): if sys.stdout.isatty(): if ask( '%s already exists, shall I delete it?' % output_directory, ...
[ "def", "render_template_directory", "(", "deck", ",", "arguments", ")", ":", "output_directory", "=", "dir_name_from_title", "(", "deck", ".", "title", ")", "if", "os", ".", "path", ".", "exists", "(", "output_directory", ")", ":", "if", "sys", ".", "stdout"...
Render a template directory
[ "Render", "a", "template", "directory" ]
python
train
30.375
pyviz/geoviews
geoviews/plotting/mpl/__init__.py
https://github.com/pyviz/geoviews/blob/cc70ac2d5a96307769bc6192eaef8576c3d24b30/geoviews/plotting/mpl/__init__.py#L393-L400
def teardown_handles(self): """ If no custom update_handles method is supplied this method is called to tear down any previous handles before replacing them. """ if not isinstance(self.handles.get('artist'), GoogleTiles): self.handles['artist'].remove()
[ "def", "teardown_handles", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "handles", ".", "get", "(", "'artist'", ")", ",", "GoogleTiles", ")", ":", "self", ".", "handles", "[", "'artist'", "]", ".", "remove", "(", ")" ]
If no custom update_handles method is supplied this method is called to tear down any previous handles before replacing them.
[ "If", "no", "custom", "update_handles", "method", "is", "supplied", "this", "method", "is", "called", "to", "tear", "down", "any", "previous", "handles", "before", "replacing", "them", "." ]
python
train
38.25
saltstack/salt
salt/modules/runit.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L206-L240
def status(name, sig=None): ''' Return ``True`` if service is running name the service's name sig signature to identify with ps CLI Example: .. code-block:: bash salt '*' runit.status <service name> ''' if sig: # usual way to do by others (debian_serv...
[ "def", "status", "(", "name", ",", "sig", "=", "None", ")", ":", "if", "sig", ":", "# usual way to do by others (debian_service, netbsdservice).", "# XXX probably does not work here (check 'runsv sshd' instead of 'sshd' ?)", "return", "bool", "(", "__salt__", "[", "'status.pi...
Return ``True`` if service is running name the service's name sig signature to identify with ps CLI Example: .. code-block:: bash salt '*' runit.status <service name>
[ "Return", "True", "if", "service", "is", "running" ]
python
train
25.314286
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L3703-L3706
def trigger_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/chat/triggers#create-trigger" api_path = "/api/v2/triggers" return self.call(api_path, method="POST", data=data, **kwargs)
[ "def", "trigger_create", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/triggers\"", "return", "self", ".", "call", "(", "api_path", ",", "method", "=", "\"POST\"", ",", "data", "=", "data", ",", "*", "*", "kwa...
https://developer.zendesk.com/rest_api/docs/chat/triggers#create-trigger
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "chat", "/", "triggers#create", "-", "trigger" ]
python
train
57.5
r-barnes/richdem
wrappers/pyrichdem/richdem/__init__.py
https://github.com/r-barnes/richdem/blob/abc04d81216d7cf5b57ad7a1e04b5699369b6f58/wrappers/pyrichdem/richdem/__init__.py#L605-L682
def FlowProportions( dem, method = None, exponent = None ): """Calculates flow proportions. A variety of methods are available. Args: dem (rdarray): An elevation model method (str): Flow accumulation method to use. (See below.) exponent (float): Some methods requi...
[ "def", "FlowProportions", "(", "dem", ",", "method", "=", "None", ",", "exponent", "=", "None", ")", ":", "if", "type", "(", "dem", ")", "is", "not", "rdarray", ":", "raise", "Exception", "(", "\"A richdem.rdarray or numpy.ndarray is required!\"", ")", "fprop_...
Calculates flow proportions. A variety of methods are available. Args: dem (rdarray): An elevation model method (str): Flow accumulation method to use. (See below.) exponent (float): Some methods require an exponent; refer to the relevant publi...
[ "Calculates", "flow", "proportions", ".", "A", "variety", "of", "methods", "are", "available", "." ]
python
train
58.230769
Fuyukai/Pyte
pyte/compiler.py
https://github.com/Fuyukai/Pyte/blob/7ef04938d80f8b646bd73d976ac9787a5b88edd9/pyte/compiler.py#L19-L43
def compile_bytecode(code: list) -> bytes: """ Compiles Pyte objects into a bytecode list. :param code: A list of objects to compile. :return: The computed bytecode. """ bc = b"" for i, op in enumerate(code): try: # Get the bytecode. if isinstance(op, _PyteOp...
[ "def", "compile_bytecode", "(", "code", ":", "list", ")", "->", "bytes", ":", "bc", "=", "b\"\"", "for", "i", ",", "op", "in", "enumerate", "(", "code", ")", ":", "try", ":", "# Get the bytecode.", "if", "isinstance", "(", "op", ",", "_PyteOp", ")", ...
Compiles Pyte objects into a bytecode list. :param code: A list of objects to compile. :return: The computed bytecode.
[ "Compiles", "Pyte", "objects", "into", "a", "bytecode", "list", "." ]
python
valid
33.28
drericstrong/pyedna
pyedna/serv.py
https://github.com/drericstrong/pyedna/blob/b8f8f52def4f26bb4f3a993ce3400769518385f6/pyedna/serv.py#L109-L130
def AddAnalogShortIdRecordNoStatus(site_service, tag, time_value, value): """ This function will add an analog value to the specified eDNA service and tag, without an associated point status. :param site_service: The site.service where data will be pushed :param tag: The eDNA tag to push data. Tag ...
[ "def", "AddAnalogShortIdRecordNoStatus", "(", "site_service", ",", "tag", ",", "time_value", ",", "value", ")", ":", "# Define all required variables in the correct ctypes format", "szService", "=", "c_char_p", "(", "site_service", ".", "encode", "(", "'utf-8'", ")", ")...
This function will add an analog value to the specified eDNA service and tag, without an associated point status. :param site_service: The site.service where data will be pushed :param tag: The eDNA tag to push data. Tag only (e.g. ADE1CA01) :param time_value: The time of the point, which MUST be in UT...
[ "This", "function", "will", "add", "an", "analog", "value", "to", "the", "specified", "eDNA", "service", "and", "tag", "without", "an", "associated", "point", "status", "." ]
python
train
47.681818
inveniosoftware/invenio-oauthclient
invenio_oauthclient/views/settings.py
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/settings.py#L47-L83
def index(): """List linked accounts.""" oauth = current_app.extensions['oauthlib.client'] services = [] service_map = {} i = 0 for appid, conf in six.iteritems( current_app.config['OAUTHCLIENT_REMOTE_APPS']): if not conf.get('hide', False): services.append(dict...
[ "def", "index", "(", ")", ":", "oauth", "=", "current_app", ".", "extensions", "[", "'oauthlib.client'", "]", "services", "=", "[", "]", "service_map", "=", "{", "}", "i", "=", "0", "for", "appid", ",", "conf", "in", "six", ".", "iteritems", "(", "cu...
List linked accounts.
[ "List", "linked", "accounts", "." ]
python
train
27.810811
tradenity/python-sdk
tradenity/resources/payment_card.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/payment_card.py#L966-L987
def update_payment_card_by_id(cls, payment_card_id, payment_card, **kwargs): """Update PaymentCard Update attributes of PaymentCard This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_payme...
[ "def", "update_payment_card_by_id", "(", "cls", ",", "payment_card_id", ",", "payment_card", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls"...
Update PaymentCard Update attributes of PaymentCard This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_payment_card_by_id(payment_card_id, payment_card, async=True) >>> result = thread.get...
[ "Update", "PaymentCard" ]
python
train
48
balabit/typesafety
typesafety/finder.py
https://github.com/balabit/typesafety/blob/452242dd93da9ebd53c173c243156d1351cd96fd/typesafety/finder.py#L116-L135
def uninstall(self): ''' Uninstall the module finder. If not installed, this will do nothing. After uninstallation, none of the newly loaded modules will be decorated (that is, everything will be back to normal). ''' if self.installed: sys.meta_path.remove(se...
[ "def", "uninstall", "(", "self", ")", ":", "if", "self", ".", "installed", ":", "sys", ".", "meta_path", ".", "remove", "(", "self", ")", "# Reload all decorated items", "import_list", "=", "[", "]", "for", "name", "in", "self", ".", "__loaded_modules", ":...
Uninstall the module finder. If not installed, this will do nothing. After uninstallation, none of the newly loaded modules will be decorated (that is, everything will be back to normal).
[ "Uninstall", "the", "module", "finder", ".", "If", "not", "installed", "this", "will", "do", "nothing", ".", "After", "uninstallation", "none", "of", "the", "newly", "loaded", "modules", "will", "be", "decorated", "(", "that", "is", "everything", "will", "be...
python
train
28.4
CityOfZion/neo-python
neo/Core/State/AssetState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/AssetState.py#L97-L129
def Deserialize(self, reader): """ Deserialize full object. Args: reader (neocore.IO.BinaryReader): """ super(AssetState, self).Deserialize(reader) self.AssetId = reader.ReadUInt256() self.AssetType = reader.ReadByte() self.Name = reader.ReadV...
[ "def", "Deserialize", "(", "self", ",", "reader", ")", ":", "super", "(", "AssetState", ",", "self", ")", ".", "Deserialize", "(", "reader", ")", "self", ".", "AssetId", "=", "reader", ".", "ReadUInt256", "(", ")", "self", ".", "AssetType", "=", "reade...
Deserialize full object. Args: reader (neocore.IO.BinaryReader):
[ "Deserialize", "full", "object", "." ]
python
train
29.363636
zhanglab/psamm
psamm/findprimarypairs.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L156-L247
def predict_compound_pairs_iterated( reactions, formulas, prior=(1, 43), max_iterations=None, element_weight=element_weight): """Predict reaction pairs using iterated method. Returns a tuple containing a dictionary of predictions keyed by the reaction IDs, and the final number of iterations...
[ "def", "predict_compound_pairs_iterated", "(", "reactions", ",", "formulas", ",", "prior", "=", "(", "1", ",", "43", ")", ",", "max_iterations", "=", "None", ",", "element_weight", "=", "element_weight", ")", ":", "prior_alpha", ",", "prior_beta", "=", "prior"...
Predict reaction pairs using iterated method. Returns a tuple containing a dictionary of predictions keyed by the reaction IDs, and the final number of iterations. Each reaction prediction entry contains a tuple with a dictionary of transfers and a dictionary of unbalanced compounds. The dictionary of ...
[ "Predict", "reaction", "pairs", "using", "iterated", "method", "." ]
python
train
40.967391
ericsuh/dirichlet
dirichlet/dirichlet.py
https://github.com/ericsuh/dirichlet/blob/bf39a6d219348cbb4ed95dc195587a9c55c633b9/dirichlet/dirichlet.py#L191-L219
def _meanprecision(D, tol=1e-7, maxiter=None): '''Mean and precision alternating method for MLE of Dirichlet distribution''' N, K = D.shape logp = log(D).mean(axis=0) a0 = _init_a(D) s0 = a0.sum() if s0 < 0: a0 = a0/s0 s0 = 1 elif s0 == 0: a0 = ones(a.shape) / len...
[ "def", "_meanprecision", "(", "D", ",", "tol", "=", "1e-7", ",", "maxiter", "=", "None", ")", ":", "N", ",", "K", "=", "D", ".", "shape", "logp", "=", "log", "(", "D", ")", ".", "mean", "(", "axis", "=", "0", ")", "a0", "=", "_init_a", "(", ...
Mean and precision alternating method for MLE of Dirichlet distribution
[ "Mean", "and", "precision", "alternating", "method", "for", "MLE", "of", "Dirichlet", "distribution" ]
python
train
28.172414
saltstack/salt
salt/spm/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/spm/__init__.py#L118-L149
def run(self, args): ''' Run the SPM command ''' command = args[0] try: if command == 'install': self._install(args) elif command == 'local': self._local(args) elif command == 'repo': self._repo(a...
[ "def", "run", "(", "self", ",", "args", ")", ":", "command", "=", "args", "[", "0", "]", "try", ":", "if", "command", "==", "'install'", ":", "self", ".", "_install", "(", "args", ")", "elif", "command", "==", "'local'", ":", "self", ".", "_local",...
Run the SPM command
[ "Run", "the", "SPM", "command" ]
python
train
33.71875
ANTsX/ANTsPy
ants/contrib/sklearn_interface/sklearn_registration.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sklearn_interface/sklearn_registration.py#L48-L87
def fit(self, X, y=None): """ X : ANTsImage | string | list of ANTsImage types | list of strings images to register to fixed image y : string | list of strings labels for images """ moving_images = X if isinstance(X, (list,tuple)) else [X] moving_...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "moving_images", "=", "X", "if", "isinstance", "(", "X", ",", "(", "list", ",", "tuple", ")", ")", "else", "[", "X", "]", "moving_labels", "=", "y", "if", "y", "is", "not", ...
X : ANTsImage | string | list of ANTsImage types | list of strings images to register to fixed image y : string | list of strings labels for images
[ "X", ":", "ANTsImage", "|", "string", "|", "list", "of", "ANTsImage", "types", "|", "list", "of", "strings", "images", "to", "register", "to", "fixed", "image" ]
python
train
48.275
CityOfZion/neo-python
neo/SmartContract/ContractParameter.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/SmartContract/ContractParameter.py#L132-L143
def ToVM(self): """ Used for turning a ContractParameter item into somethnig consumable by the VM Returns: """ if self.Type == ContractParameterType.String: return str(self.Value).encode('utf-8').hex() elif self.Type == ContractParameterType.Integer and isin...
[ "def", "ToVM", "(", "self", ")", ":", "if", "self", ".", "Type", "==", "ContractParameterType", ".", "String", ":", "return", "str", "(", "self", ".", "Value", ")", ".", "encode", "(", "'utf-8'", ")", ".", "hex", "(", ")", "elif", "self", ".", "Typ...
Used for turning a ContractParameter item into somethnig consumable by the VM Returns:
[ "Used", "for", "turning", "a", "ContractParameter", "item", "into", "somethnig", "consumable", "by", "the", "VM" ]
python
train
33.416667
StagPython/StagPy
stagpy/stagyyparsers.py
https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L494-L510
def _conglomerate_meshes(meshin, header): """Conglomerate meshes from several cores into one.""" meshout = {} npc = header['nts'] // header['ncs'] shp = [val + 1 if val != 1 else 1 for val in header['nts']] x_p = int(shp[0] != 1) y_p = int(shp[1] != 1) for coord in meshin[0]: meshout...
[ "def", "_conglomerate_meshes", "(", "meshin", ",", "header", ")", ":", "meshout", "=", "{", "}", "npc", "=", "header", "[", "'nts'", "]", "//", "header", "[", "'ncs'", "]", "shp", "=", "[", "val", "+", "1", "if", "val", "!=", "1", "else", "1", "f...
Conglomerate meshes from several cores into one.
[ "Conglomerate", "meshes", "from", "several", "cores", "into", "one", "." ]
python
train
43.117647
trehn/termdown
termdown.py
https://github.com/trehn/termdown/blob/aa0c4e39d9864fd1466ef9d76947fb93d0cf5be2/termdown.py#L235-L251
def parse_timedelta(deltastr): """ Parse a string describing a period of time. """ matches = TIMEDELTA_REGEX.match(deltastr) if not matches: return None components = {} for name, value in matches.groupdict().items(): if value: components[name] = int(value) for...
[ "def", "parse_timedelta", "(", "deltastr", ")", ":", "matches", "=", "TIMEDELTA_REGEX", ".", "match", "(", "deltastr", ")", "if", "not", "matches", ":", "return", "None", "components", "=", "{", "}", "for", "name", ",", "value", "in", "matches", ".", "gr...
Parse a string describing a period of time.
[ "Parse", "a", "string", "describing", "a", "period", "of", "time", "." ]
python
train
35.529412
geographika/mappyfile
mappyfile/utils.py
https://github.com/geographika/mappyfile/blob/aecbc5e66ec06896bc4c5db41313503468829d00/mappyfile/utils.py#L342-L397
def findall(lst, key, value): """ Find all items in lst where key matches value. For example find all ``LAYER`` s in a ``MAP`` where ``GROUP`` equals ``VALUE`` Parameters ---------- list: list A list of composite dictionaries e.g. ``layers``, ``classes`` key: string The key...
[ "def", "findall", "(", "lst", ",", "key", ",", "value", ")", ":", "return", "[", "item", "for", "item", "in", "lst", "if", "item", "[", "key", ".", "lower", "(", ")", "]", "in", "value", "]" ]
Find all items in lst where key matches value. For example find all ``LAYER`` s in a ``MAP`` where ``GROUP`` equals ``VALUE`` Parameters ---------- list: list A list of composite dictionaries e.g. ``layers``, ``classes`` key: string The key name to search each dictionary in the lis...
[ "Find", "all", "items", "in", "lst", "where", "key", "matches", "value", ".", "For", "example", "find", "all", "LAYER", "s", "in", "a", "MAP", "where", "GROUP", "equals", "VALUE" ]
python
train
23.035714
deschler/django-modeltranslation
modeltranslation/decorators.py
https://github.com/deschler/django-modeltranslation/blob/18fec04a5105cbd83fc3759f4fda20135b3a848c/modeltranslation/decorators.py#L4-L26
def register(model_or_iterable, **options): """ Registers the given model(s) with the given translation options. The model(s) should be Model classes, not instances. Fields declared for translation on a base class are inherited by subclasses. If the model or one of its subclasses is already re...
[ "def", "register", "(", "model_or_iterable", ",", "*", "*", "options", ")", ":", "from", "modeltranslation", ".", "translator", "import", "translator", ",", "TranslationOptions", "def", "wrapper", "(", "opts_class", ")", ":", "if", "not", "issubclass", "(", "o...
Registers the given model(s) with the given translation options. The model(s) should be Model classes, not instances. Fields declared for translation on a base class are inherited by subclasses. If the model or one of its subclasses is already registered for translation, this will raise an exception. ...
[ "Registers", "the", "given", "model", "(", "s", ")", "with", "the", "given", "translation", "options", "." ]
python
train
35.043478
Cologler/fsoopify-python
fsoopify/nodes.py
https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/nodes.py#L299-L303
def has_file(self, name: str): ''' check whether this directory contains the file. ''' return os.path.isfile(self._path / name)
[ "def", "has_file", "(", "self", ",", "name", ":", "str", ")", ":", "return", "os", ".", "path", ".", "isfile", "(", "self", ".", "_path", "/", "name", ")" ]
check whether this directory contains the file.
[ "check", "whether", "this", "directory", "contains", "the", "file", "." ]
python
train
31
aio-libs/aioredis
aioredis/commands/generic.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/generic.py#L255-L272
def sort(self, key, *get_patterns, by=None, offset=None, count=None, asc=None, alpha=False, store=None): """Sort the elements in a list, set or sorted set.""" args = [] if by is not None: args += [b'BY', by] if offset is not None and count is not Non...
[ "def", "sort", "(", "self", ",", "key", ",", "*", "get_patterns", ",", "by", "=", "None", ",", "offset", "=", "None", ",", "count", "=", "None", ",", "asc", "=", "None", ",", "alpha", "=", "False", ",", "store", "=", "None", ")", ":", "args", "...
Sort the elements in a list, set or sorted set.
[ "Sort", "the", "elements", "in", "a", "list", "set", "or", "sorted", "set", "." ]
python
train
39.055556
etcher-be/elib_miz
elib_miz/mission.py
https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L228-L239
def next_unit_id(self) -> int: """ Returns: next free Unit ID """ ids: typing.Set[int] = set() for unit in chain(self._blue_coa.units, self._red_coa.units): # type: ignore id_ = unit.unit_id if id_ in ids: raise IndexError(unit.unit_name)...
[ "def", "next_unit_id", "(", "self", ")", "->", "int", ":", "ids", ":", "typing", ".", "Set", "[", "int", "]", "=", "set", "(", ")", "for", "unit", "in", "chain", "(", "self", ".", "_blue_coa", ".", "units", ",", "self", ".", "_red_coa", ".", "uni...
Returns: next free Unit ID
[ "Returns", ":", "next", "free", "Unit", "ID" ]
python
train
30.166667
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L370-L384
def _initial_broks(self, broker_name): """Get initial_broks from the scheduler This is used by the brokers to prepare the initial status broks This do not send broks, it only makes scheduler internal processing. Then the broker must use the *_broks* API to get all the stuff :p...
[ "def", "_initial_broks", "(", "self", ",", "broker_name", ")", ":", "with", "self", ".", "app", ".", "conf_lock", ":", "logger", ".", "info", "(", "\"A new broker just connected : %s\"", ",", "broker_name", ")", "return", "self", ".", "app", ".", "sched", "....
Get initial_broks from the scheduler This is used by the brokers to prepare the initial status broks This do not send broks, it only makes scheduler internal processing. Then the broker must use the *_broks* API to get all the stuff :param broker_name: broker name, used to filter brok...
[ "Get", "initial_broks", "from", "the", "scheduler" ]
python
train
39.6
spyder-ide/spyder
spyder/plugins/editor/lsp/transport/main.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/transport/main.py#L102-L107
def restore(self): """Restore signal handlers to their original settings.""" signal.signal(signal.SIGINT, self.original_sigint) signal.signal(signal.SIGTERM, self.original_sigterm) if os.name == 'nt': signal.signal(signal.SIGBREAK, self.original_sigbreak)
[ "def", "restore", "(", "self", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "self", ".", "original_sigint", ")", "signal", ".", "signal", "(", "signal", ".", "SIGTERM", ",", "self", ".", "original_sigterm", ")", "if", "os", "."...
Restore signal handlers to their original settings.
[ "Restore", "signal", "handlers", "to", "their", "original", "settings", "." ]
python
train
49
kolypto/py-smsframework
smsframework/Gateway.py
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/Gateway.py#L184-L207
def receiver_blueprint_for(self, name): """ Get a Flask blueprint for the named provider that handles incoming messages & status reports Note: this requires Flask microframework. :rtype: flask.blueprints.Blueprint :returns: Flask Blueprint, fully functional :rai...
[ "def", "receiver_blueprint_for", "(", "self", ",", "name", ")", ":", "# Get the provider & blueprint", "provider", "=", "self", ".", "get_provider", "(", "name", ")", "bp", "=", "provider", ".", "make_receiver_blueprint", "(", ")", "# Register a Flask handler that ini...
Get a Flask blueprint for the named provider that handles incoming messages & status reports Note: this requires Flask microframework. :rtype: flask.blueprints.Blueprint :returns: Flask Blueprint, fully functional :raises KeyError: provider not found :raises...
[ "Get", "a", "Flask", "blueprint", "for", "the", "named", "provider", "that", "handles", "incoming", "messages", "&", "status", "reports" ]
python
test
38.666667
zomux/deepy
deepy/tensor/functions.py
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/tensor/functions.py#L72-L116
def var(tensor_type, last_dim=0, test_shape=None): """ Wrap a Theano tensor into the variable for defining neural network. :param last_dim: last dimension of tensor, 0 indicates that the last dimension is flexible :rtype: deepy.core.neural_var.NeuralVariable """ # Create tensor from deepy.co...
[ "def", "var", "(", "tensor_type", ",", "last_dim", "=", "0", ",", "test_shape", "=", "None", ")", ":", "# Create tensor", "from", "deepy", ".", "core", ".", "neural_var", "import", "NeuralVariable", "from", "deepy", ".", "core", ".", "env", "import", "env"...
Wrap a Theano tensor into the variable for defining neural network. :param last_dim: last dimension of tensor, 0 indicates that the last dimension is flexible :rtype: deepy.core.neural_var.NeuralVariable
[ "Wrap", "a", "Theano", "tensor", "into", "the", "variable", "for", "defining", "neural", "network", ".", ":", "param", "last_dim", ":", "last", "dimension", "of", "tensor", "0", "indicates", "that", "the", "last", "dimension", "is", "flexible", ":", "rtype",...
python
test
39.377778
jtwhite79/pyemu
pyemu/utils/geostats.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/geostats.py#L1544-L1612
def read_struct_file(struct_file,return_type=GeoStruct): """read an existing PEST-type structure file into a GeoStruct instance Parameters ---------- struct_file : (str) existing pest-type structure file return_type : (object) the instance type to return. Default is GeoStruct ...
[ "def", "read_struct_file", "(", "struct_file", ",", "return_type", "=", "GeoStruct", ")", ":", "VARTYPE", "=", "{", "1", ":", "SphVario", ",", "2", ":", "ExpVario", ",", "3", ":", "GauVario", ",", "4", ":", "None", "}", "assert", "os", ".", "path", "...
read an existing PEST-type structure file into a GeoStruct instance Parameters ---------- struct_file : (str) existing pest-type structure file return_type : (object) the instance type to return. Default is GeoStruct Returns ------- GeoStruct : list or GeoStruct Note...
[ "read", "an", "existing", "PEST", "-", "type", "structure", "file", "into", "a", "GeoStruct", "instance" ]
python
train
33.710145
nuagenetworks/bambou
bambou/nurest_modelcontroller.py
https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_modelcontroller.py#L87-L99
def get_first_model_with_rest_name(cls, rest_name): """ Get the first model corresponding to a rest_name Args: rest_name: the rest name """ models = cls.get_models_with_rest_name(rest_name) if len(models) > 0: return models[0] return No...
[ "def", "get_first_model_with_rest_name", "(", "cls", ",", "rest_name", ")", ":", "models", "=", "cls", ".", "get_models_with_rest_name", "(", "rest_name", ")", "if", "len", "(", "models", ")", ">", "0", ":", "return", "models", "[", "0", "]", "return", "No...
Get the first model corresponding to a rest_name Args: rest_name: the rest name
[ "Get", "the", "first", "model", "corresponding", "to", "a", "rest_name" ]
python
train
23.846154
bitesofcode/projexui
projexui/widgets/xchartwidget/xchartwidgetitem.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xchartwidgetitem.py#L246-L257
def mousePressEvent(self, event): """ Creates the drag event for this item. :param event | <QMousePressEvent> """ near_x, near_y = self.nearestPoint(event.pos()) data = self.dragData(x=near_x, y=near_y) self.startDrag(data) ...
[ "def", "mousePressEvent", "(", "self", ",", "event", ")", ":", "near_x", ",", "near_y", "=", "self", ".", "nearestPoint", "(", "event", ".", "pos", "(", ")", ")", "data", "=", "self", ".", "dragData", "(", "x", "=", "near_x", ",", "y", "=", "near_y...
Creates the drag event for this item. :param event | <QMousePressEvent>
[ "Creates", "the", "drag", "event", "for", "this", "item", ".", ":", "param", "event", "|", "<QMousePressEvent", ">" ]
python
train
31
jorgenschaefer/elpy
elpy/refactor.py
https://github.com/jorgenschaefer/elpy/blob/ffd982f829b11e53f2be187c7b770423341f29bc/elpy/refactor.py#L273-L277
def refactor_move_module(self, new_name): """Move the current module.""" refactor = create_move(self.project, self.resource) resource = path_to_resource(self.project, new_name) return self._get_changes(refactor, resource)
[ "def", "refactor_move_module", "(", "self", ",", "new_name", ")", ":", "refactor", "=", "create_move", "(", "self", ".", "project", ",", "self", ".", "resource", ")", "resource", "=", "path_to_resource", "(", "self", ".", "project", ",", "new_name", ")", "...
Move the current module.
[ "Move", "the", "current", "module", "." ]
python
train
49.8
J535D165/recordlinkage
recordlinkage/measures.py
https://github.com/J535D165/recordlinkage/blob/87a5f4af904e0834047cd07ff1c70146b1e6d693/recordlinkage/measures.py#L238-L292
def confusion_matrix(links_true, links_pred, total=None): """Compute the confusion matrix. The confusion matrix is of the following form: +----------------------+-----------------------+----------------------+ | | Predicted Positives | Predicted Negatives | +===============...
[ "def", "confusion_matrix", "(", "links_true", ",", "links_pred", ",", "total", "=", "None", ")", ":", "links_true", "=", "_get_multiindex", "(", "links_true", ")", "links_pred", "=", "_get_multiindex", "(", "links_pred", ")", "tp", "=", "true_positives", "(", ...
Compute the confusion matrix. The confusion matrix is of the following form: +----------------------+-----------------------+----------------------+ | | Predicted Positives | Predicted Negatives | +======================+=======================+======================+ | **T...
[ "Compute", "the", "confusion", "matrix", "." ]
python
train
37.745455
saltstack/salt
salt/modules/parted_partition.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/parted_partition.py#L565-L583
def rescue(device, start, end): ''' Rescue a lost partition that was located somewhere between start and end. If a partition is found, parted will ask if you want to create an entry for it in the partition table. CLI Example: .. code-block:: bash salt '*' partition.rescue /dev/sda 0 8...
[ "def", "rescue", "(", "device", ",", "start", ",", "end", ")", ":", "_validate_device", "(", "device", ")", "_validate_partition_boundary", "(", "start", ")", "_validate_partition_boundary", "(", "end", ")", "cmd", "=", "'parted -m -s {0} rescue {1} {2}'", ".", "f...
Rescue a lost partition that was located somewhere between start and end. If a partition is found, parted will ask if you want to create an entry for it in the partition table. CLI Example: .. code-block:: bash salt '*' partition.rescue /dev/sda 0 8056
[ "Rescue", "a", "lost", "partition", "that", "was", "located", "somewhere", "between", "start", "and", "end", ".", "If", "a", "partition", "is", "found", "parted", "will", "ask", "if", "you", "want", "to", "create", "an", "entry", "for", "it", "in", "the"...
python
train
29.210526
saltstack/salt
salt/modules/vsphere.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L1122-L1185
def get_syslog_config(host, username, password, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Retrieve the syslog configuration. host The location of the host. username The username used to login to the host, such as ``root``. password The password used t...
[ "def", "get_syslog_config", "(", "host", ",", "username", ",", "password", ",", "protocol", "=", "None", ",", "port", "=", "None", ",", "esxi_hosts", "=", "None", ",", "credstore", "=", "None", ")", ":", "cmd", "=", "'system syslog config get'", "ret", "="...
Retrieve the syslog configuration. host The location of the host. username The username used to login to the host, such as ``root``. password The password used to login to the host. protocol Optionally set to alternate protocol if the host is not using the default ...
[ "Retrieve", "the", "syslog", "configuration", "." ]
python
train
36.125
tensorflow/probability
tensorflow_probability/python/distributions/binomial.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/binomial.py#L43-L62
def _bdtr(k, n, p): """The binomial cumulative distribution function. Args: k: floating point `Tensor`. n: floating point `Tensor`. p: floating point `Tensor`. Returns: `sum_{j=0}^k p^j (1 - p)^(n - j)`. """ # Trick for getting safe backprop/gradients into n, k when # betainc(a = 0, ..) ...
[ "def", "_bdtr", "(", "k", ",", "n", ",", "p", ")", ":", "# Trick for getting safe backprop/gradients into n, k when", "# betainc(a = 0, ..) = nan", "# Write:", "# where(unsafe, safe_output, betainc(where(unsafe, safe_input, input)))", "ones", "=", "tf", ".", "ones_like", "(...
The binomial cumulative distribution function. Args: k: floating point `Tensor`. n: floating point `Tensor`. p: floating point `Tensor`. Returns: `sum_{j=0}^k p^j (1 - p)^(n - j)`.
[ "The", "binomial", "cumulative", "distribution", "function", "." ]
python
test
28.9
yvesalexandre/bandicoot
bandicoot/helper/group.py
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/helper/group.py#L127-L158
def _group_range(records, method): """ Yield the range of all dates between the extrema of a list of records, separated by a given time delta. """ start_date = records[0].datetime end_date = records[-1].datetime _fun = DATE_GROUPERS[method] d = start_date # Day and week use timede...
[ "def", "_group_range", "(", "records", ",", "method", ")", ":", "start_date", "=", "records", "[", "0", "]", ".", "datetime", "end_date", "=", "records", "[", "-", "1", "]", ".", "datetime", "_fun", "=", "DATE_GROUPERS", "[", "method", "]", "d", "=", ...
Yield the range of all dates between the extrema of a list of records, separated by a given time delta.
[ "Yield", "the", "range", "of", "all", "dates", "between", "the", "extrema", "of", "a", "list", "of", "records", "separated", "by", "a", "given", "time", "delta", "." ]
python
train
26.375
angr/claripy
claripy/ast/base.py
https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/ast/base.py#L926-L934
def ite_burrowed(self): """ Returns an equivalent AST that "burrows" the ITE expressions as deep as possible into the ast, for simpler printing. """ if self._burrowed is None: self._burrowed = self._burrow_ite() # pylint:disable=attribute-defined-outside-init ...
[ "def", "ite_burrowed", "(", "self", ")", ":", "if", "self", ".", "_burrowed", "is", "None", ":", "self", ".", "_burrowed", "=", "self", ".", "_burrow_ite", "(", ")", "# pylint:disable=attribute-defined-outside-init", "self", ".", "_burrowed", ".", "_burrowed", ...
Returns an equivalent AST that "burrows" the ITE expressions as deep as possible into the ast, for simpler printing.
[ "Returns", "an", "equivalent", "AST", "that", "burrows", "the", "ITE", "expressions", "as", "deep", "as", "possible", "into", "the", "ast", "for", "simpler", "printing", "." ]
python
train
48.555556
ff0000/scarlet
scarlet/cms/base_views.py
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L579-L696
def get_parent_object(self): """ Lookup a parent object. If parent_field is None this will return None. Otherwise this will try to return that object. The filter arguments are found by using the known url parameters of the bundle, finding the value in the url keyword ...
[ "def", "get_parent_object", "(", "self", ")", ":", "if", "self", ".", "parent_field", ":", "# Get the model we are querying on", "if", "getattr", "(", "self", ".", "model", ".", "_meta", ",", "'init_name_map'", ",", "None", ")", ":", "# pre-django-1.8", "cache",...
Lookup a parent object. If parent_field is None this will return None. Otherwise this will try to return that object. The filter arguments are found by using the known url parameters of the bundle, finding the value in the url keyword arguments and matching them with the argumen...
[ "Lookup", "a", "parent", "object", ".", "If", "parent_field", "is", "None", "this", "will", "return", "None", ".", "Otherwise", "this", "will", "try", "to", "return", "that", "object", "." ]
python
train
37.474576
bcbio/bcbio-nextgen
bcbio/variation/validateplot.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validateplot.py#L246-L262
def _get_chart_info(df, vtype, cat, prep, callers): """Retrieve values for a specific variant type, category and prep method. """ maxval_raw = max(list(df["value.floor"])) curdf = df[(df["variant.type"] == vtype) & (df["category"] == cat) & (df["bamprep"] == prep)] vals = [] label...
[ "def", "_get_chart_info", "(", "df", ",", "vtype", ",", "cat", ",", "prep", ",", "callers", ")", ":", "maxval_raw", "=", "max", "(", "list", "(", "df", "[", "\"value.floor\"", "]", ")", ")", "curdf", "=", "df", "[", "(", "df", "[", "\"variant.type\""...
Retrieve values for a specific variant type, category and prep method.
[ "Retrieve", "values", "for", "a", "specific", "variant", "type", "category", "and", "prep", "method", "." ]
python
train
35.588235
johntfoster/bspline
bspline/splinelab.py
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/splinelab.py#L81-L145
def aptknt(tau, order): """Create an acceptable knot vector. Minimal emulation of MATLAB's ``aptknt``. The returned knot vector can be used to generate splines of desired `order` that are suitable for interpolation to the collocation sites `tau`. Note that this is only possible when ``len(tau)`` >= `order` + 1. ...
[ "def", "aptknt", "(", "tau", ",", "order", ")", ":", "tau", "=", "np", ".", "atleast_1d", "(", "tau", ")", "k", "=", "order", "+", "1", "if", "tau", ".", "ndim", ">", "1", ":", "raise", "ValueError", "(", "\"tau must be a list or a rank-1 array\"", ")"...
Create an acceptable knot vector. Minimal emulation of MATLAB's ``aptknt``. The returned knot vector can be used to generate splines of desired `order` that are suitable for interpolation to the collocation sites `tau`. Note that this is only possible when ``len(tau)`` >= `order` + 1. When this condition does not h...
[ "Create", "an", "acceptable", "knot", "vector", "." ]
python
train
29.523077
fermiPy/fermipy
fermipy/jobs/link.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L723-L767
def check_jobs_status(self, fail_running=False, fail_pending=False): """Check the status of all the jobs run from this link and return a status flag that summarizes that. Parameters ---------- fail_running : `bool` ...
[ "def", "check_jobs_status", "(", "self", ",", "fail_running", "=", "False", ",", "fail_pending", "=", "False", ")", ":", "n_failed", "=", "0", "n_partial", "=", "0", "n_passed", "=", "0", "n_total", "=", "0", "for", "job_details", "in", "self", ".", "job...
Check the status of all the jobs run from this link and return a status flag that summarizes that. Parameters ---------- fail_running : `bool` If True, consider running jobs as failed fail_pending : `bool` If True, consider pending jobs as failed ...
[ "Check", "the", "status", "of", "all", "the", "jobs", "run", "from", "this", "link", "and", "return", "a", "status", "flag", "that", "summarizes", "that", "." ]
python
train
29.8
xtream1101/cutil
cutil/__init__.py
https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/__init__.py#L159-L172
def sanitize(string): """ Catch and replace invalid path chars [replace, with] """ replace_chars = [ ['\\', '-'], [':', '-'], ['/', '-'], ['?', ''], ['<', ''], ['>', ''], ['`', '`'], ['|', '-'], ['*', '`'], ['"', '\''], ['.', ''], ['&', 'and'] ] for ch in repl...
[ "def", "sanitize", "(", "string", ")", ":", "replace_chars", "=", "[", "[", "'\\\\'", ",", "'-'", "]", ",", "[", "':'", ",", "'-'", "]", ",", "[", "'/'", ",", "'-'", "]", ",", "[", "'?'", ",", "''", "]", ",", "[", "'<'", ",", "''", "]", ","...
Catch and replace invalid path chars [replace, with]
[ "Catch", "and", "replace", "invalid", "path", "chars", "[", "replace", "with", "]" ]
python
train
27.214286
klen/adrest
adrest/utils/paginator.py
https://github.com/klen/adrest/blob/8b75c67123cffabe5ed98c222bb7ab43c904d89c/adrest/utils/paginator.py#L32-L45
def to_simple(self, serializer=None): """ Prepare to serialization. :return dict: paginator params """ return dict( count=self.paginator.count, page=self.page_number, num_pages=self.paginator.num_pages, next=self.next_page, pr...
[ "def", "to_simple", "(", "self", ",", "serializer", "=", "None", ")", ":", "return", "dict", "(", "count", "=", "self", ".", "paginator", ".", "count", ",", "page", "=", "self", ".", "page_number", ",", "num_pages", "=", "self", ".", "paginator", ".", ...
Prepare to serialization. :return dict: paginator params
[ "Prepare", "to", "serialization", "." ]
python
train
26.928571
grantmcconnaughey/Lintly
lintly/builds.py
https://github.com/grantmcconnaughey/Lintly/blob/73c1ee36740ac5bb2a32d3f24fca2a27f4d4e466/lintly/builds.py#L51-L74
def execute(self): """ Executes a new build on a project. """ if not self.config.pr: raise NotPullRequestException logger.debug('Using the following configuration:') for name, value in self.config.as_dict().items(): logger.debug(' - {}={}'.format...
[ "def", "execute", "(", "self", ")", ":", "if", "not", "self", ".", "config", ".", "pr", ":", "raise", "NotPullRequestException", "logger", ".", "debug", "(", "'Using the following configuration:'", ")", "for", "name", ",", "value", "in", "self", ".", "config...
Executes a new build on a project.
[ "Executes", "a", "new", "build", "on", "a", "project", "." ]
python
train
39.5
ihmeuw/vivarium
src/vivarium/framework/configuration.py
https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/configuration.py#L25-L36
def validate_model_specification_file(file_path: str) -> str: """Ensures the provided file is a yaml file""" if not os.path.isfile(file_path): raise ConfigurationError('If you provide a model specification file, it must be a file. ' f'You provided {file_path}') exte...
[ "def", "validate_model_specification_file", "(", "file_path", ":", "str", ")", "->", "str", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file_path", ")", ":", "raise", "ConfigurationError", "(", "'If you provide a model specification file, it must be a fi...
Ensures the provided file is a yaml file
[ "Ensures", "the", "provided", "file", "is", "a", "yaml", "file" ]
python
train
47.416667
iterative/dvc
dvc/scm/__init__.py
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/__init__.py#L15-L29
def SCM(root_dir, repo=None): # pylint: disable=invalid-name """Returns SCM instance that corresponds to a repo at the specified path. Args: root_dir (str): path to a root directory of the repo. repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to. Returns: dvc.scm...
[ "def", "SCM", "(", "root_dir", ",", "repo", "=", "None", ")", ":", "# pylint: disable=invalid-name", "if", "Git", ".", "is_repo", "(", "root_dir", ")", "or", "Git", ".", "is_submodule", "(", "root_dir", ")", ":", "return", "Git", "(", "root_dir", ",", "r...
Returns SCM instance that corresponds to a repo at the specified path. Args: root_dir (str): path to a root directory of the repo. repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to. Returns: dvc.scm.base.Base: SCM instance.
[ "Returns", "SCM", "instance", "that", "corresponds", "to", "a", "repo", "at", "the", "specified", "path", "." ]
python
train
31.866667
fudge-py/fudge
fudge/__init__.py
https://github.com/fudge-py/fudge/blob/b283fbc1a41900f3f5845b10b8c2ef9136a67ebc/fudge/__init__.py#L807-L819
def is_callable(self): """The fake can be called. This is useful for when you stub out a function as opposed to a class. For example:: >>> import fudge >>> remove = Fake('os.remove').is_callable() >>> remove('some/path') """ self._callable ...
[ "def", "is_callable", "(", "self", ")", ":", "self", ".", "_callable", "=", "Call", "(", "self", ",", "call_name", "=", "self", ".", "_name", ",", "callable", "=", "True", ")", "return", "self" ]
The fake can be called. This is useful for when you stub out a function as opposed to a class. For example:: >>> import fudge >>> remove = Fake('os.remove').is_callable() >>> remove('some/path')
[ "The", "fake", "can", "be", "called", "." ]
python
train
29
pkkid/python-plexapi
plexapi/library.py
https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/library.py#L85-L102
def search(self, title=None, libtype=None, **kwargs): """ Searching within a library section is much more powerful. It seems certain attributes on the media objects can be targeted to filter this search down a bit, but I havent found the documentation for it. Example: "studi...
[ "def", "search", "(", "self", ",", "title", "=", "None", ",", "libtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "args", "=", "{", "}", "if", "title", ":", "args", "[", "'title'", "]", "=", "title", "if", "libtype", ":", "args", "[", "'...
Searching within a library section is much more powerful. It seems certain attributes on the media objects can be targeted to filter this search down a bit, but I havent found the documentation for it. Example: "studio=Comedy%20Central" or "year=1999" "title=Kung Fu" all work. Other...
[ "Searching", "within", "a", "library", "section", "is", "much", "more", "powerful", ".", "It", "seems", "certain", "attributes", "on", "the", "media", "objects", "can", "be", "targeted", "to", "filter", "this", "search", "down", "a", "bit", "but", "I", "ha...
python
train
49.111111
saltstack/salt
salt/modules/salt_version.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_version.py#L56-L85
def get_release_number(name): ''' Returns the release number of a given release code name in a ``<year>.<month>`` context. If the release name has not been given an assigned release number, the function returns a string. If the release cannot be found, it returns ``None``. name The...
[ "def", "get_release_number", "(", "name", ")", ":", "name", "=", "name", ".", "lower", "(", ")", "version_map", "=", "salt", ".", "version", ".", "SaltStackVersion", ".", "LNAMES", "version", "=", "version_map", ".", "get", "(", "name", ")", "if", "versi...
Returns the release number of a given release code name in a ``<year>.<month>`` context. If the release name has not been given an assigned release number, the function returns a string. If the release cannot be found, it returns ``None``. name The release codename for which to find a rele...
[ "Returns", "the", "release", "number", "of", "a", "given", "release", "code", "name", "in", "a", "<year", ">", ".", "<month", ">", "context", "." ]
python
train
28.866667
MillionIntegrals/vel
vel/rl/models/q_distributional_model.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/models/q_distributional_model.py#L83-L88
def forward(self, observations): """ Model forward pass """ input_data = self.input_block(observations) base_output = self.backbone(input_data) log_histogram = self.q_head(base_output) return log_histogram
[ "def", "forward", "(", "self", ",", "observations", ")", ":", "input_data", "=", "self", ".", "input_block", "(", "observations", ")", "base_output", "=", "self", ".", "backbone", "(", "input_data", ")", "log_histogram", "=", "self", ".", "q_head", "(", "b...
Model forward pass
[ "Model", "forward", "pass" ]
python
train
40
archman/beamline
beamline/lattice.py
https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/lattice.py#L62-L88
def resolvePrefix(self): """ extract prefix information into dict with the key of '_prefixstr' """ tmpstrlist = [] tmpstodict = {} for line in self.file_lines: if line.startswith('%'): stolist = line.replace('%', '').split('sto') rpnexp...
[ "def", "resolvePrefix", "(", "self", ")", ":", "tmpstrlist", "=", "[", "]", "tmpstodict", "=", "{", "}", "for", "line", "in", "self", ".", "file_lines", ":", "if", "line", ".", "startswith", "(", "'%'", ")", ":", "stolist", "=", "line", ".", "replace...
extract prefix information into dict with the key of '_prefixstr'
[ "extract", "prefix", "information", "into", "dict", "with", "the", "key", "of", "_prefixstr" ]
python
train
41.111111
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L518-L529
def set_mode_apm(self, mode, custom_mode = 0, custom_sub_mode = 0): '''enter arbitrary mode''' if isinstance(mode, str): mode_map = self.mode_mapping() if mode_map is None or mode not in mode_map: print("Unknown mode '%s'" % mode) return ...
[ "def", "set_mode_apm", "(", "self", ",", "mode", ",", "custom_mode", "=", "0", ",", "custom_sub_mode", "=", "0", ")", ":", "if", "isinstance", "(", "mode", ",", "str", ")", ":", "mode_map", "=", "self", ".", "mode_mapping", "(", ")", "if", "mode_map", ...
enter arbitrary mode
[ "enter", "arbitrary", "mode" ]
python
train
45.833333
laginha/django-mobileesp
src/django_mobileesp/mdetect.py
https://github.com/laginha/django-mobileesp/blob/91d4babb2343b992970bdb076508d380680c8b7e/src/django_mobileesp/mdetect.py#L259-L266
def initDeviceScan(self): """Initialize Key Stored Values.""" self.__isIphone = self.detectIphoneOrIpod() self.__isAndroidPhone = self.detectAndroidPhone() self.__isTierTablet = self.detectTierTablet() self.__isTierIphone = self.detectTierIphone() self.__isTierRichCss = s...
[ "def", "initDeviceScan", "(", "self", ")", ":", "self", ".", "__isIphone", "=", "self", ".", "detectIphoneOrIpod", "(", ")", "self", ".", "__isAndroidPhone", "=", "self", ".", "detectAndroidPhone", "(", ")", "self", ".", "__isTierTablet", "=", "self", ".", ...
Initialize Key Stored Values.
[ "Initialize", "Key", "Stored", "Values", "." ]
python
train
50.25
ruipgil/changepy
changepy/costs.py
https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L143-L169
def exponential(data): """ Creates a segment cost function for a time series with a exponential distribution with changing mean Args: data (:obj:`list` of float): 1D time series data Returns: function: Function with signature (int, int) -> float where the fir...
[ "def", "exponential", "(", "data", ")", ":", "data", "=", "np", ".", "hstack", "(", "(", "[", "0.0", "]", ",", "np", ".", "array", "(", "data", ")", ")", ")", "cumm", "=", "np", ".", "cumsum", "(", "data", ")", "def", "cost", "(", "s", ",", ...
Creates a segment cost function for a time series with a exponential distribution with changing mean Args: data (:obj:`list` of float): 1D time series data Returns: function: Function with signature (int, int) -> float where the first arg is the starting index, a...
[ "Creates", "a", "segment", "cost", "function", "for", "a", "time", "series", "with", "a", "exponential", "distribution", "with", "changing", "mean" ]
python
train
30.296296
tensorflow/cleverhans
cleverhans/utils.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils.py#L102-L124
def to_categorical(y, nb_classes, num_classes=None): """ Converts a class vector (integers) to binary class matrix. This is adapted from the Keras function with the same name. :param y: class vector to be converted into a matrix (integers from 0 to nb_classes). :param nb_classes: nb_classes: total...
[ "def", "to_categorical", "(", "y", ",", "nb_classes", ",", "num_classes", "=", "None", ")", ":", "if", "num_classes", "is", "not", "None", ":", "if", "nb_classes", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Should not specify both nb_classes and it...
Converts a class vector (integers) to binary class matrix. This is adapted from the Keras function with the same name. :param y: class vector to be converted into a matrix (integers from 0 to nb_classes). :param nb_classes: nb_classes: total number of classes. :param num_classses: depricated version...
[ "Converts", "a", "class", "vector", "(", "integers", ")", "to", "binary", "class", "matrix", ".", "This", "is", "adapted", "from", "the", "Keras", "function", "with", "the", "same", "name", ".", ":", "param", "y", ":", "class", "vector", "to", "be", "c...
python
train
42.26087
UCBerkeleySETI/blimpy
blimpy/filterbank.py
https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/filterbank.py#L515-L576
def plot_spectrum(self, t=0, f_start=None, f_stop=None, logged=False, if_id=0, c=None, **kwargs): """ Plot frequency spectrum of a given file Args: t (int): integration number to plot (0 -> len(data)) logged (bool): Plot in linear (False) or dB units (True) if_id (in...
[ "def", "plot_spectrum", "(", "self", ",", "t", "=", "0", ",", "f_start", "=", "None", ",", "f_stop", "=", "None", ",", "logged", "=", "False", ",", "if_id", "=", "0", ",", "c", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", ...
Plot frequency spectrum of a given file Args: t (int): integration number to plot (0 -> len(data)) logged (bool): Plot in linear (False) or dB units (True) if_id (int): IF identification (if multiple IF signals in file) c: color for line kwargs: keywo...
[ "Plot", "frequency", "spectrum", "of", "a", "given", "file" ]
python
test
34.451613
jmbhughes/suvi-trainer
suvitrainer/fileio.py
https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/suvitrainer/fileio.py#L72-L113
def fetch(self, multithread=True, median_kernel=5, solar_diam=740): """ For all products in products, will call the correct fetch routine and download an image :param multithread: if true will fetch the files simultaneously :type multithread: bool :param median_kernel: the size o...
[ "def", "fetch", "(", "self", ",", "multithread", "=", "True", ",", "median_kernel", "=", "5", ",", "solar_diam", "=", "740", ")", ":", "# helper function to pull data", "def", "func_map", "(", "product", ")", ":", "\"\"\"\n determines which function to ca...
For all products in products, will call the correct fetch routine and download an image :param multithread: if true will fetch the files simultaneously :type multithread: bool :param median_kernel: the size of the kernel to smooth by :type median_kernel: int >= 0 :return: a dicti...
[ "For", "all", "products", "in", "products", "will", "call", "the", "correct", "fetch", "routine", "and", "download", "an", "image", ":", "param", "multithread", ":", "if", "true", "will", "fetch", "the", "files", "simultaneously", ":", "type", "multithread", ...
python
train
42.428571
googledatalab/pydatalab
google/datalab/storage/_api.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L215-L248
def objects_list(self, bucket, prefix=None, delimiter=None, projection='noAcl', versions=False, max_results=0, page_token=None): """Issues a request to retrieve information about an object. Args: bucket: the name of the bucket. prefix: an optional key prefix. delimiter: an ...
[ "def", "objects_list", "(", "self", ",", "bucket", ",", "prefix", "=", "None", ",", "delimiter", "=", "None", ",", "projection", "=", "'noAcl'", ",", "versions", "=", "False", ",", "max_results", "=", "0", ",", "page_token", "=", "None", ")", ":", "if"...
Issues a request to retrieve information about an object. Args: bucket: the name of the bucket. prefix: an optional key prefix. delimiter: an optional key delimiter. projection: the projection of the objects to retrieve. versions: whether to list each version of a file as a distinct o...
[ "Issues", "a", "request", "to", "retrieve", "information", "about", "an", "object", "." ]
python
train
38.147059