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
akfullfo/taskforce
taskforce/task.py
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1327-L1334
def module_del(self, key): """ Deregister from python module change events. """ if key in self._module_event_map: del self._module_event_map[key] if key in self._watch_modules.names: self._watch_modules.remove(key)
[ "def", "module_del", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "_module_event_map", ":", "del", "self", ".", "_module_event_map", "[", "key", "]", "if", "key", "in", "self", ".", "_watch_modules", ".", "names", ":", "self", "."...
Deregister from python module change events.
[ "Deregister", "from", "python", "module", "change", "events", "." ]
python
train
33.375
neuropsychology/NeuroKit.py
neurokit/signal/epochs.py
https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/neurokit/signal/epochs.py#L14-L109
def create_epochs(data, events_onsets, sampling_rate=1000, duration=1, onset=0, index=None): """ Epoching a dataframe. Parameters ---------- data : pandas.DataFrame Data*time. events_onsets : list A list of event onsets indices. sampling_rate : int Sampling rate (sam...
[ "def", "create_epochs", "(", "data", ",", "events_onsets", ",", "sampling_rate", "=", "1000", ",", "duration", "=", "1", ",", "onset", "=", "0", ",", "index", "=", "None", ")", ":", "# Convert ints to arrays if needed", "if", "isinstance", "(", "duration", "...
Epoching a dataframe. Parameters ---------- data : pandas.DataFrame Data*time. events_onsets : list A list of event onsets indices. sampling_rate : int Sampling rate (samples/second). duration : int or list Duration(s) of each epoch(s) (in seconds). onset : i...
[ "Epoching", "a", "dataframe", "." ]
python
train
28.958333
StorjOld/heartbeat
heartbeat/util.py
https://github.com/StorjOld/heartbeat/blob/4d54f2011f1e9f688073d4347bc51bb7bd682718/heartbeat/util.py#L53-L64
def pad(data, length): """This function returns a padded version of the input data to the given length. this function will shorten the given data to the length specified if necessary. post-condition: len(data) = length :param data: the data byte array to pad :param length: the...
[ "def", "pad", "(", "data", ",", "length", ")", ":", "if", "(", "len", "(", "data", ")", ">", "length", ")", ":", "return", "data", "[", "0", ":", "length", "]", "else", ":", "return", "data", "+", "b\"\\0\"", "*", "(", "length", "-", "len", "("...
This function returns a padded version of the input data to the given length. this function will shorten the given data to the length specified if necessary. post-condition: len(data) = length :param data: the data byte array to pad :param length: the length to pad the array to
[ "This", "function", "returns", "a", "padded", "version", "of", "the", "input", "data", "to", "the", "given", "length", ".", "this", "function", "will", "shorten", "the", "given", "data", "to", "the", "length", "specified", "if", "necessary", ".", "post", "...
python
train
40.333333
vedarthk/exreporter
exreporter/contrib/django_middlewares.py
https://github.com/vedarthk/exreporter/blob/8adf445477341d43a13d3baa2551e1c0f68229bb/exreporter/contrib/django_middlewares.py#L29-L40
def process_exception(self, request, exception): """Report exceptions from requests via Exreporter. """ gc = GithubCredentials( user=settings.EXREPORTER_GITHUB_USER, repo=settings.EXREPORTER_GITHUB_REPO, auth_token=settings.EXREPORTER_GITHUB_AUTH_TOKEN) ...
[ "def", "process_exception", "(", "self", ",", "request", ",", "exception", ")", ":", "gc", "=", "GithubCredentials", "(", "user", "=", "settings", ".", "EXREPORTER_GITHUB_USER", ",", "repo", "=", "settings", ".", "EXREPORTER_GITHUB_REPO", ",", "auth_token", "=",...
Report exceptions from requests via Exreporter.
[ "Report", "exceptions", "from", "requests", "via", "Exreporter", "." ]
python
train
38.75
whiteclover/dbpy
db/__init__.py
https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/__init__.py#L110-L124
def execute(sql, args=None, key='default'): """It is used for update, delete records. :param sql string: the sql stamtement like 'select * from %s' :param args list: Wen set None, will use dbi execute(sql), else dbi execute(sql, args), the args keep the original rules, it shuld be tuple or lis...
[ "def", "execute", "(", "sql", ",", "args", "=", "None", ",", "key", "=", "'default'", ")", ":", "database", "=", "__db", "[", "key", "]", "return", "database", ".", "execute", "(", "sql", ",", "args", ")" ]
It is used for update, delete records. :param sql string: the sql stamtement like 'select * from %s' :param args list: Wen set None, will use dbi execute(sql), else dbi execute(sql, args), the args keep the original rules, it shuld be tuple or list of list :param key: a key for your dabtabase ...
[ "It", "is", "used", "for", "update", "delete", "records", "." ]
python
train
38.6
mardix/pylot
pylot/component/views.py
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/component/views.py#L1680-L1733
def error_view(template_dir=None): """ Create the Error view Must be instantiated import error_view ErrorView = error_view() :param template_dir: The directory containing the view pages :return: """ if not template_dir: template_dir = "Pylot/Error" template_page = "%s/...
[ "def", "error_view", "(", "template_dir", "=", "None", ")", ":", "if", "not", "template_dir", ":", "template_dir", "=", "\"Pylot/Error\"", "template_page", "=", "\"%s/index.html\"", "%", "template_dir", "class", "Error", "(", "Pylot", ")", ":", "\"\"\"\n Er...
Create the Error view Must be instantiated import error_view ErrorView = error_view() :param template_dir: The directory containing the view pages :return:
[ "Create", "the", "Error", "view", "Must", "be", "instantiated" ]
python
train
25.351852
pkgw/pwkit
pwkit/synphot.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L316-L330
def halfmax_points(self): """Get the bandpass' half-maximum wavelengths. These can be used to compute a representative bandwidth, or for display purposes. Unlike calc_halfmax_points(), this function will use a cached value if available. """ t = self.registry._halfmaxes....
[ "def", "halfmax_points", "(", "self", ")", ":", "t", "=", "self", ".", "registry", ".", "_halfmaxes", ".", "get", "(", "(", "self", ".", "telescope", ",", "self", ".", "band", ")", ")", "if", "t", "is", "not", "None", ":", "return", "t", "t", "="...
Get the bandpass' half-maximum wavelengths. These can be used to compute a representative bandwidth, or for display purposes. Unlike calc_halfmax_points(), this function will use a cached value if available.
[ "Get", "the", "bandpass", "half", "-", "maximum", "wavelengths", ".", "These", "can", "be", "used", "to", "compute", "a", "representative", "bandwidth", "or", "for", "display", "purposes", "." ]
python
train
34.8
MouseLand/rastermap
rastermap/mapping.py
https://github.com/MouseLand/rastermap/blob/eee7a46db80b6e33207543778e11618d0fed08a6/rastermap/mapping.py#L369-L382
def fit_transform(self, X, u=None): """Fit X into an embedded space and return that transformed output. Inputs ---------- X : array, shape (n_samples, n_features). X contains a sample per row. Returns ------- embedding : array, shape (n_samples, n_compone...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "u", "=", "None", ")", ":", "self", ".", "fit", "(", "X", ",", "u", ")", "return", "self", ".", "embedding" ]
Fit X into an embedded space and return that transformed output. Inputs ---------- X : array, shape (n_samples, n_features). X contains a sample per row. Returns ------- embedding : array, shape (n_samples, n_components) Embedding of the training data...
[ "Fit", "X", "into", "an", "embedded", "space", "and", "return", "that", "transformed", "output", ".", "Inputs", "----------", "X", ":", "array", "shape", "(", "n_samples", "n_features", ")", ".", "X", "contains", "a", "sample", "per", "row", "." ]
python
train
31.785714
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L3053-L3056
def debugDumpOneNode(self, output, depth): """Dumps debug information for the element node, it is not recursive """ libxml2mod.xmlDebugDumpOneNode(output, self._o, depth)
[ "def", "debugDumpOneNode", "(", "self", ",", "output", ",", "depth", ")", ":", "libxml2mod", ".", "xmlDebugDumpOneNode", "(", "output", ",", "self", ".", "_o", ",", "depth", ")" ]
Dumps debug information for the element node, it is not recursive
[ "Dumps", "debug", "information", "for", "the", "element", "node", "it", "is", "not", "recursive" ]
python
train
48.5
apache/airflow
airflow/utils/dag_processing.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1118-L1124
def wait_until_finished(self): """ Sleeps until all the processors are done. """ for file_path, processor in self._processors.items(): while not processor.done: time.sleep(0.1)
[ "def", "wait_until_finished", "(", "self", ")", ":", "for", "file_path", ",", "processor", "in", "self", ".", "_processors", ".", "items", "(", ")", ":", "while", "not", "processor", ".", "done", ":", "time", ".", "sleep", "(", "0.1", ")" ]
Sleeps until all the processors are done.
[ "Sleeps", "until", "all", "the", "processors", "are", "done", "." ]
python
test
32.857143
pytroll/trollimage
trollimage/image.py
https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/image.py#L276-L357
def pil_image(self): """Return a PIL image from the current image. """ channels, fill_value = self._finalize() if self.is_empty(): return Pil.new(self.mode, (0, 0)) if self.mode == "L": if fill_value is not None: img = Pil.fromarray(chann...
[ "def", "pil_image", "(", "self", ")", ":", "channels", ",", "fill_value", "=", "self", ".", "_finalize", "(", ")", "if", "self", ".", "is_empty", "(", ")", ":", "return", "Pil", ".", "new", "(", "self", ".", "mode", ",", "(", "0", ",", "0", ")", ...
Return a PIL image from the current image.
[ "Return", "a", "PIL", "image", "from", "the", "current", "image", "." ]
python
train
42.146341
agoragames/haigha
haigha/reader.py
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L255-L266
def _read_field(self): ''' Read a single byte for field type, then read the value. ''' ftype = self._input[self._pos] self._pos += 1 reader = self.field_type_map.get(ftype) if reader: return reader(self) raise Reader.FieldError('Unknown field...
[ "def", "_read_field", "(", "self", ")", ":", "ftype", "=", "self", ".", "_input", "[", "self", ".", "_pos", "]", "self", ".", "_pos", "+=", "1", "reader", "=", "self", ".", "field_type_map", ".", "get", "(", "ftype", ")", "if", "reader", ":", "retu...
Read a single byte for field type, then read the value.
[ "Read", "a", "single", "byte", "for", "field", "type", "then", "read", "the", "value", "." ]
python
train
27.166667
cole/aiosmtplib
src/aiosmtplib/esmtp.py
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L231-L259
async def mail( self, sender: str, options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SMTPResponse: """ Send an SMTP MAIL command, which specifies the message sender and begins a new mail transfer session ("envelope"). :raises SMT...
[ "async", "def", "mail", "(", "self", ",", "sender", ":", "str", ",", "options", ":", "Iterable", "[", "str", "]", "=", "None", ",", "timeout", ":", "DefaultNumType", "=", "_default", ",", ")", "->", "SMTPResponse", ":", "await", "self", ".", "_ehlo_or_...
Send an SMTP MAIL command, which specifies the message sender and begins a new mail transfer session ("envelope"). :raises SMTPSenderRefused: on unexpected server response code
[ "Send", "an", "SMTP", "MAIL", "command", "which", "specifies", "the", "message", "sender", "and", "begins", "a", "new", "mail", "transfer", "session", "(", "envelope", ")", "." ]
python
train
31.862069
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/flask/blueprints.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/flask/blueprints.py#L268-L275
def before_request(self, f): """Like :meth:`Flask.before_request` but for a blueprint. This function is only executed before each request that is handled by a function of that blueprint. """ self.record_once(lambda s: s.app.before_request_funcs .setdefault(self.name,...
[ "def", "before_request", "(", "self", ",", "f", ")", ":", "self", ".", "record_once", "(", "lambda", "s", ":", "s", ".", "app", ".", "before_request_funcs", ".", "setdefault", "(", "self", ".", "name", ",", "[", "]", ")", ".", "append", "(", "f", "...
Like :meth:`Flask.before_request` but for a blueprint. This function is only executed before each request that is handled by a function of that blueprint.
[ "Like", ":", "meth", ":", "Flask", ".", "before_request", "but", "for", "a", "blueprint", ".", "This", "function", "is", "only", "executed", "before", "each", "request", "that", "is", "handled", "by", "a", "function", "of", "that", "blueprint", "." ]
python
test
43.125
ga4gh/ga4gh-server
ga4gh/server/datamodel/obo_parser.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/obo_parser.py#L492-L497
def write_hier_all(self, out=sys.stdout, len_dash=1, max_depth=None, num_child=None, short_prt=False): """Write hierarchy for all GO Terms in obo file.""" # Print: [biological_process, molecular_function, and cellular_component] for go_id in ['GO:0008150', 'GO:0003674', 'GO...
[ "def", "write_hier_all", "(", "self", ",", "out", "=", "sys", ".", "stdout", ",", "len_dash", "=", "1", ",", "max_depth", "=", "None", ",", "num_child", "=", "None", ",", "short_prt", "=", "False", ")", ":", "# Print: [biological_process, molecular_function, a...
Write hierarchy for all GO Terms in obo file.
[ "Write", "hierarchy", "for", "all", "GO", "Terms", "in", "obo", "file", "." ]
python
train
68.833333
saltstack/salt
salt/utils/network.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1400-L1441
def _remotes_on(port, which_end): ''' Return a set of ip addrs active tcp connections ''' port = int(port) ret = _netlink_tool_remote_on(port, which_end) if ret is not None: return ret ret = set() proc_available = False for statf in ['/proc/net/tcp', '/proc/net/tcp6']: ...
[ "def", "_remotes_on", "(", "port", ",", "which_end", ")", ":", "port", "=", "int", "(", "port", ")", "ret", "=", "_netlink_tool_remote_on", "(", "port", ",", "which_end", ")", "if", "ret", "is", "not", "None", ":", "return", "ret", "ret", "=", "set", ...
Return a set of ip addrs active tcp connections
[ "Return", "a", "set", "of", "ip", "addrs", "active", "tcp", "connections" ]
python
train
37.142857
square/connect-python-sdk
squareconnect/models/additional_recipient_receivable.py
https://github.com/square/connect-python-sdk/blob/adc1d09e817986cdc607391580f71d6b48ed4066/squareconnect/models/additional_recipient_receivable.py#L104-L118
def transaction_id(self, transaction_id): """ Sets the transaction_id of this AdditionalRecipientReceivable. The ID of the transaction that the additional recipient receivable was applied to. :param transaction_id: The transaction_id of this AdditionalRecipientReceivable. :type:...
[ "def", "transaction_id", "(", "self", ",", "transaction_id", ")", ":", "if", "transaction_id", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `transaction_id`, must not be `None`\"", ")", "if", "len", "(", "transaction_id", ")", "<", "1", ":", ...
Sets the transaction_id of this AdditionalRecipientReceivable. The ID of the transaction that the additional recipient receivable was applied to. :param transaction_id: The transaction_id of this AdditionalRecipientReceivable. :type: str
[ "Sets", "the", "transaction_id", "of", "this", "AdditionalRecipientReceivable", ".", "The", "ID", "of", "the", "transaction", "that", "the", "additional", "recipient", "receivable", "was", "applied", "to", "." ]
python
train
42.666667
adamheins/r12
r12/shell.py
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L304-L333
def parse_help_text(self, file_path): ''' Load of list of commands and descriptions from a file. ''' with open(file_path) as f: lines = f.readlines() # Parse commands and descriptions, which are separated by a multi-space # (any sequence of two or more space characters in a ...
[ "def", "parse_help_text", "(", "self", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "# Parse commands and descriptions, which are separated by a multi-space", "# (any sequence of two ...
Load of list of commands and descriptions from a file.
[ "Load", "of", "list", "of", "commands", "and", "descriptions", "from", "a", "file", "." ]
python
train
33
soravux/scoop
bench/process_debug.py
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/bench/process_debug.py#L234-L246
def getWorkerInfo(dataTask): """Returns the total execution time and task quantity by worker""" workertime = [] workertasks = [] for fichier, vals in dataTask.items(): if hasattr(vals, 'values'): #workers_names.append(fichier) # Data from worker totaltime = su...
[ "def", "getWorkerInfo", "(", "dataTask", ")", ":", "workertime", "=", "[", "]", "workertasks", "=", "[", "]", "for", "fichier", ",", "vals", "in", "dataTask", ".", "items", "(", ")", ":", "if", "hasattr", "(", "vals", ",", "'values'", ")", ":", "#wor...
Returns the total execution time and task quantity by worker
[ "Returns", "the", "total", "execution", "time", "and", "task", "quantity", "by", "worker" ]
python
train
40.769231
napalm-automation/napalm-eos
napalm_eos/eos.py
https://github.com/napalm-automation/napalm-eos/blob/a3b37d6ee353e326ab9ea1a09ecc14045b12928b/napalm_eos/eos.py#L210-L215
def rollback(self): """Implementation of NAPALM method rollback.""" commands = [] commands.append('configure replace flash:rollback-0') commands.append('write memory') self.device.run_commands(commands)
[ "def", "rollback", "(", "self", ")", ":", "commands", "=", "[", "]", "commands", ".", "append", "(", "'configure replace flash:rollback-0'", ")", "commands", ".", "append", "(", "'write memory'", ")", "self", ".", "device", ".", "run_commands", "(", "commands"...
Implementation of NAPALM method rollback.
[ "Implementation", "of", "NAPALM", "method", "rollback", "." ]
python
train
39.5
peri-source/peri
peri/opt/optimize.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1213-L1226
def update_J(self): """Updates J, JTJ, and internal counters.""" self.calc_J() # np.dot(j, j.T) is slightly faster but 2x as much mem step = np.ceil(1e-2 * self.J.shape[1]).astype('int') # 1% more mem... self.JTJ = low_mem_sq(self.J, step=step) #copies still, since J is ...
[ "def", "update_J", "(", "self", ")", ":", "self", ".", "calc_J", "(", ")", "# np.dot(j, j.T) is slightly faster but 2x as much mem", "step", "=", "np", ".", "ceil", "(", "1e-2", "*", "self", ".", "J", ".", "shape", "[", "1", "]", ")", ".", "astype", "(",...
Updates J, JTJ, and internal counters.
[ "Updates", "J", "JTJ", "and", "internal", "counters", "." ]
python
valid
48.857143
Hackerfleet/hfos
hfos/component.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L280-L336
def _set_config(self, config=None): """Set this component's initial configuration""" if not config: config = {} try: # pprint(self.configschema) self.config = self.componentmodel(config) # self.log("Config schema:", lvl=critical) # ppr...
[ "def", "_set_config", "(", "self", ",", "config", "=", "None", ")", ":", "if", "not", "config", ":", "config", "=", "{", "}", "try", ":", "# pprint(self.configschema)", "self", ".", "config", "=", "self", ".", "componentmodel", "(", "config", ")", "# sel...
Set this component's initial configuration
[ "Set", "this", "component", "s", "initial", "configuration" ]
python
train
37.614035
daviddrysdale/python-phonenumbers
python/phonenumbers/phonenumbermatcher.py
https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/phonenumbermatcher.py#L556-L582
def _extract_match(self, candidate, offset): """Attempts to extract a match from a candidate string. Arguments: candidate -- The candidate text that might contain a phone number. offset -- The offset of candidate within self.text Returns the match found, None if none can be foun...
[ "def", "_extract_match", "(", "self", ",", "candidate", ",", "offset", ")", ":", "# Skip a match that is more likely a publication page reference or a", "# date.", "if", "(", "_SLASH_SEPARATED_DATES", ".", "search", "(", "candidate", ")", ")", ":", "return", "None", "...
Attempts to extract a match from a candidate string. Arguments: candidate -- The candidate text that might contain a phone number. offset -- The offset of candidate within self.text Returns the match found, None if none can be found
[ "Attempts", "to", "extract", "a", "match", "from", "a", "candidate", "string", "." ]
python
train
40
bitesofcode/projexui
projexui/widgets/xquerybuilderwidget/xquerybuilderwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xquerybuilderwidget/xquerybuilderwidget.py#L300-L306
def updateRules( self ): """ Updates the query line items to match the latest rule options. """ terms = sorted(self._rules.keys()) for child in self.lineWidgets(): child.setTerms(terms)
[ "def", "updateRules", "(", "self", ")", ":", "terms", "=", "sorted", "(", "self", ".", "_rules", ".", "keys", "(", ")", ")", "for", "child", "in", "self", ".", "lineWidgets", "(", ")", ":", "child", ".", "setTerms", "(", "terms", ")" ]
Updates the query line items to match the latest rule options.
[ "Updates", "the", "query", "line", "items", "to", "match", "the", "latest", "rule", "options", "." ]
python
train
33
mitsei/dlkit
dlkit/json_/repository/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L5559-L5578
def is_ancestor_of_repository(self, id_, repository_id): """Tests if an ``Id`` is an ancestor of a repository. arg: id (osid.id.Id): an ``Id`` arg: repository_id (osid.id.Id): the Id of a repository return: (boolean) - ``true`` if this ``id`` is an ancestor of ``re...
[ "def", "is_ancestor_of_repository", "(", "self", ",", "id_", ",", "repository_id", ")", ":", "# Implemented from template for", "# osid.resource.BinHierarchySession.is_ancestor_of_bin", "if", "self", ".", "_catalog_session", "is", "not", "None", ":", "return", "self", "."...
Tests if an ``Id`` is an ancestor of a repository. arg: id (osid.id.Id): an ``Id`` arg: repository_id (osid.id.Id): the Id of a repository return: (boolean) - ``true`` if this ``id`` is an ancestor of ``repository_id,`` ``false`` otherwise raise: NotFound - ``rep...
[ "Tests", "if", "an", "Id", "is", "an", "ancestor", "of", "a", "repository", "." ]
python
train
52.8
datakortet/dkfileutils
dkfileutils/changed.py
https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/changed.py#L58-L64
def changed(self, filename='.md5', glob=None): """Are any of the files matched by ``glob`` changed? """ if glob is not None: filename += '.glob-' + ''.join(ch.lower() for ch in glob if ch.isalpha()) return changed(self, filename, glo...
[ "def", "changed", "(", "self", ",", "filename", "=", "'.md5'", ",", "glob", "=", "None", ")", ":", "if", "glob", "is", "not", "None", ":", "filename", "+=", "'.glob-'", "+", "''", ".", "join", "(", "ch", ".", "lower", "(", ")", "for", "ch", "in",...
Are any of the files matched by ``glob`` changed?
[ "Are", "any", "of", "the", "files", "matched", "by", "glob", "changed?" ]
python
train
45.857143
openid/python-openid
openid/association.py
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/association.py#L423-L453
def deserialize(cls, assoc_s): """ Parse an association as stored by serialize(). inverse of serialize @param assoc_s: Association as serialized by serialize() @type assoc_s: str @return: instance of this class """ pairs = kvform.kvToSeq(assoc_s, str...
[ "def", "deserialize", "(", "cls", ",", "assoc_s", ")", ":", "pairs", "=", "kvform", ".", "kvToSeq", "(", "assoc_s", ",", "strict", "=", "True", ")", "keys", "=", "[", "]", "values", "=", "[", "]", "for", "k", ",", "v", "in", "pairs", ":", "keys",...
Parse an association as stored by serialize(). inverse of serialize @param assoc_s: Association as serialized by serialize() @type assoc_s: str @return: instance of this class
[ "Parse", "an", "association", "as", "stored", "by", "serialize", "()", "." ]
python
train
27.483871
newville/asteval
asteval/asteval.py
https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/asteval.py#L626-L635
def _printer(self, *out, **kws): """Generic print function.""" flush = kws.pop('flush', True) fileh = kws.pop('file', self.writer) sep = kws.pop('sep', ' ') end = kws.pop('sep', '\n') print(*out, file=fileh, sep=sep, end=end) if flush: fileh.flush()
[ "def", "_printer", "(", "self", ",", "*", "out", ",", "*", "*", "kws", ")", ":", "flush", "=", "kws", ".", "pop", "(", "'flush'", ",", "True", ")", "fileh", "=", "kws", ".", "pop", "(", "'file'", ",", "self", ".", "writer", ")", "sep", "=", "...
Generic print function.
[ "Generic", "print", "function", "." ]
python
train
30.9
mcs07/PubChemPy
pubchempy.py
https://github.com/mcs07/PubChemPy/blob/e3c4f4a9b6120433e5cc3383464c7a79e9b2b86e/pubchempy.py#L1065-L1076
def to_dict(self, properties=None): """Return a dictionary containing Substance data. If the properties parameter is not specified, everything except cids and aids is included. This is because the aids and cids properties each require an extra request to retrieve. :param properties: (o...
[ "def", "to_dict", "(", "self", ",", "properties", "=", "None", ")", ":", "if", "not", "properties", ":", "skip", "=", "{", "'deposited_compound'", ",", "'standardized_compound'", ",", "'cids'", ",", "'aids'", "}", "properties", "=", "[", "p", "for", "p", ...
Return a dictionary containing Substance data. If the properties parameter is not specified, everything except cids and aids is included. This is because the aids and cids properties each require an extra request to retrieve. :param properties: (optional) A list of the desired properties.
[ "Return", "a", "dictionary", "containing", "Substance", "data", "." ]
python
train
54
auth0/auth0-python
auth0/v3/management/tickets.py
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/tickets.py#L32-L38
def create_pswd_change(self, body): """Create password change ticket. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Tickets/post_password_change """ return self.client.post(self._url('password-change'), data=body)
[ "def", "create_pswd_change", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", "'password-change'", ")", ",", "data", "=", "body", ")" ]
Create password change ticket. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Tickets/post_password_change
[ "Create", "password", "change", "ticket", "." ]
python
train
38.428571
gc3-uzh-ch/elasticluster
elasticluster/utils.py
https://github.com/gc3-uzh-ch/elasticluster/blob/e6345633308c76de13b889417df572815aabe744/elasticluster/utils.py#L137-L176
def get_num_processors(): """ Return number of online processor cores. """ # try different strategies and use first one that succeeeds try: return os.cpu_count() # Py3 only except AttributeError: pass try: import multiprocessing return multiprocessing.cpu_cou...
[ "def", "get_num_processors", "(", ")", ":", "# try different strategies and use first one that succeeeds", "try", ":", "return", "os", ".", "cpu_count", "(", ")", "# Py3 only", "except", "AttributeError", ":", "pass", "try", ":", "import", "multiprocessing", "return", ...
Return number of online processor cores.
[ "Return", "number", "of", "online", "processor", "cores", "." ]
python
train
29.7
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L113-L118
def directory(self, query, **kwargs): """Search by users or channels on all server.""" if isinstance(query, dict): query = str(query).replace("'", '"') return self.__call_api_get('directory', query=query, kwargs=kwargs)
[ "def", "directory", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "query", ",", "dict", ")", ":", "query", "=", "str", "(", "query", ")", ".", "replace", "(", "\"'\"", ",", "'\"'", ")", "return", "self", "...
Search by users or channels on all server.
[ "Search", "by", "users", "or", "channels", "on", "all", "server", "." ]
python
train
41.833333
vmware/pyvmomi
pyVim/connect.py
https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVim/connect.py#L618-L644
def __GetServiceVersionDescription(protocol, server, port, path, sslContext): """ Private method that returns a root from an ElementTree describing the API versions supported by the specified server. The result will be vimServiceVersions.xml if it exists, otherwise vimService.wsdl if it exists, otherwise N...
[ "def", "__GetServiceVersionDescription", "(", "protocol", ",", "server", ",", "port", ",", "path", ",", "sslContext", ")", ":", "tree", "=", "__GetElementTree", "(", "protocol", ",", "server", ",", "port", ",", "path", "+", "\"/vimServiceVersions.xml\"", ",", ...
Private method that returns a root from an ElementTree describing the API versions supported by the specified server. The result will be vimServiceVersions.xml if it exists, otherwise vimService.wsdl if it exists, otherwise None. @param protocol: What protocol to use for the connection (e.g. https or http). ...
[ "Private", "method", "that", "returns", "a", "root", "from", "an", "ElementTree", "describing", "the", "API", "versions", "supported", "by", "the", "specified", "server", ".", "The", "result", "will", "be", "vimServiceVersions", ".", "xml", "if", "it", "exists...
python
train
38.703704
vtkiorg/vtki
vtki/renderer.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L748-L762
def enable_eye_dome_lighting(self): """Enable eye dome lighting (EDL)""" if hasattr(self, 'edl_pass'): return self # create the basic VTK render steps basic_passes = vtk.vtkRenderStepsPass() # blur the resulting image # The blur delegates rendering the unblure...
[ "def", "enable_eye_dome_lighting", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'edl_pass'", ")", ":", "return", "self", "# create the basic VTK render steps", "basic_passes", "=", "vtk", ".", "vtkRenderStepsPass", "(", ")", "# blur the resulting image",...
Enable eye dome lighting (EDL)
[ "Enable", "eye", "dome", "lighting", "(", "EDL", ")" ]
python
train
42.333333
dbcli/athenacli
athenacli/packages/special/utils.py
https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/utils.py#L5-L17
def handle_cd_command(arg): """Handles a `cd` shell command by calling python's os.chdir.""" CD_CMD = 'cd' tokens = arg.split(CD_CMD + ' ') directory = tokens[-1] if len(tokens) > 1 else None if not directory: return False, "No folder name was provided." try: os.chdir(directory) ...
[ "def", "handle_cd_command", "(", "arg", ")", ":", "CD_CMD", "=", "'cd'", "tokens", "=", "arg", ".", "split", "(", "CD_CMD", "+", "' '", ")", "directory", "=", "tokens", "[", "-", "1", "]", "if", "len", "(", "tokens", ")", ">", "1", "else", "None", ...
Handles a `cd` shell command by calling python's os.chdir.
[ "Handles", "a", "cd", "shell", "command", "by", "calling", "python", "s", "os", ".", "chdir", "." ]
python
train
32.615385
johnbywater/eventsourcing
eventsourcing/infrastructure/sqlalchemy/manager.py
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/sqlalchemy/manager.py#L274-L285
def delete_record(self, record): """ Permanently removes record from table. """ try: self.session.delete(record) self.session.commit() except Exception as e: self.session.rollback() raise ProgrammingError(e) finally: ...
[ "def", "delete_record", "(", "self", ",", "record", ")", ":", "try", ":", "self", ".", "session", ".", "delete", "(", "record", ")", "self", ".", "session", ".", "commit", "(", ")", "except", "Exception", "as", "e", ":", "self", ".", "session", ".", ...
Permanently removes record from table.
[ "Permanently", "removes", "record", "from", "table", "." ]
python
train
27.833333
grangier/python-goose
goose/extractors/images.py
https://github.com/grangier/python-goose/blob/09023ec9f5ef26a628a2365616c0a7c864f0ecea/goose/extractors/images.py#L397-L410
def build_image_path(self, src): """\ This method will take an image path and build out the absolute path to that image * using the initial url we crawled so we can find a link to the image if they use relative urls like ../myimage.jpg """ o = urlparse...
[ "def", "build_image_path", "(", "self", ",", "src", ")", ":", "o", "=", "urlparse", "(", "src", ")", "# we have a full url", "if", "o", ".", "hostname", ":", "return", "o", ".", "geturl", "(", ")", "# we have a relative url", "return", "urljoin", "(", "sel...
\ This method will take an image path and build out the absolute path to that image * using the initial url we crawled so we can find a link to the image if they use relative urls like ../myimage.jpg
[ "\\", "This", "method", "will", "take", "an", "image", "path", "and", "build", "out", "the", "absolute", "path", "to", "that", "image", "*", "using", "the", "initial", "url", "we", "crawled", "so", "we", "can", "find", "a", "link", "to", "the", "image"...
python
train
33.714286
xapple/plumbing
plumbing/trees/__init__.py
https://github.com/xapple/plumbing/blob/4a7706c7722f5996d0ca366f191aff9ac145880a/plumbing/trees/__init__.py#L63-L69
def get_level(self, level=2): """Get all nodes that are exactly this far away.""" if level == 1: for child in self.children.values(): yield child else: for child in self.children.values(): for node in child.get_level(level-1): yield node
[ "def", "get_level", "(", "self", ",", "level", "=", "2", ")", ":", "if", "level", "==", "1", ":", "for", "child", "in", "self", ".", "children", ".", "values", "(", ")", ":", "yield", "child", "else", ":", "for", "child", "in", "self", ".", "chil...
Get all nodes that are exactly this far away.
[ "Get", "all", "nodes", "that", "are", "exactly", "this", "far", "away", "." ]
python
train
42.142857
quantopian/zipline
zipline/pipeline/mixins.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/mixins.py#L153-L180
def _allocate_output(self, windows, shape): """ Allocate an output array whose rows should be passed to `self.compute`. The resulting array must have a shape of ``shape``. If we have standard outputs (i.e. self.outputs is NotSpecified), the default is an empty ndarray whose dty...
[ "def", "_allocate_output", "(", "self", ",", "windows", ",", "shape", ")", ":", "missing_value", "=", "self", ".", "missing_value", "outputs", "=", "self", ".", "outputs", "if", "outputs", "is", "not", "NotSpecified", ":", "out", "=", "recarray", "(", "sha...
Allocate an output array whose rows should be passed to `self.compute`. The resulting array must have a shape of ``shape``. If we have standard outputs (i.e. self.outputs is NotSpecified), the default is an empty ndarray whose dtype is ``self.dtype``. If we have an outputs tuple, the ...
[ "Allocate", "an", "output", "array", "whose", "rows", "should", "be", "passed", "to", "self", ".", "compute", "." ]
python
train
36.678571
mrtazz/simplenote.py
simplenote/simplenote.py
https://github.com/mrtazz/simplenote.py/blob/19a8c6e5de8db2e5ff9f0a82e86b8a6fb35eac82/simplenote/simplenote.py#L90-L105
def get_token(self): """ Method to retrieve an auth token. The cached global token is looked up and returned if it exists. If it is `None` a new one is requested and returned. Returns: Simplenote API token as string """ if self.token == None: se...
[ "def", "get_token", "(", "self", ")", ":", "if", "self", ".", "token", "==", "None", ":", "self", ".", "token", "=", "self", ".", "authenticate", "(", "self", ".", "username", ",", "self", ".", "password", ")", "try", ":", "return", "str", "(", "se...
Method to retrieve an auth token. The cached global token is looked up and returned if it exists. If it is `None` a new one is requested and returned. Returns: Simplenote API token as string
[ "Method", "to", "retrieve", "an", "auth", "token", "." ]
python
train
29.6875
googleapis/google-auth-library-python
google/oauth2/_client.py
https://github.com/googleapis/google-auth-library-python/blob/2c6ad78917e936f38f87c946209c8031166dc96e/google/oauth2/_client.py#L159-L201
def id_token_jwt_grant(request, token_uri, assertion): """Implements the JWT Profile for OAuth 2.0 Authorization Grants, but requests an OpenID Connect ID Token instead of an access token. This is a variant on the standard JWT Profile that is currently unique to Google. This was added for the benefit o...
[ "def", "id_token_jwt_grant", "(", "request", ",", "token_uri", ",", "assertion", ")", ":", "body", "=", "{", "'assertion'", ":", "assertion", ",", "'grant_type'", ":", "_JWT_GRANT_TYPE", ",", "}", "response_data", "=", "_token_endpoint_request", "(", "request", ...
Implements the JWT Profile for OAuth 2.0 Authorization Grants, but requests an OpenID Connect ID Token instead of an access token. This is a variant on the standard JWT Profile that is currently unique to Google. This was added for the benefit of authenticating to services that require ID Tokens instea...
[ "Implements", "the", "JWT", "Profile", "for", "OAuth", "2", ".", "0", "Authorization", "Grants", "but", "requests", "an", "OpenID", "Connect", "ID", "Token", "instead", "of", "an", "access", "token", "." ]
python
train
36.930233
OpenKMIP/PyKMIP
kmip/core/objects.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/core/objects.py#L250-L310
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_2_0): """ Read the data stream and decode the AttributeReference structure into its parts. Args: input_buffer (stream): A data stream containing encoded object data, supporting a read method. ...
[ "def", "read", "(", "self", ",", "input_buffer", ",", "kmip_version", "=", "enums", ".", "KMIPVersion", ".", "KMIP_2_0", ")", ":", "if", "kmip_version", "<", "enums", ".", "KMIPVersion", ".", "KMIP_2_0", ":", "raise", "exceptions", ".", "VersionNotSupported", ...
Read the data stream and decode the AttributeReference structure into its parts. Args: input_buffer (stream): A data stream containing encoded object data, supporting a read method. kmip_version (enum): A KMIPVersion enumeration defining the KMIP ...
[ "Read", "the", "data", "stream", "and", "decode", "the", "AttributeReference", "structure", "into", "its", "parts", "." ]
python
test
37.590164
iotile/coretools
iotilecore/iotile/core/hw/reports/utc_assigner.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/reports/utc_assigner.py#L318-L371
def fix_report(self, report, errors="drop", prefer="before"): """Perform utc assignment on all readings in a report. The returned report will have all reading timestamps in UTC. This only works on SignedListReport objects. Note that the report should typically have previously been adde...
[ "def", "fix_report", "(", "self", ",", "report", ",", "errors", "=", "\"drop\"", ",", "prefer", "=", "\"before\"", ")", ":", "if", "not", "isinstance", "(", "report", ",", "SignedListReport", ")", ":", "raise", "ArgumentError", "(", "\"Report must be a SignedL...
Perform utc assignment on all readings in a report. The returned report will have all reading timestamps in UTC. This only works on SignedListReport objects. Note that the report should typically have previously been added to the UTC assigner using add_report or no reference points fro...
[ "Perform", "utc", "assignment", "on", "all", "readings", "in", "a", "report", "." ]
python
train
47.592593
agoragames/kairos
kairos/sql_backend.py
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/sql_backend.py#L189-L212
def _get(self, name, interval, config, timestamp, **kws): ''' Get the interval. ''' i_bucket = config['i_calc'].to_bucket(timestamp) fetch = kws.get('fetch') process_row = kws.get('process_row') or self._process_row rval = OrderedDict() if fetch: data = fetch( self._client.connect...
[ "def", "_get", "(", "self", ",", "name", ",", "interval", ",", "config", ",", "timestamp", ",", "*", "*", "kws", ")", ":", "i_bucket", "=", "config", "[", "'i_calc'", "]", ".", "to_bucket", "(", "timestamp", ")", "fetch", "=", "kws", ".", "get", "(...
Get the interval.
[ "Get", "the", "interval", "." ]
python
train
33
Azure/azure-cosmos-python
azure/cosmos/session.py
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/session.py#L169-L198
def parse_session_token(response_headers): """ Extracts session token from response headers and parses :param dict response_headers: :return: A dictionary of partition id to session lsn for given collection :rtype: dict """ # extract sessio...
[ "def", "parse_session_token", "(", "response_headers", ")", ":", "# extract session token from response header", "session_token", "=", "''", "if", "http_constants", ".", "HttpHeaders", ".", "SessionToken", "in", "response_headers", ":", "session_token", "=", "response_heade...
Extracts session token from response headers and parses :param dict response_headers: :return: A dictionary of partition id to session lsn for given collection :rtype: dict
[ "Extracts", "session", "token", "from", "response", "headers", "and", "parses" ]
python
train
43.1
Xion/taipan
taipan/collections/__init__.py
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/__init__.py#L40-L55
def is_ordered_mapping(obj): """Checks whether given object is an ordered mapping, e.g. a :class:`OrderedDict`. :return: ``True`` if argument is an ordered mapping, ``False`` otherwise """ if not (is_mapping(obj) and hasattr(obj, '__reversed__')): return False # PyPy has a bug where the...
[ "def", "is_ordered_mapping", "(", "obj", ")", ":", "if", "not", "(", "is_mapping", "(", "obj", ")", "and", "hasattr", "(", "obj", ",", "'__reversed__'", ")", ")", ":", "return", "False", "# PyPy has a bug where the standard :class:`dict` has the ``__reversed__``", "...
Checks whether given object is an ordered mapping, e.g. a :class:`OrderedDict`. :return: ``True`` if argument is an ordered mapping, ``False`` otherwise
[ "Checks", "whether", "given", "object", "is", "an", "ordered", "mapping", "e", ".", "g", ".", "a", ":", "class", ":", "OrderedDict", ".", ":", "return", ":", "True", "if", "argument", "is", "an", "ordered", "mapping", "False", "otherwise" ]
python
train
33.0625
changhiskhan/poseidon
poseidon/api.py
https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/api.py#L362-L372
def records(self, name): """ Get a list of all domain records for the given domain name Parameters ---------- name: str domain name """ if self.get(name): return DomainRecords(self.api, name)
[ "def", "records", "(", "self", ",", "name", ")", ":", "if", "self", ".", "get", "(", "name", ")", ":", "return", "DomainRecords", "(", "self", ".", "api", ",", "name", ")" ]
Get a list of all domain records for the given domain name Parameters ---------- name: str domain name
[ "Get", "a", "list", "of", "all", "domain", "records", "for", "the", "given", "domain", "name" ]
python
valid
23.818182
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_graph.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_graph.py#L104-L115
def add_mavlink_packet(self, msg): '''add data to the graph''' mtype = msg.get_type() if mtype not in self.msg_types: return for i in range(len(self.fields)): if mtype not in self.field_types[i]: continue f = self.fields[i] ...
[ "def", "add_mavlink_packet", "(", "self", ",", "msg", ")", ":", "mtype", "=", "msg", ".", "get_type", "(", ")", "if", "mtype", "not", "in", "self", ".", "msg_types", ":", "return", "for", "i", "in", "range", "(", "len", "(", "self", ".", "fields", ...
add data to the graph
[ "add", "data", "to", "the", "graph" ]
python
train
39.5
berkeley-cocosci/Wallace
wallace/command_line.py
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L66-L80
def setup(): """Walk the user though the Wallace setup.""" # Create the Wallace config file if it does not already exist. config_name = ".wallaceconfig" config_path = os.path.join(os.path.expanduser("~"), config_name) if os.path.isfile(config_path): log("Wallace config file already exists."...
[ "def", "setup", "(", ")", ":", "# Create the Wallace config file if it does not already exist.", "config_name", "=", "\".wallaceconfig\"", "config_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "confi...
Walk the user though the Wallace setup.
[ "Walk", "the", "user", "though", "the", "Wallace", "setup", "." ]
python
train
41.066667
LogicalDash/LiSE
LiSE/LiSE/node.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/node.py#L439-L452
def path_exists(self, dest, weight=None): """Return whether there is a path leading from me to ``dest``. With ``weight``, only consider edges that have a stat by the given name. Raise ``ValueError`` if ``dest`` is not a node in my character or the name of one. """ ...
[ "def", "path_exists", "(", "self", ",", "dest", ",", "weight", "=", "None", ")", ":", "try", ":", "return", "bool", "(", "self", ".", "shortest_path_length", "(", "dest", ",", "weight", ")", ")", "except", "KeyError", ":", "return", "False" ]
Return whether there is a path leading from me to ``dest``. With ``weight``, only consider edges that have a stat by the given name. Raise ``ValueError`` if ``dest`` is not a node in my character or the name of one.
[ "Return", "whether", "there", "is", "a", "path", "leading", "from", "me", "to", "dest", "." ]
python
train
30.714286
zaturox/glin
glin/app.py
https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/app.py#L56-L59
def register_animation(self, animation_class): """Add a new animation""" self.state.animationClasses.append(animation_class) return len(self.state.animationClasses) - 1
[ "def", "register_animation", "(", "self", ",", "animation_class", ")", ":", "self", ".", "state", ".", "animationClasses", ".", "append", "(", "animation_class", ")", "return", "len", "(", "self", ".", "state", ".", "animationClasses", ")", "-", "1" ]
Add a new animation
[ "Add", "a", "new", "animation" ]
python
train
47.25
AoiKuiyuyou/AoikLiveReload
tools/waf/aoikwafutil.py
https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/tools/waf/aoikwafutil.py#L2162-L2204
def git_clean(ctx): """ Delete all files untracked by git. :param ctx: Context object. :return: None. """ # Get command parts cmd_part_s = [ # Program path 'git', # Clean untracked files 'clean', # Remove all untracked files '-x', ...
[ "def", "git_clean", "(", "ctx", ")", ":", "# Get command parts", "cmd_part_s", "=", "[", "# Program path", "'git'", ",", "# Clean untracked files", "'clean'", ",", "# Remove all untracked files", "'-x'", ",", "# Remove untracked directories too", "'-d'", ",", "# Force to ...
Delete all files untracked by git. :param ctx: Context object. :return: None.
[ "Delete", "all", "files", "untracked", "by", "git", "." ]
python
train
19.395349
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L113-L117
def p_pragma(self, p): 'pragma : LPAREN TIMES ID TIMES RPAREN' p[0] = Pragma(PragmaEntry(p[3], lineno=p.lineno(1)), lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_pragma", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "Pragma", "(", "PragmaEntry", "(", "p", "[", "3", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", ",", "lineno", "=", "p", ".", "lineno", "(", "1"...
pragma : LPAREN TIMES ID TIMES RPAREN
[ "pragma", ":", "LPAREN", "TIMES", "ID", "TIMES", "RPAREN" ]
python
train
41.2
davidmiller/letter
letter/contrib/contact.py
https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/contrib/contact.py#L87-L92
def form_valid(self, form): """ Praise be, someone has spammed us. """ form.send_email(to=self.to_addr) return super(EmailView, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "form", ".", "send_email", "(", "to", "=", "self", ".", "to_addr", ")", "return", "super", "(", "EmailView", ",", "self", ")", ".", "form_valid", "(", "form", ")" ]
Praise be, someone has spammed us.
[ "Praise", "be", "someone", "has", "spammed", "us", "." ]
python
train
30.833333
nats-io/asyncio-nats
nats/aio/client.py
https://github.com/nats-io/asyncio-nats/blob/39e840be0b12ce326edac0bba69aeb1be930dcb8/nats/aio/client.py#L1111-L1146
def _connect_command(self): ''' Generates a JSON string with the params to be used when sending CONNECT to the server. ->> CONNECT {"lang": "python3"} ''' options = { "verbose": self.options["verbose"], "pedantic": self.options["pedantic"], ...
[ "def", "_connect_command", "(", "self", ")", ":", "options", "=", "{", "\"verbose\"", ":", "self", ".", "options", "[", "\"verbose\"", "]", ",", "\"pedantic\"", ":", "self", ".", "options", "[", "\"pedantic\"", "]", ",", "\"lang\"", ":", "__lang__", ",", ...
Generates a JSON string with the params to be used when sending CONNECT to the server. ->> CONNECT {"lang": "python3"}
[ "Generates", "a", "JSON", "string", "with", "the", "params", "to", "be", "used", "when", "sending", "CONNECT", "to", "the", "server", "." ]
python
test
44.138889
tornadoweb/tornado
tornado/options.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L180-L201
def group_dict(self, group: str) -> Dict[str, Any]: """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') de...
[ "def", "group_dict", "(", "self", ",", "group", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ...
The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') define('static_path', group='application') parse_com...
[ "The", "names", "and", "values", "of", "options", "in", "a", "group", "." ]
python
train
31.318182
splitkeycoffee/pyhottop
pyhottop/pyhottop.py
https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L626-L636
def end(self): """End the roaster control process via thread signal. This simply sends an exit signal to the thread, and shuts it down. In order to stop monitoring, call the `set_monitor` method with false. :returns: None """ self._process.shutdown() self._roast...
[ "def", "end", "(", "self", ")", ":", "self", ".", "_process", ".", "shutdown", "(", ")", "self", ".", "_roasting", "=", "False", "self", ".", "_roast", "[", "'date'", "]", "=", "now_date", "(", "str", "=", "True", ")" ]
End the roaster control process via thread signal. This simply sends an exit signal to the thread, and shuts it down. In order to stop monitoring, call the `set_monitor` method with false. :returns: None
[ "End", "the", "roaster", "control", "process", "via", "thread", "signal", "." ]
python
train
33.636364
thieman/dagobah
dagobah/core/core.py
https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/core/core.py#L156-L172
def add_job(self, job_name, job_id=None): """ Create a new, empty Job. """ logger.debug('Creating a new job named {0}'.format(job_name)) if not self._name_is_available(job_name): raise DagobahError('name %s is not available' % job_name) if not job_id: job_id = se...
[ "def", "add_job", "(", "self", ",", "job_name", ",", "job_id", "=", "None", ")", ":", "logger", ".", "debug", "(", "'Creating a new job named {0}'", ".", "format", "(", "job_name", ")", ")", "if", "not", "self", ".", "_name_is_available", "(", "job_name", ...
Create a new, empty Job.
[ "Create", "a", "new", "empty", "Job", "." ]
python
train
34.176471
kennethreitz/omnijson
omnijson/packages/simplejson/decoder.py
https://github.com/kennethreitz/omnijson/blob/a5890a51a59ad76f78a61f5bf91fa86b784cf694/omnijson/packages/simplejson/decoder.py#L397-L406
def decode(self, s, _w=WHITESPACE.match): """Return the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) """ obj, end = self.raw_decode(s, idx=_w(s, 0).end()) end = _w(s, end).end() if end != len(s): raise JSONDeco...
[ "def", "decode", "(", "self", ",", "s", ",", "_w", "=", "WHITESPACE", ".", "match", ")", ":", "obj", ",", "end", "=", "self", ".", "raw_decode", "(", "s", ",", "idx", "=", "_w", "(", "s", ",", "0", ")", ".", "end", "(", ")", ")", "end", "="...
Return the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document)
[ "Return", "the", "Python", "representation", "of", "s", "(", "a", "str", "or", "unicode", "instance", "containing", "a", "JSON", "document", ")" ]
python
train
36.7
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L4787-L4913
def dokent(data, NN): """ gets Kent parameters for data Parameters ___________________ data : nested pairs of [Dec,Inc] NN : normalization NN is the number of data for Kent ellipse NN is 1 for Kent ellipses of bootstrapped mean directions Return kpars dictionary keys ...
[ "def", "dokent", "(", "data", ",", "NN", ")", ":", "X", ",", "kpars", "=", "[", "]", ",", "{", "}", "N", "=", "len", "(", "data", ")", "if", "N", "<", "2", ":", "return", "kpars", "#", "# get fisher mean and convert to co-inclination (theta)/dec (phi) i...
gets Kent parameters for data Parameters ___________________ data : nested pairs of [Dec,Inc] NN : normalization NN is the number of data for Kent ellipse NN is 1 for Kent ellipses of bootstrapped mean directions Return kpars dictionary keys dec : mean declination ...
[ "gets", "Kent", "parameters", "for", "data", "Parameters", "___________________", "data", ":", "nested", "pairs", "of", "[", "Dec", "Inc", "]", "NN", ":", "normalization", "NN", "is", "the", "number", "of", "data", "for", "Kent", "ellipse", "NN", "is", "1"...
python
train
30.480315
ZELLMECHANIK-DRESDEN/dclab
dclab/rtdc_dataset/ancillaries/ancillary_feature.py
https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/ancillaries/ancillary_feature.py#L169-L229
def is_available(self, rtdc_ds, verbose=False): """Check whether the feature is available Parameters ---------- rtdc_ds: instance of RTDCBase The dataset to check availability for Returns ------- available: bool `True`, if feature can be ...
[ "def", "is_available", "(", "self", ",", "rtdc_ds", ",", "verbose", "=", "False", ")", ":", "# Check config keys", "for", "item", "in", "self", ".", "req_config", ":", "section", ",", "keys", "=", "item", "if", "section", "not", "in", "rtdc_ds", ".", "co...
Check whether the feature is available Parameters ---------- rtdc_ds: instance of RTDCBase The dataset to check availability for Returns ------- available: bool `True`, if feature can be computed with `compute` Notes ----- ...
[ "Check", "whether", "the", "feature", "is", "available" ]
python
train
34.590164
tdryer/hangups
hangups/message_parser.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/message_parser.py#L92-L94
def html(tag): """Return sequence of start and end regex patterns for simple HTML tag""" return (HTML_START.format(tag=tag), HTML_END.format(tag=tag))
[ "def", "html", "(", "tag", ")", ":", "return", "(", "HTML_START", ".", "format", "(", "tag", "=", "tag", ")", ",", "HTML_END", ".", "format", "(", "tag", "=", "tag", ")", ")" ]
Return sequence of start and end regex patterns for simple HTML tag
[ "Return", "sequence", "of", "start", "and", "end", "regex", "patterns", "for", "simple", "HTML", "tag" ]
python
valid
52
ml4ai/delphi
scripts/evaluations/create_CAG_with_indicators.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/scripts/evaluations/create_CAG_with_indicators.py#L5-L18
def create_CAG_with_indicators(input, output, filename="CAG_with_indicators.pdf"): """ Create a CAG with mapped indicators """ with open(input, "rb") as f: G = pickle.load(f) G.map_concepts_to_indicators(min_temporal_res="month") G.set_indicator("UN/events/weather/precipitation", "Historical Ave...
[ "def", "create_CAG_with_indicators", "(", "input", ",", "output", ",", "filename", "=", "\"CAG_with_indicators.pdf\"", ")", ":", "with", "open", "(", "input", ",", "\"rb\"", ")", "as", "f", ":", "G", "=", "pickle", ".", "load", "(", "f", ")", "G", ".", ...
Create a CAG with mapped indicators
[ "Create", "a", "CAG", "with", "mapped", "indicators" ]
python
train
64.928571
PaulHancock/Aegean
AegeanTools/angle_tools.py
https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L62-L87
def dec2dms(x): """ Convert decimal degrees into a sexagessimal string in degrees. Parameters ---------- x : float Angle in degrees Returns ------- dms : string String of format [+-]DD:MM:SS.SS or XX:XX:XX.XX if x is not finite. """ if not np.isfinite(x)...
[ "def", "dec2dms", "(", "x", ")", ":", "if", "not", "np", ".", "isfinite", "(", "x", ")", ":", "return", "'XX:XX:XX.XX'", "if", "x", "<", "0", ":", "sign", "=", "'-'", "else", ":", "sign", "=", "'+'", "x", "=", "abs", "(", "x", ")", "d", "=", ...
Convert decimal degrees into a sexagessimal string in degrees. Parameters ---------- x : float Angle in degrees Returns ------- dms : string String of format [+-]DD:MM:SS.SS or XX:XX:XX.XX if x is not finite.
[ "Convert", "decimal", "degrees", "into", "a", "sexagessimal", "string", "in", "degrees", "." ]
python
train
21.961538
inveniosoftware/invenio-pidrelations
invenio_pidrelations/api.py
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L69-L78
def resolve_pid(fetched_pid): """Retrieve the real PID given a fetched PID. :param pid: fetched PID to resolve. """ return PersistentIdentifier.get( pid_type=fetched_pid.pid_type, pid_value=fetched_pid.pid_value, pid_provider=fetched_pid.provider.pid_provider )
[ "def", "resolve_pid", "(", "fetched_pid", ")", ":", "return", "PersistentIdentifier", ".", "get", "(", "pid_type", "=", "fetched_pid", ".", "pid_type", ",", "pid_value", "=", "fetched_pid", ".", "pid_value", ",", "pid_provider", "=", "fetched_pid", ".", "provide...
Retrieve the real PID given a fetched PID. :param pid: fetched PID to resolve.
[ "Retrieve", "the", "real", "PID", "given", "a", "fetched", "PID", "." ]
python
train
29.7
jf-parent/brome
brome/runner/localhost_instance.py
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/localhost_instance.py#L49-L67
def execute_command(self, command): """Execute a command Args: command (str) Returns: process (object) """ self.runner.info_log("Executing command: %s" % command) process = Popen( command, stdout=open(os.devnull,...
[ "def", "execute_command", "(", "self", ",", "command", ")", ":", "self", ".", "runner", ".", "info_log", "(", "\"Executing command: %s\"", "%", "command", ")", "process", "=", "Popen", "(", "command", ",", "stdout", "=", "open", "(", "os", ".", "devnull", ...
Execute a command Args: command (str) Returns: process (object)
[ "Execute", "a", "command" ]
python
train
20.526316
JoelBender/bacpypes
py34/bacpypes/primitivedata.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py34/bacpypes/primitivedata.py#L1407-L1418
def now(self, when=None): """Set the current value to the correct tuple based on the seconds since the epoch. If 'when' is not provided, get the current time from the task manager. """ if when is None: when = _TaskManager().get_time() tup = time.localtime(whe...
[ "def", "now", "(", "self", ",", "when", "=", "None", ")", ":", "if", "when", "is", "None", ":", "when", "=", "_TaskManager", "(", ")", ".", "get_time", "(", ")", "tup", "=", "time", ".", "localtime", "(", "when", ")", "self", ".", "value", "=", ...
Set the current value to the correct tuple based on the seconds since the epoch. If 'when' is not provided, get the current time from the task manager.
[ "Set", "the", "current", "value", "to", "the", "correct", "tuple", "based", "on", "the", "seconds", "since", "the", "epoch", ".", "If", "when", "is", "not", "provided", "get", "the", "current", "time", "from", "the", "task", "manager", "." ]
python
train
33
saltstack/salt
salt/modules/boto_iot.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_iot.py#L454-L476
def delete_policy_version(policyName, policyVersionId, region=None, key=None, keyid=None, profile=None): ''' Given a policy name and version, delete it. Returns {deleted: true} if the policy version was deleted and returns {deleted: false} if the policy version was not deleted. CLI Exa...
[ "def", "delete_policy_version", "(", "policyName", ",", "policyVersionId", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "try", ":", "conn", "=", "_get_conn", "(", "region", "=", ...
Given a policy name and version, delete it. Returns {deleted: true} if the policy version was deleted and returns {deleted: false} if the policy version was not deleted. CLI Example: .. code-block:: bash salt myminion boto_iot.delete_policy_version mypolicy version
[ "Given", "a", "policy", "name", "and", "version", "delete", "it", "." ]
python
train
33.130435
project-rig/rig
rig/place_and_route/machine.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/machine.py#L220-L265
def has_wrap_around_links(self, minimum_working=0.9): """Test if a machine has wrap-around connections installed. Since the Machine object does not explicitly define whether a machine has wrap-around links they must be tested for directly. This test performs a "fuzzy" test on the number...
[ "def", "has_wrap_around_links", "(", "self", ",", "minimum_working", "=", "0.9", ")", ":", "working", "=", "0", "for", "x", "in", "range", "(", "self", ".", "width", ")", ":", "if", "(", "x", ",", "0", ",", "Links", ".", "south", ")", "in", "self",...
Test if a machine has wrap-around connections installed. Since the Machine object does not explicitly define whether a machine has wrap-around links they must be tested for directly. This test performs a "fuzzy" test on the number of wrap-around links which are working to determine if w...
[ "Test", "if", "a", "machine", "has", "wrap", "-", "around", "connections", "installed", "." ]
python
train
37.326087
funilrys/PyFunceble
PyFunceble/database.py
https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/database.py#L789-L814
def is_time_older(self): """ Check if the current time is older than the one in the database. """ if ( self._authorization() and self.is_in_database() and int( PyFunceble.INTERN["whois_db"][PyFunceble.INTERN["file_to_test"]][ ...
[ "def", "is_time_older", "(", "self", ")", ":", "if", "(", "self", ".", "_authorization", "(", ")", "and", "self", ".", "is_in_database", "(", ")", "and", "int", "(", "PyFunceble", ".", "INTERN", "[", "\"whois_db\"", "]", "[", "PyFunceble", ".", "INTERN",...
Check if the current time is older than the one in the database.
[ "Check", "if", "the", "current", "time", "is", "older", "than", "the", "one", "in", "the", "database", "." ]
python
test
31.692308
tensorflow/cleverhans
cleverhans/train.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/train.py#L277-L309
def avg_grads(tower_grads): """Calculate the average gradient for each shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over individual gradients. The inner ...
[ "def", "avg_grads", "(", "tower_grads", ")", ":", "if", "len", "(", "tower_grads", ")", "==", "1", ":", "return", "tower_grads", "[", "0", "]", "average_grads", "=", "[", "]", "for", "grad_and_vars", "in", "zip", "(", "*", "tower_grads", ")", ":", "# N...
Calculate the average gradient for each shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over individual gradients. The inner list is over the gradient c...
[ "Calculate", "the", "average", "gradient", "for", "each", "shared", "variable", "across", "all", "towers", ".", "Note", "that", "this", "function", "provides", "a", "synchronization", "point", "across", "all", "towers", ".", "Args", ":", "tower_grads", ":", "L...
python
train
38.151515
saltstack/salt
salt/states/ssh_known_hosts.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ssh_known_hosts.py#L45-L191
def present( name, user=None, fingerprint=None, key=None, port=None, enc=None, config=None, hash_known_hosts=True, timeout=5, fingerprint_hash_type=None): ''' Verifies that the specified host is known by the specified user On m...
[ "def", "present", "(", "name", ",", "user", "=", "None", ",", "fingerprint", "=", "None", ",", "key", "=", "None", ",", "port", "=", "None", ",", "enc", "=", "None", ",", "config", "=", "None", ",", "hash_known_hosts", "=", "True", ",", "timeout", ...
Verifies that the specified host is known by the specified user On many systems, specifically those running with openssh 4 or older, the ``enc`` option must be set, only openssh 5 and above can detect the key type. name The name of the remote host (e.g. "github.com") Note that only a s...
[ "Verifies", "that", "the", "specified", "host", "is", "known", "by", "the", "specified", "user" ]
python
train
37.666667
inveniosoftware/invenio-deposit
invenio_deposit/api.py
https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L249-L261
def _process_files(self, record_id, data): """Snapshot bucket and add files in record during first publishing.""" if self.files: assert not self.files.bucket.locked self.files.bucket.locked = True snapshot = self.files.bucket.snapshot(lock=True) data['_fil...
[ "def", "_process_files", "(", "self", ",", "record_id", ",", "data", ")", ":", "if", "self", ".", "files", ":", "assert", "not", "self", ".", "files", ".", "bucket", ".", "locked", "self", ".", "files", ".", "bucket", ".", "locked", "=", "True", "sna...
Snapshot bucket and add files in record during first publishing.
[ "Snapshot", "bucket", "and", "add", "files", "in", "record", "during", "first", "publishing", "." ]
python
valid
40.615385
MacHu-GWU/crawl_zillow-project
crawl_zillow/model.py
https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/model.py#L50-L63
def key(self): """ Example:: /browse/homes/ca/ -> ca /browse/homes/ca/los-angeles-county/ -> los-angeles-county /browse/homes/ca/los-angeles-county/91001/ -> 91001 /browse/homes/ca/los-angeles-county/91001/tola-ave_5038895/ -> tola-ave_5038895 :r...
[ "def", "key", "(", "self", ")", ":", "return", "[", "part", ".", "strip", "(", ")", "for", "part", "in", "self", ".", "href", ".", "split", "(", "\"/\"", ")", "if", "part", ".", "strip", "(", ")", "]", "[", "-", "1", "]" ]
Example:: /browse/homes/ca/ -> ca /browse/homes/ca/los-angeles-county/ -> los-angeles-county /browse/homes/ca/los-angeles-county/91001/ -> 91001 /browse/homes/ca/los-angeles-county/91001/tola-ave_5038895/ -> tola-ave_5038895 :return:
[ "Example", "::" ]
python
train
30.142857
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L290-L311
def count(cls, *criterion, **kwargs): """Returns a count of the instances meeting the specified filter criterion and kwargs. Examples: >>> User.count() 500 >>> User.count(country="India") 300 >>> User.count(User.age > 50, country="I...
[ "def", "count", "(", "cls", ",", "*", "criterion", ",", "*", "*", "kwargs", ")", ":", "if", "criterion", "or", "kwargs", ":", "return", "cls", ".", "filter", "(", "*", "criterion", ",", "*", "*", "kwargs", ")", ".", "count", "(", ")", "else", ":"...
Returns a count of the instances meeting the specified filter criterion and kwargs. Examples: >>> User.count() 500 >>> User.count(country="India") 300 >>> User.count(User.age > 50, country="India") 39
[ "Returns", "a", "count", "of", "the", "instances", "meeting", "the", "specified", "filter", "criterion", "and", "kwargs", "." ]
python
train
23.136364
python-rope/rope
rope/refactor/restructure.py
https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/refactor/restructure.py#L94-L153
def get_changes(self, checks=None, imports=None, resources=None, task_handle=taskhandle.NullTaskHandle()): """Get the changes needed by this restructuring `resources` can be a list of `rope.base.resources.File`\s to apply the restructuring on. If `None`, the restructuring w...
[ "def", "get_changes", "(", "self", ",", "checks", "=", "None", ",", "imports", "=", "None", ",", "resources", "=", "None", ",", "task_handle", "=", "taskhandle", ".", "NullTaskHandle", "(", ")", ")", ":", "if", "checks", "is", "not", "None", ":", "warn...
Get the changes needed by this restructuring `resources` can be a list of `rope.base.resources.File`\s to apply the restructuring on. If `None`, the restructuring will be applied to all python files. `checks` argument has been deprecated. Use the `args` argument of the constr...
[ "Get", "the", "changes", "needed", "by", "this", "restructuring" ]
python
train
45.516667
xav/Grapefruit
grapefruit.py
https://github.com/xav/Grapefruit/blob/b3d88375be727a3a1ec5839fbc462e0e8e0836e4/grapefruit.py#L1259-L1283
def from_xyz(x, y, z, alpha=1.0, wref=_DEFAULT_WREF): """Create a new instance based on the specifed CIE-XYZ values. Parameters: :x: The Red component value [0...1] :y: The Green component value [0...1] :z: The Blue component value [0...1] :alpha: The col...
[ "def", "from_xyz", "(", "x", ",", "y", ",", "z", ",", "alpha", "=", "1.0", ",", "wref", "=", "_DEFAULT_WREF", ")", ":", "return", "Color", "(", "xyz_to_rgb", "(", "x", ",", "y", ",", "z", ")", ",", "'rgb'", ",", "alpha", ",", "wref", ")" ]
Create a new instance based on the specifed CIE-XYZ values. Parameters: :x: The Red component value [0...1] :y: The Green component value [0...1] :z: The Blue component value [0...1] :alpha: The color transparency [0...1], default is opaque :wref: ...
[ "Create", "a", "new", "instance", "based", "on", "the", "specifed", "CIE", "-", "XYZ", "values", "." ]
python
train
27.76
samuraisam/pyapns
pyapns/server.py
https://github.com/samuraisam/pyapns/blob/78c1875f28f8af51c7dd7f60d4436a8b282b0394/pyapns/server.py#L215-L239
def read(self): "Connect to the feedback service and read all data." log.msg('APNSService read (connecting)') try: server, port = ((FEEDBACK_SERVER_SANDBOX_HOSTNAME if self.environment == 'sandbox' else FEEDBACK_SERVER_HOSTNAME), FEEDBACK_SERVER_PORT) ...
[ "def", "read", "(", "self", ")", ":", "log", ".", "msg", "(", "'APNSService read (connecting)'", ")", "try", ":", "server", ",", "port", "=", "(", "(", "FEEDBACK_SERVER_SANDBOX_HOSTNAME", "if", "self", ".", "environment", "==", "'sandbox'", "else", "FEEDBACK_S...
Connect to the feedback service and read all data.
[ "Connect", "to", "the", "feedback", "service", "and", "read", "all", "data", "." ]
python
train
39.8
sandwichcloud/ingredients.tasks
ingredients_tasks/vmware.py
https://github.com/sandwichcloud/ingredients.tasks/blob/23d2772536f07aa5e4787b7ee67dee2f1faedb08/ingredients_tasks/vmware.py#L240-L284
def wait_for_tasks(self, tasks): """Given the service instance si and tasks, it returns after all the tasks are complete """ property_collector = self.service_instance.RetrieveContent().propertyCollector task_list = [str(task) for task in tasks] # Create filter obj_...
[ "def", "wait_for_tasks", "(", "self", ",", "tasks", ")", ":", "property_collector", "=", "self", ".", "service_instance", ".", "RetrieveContent", "(", ")", ".", "propertyCollector", "task_list", "=", "[", "str", "(", "task", ")", "for", "task", "in", "tasks"...
Given the service instance si and tasks, it returns after all the tasks are complete
[ "Given", "the", "service", "instance", "si", "and", "tasks", "it", "returns", "after", "all", "the", "tasks", "are", "complete" ]
python
train
47.777778
apache/incubator-superset
superset/views/core.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1281-L1287
def explorev2(self, datasource_type, datasource_id): """Deprecated endpoint, here for backward compatibility of urls""" return redirect(url_for( 'Superset.explore', datasource_type=datasource_type, datasource_id=datasource_id, **request.args))
[ "def", "explorev2", "(", "self", ",", "datasource_type", ",", "datasource_id", ")", ":", "return", "redirect", "(", "url_for", "(", "'Superset.explore'", ",", "datasource_type", "=", "datasource_type", ",", "datasource_id", "=", "datasource_id", ",", "*", "*", "...
Deprecated endpoint, here for backward compatibility of urls
[ "Deprecated", "endpoint", "here", "for", "backward", "compatibility", "of", "urls" ]
python
train
43
Kozea/wdb
client/wdb/__init__.py
https://github.com/Kozea/wdb/blob/6af7901b02e866d76f8b0a697a8c078e5b70d1aa/client/wdb/__init__.py#L412-L421
def stop_trace(self, frame=None): """Stop tracing from here""" self.tracing = False self.full = False frame = frame or sys._getframe().f_back while frame: del frame.f_trace frame = frame.f_back sys.settrace(None) log.info('Stopping trace')
[ "def", "stop_trace", "(", "self", ",", "frame", "=", "None", ")", ":", "self", ".", "tracing", "=", "False", "self", ".", "full", "=", "False", "frame", "=", "frame", "or", "sys", ".", "_getframe", "(", ")", ".", "f_back", "while", "frame", ":", "d...
Stop tracing from here
[ "Stop", "tracing", "from", "here" ]
python
train
31
mcieslik-mctp/papy
src/papy/core.py
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1591-L1604
def _rebuffer(self): """ (very internal) refill the repeat buffer """ results = [] exceptions = [] for i in xrange(self.stride): try: results.append(self.iterable.next()) exceptions.append(False) except Exception, ex...
[ "def", "_rebuffer", "(", "self", ")", ":", "results", "=", "[", "]", "exceptions", "=", "[", "]", "for", "i", "in", "xrange", "(", "self", ".", "stride", ")", ":", "try", ":", "results", ".", "append", "(", "self", ".", "iterable", ".", "next", "...
(very internal) refill the repeat buffer
[ "(", "very", "internal", ")", "refill", "the", "repeat", "buffer" ]
python
train
32.5
toumorokoshi/sprinter
sprinter/next/environment/injections.py
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/next/environment/injections.py#L59-L72
def commit(self): """ commit the injections desired, overwriting any previous injections in the file. """ self.logger.debug("Starting injections...") self.logger.debug("Injections dict is:") self.logger.debug(self.inject_dict) self.logger.debug("Clear list is:") self.logg...
[ "def", "commit", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Starting injections...\"", ")", "self", ".", "logger", ".", "debug", "(", "\"Injections dict is:\"", ")", "self", ".", "logger", ".", "debug", "(", "self", ".", "inject_di...
commit the injections desired, overwriting any previous injections in the file.
[ "commit", "the", "injections", "desired", "overwriting", "any", "previous", "injections", "in", "the", "file", "." ]
python
train
51.142857
postlund/pyatv
pyatv/mrp/messages.py
https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L9-L14
def create(message_type, priority=0): """Create a ProtocolMessage.""" message = protobuf.ProtocolMessage() message.type = message_type message.priority = priority return message
[ "def", "create", "(", "message_type", ",", "priority", "=", "0", ")", ":", "message", "=", "protobuf", ".", "ProtocolMessage", "(", ")", "message", ".", "type", "=", "message_type", "message", ".", "priority", "=", "priority", "return", "message" ]
Create a ProtocolMessage.
[ "Create", "a", "ProtocolMessage", "." ]
python
train
32
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L299-L310
def commitLine(self, line) : """Commits a line making it ready to be streamed to a file and saves the current buffer if needed. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") self.streamBuffer.append(l...
[ "def", "commitLine", "(", "self", ",", "line", ")", ":", "if", "self", ".", "streamBuffer", "is", "None", ":", "raise", "ValueError", "(", "\"Commit lines is only for when you are streaming to a file\"", ")", "self", ".", "streamBuffer", ".", "append", "(", "line"...
Commits a line making it ready to be streamed to a file and saves the current buffer if needed. If no stream is active, raises a ValueError
[ "Commits", "a", "line", "making", "it", "ready", "to", "be", "streamed", "to", "a", "file", "and", "saves", "the", "current", "buffer", "if", "needed", ".", "If", "no", "stream", "is", "active", "raises", "a", "ValueError" ]
python
train
48.5
edx/XBlock
xblock/runtime.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/runtime.py#L1095-L1156
def querypath(self, block, path): """An XPath-like interface to `query`.""" class BadPath(Exception): """Bad path exception thrown when path cannot be found.""" pass results = self.query(block) ROOT, SEP, WORD, FINAL = six.moves.range(4) # pylint: di...
[ "def", "querypath", "(", "self", ",", "block", ",", "path", ")", ":", "class", "BadPath", "(", "Exception", ")", ":", "\"\"\"Bad path exception thrown when path cannot be found.\"\"\"", "pass", "results", "=", "self", ".", "query", "(", "block", ")", "ROOT", ","...
An XPath-like interface to `query`.
[ "An", "XPath", "-", "like", "interface", "to", "query", "." ]
python
train
35.612903
coghost/izen
izen/helper.py
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L989-L1001
def get_domain_home_from_url(url): """ parse url for domain and homepage :param url: the req url :type url: str :return: (homepage, domain) :rtype: """ p = parse.urlparse(url) if p.netloc: return '{}://{}'.format(p.scheme, p.netloc), p.netloc else: return '', ''
[ "def", "get_domain_home_from_url", "(", "url", ")", ":", "p", "=", "parse", ".", "urlparse", "(", "url", ")", "if", "p", ".", "netloc", ":", "return", "'{}://{}'", ".", "format", "(", "p", ".", "scheme", ",", "p", ".", "netloc", ")", ",", "p", ".",...
parse url for domain and homepage :param url: the req url :type url: str :return: (homepage, domain) :rtype:
[ "parse", "url", "for", "domain", "and", "homepage" ]
python
train
23.307692
databio/pypiper
pypiper/ngstk.py
https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L384-L457
def input_to_fastq( self, input_file, sample_name, paired_end, fastq_folder, output_file=None, multiclass=False): """ Builds a command to convert input file to fastq, for various inputs. Takes either .bam, .fastq.gz, or .fastq input and returns commands that will create ...
[ "def", "input_to_fastq", "(", "self", ",", "input_file", ",", "sample_name", ",", "paired_end", ",", "fastq_folder", ",", "output_file", "=", "None", ",", "multiclass", "=", "False", ")", ":", "fastq_prefix", "=", "os", ".", "path", ".", "join", "(", "fast...
Builds a command to convert input file to fastq, for various inputs. Takes either .bam, .fastq.gz, or .fastq input and returns commands that will create the .fastq file, regardless of input type. This is useful to made your pipeline easily accept any of these input types seamlessly, sta...
[ "Builds", "a", "command", "to", "convert", "input", "file", "to", "fastq", "for", "various", "inputs", "." ]
python
train
47.351351
census-instrumentation/opencensus-python
opencensus/trace/propagation/google_cloud_format.py
https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/opencensus/trace/propagation/google_cloud_format.py#L94-L112
def to_header(self, span_context): """Convert a SpanContext object to header string. :type span_context: :class:`~opencensus.trace.span_context.SpanContext` :param span_context: SpanContext object. :rtype: str :returns: A trace context header string in google cloud ...
[ "def", "to_header", "(", "self", ",", "span_context", ")", ":", "trace_id", "=", "span_context", ".", "trace_id", "span_id", "=", "span_context", ".", "span_id", "trace_options", "=", "span_context", ".", "trace_options", ".", "trace_options_byte", "header", "=", ...
Convert a SpanContext object to header string. :type span_context: :class:`~opencensus.trace.span_context.SpanContext` :param span_context: SpanContext object. :rtype: str :returns: A trace context header string in google cloud format.
[ "Convert", "a", "SpanContext", "object", "to", "header", "string", "." ]
python
train
31.947368
tensorflow/tensor2tensor
tensor2tensor/data_generators/wiki_revision_utils.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wiki_revision_utils.py#L231-L255
def get_text(revision, strip=True): """Extract the text from a revision. Args: revision: a string strip: a boolean Returns: a string """ # text start tag looks like "<text ..otherstuff>" start_pos = revision.find("<text") assert start_pos != -1 end_tag_pos = revision.find(">", start_pos) ...
[ "def", "get_text", "(", "revision", ",", "strip", "=", "True", ")", ":", "# text start tag looks like \"<text ..otherstuff>\"", "start_pos", "=", "revision", ".", "find", "(", "\"<text\"", ")", "assert", "start_pos", "!=", "-", "1", "end_tag_pos", "=", "revision",...
Extract the text from a revision. Args: revision: a string strip: a boolean Returns: a string
[ "Extract", "the", "text", "from", "a", "revision", "." ]
python
train
22.32
diffeo/rejester
rejester/_task_master.py
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L959-L962
def get_work_spec(self, work_spec_name): '''Get the dictionary defining some work spec.''' with self.registry.lock(identifier=self.worker_id) as session: return session.get(WORK_SPECS, work_spec_name)
[ "def", "get_work_spec", "(", "self", ",", "work_spec_name", ")", ":", "with", "self", ".", "registry", ".", "lock", "(", "identifier", "=", "self", ".", "worker_id", ")", "as", "session", ":", "return", "session", ".", "get", "(", "WORK_SPECS", ",", "wor...
Get the dictionary defining some work spec.
[ "Get", "the", "dictionary", "defining", "some", "work", "spec", "." ]
python
train
56.25
bitesofcode/projexui
projexui/widgets/xcurrencyspinbox.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcurrencyspinbox.py#L37-L44
def setCurrency( self, currency ): """ Sets the currency for this widget. :param currency | <str> """ self._currency = currency self.setValue(self.value())
[ "def", "setCurrency", "(", "self", ",", "currency", ")", ":", "self", ".", "_currency", "=", "currency", "self", ".", "setValue", "(", "self", ".", "value", "(", ")", ")" ]
Sets the currency for this widget. :param currency | <str>
[ "Sets", "the", "currency", "for", "this", "widget", ".", ":", "param", "currency", "|", "<str", ">" ]
python
train
27.125
DerwenAI/pytextrank
pytextrank/pytextrank.py
https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L678-L699
def top_sentences (kernel, path): """ determine distance for each sentence """ key_sent = {} i = 0 if isinstance(path, str): path = json_iter(path) for meta in path: graf = meta["graf"] tagged_sent = [WordNode._make(x) for x in graf] text = " ".join([w.raw f...
[ "def", "top_sentences", "(", "kernel", ",", "path", ")", ":", "key_sent", "=", "{", "}", "i", "=", "0", "if", "isinstance", "(", "path", ",", "str", ")", ":", "path", "=", "json_iter", "(", "path", ")", "for", "meta", "in", "path", ":", "graf", "...
determine distance for each sentence
[ "determine", "distance", "for", "each", "sentence" ]
python
valid
29.681818
mcieslik-mctp/papy
src/papy/util/func.py
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/util/func.py#L119-L131
def sjoiner(inbox, s=None, join=""): """ String joins input with indices in s. Arguments: - s(sequence) [default: ``None``] ``tuple`` or ``list`` of indices of the elements which will be joined. - join(``str``) [default: ``""``] String which will join the elements of the inbo...
[ "def", "sjoiner", "(", "inbox", ",", "s", "=", "None", ",", "join", "=", "\"\"", ")", ":", "return", "join", ".", "join", "(", "[", "input_", "for", "i", ",", "input_", "in", "enumerate", "(", "inbox", ")", "if", "i", "in", "s", "]", ")" ]
String joins input with indices in s. Arguments: - s(sequence) [default: ``None``] ``tuple`` or ``list`` of indices of the elements which will be joined. - join(``str``) [default: ``""``] String which will join the elements of the inbox i.e. ``join.join()``.
[ "String", "joins", "input", "with", "indices", "in", "s", "." ]
python
train
31.923077
saltstack/salt
salt/modules/tomcat.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tomcat.py#L324-L358
def ls(url='http://localhost:8080/manager', timeout=180): ''' list all the deployed webapps url : http://localhost:8080/manager the URL of the server manager webapp timeout : 180 timeout for HTTP request CLI Examples: .. code-block:: bash salt '*' tomcat.ls sa...
[ "def", "ls", "(", "url", "=", "'http://localhost:8080/manager'", ",", "timeout", "=", "180", ")", ":", "ret", "=", "{", "}", "data", "=", "_wget", "(", "'list'", ",", "''", ",", "url", ",", "timeout", "=", "timeout", ")", "if", "data", "[", "'res'", ...
list all the deployed webapps url : http://localhost:8080/manager the URL of the server manager webapp timeout : 180 timeout for HTTP request CLI Examples: .. code-block:: bash salt '*' tomcat.ls salt '*' tomcat.ls http://localhost:8080/manager
[ "list", "all", "the", "deployed", "webapps" ]
python
train
23.257143
saltstack/salt
salt/modules/win_timezone.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_timezone.py#L201-L223
def get_zone(): ''' Get current timezone (i.e. America/Denver) Returns: str: Timezone in unix format Raises: CommandExecutionError: If timezone could not be gathered CLI Example: .. code-block:: bash salt '*' timezone.get_zone ''' cmd = ['tzutil', '/g'] r...
[ "def", "get_zone", "(", ")", ":", "cmd", "=", "[", "'tzutil'", ",", "'/g'", "]", "res", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "cmd", ",", "python_shell", "=", "False", ")", "if", "res", "[", "'retcode'", "]", "or", "not", "res", "[", "'s...
Get current timezone (i.e. America/Denver) Returns: str: Timezone in unix format Raises: CommandExecutionError: If timezone could not be gathered CLI Example: .. code-block:: bash salt '*' timezone.get_zone
[ "Get", "current", "timezone", "(", "i", ".", "e", ".", "America", "/", "Denver", ")" ]
python
train
27.173913
rigetti/pyquil
pyquil/api/_quantum_computer.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/api/_quantum_computer.py#L157-L190
def run_symmetrized_readout(self, program: Program, trials: int) -> np.ndarray: """ Run a quil program in such a way that the readout error is made collectively symmetric This means the probability of a bitstring ``b`` being mistaken for a bitstring ``c`` is the same as the probability ...
[ "def", "run_symmetrized_readout", "(", "self", ",", "program", ":", "Program", ",", "trials", ":", "int", ")", "->", "np", ".", "ndarray", ":", "flipped_program", "=", "_get_flipped_protoquil_program", "(", "program", ")", "if", "trials", "%", "2", "!=", "0"...
Run a quil program in such a way that the readout error is made collectively symmetric This means the probability of a bitstring ``b`` being mistaken for a bitstring ``c`` is the same as the probability of ``not(b)`` being mistaken for ``not(c)`` A more general symmetrization would guarantee t...
[ "Run", "a", "quil", "program", "in", "such", "a", "way", "that", "the", "readout", "error", "is", "made", "collectively", "symmetric" ]
python
train
55.235294
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Action.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Action.py#L886-L947
def execute(self, target, source, env, executor=None): """Execute a command action. This will handle lists of commands as well as individual commands, because construction variable substitution may turn a single "command" into a list. This means that this class can actually han...
[ "def", "execute", "(", "self", ",", "target", ",", "source", ",", "env", ",", "executor", "=", "None", ")", ":", "escape_list", "=", "SCons", ".", "Subst", ".", "escape_list", "flatten_sequence", "=", "SCons", ".", "Util", ".", "flatten_sequence", "try", ...
Execute a command action. This will handle lists of commands as well as individual commands, because construction variable substitution may turn a single "command" into a list. This means that this class can actually handle lists of commands, even though that's not how we use it ...
[ "Execute", "a", "command", "action", "." ]
python
train
42.919355
dsoprea/PySvn
svn/common.py
https://github.com/dsoprea/PySvn/blob/0c222a9a49b25d1fcfbc170ab9bc54288efe7f49/svn/common.py#L420-L441
def diff_summary(self, old, new, rel_path=None): """ Provides a summarized output of a diff between two revisions (file, change type, file type) """ full_url_or_path = self.__url_or_path if rel_path is not None: full_url_or_path += '/' + rel_path resul...
[ "def", "diff_summary", "(", "self", ",", "old", ",", "new", ",", "rel_path", "=", "None", ")", ":", "full_url_or_path", "=", "self", ".", "__url_or_path", "if", "rel_path", "is", "not", "None", ":", "full_url_or_path", "+=", "'/'", "+", "rel_path", "result...
Provides a summarized output of a diff between two revisions (file, change type, file type)
[ "Provides", "a", "summarized", "output", "of", "a", "diff", "between", "two", "revisions", "(", "file", "change", "type", "file", "type", ")" ]
python
train
38.136364
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L133-L157
def energy_upperbound(self, spins): """A formula for an upper bound on the energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. Returns: Formula that upper bounds the energy with spins fixed. """ subt...
[ "def", "energy_upperbound", "(", "self", ",", "spins", ")", ":", "subtheta", "=", "self", ".", "theta", ".", "copy", "(", ")", "subtheta", ".", "fix_variables", "(", "spins", ")", "# ok, let's start eliminating variables", "trees", "=", "self", ".", "_trees", ...
A formula for an upper bound on the energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. Returns: Formula that upper bounds the energy with spins fixed.
[ "A", "formula", "for", "an", "upper", "bound", "on", "the", "energy", "of", "Theta", "with", "spins", "fixed", "." ]
python
train
32.36