repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
ethan92429/onshapepy
onshapepy/part.py
Configuration.params
def params(self): """Get the params of response data from the API. Returns: - d (dict): Dictionary mapping of all configuration values """ payload = self.payload d = {} for i, p in enumerate(payload["currentConfiguration"]): type_name = p["typeNam...
python
def params(self): """Get the params of response data from the API. Returns: - d (dict): Dictionary mapping of all configuration values """ payload = self.payload d = {} for i, p in enumerate(payload["currentConfiguration"]): type_name = p["typeNam...
[ "def", "params", "(", "self", ")", ":", "payload", "=", "self", ".", "payload", "d", "=", "{", "}", "for", "i", ",", "p", "in", "enumerate", "(", "payload", "[", "\"currentConfiguration\"", "]", ")", ":", "type_name", "=", "p", "[", "\"typeName\"", "...
Get the params of response data from the API. Returns: - d (dict): Dictionary mapping of all configuration values
[ "Get", "the", "params", "of", "response", "data", "from", "the", "API", "." ]
61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df
https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/part.py#L103-L127
train
Get the params of response data from the API.
ethan92429/onshapepy
onshapepy/part.py
Measurements.update
def update(self): """ Update all local variable names to match OnShape. """ uri = self.parent.uri script = r""" function(context, queries) { return getVariable(context, "measurements"); } """ self.res = c.evaluate_featurescript(uri.as_dict(), script)
python
def update(self): """ Update all local variable names to match OnShape. """ uri = self.parent.uri script = r""" function(context, queries) { return getVariable(context, "measurements"); } """ self.res = c.evaluate_featurescript(uri.as_dict(), script)
[ "def", "update", "(", "self", ")", ":", "uri", "=", "self", ".", "parent", ".", "uri", "script", "=", "r\"\"\"\n function(context, queries) {\n return getVariable(context, \"measurements\");\n }\n \"\"\"", "self", ".", "res", "=", "c", ".", ...
Update all local variable names to match OnShape.
[ "Update", "all", "local", "variable", "names", "to", "match", "OnShape", "." ]
61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df
https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/part.py#L146-L155
train
Update all local variable names to match OnShape.
berkeley-cocosci/Wallace
examples/function-learning/experiment.py
FunctionLearning.setup
def setup(self): """Setup does stuff only if there are no networks. This is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in wallace). Then it adds a source to each network. """ if not self.networks...
python
def setup(self): """Setup does stuff only if there are no networks. This is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in wallace). Then it adds a source to each network. """ if not self.networks...
[ "def", "setup", "(", "self", ")", ":", "if", "not", "self", ".", "networks", "(", ")", ":", "super", "(", "FunctionLearning", ",", "self", ")", ".", "setup", "(", ")", "for", "net", "in", "self", ".", "networks", "(", ")", ":", "self", ".", "sour...
Setup does stuff only if there are no networks. This is so it only runs once at the start of the experiment. It first calls the same function in the super (see experiments.py in wallace). Then it adds a source to each network.
[ "Setup", "does", "stuff", "only", "if", "there", "are", "no", "networks", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/function-learning/experiment.py#L25-L35
train
This is a method that is called by the experiment once at the start of the experiment. It does stuff only if there are no networks.
Kortemme-Lab/klab
klab/retrospect.py
ExpectedScripts.SymmetricDifference
def SymmetricDifference(self, scriptnames): '''Takes in a set, list, or tuple scriptnames and returns the symmetric difference (as a list) of scriptnames and the stored names.''' scriptnames = set(scriptnames) myscripts = set(self.scripts.keys()) return list(scriptnames.difference(myscripts).union(myscripts.d...
python
def SymmetricDifference(self, scriptnames): '''Takes in a set, list, or tuple scriptnames and returns the symmetric difference (as a list) of scriptnames and the stored names.''' scriptnames = set(scriptnames) myscripts = set(self.scripts.keys()) return list(scriptnames.difference(myscripts).union(myscripts.d...
[ "def", "SymmetricDifference", "(", "self", ",", "scriptnames", ")", ":", "scriptnames", "=", "set", "(", "scriptnames", ")", "myscripts", "=", "set", "(", "self", ".", "scripts", ".", "keys", "(", ")", ")", "return", "list", "(", "scriptnames", ".", "dif...
Takes in a set, list, or tuple scriptnames and returns the symmetric difference (as a list) of scriptnames and the stored names.
[ "Takes", "in", "a", "set", "list", "or", "tuple", "scriptnames", "and", "returns", "the", "symmetric", "difference", "(", "as", "a", "list", ")", "of", "scriptnames", "and", "the", "stored", "names", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/retrospect.py#L69-L74
train
Takes in a set list or tuple scriptnames and returns the symmetric difference of scriptnames and the stored names.
Kortemme-Lab/klab
klab/retrospect.py
LogReader.getFailedJobIDs
def getFailedJobIDs(self, extraLapse = TYPICAL_LAPSE): '''Returns a list of which identify failed jobs in the scriptsRun table. If a time stamp for a job can be found, we return this. The time stamp can be used to index the log. If no time stamp was found, return the name of the script instead. ''' scripts...
python
def getFailedJobIDs(self, extraLapse = TYPICAL_LAPSE): '''Returns a list of which identify failed jobs in the scriptsRun table. If a time stamp for a job can be found, we return this. The time stamp can be used to index the log. If no time stamp was found, return the name of the script instead. ''' scripts...
[ "def", "getFailedJobIDs", "(", "self", ",", "extraLapse", "=", "TYPICAL_LAPSE", ")", ":", "scriptsRun", "=", "self", ".", "scriptsRun", "failedJobTimestamps", "=", "[", "]", "nodata", "=", "[", "]", "for", "name", ",", "details", "in", "sorted", "(", "scri...
Returns a list of which identify failed jobs in the scriptsRun table. If a time stamp for a job can be found, we return this. The time stamp can be used to index the log. If no time stamp was found, return the name of the script instead.
[ "Returns", "a", "list", "of", "which", "identify", "failed", "jobs", "in", "the", "scriptsRun", "table", ".", "If", "a", "time", "stamp", "for", "a", "job", "can", "be", "found", "we", "return", "this", ".", "The", "time", "stamp", "can", "be", "used",...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/retrospect.py#L302-L331
train
Returns a list of which identify failed jobs in the scriptsRun table.
Kortemme-Lab/klab
klab/retrospect.py
LogReader.generateSummary
def generateSummary(self, extraLapse = TYPICAL_LAPSE): '''Generates a summary of the status of the expected scripts broken based on the log. This summary (a list of strings) is returned as well as a list with the dates (which can be used to index the log)of the most recent attempts at the failed jobs. ''' ...
python
def generateSummary(self, extraLapse = TYPICAL_LAPSE): '''Generates a summary of the status of the expected scripts broken based on the log. This summary (a list of strings) is returned as well as a list with the dates (which can be used to index the log)of the most recent attempts at the failed jobs. ''' ...
[ "def", "generateSummary", "(", "self", ",", "extraLapse", "=", "TYPICAL_LAPSE", ")", ":", "scriptsRun", "=", "self", ".", "scriptsRun", "body", "=", "[", "]", "numberOfFailed", "=", "0", "numberWithWarnings", "=", "0", "failedList", "=", "[", "]", "successLi...
Generates a summary of the status of the expected scripts broken based on the log. This summary (a list of strings) is returned as well as a list with the dates (which can be used to index the log)of the most recent attempts at the failed jobs.
[ "Generates", "a", "summary", "of", "the", "status", "of", "the", "expected", "scripts", "broken", "based", "on", "the", "log", ".", "This", "summary", "(", "a", "list", "of", "strings", ")", "is", "returned", "as", "well", "as", "a", "list", "with", "t...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/retrospect.py#L333-L405
train
Generates a summary of the status of the expected scripts broken based on the log.
Kortemme-Lab/klab
klab/retrospect.py
LogReader.generateSummaryHTMLTable
def generateSummaryHTMLTable(self, extraLapse = TYPICAL_LAPSE): '''Generates a summary in HTML of the status of the expected scripts broken based on the log. This summary is returned as a list of strings. ''' scriptsRun = self.scriptsRun html = [] html.append("<table style='text-align:center;border:1px...
python
def generateSummaryHTMLTable(self, extraLapse = TYPICAL_LAPSE): '''Generates a summary in HTML of the status of the expected scripts broken based on the log. This summary is returned as a list of strings. ''' scriptsRun = self.scriptsRun html = [] html.append("<table style='text-align:center;border:1px...
[ "def", "generateSummaryHTMLTable", "(", "self", ",", "extraLapse", "=", "TYPICAL_LAPSE", ")", ":", "scriptsRun", "=", "self", ".", "scriptsRun", "html", "=", "[", "]", "html", ".", "append", "(", "\"<table style='text-align:center;border:1px solid black;margin-left: aut...
Generates a summary in HTML of the status of the expected scripts broken based on the log. This summary is returned as a list of strings.
[ "Generates", "a", "summary", "in", "HTML", "of", "the", "status", "of", "the", "expected", "scripts", "broken", "based", "on", "the", "log", ".", "This", "summary", "is", "returned", "as", "a", "list", "of", "strings", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/retrospect.py#L411-L482
train
Generates a summary HTML table of the expected scripts broken based on the log.
mardix/Mocha
mocha/ext.py
send_mail
def send_mail(template, to, **kwargs): """ Alias to mail.send(), but makes template required ie: send_mail("welcome-to-the-site.txt", "user@email.com") :param template: :param to: :param kwargs: :return: """ def cb(): return mail.send(to=to, template=template, **kwargs) ...
python
def send_mail(template, to, **kwargs): """ Alias to mail.send(), but makes template required ie: send_mail("welcome-to-the-site.txt", "user@email.com") :param template: :param to: :param kwargs: :return: """ def cb(): return mail.send(to=to, template=template, **kwargs) ...
[ "def", "send_mail", "(", "template", ",", "to", ",", "*", "*", "kwargs", ")", ":", "def", "cb", "(", ")", ":", "return", "mail", ".", "send", "(", "to", "=", "to", ",", "template", "=", "template", ",", "*", "*", "kwargs", ")", "return", "signals...
Alias to mail.send(), but makes template required ie: send_mail("welcome-to-the-site.txt", "user@email.com") :param template: :param to: :param kwargs: :return:
[ "Alias", "to", "mail", ".", "send", "()", "but", "makes", "template", "required", "ie", ":", "send_mail", "(", "welcome", "-", "to", "-", "the", "-", "site", ".", "txt", "user" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/ext.py#L244-L257
train
Send a mail to a specific recipient.
mardix/Mocha
mocha/ext.py
set_cors_config
def set_cors_config(app): """ Flask-Cors (3.x.x) extension set the config as CORS_*, But we'll hold the config in CORS key. This function will convert them to CORS_* values :param app: :return: """ if "CORS" in app.config: for k, v in app.config["CORS"].items(): _ =...
python
def set_cors_config(app): """ Flask-Cors (3.x.x) extension set the config as CORS_*, But we'll hold the config in CORS key. This function will convert them to CORS_* values :param app: :return: """ if "CORS" in app.config: for k, v in app.config["CORS"].items(): _ =...
[ "def", "set_cors_config", "(", "app", ")", ":", "if", "\"CORS\"", "in", "app", ".", "config", ":", "for", "k", ",", "v", "in", "app", ".", "config", "[", "\"CORS\"", "]", ".", "items", "(", ")", ":", "_", "=", "\"CORS_\"", "+", "k", ".", "upper",...
Flask-Cors (3.x.x) extension set the config as CORS_*, But we'll hold the config in CORS key. This function will convert them to CORS_* values :param app: :return:
[ "Flask", "-", "Cors", "(", "3", ".", "x", ".", "x", ")", "extension", "set", "the", "config", "as", "CORS_", "*", "But", "we", "ll", "hold", "the", "config", "in", "CORS", "key", ".", "This", "function", "will", "convert", "them", "to", "CORS_", "*...
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/ext.py#L294-L306
train
This function will set the config as CORS_* and the value of the application s config as CORS_*.
mardix/Mocha
mocha/ext.py
upload_file
def upload_file(_props_key, file, **kw): """ Wrapper around storage.upload to upload a file conveniently by using set properties, so no need to keep rewriting the same code. config file must have STORAGE_UPLOAD_FILE_PROPS where it contains k/v, ie: STORAGE_UPLOAD_FILE_PROPS = { "profile-im...
python
def upload_file(_props_key, file, **kw): """ Wrapper around storage.upload to upload a file conveniently by using set properties, so no need to keep rewriting the same code. config file must have STORAGE_UPLOAD_FILE_PROPS where it contains k/v, ie: STORAGE_UPLOAD_FILE_PROPS = { "profile-im...
[ "def", "upload_file", "(", "_props_key", ",", "file", ",", "*", "*", "kw", ")", ":", "kwargs", "=", "{", "}", "if", "_props_key", "is", "not", "None", ":", "conf", "=", "config", "(", "\"STORAGE_UPLOAD_FILE_PROPS\"", ")", "if", "not", "conf", ":", "rai...
Wrapper around storage.upload to upload a file conveniently by using set properties, so no need to keep rewriting the same code. config file must have STORAGE_UPLOAD_FILE_PROPS where it contains k/v, ie: STORAGE_UPLOAD_FILE_PROPS = { "profile-image": { "extensions": ["jpg", "jpeg", "gi...
[ "Wrapper", "around", "storage", ".", "upload", "to", "upload", "a", "file", "conveniently", "by", "using", "set", "properties", "so", "no", "need", "to", "keep", "rewriting", "the", "same", "code", ".", "config", "file", "must", "have", "STORAGE_UPLOAD_FILE_PR...
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/ext.py#L357-L388
train
Wrapper around storage. upload to upload a file conveniently by using set properties.
mardix/Mocha
mocha/ext.py
delete_file
def delete_file(fileobj): """ Alias to delete a file from storage :param fileobj: :return: """ if not isinstance(fileobj, (flask_cloudy.Object, mocha_db.StorageObject)): raise TypeError("Invalid file type. Must be of flask_cloudy.Object") return signals.delete_file(lambda: fileobj....
python
def delete_file(fileobj): """ Alias to delete a file from storage :param fileobj: :return: """ if not isinstance(fileobj, (flask_cloudy.Object, mocha_db.StorageObject)): raise TypeError("Invalid file type. Must be of flask_cloudy.Object") return signals.delete_file(lambda: fileobj....
[ "def", "delete_file", "(", "fileobj", ")", ":", "if", "not", "isinstance", "(", "fileobj", ",", "(", "flask_cloudy", ".", "Object", ",", "mocha_db", ".", "StorageObject", ")", ")", ":", "raise", "TypeError", "(", "\"Invalid file type. Must be of flask_cloudy.Objec...
Alias to delete a file from storage :param fileobj: :return:
[ "Alias", "to", "delete", "a", "file", "from", "storage", ":", "param", "fileobj", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/ext.py#L400-L408
train
Alias to delete a file from storage
mardix/Mocha
mocha/ext.py
download_file
def download_file(filename, object_name=None, content=None, as_attachment=True, timeout=60): """ Alias to download a file object as attachment, or convert some text as . :param filename: the filename with extension. If the file to download is an StorageOject, filename doesn't need to have an extens...
python
def download_file(filename, object_name=None, content=None, as_attachment=True, timeout=60): """ Alias to download a file object as attachment, or convert some text as . :param filename: the filename with extension. If the file to download is an StorageOject, filename doesn't need to have an extens...
[ "def", "download_file", "(", "filename", ",", "object_name", "=", "None", ",", "content", "=", "None", ",", "as_attachment", "=", "True", ",", "timeout", "=", "60", ")", ":", "if", "object_name", ":", "file", "=", "get_file", "(", "object_name", ")", "if...
Alias to download a file object as attachment, or convert some text as . :param filename: the filename with extension. If the file to download is an StorageOject, filename doesn't need to have an extension. It will automatically put it If the file to download is a `content` text, exten...
[ "Alias", "to", "download", "a", "file", "object", "as", "attachment", "or", "convert", "some", "text", "as", ".", ":", "param", "filename", ":", "the", "filename", "with", "extension", ".", "If", "the", "file", "to", "download", "is", "an", "StorageOject",...
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/ext.py#L411-L436
train
Download a file from the Cloud object.
mardix/Mocha
mocha/ext.py
paginate
def paginate(iter, **kwargs): """ A wrapper around the Paginator that takes config data :param iter: Query object or any iterables :param kwargs: - page: current page - per_page: max number of items per page - total: Max number of items. If not provided, it will use the query to...
python
def paginate(iter, **kwargs): """ A wrapper around the Paginator that takes config data :param iter: Query object or any iterables :param kwargs: - page: current page - per_page: max number of items per page - total: Max number of items. If not provided, it will use the query to...
[ "def", "paginate", "(", "iter", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"page\"", ",", "int", "(", "request", ".", "args", ".", "get", "(", "'page'", ",", "1", ")", ")", ")", "kwargs", ".", "setdefault", "(", "\"per_p...
A wrapper around the Paginator that takes config data :param iter: Query object or any iterables :param kwargs: - page: current page - per_page: max number of items per page - total: Max number of items. If not provided, it will use the query to count - padding: Number of element...
[ "A", "wrapper", "around", "the", "Paginator", "that", "takes", "config", "data", ":", "param", "iter", ":", "Query", "object", "or", "any", "iterables", ":", "param", "kwargs", ":", "-", "page", ":", "current", "page", "-", "per_page", ":", "max", "numbe...
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/ext.py#L448-L464
train
A wrapper around the Paginator that takes config data and returns a Paginator object with the pagination options set to the default values.
TheGhouls/oct
oct/tools/results_to_csv.py
to_csv
def to_csv(args): """Take a sqlite filled database of results and return a csv file :param str result_file: the path of the sqlite database :param str output_file: the path of the csv output file :param str delimiter: the desired delimiter for the output csv file """ result_file = args.result_f...
python
def to_csv(args): """Take a sqlite filled database of results and return a csv file :param str result_file: the path of the sqlite database :param str output_file: the path of the csv output file :param str delimiter: the desired delimiter for the output csv file """ result_file = args.result_f...
[ "def", "to_csv", "(", "args", ")", ":", "result_file", "=", "args", ".", "result_file", "output_file", "=", "args", ".", "output_file", "delimiter", "=", "args", ".", "delimiter", "if", "not", "os", ".", "path", ".", "isfile", "(", "result_file", ")", ":...
Take a sqlite filled database of results and return a csv file :param str result_file: the path of the sqlite database :param str output_file: the path of the csv output file :param str delimiter: the desired delimiter for the output csv file
[ "Take", "a", "sqlite", "filled", "database", "of", "results", "and", "return", "a", "csv", "file" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/tools/results_to_csv.py#L8-L49
train
Take a sqlite filled database of results and return a csv file
Kortemme-Lab/klab
klab/stats/misc.py
fraction_correct_values
def fraction_correct_values(indices, x_values, y_values, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): ''' An approximation to the metric used in the Kellogg et al. paper: "The fraction correct is defined as the number of mutations categorized correctly divided by the total number of mutations in...
python
def fraction_correct_values(indices, x_values, y_values, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): ''' An approximation to the metric used in the Kellogg et al. paper: "The fraction correct is defined as the number of mutations categorized correctly divided by the total number of mutations in...
[ "def", "fraction_correct_values", "(", "indices", ",", "x_values", ",", "y_values", ",", "x_cutoff", "=", "1.0", ",", "y_cutoff", "=", "1.0", ",", "ignore_null_values", "=", "False", ")", ":", "num_points", "=", "len", "(", "indices", ")", "assert", "(", "...
An approximation to the metric used in the Kellogg et al. paper: "The fraction correct is defined as the number of mutations categorized correctly divided by the total number of mutations in the benchmark set."
[ "An", "approximation", "to", "the", "metric", "used", "in", "the", "Kellogg", "et", "al", ".", "paper", ":", "The", "fraction", "correct", "is", "defined", "as", "the", "number", "of", "mutations", "categorized", "correctly", "divided", "by", "the", "total",...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L48-L69
train
The fraction correct is defined as the number of mutations categorized correctly divided by the total number of mutations in the benchmark set.
Kortemme-Lab/klab
klab/stats/misc.py
fraction_correct
def fraction_correct(x_values, y_values, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): '''My version of the metric used in the Kellogg et al. paper. "Role of conformational sampling in computing mutation-induced changes in protein structure and stability", Proteins, Volume 79, Issue 3, pages 8...
python
def fraction_correct(x_values, y_values, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): '''My version of the metric used in the Kellogg et al. paper. "Role of conformational sampling in computing mutation-induced changes in protein structure and stability", Proteins, Volume 79, Issue 3, pages 8...
[ "def", "fraction_correct", "(", "x_values", ",", "y_values", ",", "x_cutoff", "=", "1.0", ",", "y_cutoff", "=", "1.0", ",", "ignore_null_values", "=", "False", ")", ":", "expected_types", ",", "xtypes", ",", "ytypes", "=", "set", "(", "[", "type", "(", "...
My version of the metric used in the Kellogg et al. paper. "Role of conformational sampling in computing mutation-induced changes in protein structure and stability", Proteins, Volume 79, Issue 3, pages 830–838, March 2011. http://dx.doi.org/10.1002/prot.22921 Description: "The fraction correct is ...
[ "My", "version", "of", "the", "metric", "used", "in", "the", "Kellogg", "et", "al", ".", "paper", ".", "Role", "of", "conformational", "sampling", "in", "computing", "mutation", "-", "induced", "changes", "in", "protein", "structure", "and", "stability", "Pr...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L72-L97
train
This function calculates the fraction of mutations in a single file.
Kortemme-Lab/klab
klab/stats/misc.py
fraction_correct_pandas
def fraction_correct_pandas(dataframe, x_series, y_series, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): '''A little (<6%) slower than fraction_correct due to the data extraction overhead.''' return fraction_correct(dataframe[x_series].values.tolist(), dataframe[y_series].values.tolist(), x_cutof...
python
def fraction_correct_pandas(dataframe, x_series, y_series, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): '''A little (<6%) slower than fraction_correct due to the data extraction overhead.''' return fraction_correct(dataframe[x_series].values.tolist(), dataframe[y_series].values.tolist(), x_cutof...
[ "def", "fraction_correct_pandas", "(", "dataframe", ",", "x_series", ",", "y_series", ",", "x_cutoff", "=", "1.0", ",", "y_cutoff", "=", "1.0", ",", "ignore_null_values", "=", "False", ")", ":", "return", "fraction_correct", "(", "dataframe", "[", "x_series", ...
A little (<6%) slower than fraction_correct due to the data extraction overhead.
[ "A", "little", "(", "<6%", ")", "slower", "than", "fraction_correct", "due", "to", "the", "data", "extraction", "overhead", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L100-L102
train
A little faster than fraction_correct due to the data extraction overhead.
Kortemme-Lab/klab
klab/stats/misc.py
add_fraction_correct_values_to_dataframe
def add_fraction_correct_values_to_dataframe(dataframe, x_series, y_series, new_label, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): '''Adds a new column (new_label) to the dataframe with the fraction correct computed over X and Y values.''' new_series_values = fraction_correct_values(dataframe.i...
python
def add_fraction_correct_values_to_dataframe(dataframe, x_series, y_series, new_label, x_cutoff = 1.0, y_cutoff = 1.0, ignore_null_values = False): '''Adds a new column (new_label) to the dataframe with the fraction correct computed over X and Y values.''' new_series_values = fraction_correct_values(dataframe.i...
[ "def", "add_fraction_correct_values_to_dataframe", "(", "dataframe", ",", "x_series", ",", "y_series", ",", "new_label", ",", "x_cutoff", "=", "1.0", ",", "y_cutoff", "=", "1.0", ",", "ignore_null_values", "=", "False", ")", ":", "new_series_values", "=", "fractio...
Adds a new column (new_label) to the dataframe with the fraction correct computed over X and Y values.
[ "Adds", "a", "new", "column", "(", "new_label", ")", "to", "the", "dataframe", "with", "the", "fraction", "correct", "computed", "over", "X", "and", "Y", "values", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L105-L110
train
Adds a new column to the dataframe with the fraction correct computed over X and Y values.
Kortemme-Lab/klab
klab/stats/misc.py
fraction_correct_fuzzy_linear_create_vector
def fraction_correct_fuzzy_linear_create_vector(z, z_cutoff, z_fuzzy_range): '''A helper function for fraction_correct_fuzzy_linear.''' assert(z_fuzzy_range * 2 < z_cutoff) if (z == None or numpy.isnan(z)): # todo: and ignore_null_values: # If we are missing values then we either discount the case or consi...
python
def fraction_correct_fuzzy_linear_create_vector(z, z_cutoff, z_fuzzy_range): '''A helper function for fraction_correct_fuzzy_linear.''' assert(z_fuzzy_range * 2 < z_cutoff) if (z == None or numpy.isnan(z)): # todo: and ignore_null_values: # If we are missing values then we either discount the case or consi...
[ "def", "fraction_correct_fuzzy_linear_create_vector", "(", "z", ",", "z_cutoff", ",", "z_fuzzy_range", ")", ":", "assert", "(", "z_fuzzy_range", "*", "2", "<", "z_cutoff", ")", "if", "(", "z", "==", "None", "or", "numpy", ".", "isnan", "(", "z", ")", ")", ...
A helper function for fraction_correct_fuzzy_linear.
[ "A", "helper", "function", "for", "fraction_correct_fuzzy_linear", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L113-L135
train
A helper function for fraction_correct_fuzzy_linear.
Kortemme-Lab/klab
klab/stats/misc.py
fraction_correct_fuzzy_linear
def fraction_correct_fuzzy_linear(x_values, y_values, x_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, y_cutoff = None): '''A version of fraction_correct which is more forgiving at the boundary positions. In fraction_correct, if the x value is 1.01 and the y value is 0.99 (with cutoffs of 1.0) then that ...
python
def fraction_correct_fuzzy_linear(x_values, y_values, x_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, y_cutoff = None): '''A version of fraction_correct which is more forgiving at the boundary positions. In fraction_correct, if the x value is 1.01 and the y value is 0.99 (with cutoffs of 1.0) then that ...
[ "def", "fraction_correct_fuzzy_linear", "(", "x_values", ",", "y_values", ",", "x_cutoff", "=", "1.0", ",", "x_fuzzy_range", "=", "0.1", ",", "y_scalar", "=", "1.0", ",", "y_cutoff", "=", "None", ")", ":", "num_points", "=", "len", "(", "x_values", ")", "a...
A version of fraction_correct which is more forgiving at the boundary positions. In fraction_correct, if the x value is 1.01 and the y value is 0.99 (with cutoffs of 1.0) then that pair evaluates to zero despite the results being very close to each other. This function corrects for the boundary by ...
[ "A", "version", "of", "fraction_correct", "which", "is", "more", "forgiving", "at", "the", "boundary", "positions", ".", "In", "fraction_correct", "if", "the", "x", "value", "is", "1", ".", "01", "and", "the", "y", "value", "is", "0", ".", "99", "(", "...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L138-L167
train
A version of fraction_correct which is more forgiving at the boundary positions.
Kortemme-Lab/klab
klab/stats/misc.py
mae
def mae(x_values, y_values, drop_missing = True): '''Mean absolute/unsigned error.''' num_points = len(x_values) assert(num_points == len(y_values) and num_points > 0) return numpy.sum(numpy.apply_along_axis(numpy.abs, 0, numpy.subtract(x_values, y_values))) / float(num_points)
python
def mae(x_values, y_values, drop_missing = True): '''Mean absolute/unsigned error.''' num_points = len(x_values) assert(num_points == len(y_values) and num_points > 0) return numpy.sum(numpy.apply_along_axis(numpy.abs, 0, numpy.subtract(x_values, y_values))) / float(num_points)
[ "def", "mae", "(", "x_values", ",", "y_values", ",", "drop_missing", "=", "True", ")", ":", "num_points", "=", "len", "(", "x_values", ")", "assert", "(", "num_points", "==", "len", "(", "y_values", ")", "and", "num_points", ">", "0", ")", "return", "n...
Mean absolute/unsigned error.
[ "Mean", "absolute", "/", "unsigned", "error", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L170-L174
train
Mean absolute / unsigned error.
Kortemme-Lab/klab
klab/stats/misc.py
error_unzip_helper
def error_unzip_helper(values, func, func_kwargs): '''Splits [(x1, y1), (x2, y2), ...] and gives to func''' x_values = [x for x, y in values] y_values = [y for x, y in values] result = func(x_values, y_values, **func_kwargs) if isinstance(result, float): return result else: retur...
python
def error_unzip_helper(values, func, func_kwargs): '''Splits [(x1, y1), (x2, y2), ...] and gives to func''' x_values = [x for x, y in values] y_values = [y for x, y in values] result = func(x_values, y_values, **func_kwargs) if isinstance(result, float): return result else: retur...
[ "def", "error_unzip_helper", "(", "values", ",", "func", ",", "func_kwargs", ")", ":", "x_values", "=", "[", "x", "for", "x", ",", "y", "in", "values", "]", "y_values", "=", "[", "y", "for", "x", ",", "y", "in", "values", "]", "result", "=", "func"...
Splits [(x1, y1), (x2, y2), ...] and gives to func
[ "Splits", "[", "(", "x1", "y1", ")", "(", "x2", "y2", ")", "...", "]", "and", "gives", "to", "func" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L187-L195
train
Unzips a list of values and returns the first value of the function func.
Kortemme-Lab/klab
klab/stats/misc.py
_get_xy_dataset_statistics
def _get_xy_dataset_statistics(x_values, y_values, fcorrect_x_cutoff = 1.0, fcorrect_y_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, ignore_null_values = False, bootstrap_data = False, expect_negative_correlation = False, ...
python
def _get_xy_dataset_statistics(x_values, y_values, fcorrect_x_cutoff = 1.0, fcorrect_y_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, ignore_null_values = False, bootstrap_data = False, expect_negative_correlation = False, ...
[ "def", "_get_xy_dataset_statistics", "(", "x_values", ",", "y_values", ",", "fcorrect_x_cutoff", "=", "1.0", ",", "fcorrect_y_cutoff", "=", "1.0", ",", "x_fuzzy_range", "=", "0.1", ",", "y_scalar", "=", "1.0", ",", "ignore_null_values", "=", "False", ",", "boots...
A function which takes two lists of values of equal length with corresponding entries and returns a dict containing a variety of metrics. :param x_values: A list of values for the X-axis (experimental values). :param y_values: A list of values for the X-axis (predicted values). :param fcorrect_x_cutoff:...
[ "A", "function", "which", "takes", "two", "lists", "of", "values", "of", "equal", "length", "with", "corresponding", "entries", "and", "returns", "a", "dict", "containing", "a", "variety", "of", "metrics", ".", ":", "param", "x_values", ":", "A", "list", "...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L215-L293
train
A function which takes two lists of values of equal length with corresponding entries and returns a dict containing the statistics of the X - axis.
Kortemme-Lab/klab
klab/stats/misc.py
get_xy_dataset_statistics
def get_xy_dataset_statistics(analysis_table, fcorrect_x_cutoff = 1.0, fcorrect_y_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, ignore_null_values = False, bootstrap_data = False, expect_negative_correlation = False, STDev_cutoff = 1.0, ...
python
def get_xy_dataset_statistics(analysis_table, fcorrect_x_cutoff = 1.0, fcorrect_y_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, ignore_null_values = False, bootstrap_data = False, expect_negative_correlation = False, STDev_cutoff = 1.0, ...
[ "def", "get_xy_dataset_statistics", "(", "analysis_table", ",", "fcorrect_x_cutoff", "=", "1.0", ",", "fcorrect_y_cutoff", "=", "1.0", ",", "x_fuzzy_range", "=", "0.1", ",", "y_scalar", "=", "1.0", ",", "ignore_null_values", "=", "False", ",", "bootstrap_data", "=...
A version of _get_xy_dataset_statistics which accepts a list of dicts rather than X- and Y-value lists. :param analysis_table: A list of dict where each dict has Experimental and Predicted float elements :param fcorrect_x_cutoff: The X-axis cutoff value for the fraction correct metric. :param fcorrect_y_cut...
[ "A", "version", "of", "_get_xy_dataset_statistics", "which", "accepts", "a", "list", "of", "dicts", "rather", "than", "X", "-", "and", "Y", "-", "value", "lists", ".", ":", "param", "analysis_table", ":", "A", "list", "of", "dict", "where", "each", "dict",...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L296-L319
train
This function is a wrapper for _get_xy_dataset_statistics which takes a list of dicts rather than X - and Y - values lists and returns a table of statistics.
Kortemme-Lab/klab
klab/stats/misc.py
get_xy_dataset_statistics_pandas
def get_xy_dataset_statistics_pandas(dataframe, x_series, y_series, fcorrect_x_cutoff = 1.0, fcorrect_y_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, ignore_null_values = False, bootstrap_data = False, expect_negative_correlation = False, STDe...
python
def get_xy_dataset_statistics_pandas(dataframe, x_series, y_series, fcorrect_x_cutoff = 1.0, fcorrect_y_cutoff = 1.0, x_fuzzy_range = 0.1, y_scalar = 1.0, ignore_null_values = False, bootstrap_data = False, expect_negative_correlation = False, STDe...
[ "def", "get_xy_dataset_statistics_pandas", "(", "dataframe", ",", "x_series", ",", "y_series", ",", "fcorrect_x_cutoff", "=", "1.0", ",", "fcorrect_y_cutoff", "=", "1.0", ",", "x_fuzzy_range", "=", "0.1", ",", "y_scalar", "=", "1.0", ",", "ignore_null_values", "="...
A version of _get_xy_dataset_statistics which accepts a pandas dataframe rather than X- and Y-value lists. :param dataframe: A pandas dataframe :param x_series: The column name of the X-axis series :param y_series: The column name of the Y-axis series :param fcorrect_x_cutoff: The X-axis cutoff value fo...
[ "A", "version", "of", "_get_xy_dataset_statistics", "which", "accepts", "a", "pandas", "dataframe", "rather", "than", "X", "-", "and", "Y", "-", "value", "lists", ".", ":", "param", "dataframe", ":", "A", "pandas", "dataframe", ":", "param", "x_series", ":",...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/stats/misc.py#L325-L351
train
A version of _get_xy_dataset_statistics which accepts a pandas dataframe rather than X - and Y - values lists.
Kortemme-Lab/klab
klab/cloning/gen9.py
apply_quality_control_checks
def apply_quality_control_checks( seq, check_gen9_seqs=True, check_short_length=True, check_local_gc_content=True, check_global_gc_content=True): """ Raise a ValueError if the given sequence doesn't pass all of the Gen9 quality control design guidelines. Certain che...
python
def apply_quality_control_checks( seq, check_gen9_seqs=True, check_short_length=True, check_local_gc_content=True, check_global_gc_content=True): """ Raise a ValueError if the given sequence doesn't pass all of the Gen9 quality control design guidelines. Certain che...
[ "def", "apply_quality_control_checks", "(", "seq", ",", "check_gen9_seqs", "=", "True", ",", "check_short_length", "=", "True", ",", "check_local_gc_content", "=", "True", ",", "check_global_gc_content", "=", "True", ")", ":", "seq", "=", "seq", ".", "upper", "(...
Raise a ValueError if the given sequence doesn't pass all of the Gen9 quality control design guidelines. Certain checks can be enabled or disabled via the command line.
[ "Raise", "a", "ValueError", "if", "the", "given", "sequence", "doesn", "t", "pass", "all", "of", "the", "Gen9", "quality", "control", "design", "guidelines", ".", "Certain", "checks", "can", "be", "enabled", "or", "disabled", "via", "the", "command", "line",...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cloning/gen9.py#L17-L90
train
Apply quality control checks to the given sequence.
adaptive-learning/proso-apps
proso/dict.py
group_keys_by_values
def group_keys_by_values(d): """ Take a dict (A -> B( and return another one (B -> [A]). It groups keys from the original dict by their values. .. testsetup:: from proso.dict import group_keys_by_values from pprint import pprint .. doctest:: >>> pprint(group_keys_by_value...
python
def group_keys_by_values(d): """ Take a dict (A -> B( and return another one (B -> [A]). It groups keys from the original dict by their values. .. testsetup:: from proso.dict import group_keys_by_values from pprint import pprint .. doctest:: >>> pprint(group_keys_by_value...
[ "def", "group_keys_by_values", "(", "d", ")", ":", "result", "=", "{", "}", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "saved", "=", "result", ".", "get", "(", "v", ",", "[", "]", ")", "saved", ".", "append", "(", "k", ")",...
Take a dict (A -> B( and return another one (B -> [A]). It groups keys from the original dict by their values. .. testsetup:: from proso.dict import group_keys_by_values from pprint import pprint .. doctest:: >>> pprint(group_keys_by_values({1: True, 2: False, 3: True, 4: True}))...
[ "Take", "a", "dict", "(", "A", "-", ">", "B", "(", "and", "return", "another", "one", "(", "B", "-", ">", "[", "A", "]", ")", ".", "It", "groups", "keys", "from", "the", "original", "dict", "by", "their", "values", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/dict.py#L6-L32
train
Takes a dict A -> B and returns another dict A -> B where A is a list where all values are original keys pointing to the same value.
adaptive-learning/proso-apps
proso/dict.py
group_keys_by_value_lists
def group_keys_by_value_lists(d): """ Take a dict (A -> [B]( and return another one (B -> [A]). It groups keys from the original dict by their values in lists. .. testsetup:: from proso.dict import group_keys_by_value_lists from pprint import pprint .. doctest:: >>> pprin...
python
def group_keys_by_value_lists(d): """ Take a dict (A -> [B]( and return another one (B -> [A]). It groups keys from the original dict by their values in lists. .. testsetup:: from proso.dict import group_keys_by_value_lists from pprint import pprint .. doctest:: >>> pprin...
[ "def", "group_keys_by_value_lists", "(", "d", ")", ":", "result", "=", "{", "}", "for", "k", ",", "values", "in", "d", ".", "items", "(", ")", ":", "for", "v", "in", "values", ":", "saved", "=", "result", ".", "get", "(", "v", ",", "[", "]", ")...
Take a dict (A -> [B]( and return another one (B -> [A]). It groups keys from the original dict by their values in lists. .. testsetup:: from proso.dict import group_keys_by_value_lists from pprint import pprint .. doctest:: >>> pprint(group_keys_by_value_lists({1: [True], 2: [Fa...
[ "Take", "a", "dict", "(", "A", "-", ">", "[", "B", "]", "(", "and", "return", "another", "one", "(", "B", "-", ">", "[", "A", "]", ")", ".", "It", "groups", "keys", "from", "the", "original", "dict", "by", "their", "values", "in", "lists", "." ...
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/dict.py#L35-L62
train
This function takes a dict and returns another dict where each key points to the same value.
Dapid/tmscoring
tmscoring/tmscore.py
Aligning.get_default_values
def get_default_values(self): """ Make a crude estimation of the alignment using the center of mass and general C->N orientation. """ out = dict(dx=0, dy=0, dz=0, theta=0, phi=0, psi=0) dx, dy, dz, _ = np.mean(self.coord1 - self.coord2, axis=1) out['dx'] = dx ...
python
def get_default_values(self): """ Make a crude estimation of the alignment using the center of mass and general C->N orientation. """ out = dict(dx=0, dy=0, dz=0, theta=0, phi=0, psi=0) dx, dy, dz, _ = np.mean(self.coord1 - self.coord2, axis=1) out['dx'] = dx ...
[ "def", "get_default_values", "(", "self", ")", ":", "out", "=", "dict", "(", "dx", "=", "0", ",", "dy", "=", "0", ",", "dz", "=", "0", ",", "theta", "=", "0", ",", "phi", "=", "0", ",", "psi", "=", "0", ")", "dx", ",", "dy", ",", "dz", ",...
Make a crude estimation of the alignment using the center of mass and general C->N orientation.
[ "Make", "a", "crude", "estimation", "of", "the", "alignment", "using", "the", "center", "of", "mass", "and", "general", "C", "-", ">", "N", "orientation", "." ]
353c567e201ee9835c8209f6130b80b1cfb5b10f
https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L45-L81
train
Get the default values for the current species.
Dapid/tmscoring
tmscoring/tmscore.py
Aligning.get_matrix
def get_matrix(theta, phi, psi, dx, dy, dz, matrix=np.zeros((4, 4), dtype=DTYPE), angles=np.zeros(3, dtype=DTYPE)): """ Build the rotation-translation matrix. It has the form: [ | dx ] [ R | dy ] [ | dz ] ...
python
def get_matrix(theta, phi, psi, dx, dy, dz, matrix=np.zeros((4, 4), dtype=DTYPE), angles=np.zeros(3, dtype=DTYPE)): """ Build the rotation-translation matrix. It has the form: [ | dx ] [ R | dy ] [ | dz ] ...
[ "def", "get_matrix", "(", "theta", ",", "phi", ",", "psi", ",", "dx", ",", "dy", ",", "dz", ",", "matrix", "=", "np", ".", "zeros", "(", "(", "4", ",", "4", ")", ",", "dtype", "=", "DTYPE", ")", ",", "angles", "=", "np", ".", "zeros", "(", ...
Build the rotation-translation matrix. It has the form: [ | dx ] [ R | dy ] [ | dz ] [ 0 0 0 | 1 ]
[ "Build", "the", "rotation", "-", "translation", "matrix", "." ]
353c567e201ee9835c8209f6130b80b1cfb5b10f
https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L84-L118
train
Builds the rotation - translation matrix for the current language.
Dapid/tmscoring
tmscoring/tmscore.py
Aligning._tm
def _tm(self, theta, phi, psi, dx, dy, dz): """ Compute the minimisation target, not normalised. """ matrix = self.get_matrix(theta, phi, psi, dx, dy, dz) coord = matrix.dot(self.coord2) dist = coord - self.coord1 d_i2 = (dist * dist).sum(axis=0) tm = -(...
python
def _tm(self, theta, phi, psi, dx, dy, dz): """ Compute the minimisation target, not normalised. """ matrix = self.get_matrix(theta, phi, psi, dx, dy, dz) coord = matrix.dot(self.coord2) dist = coord - self.coord1 d_i2 = (dist * dist).sum(axis=0) tm = -(...
[ "def", "_tm", "(", "self", ",", "theta", ",", "phi", ",", "psi", ",", "dx", ",", "dy", ",", "dz", ")", ":", "matrix", "=", "self", ".", "get_matrix", "(", "theta", ",", "phi", ",", "psi", ",", "dx", ",", "dy", ",", "dz", ")", "coord", "=", ...
Compute the minimisation target, not normalised.
[ "Compute", "the", "minimisation", "target", "not", "normalised", "." ]
353c567e201ee9835c8209f6130b80b1cfb5b10f
https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L138-L150
train
Compute the minimisation target not normalised.
Dapid/tmscoring
tmscoring/tmscore.py
Aligning.write
def write(self, outputfile='out.pdb', appended=False): """ Save the second PDB file aligned to the first. If appended is True, both are saved as different chains. """ # FIXME some cases don't work. matrix = self.get_matrix(**self.get_current_values()) out = open...
python
def write(self, outputfile='out.pdb', appended=False): """ Save the second PDB file aligned to the first. If appended is True, both are saved as different chains. """ # FIXME some cases don't work. matrix = self.get_matrix(**self.get_current_values()) out = open...
[ "def", "write", "(", "self", ",", "outputfile", "=", "'out.pdb'", ",", "appended", "=", "False", ")", ":", "# FIXME some cases don't work.", "matrix", "=", "self", ".", "get_matrix", "(", "*", "*", "self", ".", "get_current_values", "(", ")", ")", "out", "...
Save the second PDB file aligned to the first. If appended is True, both are saved as different chains.
[ "Save", "the", "second", "PDB", "file", "aligned", "to", "the", "first", "." ]
353c567e201ee9835c8209f6130b80b1cfb5b10f
https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L187-L228
train
Write the current set of current entries to a PDB file.
Dapid/tmscoring
tmscoring/tmscore.py
Aligning._load_data_alignment
def _load_data_alignment(self, chain1, chain2): """ Extract the sequences from the PDB file, perform the alignment, and load the coordinates of the CA of the common residues. """ parser = PDB.PDBParser(QUIET=True) ppb = PDB.PPBuilder() structure1 = parser.get_str...
python
def _load_data_alignment(self, chain1, chain2): """ Extract the sequences from the PDB file, perform the alignment, and load the coordinates of the CA of the common residues. """ parser = PDB.PDBParser(QUIET=True) ppb = PDB.PPBuilder() structure1 = parser.get_str...
[ "def", "_load_data_alignment", "(", "self", ",", "chain1", ",", "chain2", ")", ":", "parser", "=", "PDB", ".", "PDBParser", "(", "QUIET", "=", "True", ")", "ppb", "=", "PDB", ".", "PPBuilder", "(", ")", "structure1", "=", "parser", ".", "get_structure", ...
Extract the sequences from the PDB file, perform the alignment, and load the coordinates of the CA of the common residues.
[ "Extract", "the", "sequences", "from", "the", "PDB", "file", "perform", "the", "alignment", "and", "load", "the", "coordinates", "of", "the", "CA", "of", "the", "common", "residues", "." ]
353c567e201ee9835c8209f6130b80b1cfb5b10f
https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L230-L259
train
Load the alignment parameters from the first and second chains of the common residues.
Dapid/tmscoring
tmscoring/tmscore.py
Aligning._load_data_index
def _load_data_index(self, chain1, chain2): """ Load the coordinates of the CA of the common residues. """ parser = PDB.PDBParser(QUIET=True) structure1 = parser.get_structure(chain1, self.pdb1) structure2 = parser.get_structure(chain2, self.pdb2) residues1 = li...
python
def _load_data_index(self, chain1, chain2): """ Load the coordinates of the CA of the common residues. """ parser = PDB.PDBParser(QUIET=True) structure1 = parser.get_structure(chain1, self.pdb1) structure2 = parser.get_structure(chain2, self.pdb2) residues1 = li...
[ "def", "_load_data_index", "(", "self", ",", "chain1", ",", "chain2", ")", ":", "parser", "=", "PDB", ".", "PDBParser", "(", "QUIET", "=", "True", ")", "structure1", "=", "parser", ".", "get_structure", "(", "chain1", ",", "self", ".", "pdb1", ")", "st...
Load the coordinates of the CA of the common residues.
[ "Load", "the", "coordinates", "of", "the", "CA", "of", "the", "common", "residues", "." ]
353c567e201ee9835c8209f6130b80b1cfb5b10f
https://github.com/Dapid/tmscoring/blob/353c567e201ee9835c8209f6130b80b1cfb5b10f/tmscoring/tmscore.py#L261-L297
train
Load the coordinates of the CA of the common residues.
uw-it-aca/uw-restclients-sws
uw_sws/section_status.py
_json_to_sectionstatus
def _json_to_sectionstatus(section_data): """ Returns a uw_sws.models.SectionStatus object created from the passed json. """ section_status = SectionStatus() if section_data["AddCodeRequired"] == 'true': section_status.add_code_required = True else: section_status.add_code_re...
python
def _json_to_sectionstatus(section_data): """ Returns a uw_sws.models.SectionStatus object created from the passed json. """ section_status = SectionStatus() if section_data["AddCodeRequired"] == 'true': section_status.add_code_required = True else: section_status.add_code_re...
[ "def", "_json_to_sectionstatus", "(", "section_data", ")", ":", "section_status", "=", "SectionStatus", "(", ")", "if", "section_data", "[", "\"AddCodeRequired\"", "]", "==", "'true'", ":", "section_status", ".", "add_code_required", "=", "True", "else", ":", "sec...
Returns a uw_sws.models.SectionStatus object created from the passed json.
[ "Returns", "a", "uw_sws", ".", "models", ".", "SectionStatus", "object", "created", "from", "the", "passed", "json", "." ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/section_status.py#L21-L52
train
Convert the passed json to a uw_sws. models. SectionStatus object.
Kortemme-Lab/klab
klab/cluster/sge_interface.py
create_script
def create_script(job_name, job_directory, job_data_arrays = '', job_setup_commands = '', job_execution_commands = '', job_post_processing_commands = '', architecture = 'linux-x64', num_tasks = 1, memory_in_GB = 2, scratch_space_in_GB = 1, runtime_string = '24:00:00...
python
def create_script(job_name, job_directory, job_data_arrays = '', job_setup_commands = '', job_execution_commands = '', job_post_processing_commands = '', architecture = 'linux-x64', num_tasks = 1, memory_in_GB = 2, scratch_space_in_GB = 1, runtime_string = '24:00:00...
[ "def", "create_script", "(", "job_name", ",", "job_directory", ",", "job_data_arrays", "=", "''", ",", "job_setup_commands", "=", "''", ",", "job_execution_commands", "=", "''", ",", "job_post_processing_commands", "=", "''", ",", "architecture", "=", "'linux-x64'",...
This function uses python_script_template to create a script that can execute on the cluster. The template has useful boiler-plate functionality and contains Genshi-style substitution syntax - strings of the form ${varname} inside the template (typically syntax errors) are meant to be replaced with valid ...
[ "This", "function", "uses", "python_script_template", "to", "create", "a", "script", "that", "can", "execute", "on", "the", "cluster", ".", "The", "template", "has", "useful", "boiler", "-", "plate", "functionality", "and", "contains", "Genshi", "-", "style", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cluster/sge_interface.py#L14-L83
train
This function creates a script that can be used to execute a cluster.
Kortemme-Lab/klab
klab/cluster/sge_interface.py
submit
def submit(command_filename, workingdir, send_mail = False, username = None): '''Submit the given command filename to the queue. Adapted from the qb3 example.''' # Open streams command_filename = command_filename outfile = command_filename + ".out" file_stdout = open(outfile, 'w') # Form comma...
python
def submit(command_filename, workingdir, send_mail = False, username = None): '''Submit the given command filename to the queue. Adapted from the qb3 example.''' # Open streams command_filename = command_filename outfile = command_filename + ".out" file_stdout = open(outfile, 'w') # Form comma...
[ "def", "submit", "(", "command_filename", ",", "workingdir", ",", "send_mail", "=", "False", ",", "username", "=", "None", ")", ":", "# Open streams", "command_filename", "=", "command_filename", "outfile", "=", "command_filename", "+", "\".out\"", "file_stdout", ...
Submit the given command filename to the queue. Adapted from the qb3 example.
[ "Submit", "the", "given", "command", "filename", "to", "the", "queue", ".", "Adapted", "from", "the", "qb3", "example", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cluster/sge_interface.py#L86-L139
train
Submit the given command filename to the queue. Adapted from the qb3 example.
Kortemme-Lab/klab
klab/bio/pdb_util.py
renumber_atoms
def renumber_atoms(lines): ''' Takes in a list of PDB lines and renumbers the atoms appropriately ''' new_lines = [] current_number = 1 for line in lines: if line.startswith('ATOM') or line.startswith('HETATM'): new_lines.append( line[:6] + string.rjust('%d' %...
python
def renumber_atoms(lines): ''' Takes in a list of PDB lines and renumbers the atoms appropriately ''' new_lines = [] current_number = 1 for line in lines: if line.startswith('ATOM') or line.startswith('HETATM'): new_lines.append( line[:6] + string.rjust('%d' %...
[ "def", "renumber_atoms", "(", "lines", ")", ":", "new_lines", "=", "[", "]", "current_number", "=", "1", "for", "line", "in", "lines", ":", "if", "line", ".", "startswith", "(", "'ATOM'", ")", "or", "line", ".", "startswith", "(", "'HETATM'", ")", ":",...
Takes in a list of PDB lines and renumbers the atoms appropriately
[ "Takes", "in", "a", "list", "of", "PDB", "lines", "and", "renumbers", "the", "atoms", "appropriately" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdb_util.py#L30-L46
train
Takes in a list of PDB lines and renumbers the atoms appropriately
Kortemme-Lab/klab
klab/bio/pdb_util.py
clean_alternate_location_indicators
def clean_alternate_location_indicators(lines): ''' Keeps only the first atom, if alternated location identifiers are being used Removes alternate location ID charactor ''' new_lines = [] previously_seen_alt_atoms = set() for line in lines: if line.startswith('ATOM'): alt...
python
def clean_alternate_location_indicators(lines): ''' Keeps only the first atom, if alternated location identifiers are being used Removes alternate location ID charactor ''' new_lines = [] previously_seen_alt_atoms = set() for line in lines: if line.startswith('ATOM'): alt...
[ "def", "clean_alternate_location_indicators", "(", "lines", ")", ":", "new_lines", "=", "[", "]", "previously_seen_alt_atoms", "=", "set", "(", ")", "for", "line", "in", "lines", ":", "if", "line", ".", "startswith", "(", "'ATOM'", ")", ":", "alt_loc_id", "=...
Keeps only the first atom, if alternated location identifiers are being used Removes alternate location ID charactor
[ "Keeps", "only", "the", "first", "atom", "if", "alternated", "location", "identifiers", "are", "being", "used", "Removes", "alternate", "location", "ID", "charactor" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdb_util.py#L48-L71
train
Removes alternate location identifiers from the list of lines.
TUNE-Archive/freight_forwarder
freight_forwarder/registry/auth.py
Auth.clean_up
def clean_up(self): """ :return: """ if self.auth_type == 'registry_rubber' and self.user: self._registry_rubber_uonce('delete') # clean up old docker configs. user_home = os.environ.get('HOME') for file_name in os.listdir(user_home): if '...
python
def clean_up(self): """ :return: """ if self.auth_type == 'registry_rubber' and self.user: self._registry_rubber_uonce('delete') # clean up old docker configs. user_home = os.environ.get('HOME') for file_name in os.listdir(user_home): if '...
[ "def", "clean_up", "(", "self", ")", ":", "if", "self", ".", "auth_type", "==", "'registry_rubber'", "and", "self", ".", "user", ":", "self", ".", "_registry_rubber_uonce", "(", "'delete'", ")", "# clean up old docker configs.", "user_home", "=", "os", ".", "e...
:return:
[ ":", "return", ":" ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/registry/auth.py#L37-L57
train
Clean up old docker configs.
TUNE-Archive/freight_forwarder
freight_forwarder/registry/auth.py
Auth.load_dockercfg
def load_dockercfg(self): """ :return: """ if self.ssl_cert_path: self._validate_ssl_certs() if self.auth_type == 'registry_rubber': self.user, self.passwd = self._registry_rubber_uonce('add') self._config_path = self._create_dockercfg( ...
python
def load_dockercfg(self): """ :return: """ if self.ssl_cert_path: self._validate_ssl_certs() if self.auth_type == 'registry_rubber': self.user, self.passwd = self._registry_rubber_uonce('add') self._config_path = self._create_dockercfg( ...
[ "def", "load_dockercfg", "(", "self", ")", ":", "if", "self", ".", "ssl_cert_path", ":", "self", ".", "_validate_ssl_certs", "(", ")", "if", "self", ".", "auth_type", "==", "'registry_rubber'", ":", "self", ".", "user", ",", "self", ".", "passwd", "=", "...
:return:
[ ":", "return", ":" ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/registry/auth.py#L114-L148
train
Load the dockercfg file and set the user and password.
mrtazz/InstapaperLibrary
bin/instapaper.py
main
def main(): """ main method """ # initialize parser usage = "usage: %prog [-u USER] [-p PASSWORD] [-t TITLE] [-s selection] url" parser = OptionParser(usage, version="%prog "+instapaperlib.__version__) parser.add_option("-u", "--user", action="store", dest="user", m...
python
def main(): """ main method """ # initialize parser usage = "usage: %prog [-u USER] [-p PASSWORD] [-t TITLE] [-s selection] url" parser = OptionParser(usage, version="%prog "+instapaperlib.__version__) parser.add_option("-u", "--user", action="store", dest="user", m...
[ "def", "main", "(", ")", ":", "# initialize parser", "usage", "=", "\"usage: %prog [-u USER] [-p PASSWORD] [-t TITLE] [-s selection] url\"", "parser", "=", "OptionParser", "(", "usage", ",", "version", "=", "\"%prog \"", "+", "instapaperlib", ".", "__version__", ")", "p...
main method
[ "main", "method" ]
bf273c02b468e523994d46def07f70902f596676
https://github.com/mrtazz/InstapaperLibrary/blob/bf273c02b468e523994d46def07f70902f596676/bin/instapaper.py#L14-L58
train
main method of instapaperlib. add_item
fastmonkeys/pontus
pontus/_compat.py
unicode_compatible
def unicode_compatible(cls): """ A decorator that defines ``__str__`` and ``__unicode__`` methods under Python 2. """ if not is_py3: cls.__unicode__ = cls.__str__ cls.__str__ = lambda self: self.__unicode__().encode('utf-8') return cls
python
def unicode_compatible(cls): """ A decorator that defines ``__str__`` and ``__unicode__`` methods under Python 2. """ if not is_py3: cls.__unicode__ = cls.__str__ cls.__str__ = lambda self: self.__unicode__().encode('utf-8') return cls
[ "def", "unicode_compatible", "(", "cls", ")", ":", "if", "not", "is_py3", ":", "cls", ".", "__unicode__", "=", "cls", ".", "__str__", "cls", ".", "__str__", "=", "lambda", "self", ":", "self", ".", "__unicode__", "(", ")", ".", "encode", "(", "'utf-8'"...
A decorator that defines ``__str__`` and ``__unicode__`` methods under Python 2.
[ "A", "decorator", "that", "defines", "__str__", "and", "__unicode__", "methods", "under", "Python", "2", "." ]
cf02fb22c4558b899e2dcbe437a1a525321c4f12
https://github.com/fastmonkeys/pontus/blob/cf02fb22c4558b899e2dcbe437a1a525321c4f12/pontus/_compat.py#L25-L33
train
A class decorator that makes unicode - compatible.
Kortemme-Lab/klab
klab/bio/ligand.py
Ligand.retrieve_data_from_rcsb
def retrieve_data_from_rcsb(cls, ligand_code, pdb_id = None, silent = True, cached_dir = None): '''Retrieve a file from the RCSB.''' if not silent: colortext.printf("Retrieving data from RCSB") if cached_dir: assert(os.path.exists(cached_dir)) ligand_info_path, l...
python
def retrieve_data_from_rcsb(cls, ligand_code, pdb_id = None, silent = True, cached_dir = None): '''Retrieve a file from the RCSB.''' if not silent: colortext.printf("Retrieving data from RCSB") if cached_dir: assert(os.path.exists(cached_dir)) ligand_info_path, l...
[ "def", "retrieve_data_from_rcsb", "(", "cls", ",", "ligand_code", ",", "pdb_id", "=", "None", ",", "silent", "=", "True", ",", "cached_dir", "=", "None", ")", ":", "if", "not", "silent", ":", "colortext", ".", "printf", "(", "\"Retrieving data from RCSB\"", ...
Retrieve a file from the RCSB.
[ "Retrieve", "a", "file", "from", "the", "RCSB", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L90-L130
train
Retrieve a file from the RCSB.
Kortemme-Lab/klab
klab/bio/ligand.py
Ligand.parse_cif
def parse_cif(self, cif): '''See http://www.iucr.org/__data/iucr/cif/standard/cifstd4.html, Acta Cryst. (1991). A47, 655-685.''' found_cif_header = False found_cif_descriptors = False found_cif_identifiers = False blocks = [] blocklines = [] for l in cif.split('\...
python
def parse_cif(self, cif): '''See http://www.iucr.org/__data/iucr/cif/standard/cifstd4.html, Acta Cryst. (1991). A47, 655-685.''' found_cif_header = False found_cif_descriptors = False found_cif_identifiers = False blocks = [] blocklines = [] for l in cif.split('\...
[ "def", "parse_cif", "(", "self", ",", "cif", ")", ":", "found_cif_header", "=", "False", "found_cif_descriptors", "=", "False", "found_cif_identifiers", "=", "False", "blocks", "=", "[", "]", "blocklines", "=", "[", "]", "for", "l", "in", "cif", ".", "spli...
See http://www.iucr.org/__data/iucr/cif/standard/cifstd4.html, Acta Cryst. (1991). A47, 655-685.
[ "See", "http", ":", "//", "www", ".", "iucr", ".", "org", "/", "__data", "/", "iucr", "/", "cif", "/", "standard", "/", "cifstd4", ".", "html", "Acta", "Cryst", ".", "(", "1991", ")", ".", "A47", "655", "-", "685", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L133-L171
train
Parses a CIF file into a set of attributes.
Kortemme-Lab/klab
klab/bio/ligand.py
LigandMap.from_tuples_dict
def from_tuples_dict(pair_dict): '''pair_dict should be a dict mapping tuple (HET code, residue ID) -> (HET code, residue ID) e.g. {('MG ', 'A 204 ') : ('MG ', 'C 221 '), ...}. HET codes and residue IDs should respectively correspond to columns 17:20 and 21:27 of the PDB file. ''' lm ...
python
def from_tuples_dict(pair_dict): '''pair_dict should be a dict mapping tuple (HET code, residue ID) -> (HET code, residue ID) e.g. {('MG ', 'A 204 ') : ('MG ', 'C 221 '), ...}. HET codes and residue IDs should respectively correspond to columns 17:20 and 21:27 of the PDB file. ''' lm ...
[ "def", "from_tuples_dict", "(", "pair_dict", ")", ":", "lm", "=", "LigandMap", "(", ")", "for", "k", ",", "v", "in", "pair_dict", ".", "iteritems", "(", ")", ":", "lm", ".", "add", "(", "k", "[", "0", "]", ",", "k", "[", "1", "]", ",", "v", "...
pair_dict should be a dict mapping tuple (HET code, residue ID) -> (HET code, residue ID) e.g. {('MG ', 'A 204 ') : ('MG ', 'C 221 '), ...}. HET codes and residue IDs should respectively correspond to columns 17:20 and 21:27 of the PDB file.
[ "pair_dict", "should", "be", "a", "dict", "mapping", "tuple", "(", "HET", "code", "residue", "ID", ")", "-", ">", "(", "HET", "code", "residue", "ID", ")", "e", ".", "g", ".", "{", "(", "MG", "A", "204", ")", ":", "(", "MG", "C", "221", ")", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L530-L537
train
Convert a dictionary mapping HET codes residue IDs to LigandMap.
Kortemme-Lab/klab
klab/bio/ligand.py
LigandMap.add_code_mapping
def add_code_mapping(self, from_pdb_code, to_pdb_code): '''Add a code mapping without a given instance.''' # Consistency check - make sure that we always map the same code e.g. 'LIG' to the same code e.g. 'GTP' if from_pdb_code in self.code_map: assert(self.code_map[from_pdb_code] =...
python
def add_code_mapping(self, from_pdb_code, to_pdb_code): '''Add a code mapping without a given instance.''' # Consistency check - make sure that we always map the same code e.g. 'LIG' to the same code e.g. 'GTP' if from_pdb_code in self.code_map: assert(self.code_map[from_pdb_code] =...
[ "def", "add_code_mapping", "(", "self", ",", "from_pdb_code", ",", "to_pdb_code", ")", ":", "# Consistency check - make sure that we always map the same code e.g. 'LIG' to the same code e.g. 'GTP'", "if", "from_pdb_code", "in", "self", ".", "code_map", ":", "assert", "(", "se...
Add a code mapping without a given instance.
[ "Add", "a", "code", "mapping", "without", "a", "given", "instance", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L554-L561
train
Add a code mapping without a given instance.
Kortemme-Lab/klab
klab/bio/ligand.py
LigandMap.is_injective
def is_injective(self): '''Returns True if the mapping is injective (1-to-1).''' codomain_residues = [v.to_pdb_residue_id for k, v in self.mapping.iteritems()] return(len(codomain_residues) == len(set(codomain_residues)))
python
def is_injective(self): '''Returns True if the mapping is injective (1-to-1).''' codomain_residues = [v.to_pdb_residue_id for k, v in self.mapping.iteritems()] return(len(codomain_residues) == len(set(codomain_residues)))
[ "def", "is_injective", "(", "self", ")", ":", "codomain_residues", "=", "[", "v", ".", "to_pdb_residue_id", "for", "k", ",", "v", "in", "self", ".", "mapping", ".", "iteritems", "(", ")", "]", "return", "(", "len", "(", "codomain_residues", ")", "==", ...
Returns True if the mapping is injective (1-to-1).
[ "Returns", "True", "if", "the", "mapping", "is", "injective", "(", "1", "-", "to", "-", "1", ")", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L568-L571
train
Returns True if the mapping is injective ( 1 - to - 1.
Kortemme-Lab/klab
klab/bio/ligand.py
LigandMap.is_complete
def is_complete(self, all_domain_residue_ids): '''Check that all ligands (specified via the set or list all_domain_residue_ids containing columns 21:27 of the HETATM records) in the source PDB file are considered in the mapping.''' mapped_domain_residues = sorted([v.from_pdb_residue_id for k,...
python
def is_complete(self, all_domain_residue_ids): '''Check that all ligands (specified via the set or list all_domain_residue_ids containing columns 21:27 of the HETATM records) in the source PDB file are considered in the mapping.''' mapped_domain_residues = sorted([v.from_pdb_residue_id for k,...
[ "def", "is_complete", "(", "self", ",", "all_domain_residue_ids", ")", ":", "mapped_domain_residues", "=", "sorted", "(", "[", "v", ".", "from_pdb_residue_id", "for", "k", ",", "v", "in", "self", ".", "mapping", ".", "iteritems", "(", ")", "]", ")", "asser...
Check that all ligands (specified via the set or list all_domain_residue_ids containing columns 21:27 of the HETATM records) in the source PDB file are considered in the mapping.
[ "Check", "that", "all", "ligands", "(", "specified", "via", "the", "set", "or", "list", "all_domain_residue_ids", "containing", "columns", "21", ":", "27", "of", "the", "HETATM", "records", ")", "in", "the", "source", "PDB", "file", "are", "considered", "in"...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/ligand.py#L574-L579
train
Check that all ligands in the source PDB file are in the mapping.
tech-pi/doufo
src/python/doufo/maybe.py
Maybe.fmap
def fmap(self, f: Callable[[T], B]) -> 'Maybe[B]': """doufo.maybe.fmap: map a `Maybe` object with a function Args: `self` f (`Callable[[T], B]`): a function Returns: return (`Maybe[B]`): returned `Maybe` objects from function `f` Raises...
python
def fmap(self, f: Callable[[T], B]) -> 'Maybe[B]': """doufo.maybe.fmap: map a `Maybe` object with a function Args: `self` f (`Callable[[T], B]`): a function Returns: return (`Maybe[B]`): returned `Maybe` objects from function `f` Raises...
[ "def", "fmap", "(", "self", ",", "f", ":", "Callable", "[", "[", "T", "]", ",", "B", "]", ")", "->", "'Maybe[B]'", ":", "return", "Maybe", "(", "None", ")", "if", "self", ".", "unbox", "(", ")", "is", "None", "else", "Maybe", "(", "f", "(", "...
doufo.maybe.fmap: map a `Maybe` object with a function Args: `self` f (`Callable[[T], B]`): a function Returns: return (`Maybe[B]`): returned `Maybe` objects from function `f` Raises:
[ "doufo", ".", "maybe", ".", "fmap", ":", "map", "a", "Maybe", "object", "with", "a", "function", "Args", ":", "self", "f", "(", "Callable", "[[", "T", "]", "B", "]", ")", ":", "a", "function", "Returns", ":", "return", "(", "Maybe", "[", "B", "]"...
3d375fef30670597768a6eef809b75b4b1b5a3fd
https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/maybe.py#L50-L59
train
Returns a function from function f
tech-pi/doufo
src/python/doufo/maybe.py
Maybe.bind
def bind(self, f: Callable[[T], 'Maybe[B]']) -> 'Maybe[B]': """doufo.Maybe.bind Args: `self`: f (`Callable[[T], Maybe[B]`): A function that returns `Maybe[B]` Returns: return (`Maybe[B]`): results of mapping in form of `Maybe[B]` Raises: ...
python
def bind(self, f: Callable[[T], 'Maybe[B]']) -> 'Maybe[B]': """doufo.Maybe.bind Args: `self`: f (`Callable[[T], Maybe[B]`): A function that returns `Maybe[B]` Returns: return (`Maybe[B]`): results of mapping in form of `Maybe[B]` Raises: ...
[ "def", "bind", "(", "self", ",", "f", ":", "Callable", "[", "[", "T", "]", ",", "'Maybe[B]'", "]", ")", "->", "'Maybe[B]'", ":", "return", "self", ".", "fmap", "(", "lambda", "x", ":", "f", "(", "x", ")", ".", "unbox", "(", ")", ")" ]
doufo.Maybe.bind Args: `self`: f (`Callable[[T], Maybe[B]`): A function that returns `Maybe[B]` Returns: return (`Maybe[B]`): results of mapping in form of `Maybe[B]` Raises:
[ "doufo", ".", "Maybe", ".", "bind", "Args", ":", "self", ":", "f", "(", "Callable", "[[", "T", "]", "Maybe", "[", "B", "]", ")", ":", "A", "function", "that", "returns", "Maybe", "[", "B", "]", "Returns", ":", "return", "(", "Maybe", "[", "B", ...
3d375fef30670597768a6eef809b75b4b1b5a3fd
https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/maybe.py#L72-L81
train
Returns a copy of the current Maybe with the result of applying f to the current Maybe.
projectshift/shift-boiler
boiler/routes/route.py
route
def route(view, endpoint=None, methods=None, defaults=None, **options): """ Route: a shorthand for route declaration Import and use it in your app.urls file by calling: url['/path/to/view'] = route('module.views.view', 'route_name') """ if not endpoint: endpoint = view if not met...
python
def route(view, endpoint=None, methods=None, defaults=None, **options): """ Route: a shorthand for route declaration Import and use it in your app.urls file by calling: url['/path/to/view'] = route('module.views.view', 'route_name') """ if not endpoint: endpoint = view if not met...
[ "def", "route", "(", "view", ",", "endpoint", "=", "None", ",", "methods", "=", "None", ",", "defaults", "=", "None", ",", "*", "*", "options", ")", ":", "if", "not", "endpoint", ":", "endpoint", "=", "view", "if", "not", "methods", ":", "methods", ...
Route: a shorthand for route declaration Import and use it in your app.urls file by calling: url['/path/to/view'] = route('module.views.view', 'route_name')
[ "Route", ":", "a", "shorthand", "for", "route", "declaration", "Import", "and", "use", "it", "in", "your", "app", ".", "urls", "file", "by", "calling", ":", "url", "[", "/", "path", "/", "to", "/", "view", "]", "=", "route", "(", "module", ".", "vi...
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/routes/route.py#L4-L20
train
Route is a shorthand for route declaration
projectshift/shift-boiler
boiler/bootstrap.py
get_config
def get_config(): """ Imports config based on environment. :return: """ app_module = os.getenv('APP_MODULE') if not app_module: err = 'Unable to bootstrap application APP_MODULE is not defined' raise x.BootstrapException(err) app_config = os.getenv('APP_CONFIG') if not a...
python
def get_config(): """ Imports config based on environment. :return: """ app_module = os.getenv('APP_MODULE') if not app_module: err = 'Unable to bootstrap application APP_MODULE is not defined' raise x.BootstrapException(err) app_config = os.getenv('APP_CONFIG') if not a...
[ "def", "get_config", "(", ")", ":", "app_module", "=", "os", ".", "getenv", "(", "'APP_MODULE'", ")", "if", "not", "app_module", ":", "err", "=", "'Unable to bootstrap application APP_MODULE is not defined'", "raise", "x", ".", "BootstrapException", "(", "err", ")...
Imports config based on environment. :return:
[ "Imports", "config", "based", "on", "environment", ".", ":", "return", ":" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/bootstrap.py#L14-L37
train
Imports config based on environment.
projectshift/shift-boiler
boiler/bootstrap.py
create_app
def create_app(name, config=None, flask_params=None): """ Create app Generalized way of creating a flask app. Use it in your concrete apps and do further configuration there: add app-specific options, extensions, listeners and other features. Note: application name should be its fully qualified...
python
def create_app(name, config=None, flask_params=None): """ Create app Generalized way of creating a flask app. Use it in your concrete apps and do further configuration there: add app-specific options, extensions, listeners and other features. Note: application name should be its fully qualified...
[ "def", "create_app", "(", "name", ",", "config", "=", "None", ",", "flask_params", "=", "None", ")", ":", "from", "boiler", ".", "config", "import", "DefaultConfig", "if", "config", "is", "None", ":", "config", "=", "DefaultConfig", "(", ")", "# get flask ...
Create app Generalized way of creating a flask app. Use it in your concrete apps and do further configuration there: add app-specific options, extensions, listeners and other features. Note: application name should be its fully qualified __name__, something like project.api.app. This is how we fetc...
[ "Create", "app", "Generalized", "way", "of", "creating", "a", "flask", "app", ".", "Use", "it", "in", "your", "concrete", "apps", "and", "do", "further", "configuration", "there", ":", "add", "app", "-", "specific", "options", "extensions", "listeners", "and...
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/bootstrap.py#L53-L107
train
Create a new app with the given name.
mardix/Mocha
mocha/contrib/views/auth.py
Login.register
def register(self): """ Registration """ if not __options__.get("allow_registration"): abort(403, "Registration is not allowed. Contact admin if it's a mistake") page_attr("Register") if request.method == "POST": try: if not recaptcha.verify(): ...
python
def register(self): """ Registration """ if not __options__.get("allow_registration"): abort(403, "Registration is not allowed. Contact admin if it's a mistake") page_attr("Register") if request.method == "POST": try: if not recaptcha.verify(): ...
[ "def", "register", "(", "self", ")", ":", "if", "not", "__options__", ".", "get", "(", "\"allow_registration\"", ")", ":", "abort", "(", "403", ",", "\"Registration is not allowed. Contact admin if it's a mistake\"", ")", "page_attr", "(", "\"Register\"", ")", "if",...
Registration
[ "Registration" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/auth.py#L205-L295
train
Register a new user in the database.
mardix/Mocha
mocha/contrib/views/auth.py
Login._register_oauth_session_user
def _register_oauth_session_user(self, user): """ Add the :param user: :return: """ oauth_session = get_oauth_session() if oauth_session: if "provider" in oauth_session and "user_id" in oauth_session: user.add_federated_login(provider=o...
python
def _register_oauth_session_user(self, user): """ Add the :param user: :return: """ oauth_session = get_oauth_session() if oauth_session: if "provider" in oauth_session and "user_id" in oauth_session: user.add_federated_login(provider=o...
[ "def", "_register_oauth_session_user", "(", "self", ",", "user", ")", ":", "oauth_session", "=", "get_oauth_session", "(", ")", "if", "oauth_session", ":", "if", "\"provider\"", "in", "oauth_session", "and", "\"user_id\"", "in", "oauth_session", ":", "user", ".", ...
Add the :param user: :return:
[ "Add", "the", ":", "param", "user", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/auth.py#L297-L308
train
Add the user to the user s oauth session.
mardix/Mocha
mocha/contrib/views/auth.py
Login.reset_password
def reset_password(self, action_token, signed_data): """Reset the user password. It was triggered by LOST-PASSWORD """ try: action = "reset-password" user = get_user_by_action_token(action, action_token) if not user or not user.signed_data_match(signed_data, action): ...
python
def reset_password(self, action_token, signed_data): """Reset the user password. It was triggered by LOST-PASSWORD """ try: action = "reset-password" user = get_user_by_action_token(action, action_token) if not user or not user.signed_data_match(signed_data, action): ...
[ "def", "reset_password", "(", "self", ",", "action_token", ",", "signed_data", ")", ":", "try", ":", "action", "=", "\"reset-password\"", "user", "=", "get_user_by_action_token", "(", "action", ",", "action_token", ")", "if", "not", "user", "or", "not", "user"...
Reset the user password. It was triggered by LOST-PASSWORD
[ "Reset", "the", "user", "password", ".", "It", "was", "triggered", "by", "LOST", "-", "PASSWORD" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/auth.py#L337-L366
train
Reset the user password.
mardix/Mocha
mocha/contrib/views/auth.py
Login.verify_email
def verify_email(self, action_token, signed_data): """ Verify email account, in which a link was sent to """ try: action = "verify-email" user = get_user_by_action_token(action, action_token) if not user or not user.signed_data_match(signed_data, action): ...
python
def verify_email(self, action_token, signed_data): """ Verify email account, in which a link was sent to """ try: action = "verify-email" user = get_user_by_action_token(action, action_token) if not user or not user.signed_data_match(signed_data, action): ...
[ "def", "verify_email", "(", "self", ",", "action_token", ",", "signed_data", ")", ":", "try", ":", "action", "=", "\"verify-email\"", "user", "=", "get_user_by_action_token", "(", "action", ",", "action_token", ")", "if", "not", "user", "or", "not", "user", ...
Verify email account, in which a link was sent to
[ "Verify", "email", "account", "in", "which", "a", "link", "was", "sent", "to" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/auth.py#L372-L390
train
Verify email account in which a link was sent to
mardix/Mocha
mocha/contrib/views/auth.py
Login.oauth_connect
def oauth_connect(self, provider, action): """ This endpoint doesn't check if user is logged in, because it has two functions 1. If the user is not logged in, it will try to signup the user - if the social info exist, it will login - not, it will create a new account and...
python
def oauth_connect(self, provider, action): """ This endpoint doesn't check if user is logged in, because it has two functions 1. If the user is not logged in, it will try to signup the user - if the social info exist, it will login - not, it will create a new account and...
[ "def", "oauth_connect", "(", "self", ",", "provider", ",", "action", ")", ":", "valid_actions", "=", "[", "\"connect\"", ",", "\"authorized\"", ",", "\"test\"", "]", "_redirect", "=", "views", ".", "auth", ".", "Account", ".", "account_settings", "if", "is_a...
This endpoint doesn't check if user is logged in, because it has two functions 1. If the user is not logged in, it will try to signup the user - if the social info exist, it will login - not, it will create a new account and proceed 2. If user is logged in, it will try to create...
[ "This", "endpoint", "doesn", "t", "check", "if", "user", "is", "logged", "in", "because", "it", "has", "two", "functions" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/auth.py#L430-L537
train
This endpoint does not check if user is logged in and if it is authorized to connect to the endpoint
projectshift/shift-boiler
boiler/abstract/abstract_service.py
AbstractService.log
def log(self, message, level=None): """ Write a message to log """ if level is None: level = logging.INFO current_app.logger.log(msg=message, level=level)
python
def log(self, message, level=None): """ Write a message to log """ if level is None: level = logging.INFO current_app.logger.log(msg=message, level=level)
[ "def", "log", "(", "self", ",", "message", ",", "level", "=", "None", ")", ":", "if", "level", "is", "None", ":", "level", "=", "logging", ".", "INFO", "current_app", ".", "logger", ".", "log", "(", "msg", "=", "message", ",", "level", "=", "level"...
Write a message to log
[ "Write", "a", "message", "to", "log" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/abstract/abstract_service.py#L15-L20
train
Write a message to log
projectshift/shift-boiler
boiler/abstract/abstract_service.py
AbstractService.is_instance
def is_instance(self, model): """ Is instance? Checks if provided object is instance of this service's model. :param model: object :return: bool """ result = isinstance(model, self.__model__) if result is True: return ...
python
def is_instance(self, model): """ Is instance? Checks if provided object is instance of this service's model. :param model: object :return: bool """ result = isinstance(model, self.__model__) if result is True: return ...
[ "def", "is_instance", "(", "self", ",", "model", ")", ":", "result", "=", "isinstance", "(", "model", ",", "self", ".", "__model__", ")", "if", "result", "is", "True", ":", "return", "True", "err", "=", "'Object {} is not of type {}'", "raise", "ValueError",...
Is instance? Checks if provided object is instance of this service's model. :param model: object :return: bool
[ "Is", "instance?", "Checks", "if", "provided", "object", "is", "instance", "of", "this", "service", "s", "model", "." ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/abstract/abstract_service.py#L22-L35
train
Checks if provided object is instance of this service s model.
projectshift/shift-boiler
boiler/abstract/abstract_service.py
AbstractService.create
def create(self, **kwargs): """ Create Instantiates and persists new model populated from provided arguments :param kwargs: varargs, data to populate with :return: object, persisted new instance of model """ model = self.new(**kwar...
python
def create(self, **kwargs): """ Create Instantiates and persists new model populated from provided arguments :param kwargs: varargs, data to populate with :return: object, persisted new instance of model """ model = self.new(**kwar...
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "model", "=", "self", ".", "new", "(", "*", "*", "kwargs", ")", "return", "self", ".", "save", "(", "model", ")" ]
Create Instantiates and persists new model populated from provided arguments :param kwargs: varargs, data to populate with :return: object, persisted new instance of model
[ "Create", "Instantiates", "and", "persists", "new", "model", "populated", "from", "provided", "arguments" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/abstract/abstract_service.py#L58-L68
train
Create a new object populated from provided data and persists it
projectshift/shift-boiler
boiler/abstract/abstract_service.py
AbstractService.save
def save(self, model, commit=True): """ Save Puts model into unit of work for persistence. Can optionally commit transaction. Returns persisted model as a result. :param model: object, model to persist :param commit: bool, commit transaction? :...
python
def save(self, model, commit=True): """ Save Puts model into unit of work for persistence. Can optionally commit transaction. Returns persisted model as a result. :param model: object, model to persist :param commit: bool, commit transaction? :...
[ "def", "save", "(", "self", ",", "model", ",", "commit", "=", "True", ")", ":", "self", ".", "is_instance", "(", "model", ")", "db", ".", "session", ".", "add", "(", "model", ")", "if", "commit", ":", "db", ".", "session", ".", "commit", "(", ")"...
Save Puts model into unit of work for persistence. Can optionally commit transaction. Returns persisted model as a result. :param model: object, model to persist :param commit: bool, commit transaction? :return: object, saved model
[ "Save", "Puts", "model", "into", "unit", "of", "work", "for", "persistence", ".", "Can", "optionally", "commit", "transaction", ".", "Returns", "persisted", "model", "as", "a", "result", "." ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/abstract/abstract_service.py#L70-L85
train
Save a record into the database.
projectshift/shift-boiler
boiler/abstract/abstract_service.py
AbstractService.delete
def delete(self, model, commit=True): """ Delete Puts model for deletion into unit of work and optionall commits transaction :param model: object, model to delete :param commit: bool, commit? :return: object, deleted model ...
python
def delete(self, model, commit=True): """ Delete Puts model for deletion into unit of work and optionall commits transaction :param model: object, model to delete :param commit: bool, commit? :return: object, deleted model ...
[ "def", "delete", "(", "self", ",", "model", ",", "commit", "=", "True", ")", ":", "self", ".", "is_instance", "(", "model", ")", "db", ".", "session", ".", "delete", "(", "model", ")", "if", "commit", ":", "db", ".", "session", ".", "commit", "(", ...
Delete Puts model for deletion into unit of work and optionall commits transaction :param model: object, model to delete :param commit: bool, commit? :return: object, deleted model
[ "Delete", "Puts", "model", "for", "deletion", "into", "unit", "of", "work", "and", "optionall", "commits", "transaction" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/abstract/abstract_service.py#L87-L102
train
Deletes the specified object from the database.
inveniosoftware/invenio-pidrelations
invenio_pidrelations/alembic/1d4e361b7586_create_pidrelations_tables.py
upgrade
def upgrade(): """Upgrade database.""" op.create_table( 'pidrelations_pidrelation', sa.Column('created', sa.DateTime(), nullable=False), sa.Column('updated', sa.DateTime(), nullable=False), sa.Column('parent_id', sa.Integer(), nullable=False), sa.Column('child_id', sa.Int...
python
def upgrade(): """Upgrade database.""" op.create_table( 'pidrelations_pidrelation', sa.Column('created', sa.DateTime(), nullable=False), sa.Column('updated', sa.DateTime(), nullable=False), sa.Column('parent_id', sa.Integer(), nullable=False), sa.Column('child_id', sa.Int...
[ "def", "upgrade", "(", ")", ":", "op", ".", "create_table", "(", "'pidrelations_pidrelation'", ",", "sa", ".", "Column", "(", "'created'", ",", "sa", ".", "DateTime", "(", ")", ",", "nullable", "=", "False", ")", ",", "sa", ".", "Column", "(", "'update...
Upgrade database.
[ "Upgrade", "database", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/alembic/1d4e361b7586_create_pidrelations_tables.py#L36-L58
train
Upgrade database.
fjwCode/cerium
cerium/utils.py
is_connectable
def is_connectable(host: str, port: Union[int, str]) -> bool: """Tries to connect to the device to see if it is connectable. Args: host: The host to connect. port: The port to connect. Returns: True or False. """ socket_ = None try: socket_ = socket.create_conne...
python
def is_connectable(host: str, port: Union[int, str]) -> bool: """Tries to connect to the device to see if it is connectable. Args: host: The host to connect. port: The port to connect. Returns: True or False. """ socket_ = None try: socket_ = socket.create_conne...
[ "def", "is_connectable", "(", "host", ":", "str", ",", "port", ":", "Union", "[", "int", ",", "str", "]", ")", "->", "bool", ":", "socket_", "=", "None", "try", ":", "socket_", "=", "socket", ".", "create_connection", "(", "(", "host", ",", "port", ...
Tries to connect to the device to see if it is connectable. Args: host: The host to connect. port: The port to connect. Returns: True or False.
[ "Tries", "to", "connect", "to", "the", "device", "to", "see", "if", "it", "is", "connectable", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/utils.py#L34-L53
train
Tries to connect to the device to see if it is connectable.
projectshift/shift-boiler
boiler/collections/api_collection.py
ApiCollection.dict
def dict(self): """ Returns current collection as a dictionary """ collection = super().dict() serialized_items = [] for item in collection['items']: serialized_items.append(self.serializer(item)) collection['items'] = serialized_items return collection
python
def dict(self): """ Returns current collection as a dictionary """ collection = super().dict() serialized_items = [] for item in collection['items']: serialized_items.append(self.serializer(item)) collection['items'] = serialized_items return collection
[ "def", "dict", "(", "self", ")", ":", "collection", "=", "super", "(", ")", ".", "dict", "(", ")", "serialized_items", "=", "[", "]", "for", "item", "in", "collection", "[", "'items'", "]", ":", "serialized_items", ".", "append", "(", "self", ".", "s...
Returns current collection as a dictionary
[ "Returns", "current", "collection", "as", "a", "dictionary" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/collections/api_collection.py#L23-L31
train
Returns current collection as a dictionary
ronhanson/python-tbx
fabfile/__init__.py
init
def init(): """Execute init tasks for all components (virtualenv, pip).""" print(yellow("# Setting up development environment...\n", True)) virtualenv.init() virtualenv.update() print(green("\n# DONE.", True)) print(green("Type ") + green("activate", True) + green(" to enable your dev virtual en...
python
def init(): """Execute init tasks for all components (virtualenv, pip).""" print(yellow("# Setting up development environment...\n", True)) virtualenv.init() virtualenv.update() print(green("\n# DONE.", True)) print(green("Type ") + green("activate", True) + green(" to enable your dev virtual en...
[ "def", "init", "(", ")", ":", "print", "(", "yellow", "(", "\"# Setting up development environment...\\n\"", ",", "True", ")", ")", "virtualenv", ".", "init", "(", ")", "virtualenv", ".", "update", "(", ")", "print", "(", "green", "(", "\"\\n# DONE.\"", ",",...
Execute init tasks for all components (virtualenv, pip).
[ "Execute", "init", "tasks", "for", "all", "components", "(", "virtualenv", "pip", ")", "." ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/__init__.py#L11-L17
train
Execute init tasks for all components of virtualenv.
truveris/py-mdstat
mdstat/utils.py
group_lines
def group_lines(lines): """Split a list of lines using empty lines as separators.""" groups = [] group = [] for line in lines: if line.strip() == "": groups.append(group[:]) group = [] continue group.append(line) if group: groups.append(g...
python
def group_lines(lines): """Split a list of lines using empty lines as separators.""" groups = [] group = [] for line in lines: if line.strip() == "": groups.append(group[:]) group = [] continue group.append(line) if group: groups.append(g...
[ "def", "group_lines", "(", "lines", ")", ":", "groups", "=", "[", "]", "group", "=", "[", "]", "for", "line", "in", "lines", ":", "if", "line", ".", "strip", "(", ")", "==", "\"\"", ":", "groups", ".", "append", "(", "group", "[", ":", "]", ")"...
Split a list of lines using empty lines as separators.
[ "Split", "a", "list", "of", "lines", "using", "empty", "lines", "as", "separators", "." ]
881af99d1168694d2f38e606af377ef6cabe2297
https://github.com/truveris/py-mdstat/blob/881af99d1168694d2f38e606af377ef6cabe2297/mdstat/utils.py#L6-L21
train
Split a list of lines using empty lines as separators.
assamite/creamas
creamas/examples/grid/main.py
DistributedGridEnvironment.set_neighbors
async def set_neighbors(self): '''Set neighbors for multi-environments, their slave environments, and agents. ''' t = time.time() self.logger.debug("Settings grid neighbors for the multi-environments.") tasks = [] for i in range(len(self.grid)): for j ...
python
async def set_neighbors(self): '''Set neighbors for multi-environments, their slave environments, and agents. ''' t = time.time() self.logger.debug("Settings grid neighbors for the multi-environments.") tasks = [] for i in range(len(self.grid)): for j ...
[ "async", "def", "set_neighbors", "(", "self", ")", ":", "t", "=", "time", ".", "time", "(", ")", "self", ".", "logger", ".", "debug", "(", "\"Settings grid neighbors for the multi-environments.\"", ")", "tasks", "=", "[", "]", "for", "i", "in", "range", "(...
Set neighbors for multi-environments, their slave environments, and agents.
[ "Set", "neighbors", "for", "multi", "-", "environments", "their", "slave", "environments", "and", "agents", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/grid/main.py#L151-L186
train
Set neighbors for multi - environments their slave environments and agents.
assamite/creamas
creamas/ds.py
ssh_exec
async def ssh_exec(server, cmd, timeout=10, **ssh_kwargs): """Execute a command on a given server using asynchronous SSH-connection. The connection to the server is wrapped in :func:`asyncio.wait_for` and given :attr:`timeout` is applied to it. If the server is not reachable before timeout expires, :ex...
python
async def ssh_exec(server, cmd, timeout=10, **ssh_kwargs): """Execute a command on a given server using asynchronous SSH-connection. The connection to the server is wrapped in :func:`asyncio.wait_for` and given :attr:`timeout` is applied to it. If the server is not reachable before timeout expires, :ex...
[ "async", "def", "ssh_exec", "(", "server", ",", "cmd", ",", "timeout", "=", "10", ",", "*", "*", "ssh_kwargs", ")", ":", "conn", "=", "await", "asyncio", ".", "wait_for", "(", "asyncssh", ".", "connect", "(", "server", ",", "*", "*", "ssh_kwargs", ")...
Execute a command on a given server using asynchronous SSH-connection. The connection to the server is wrapped in :func:`asyncio.wait_for` and given :attr:`timeout` is applied to it. If the server is not reachable before timeout expires, :exc:`asyncio.TimeoutError` is raised. :param str server: Addres...
[ "Execute", "a", "command", "on", "a", "given", "server", "using", "asynchronous", "SSH", "-", "connection", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L28-L52
train
Execute a command on a given server using asynchronous SSH - connection.
assamite/creamas
creamas/ds.py
ssh_exec_in_new_loop
def ssh_exec_in_new_loop(server, cmd, timeout=10, **ssh_kwargs): """Same as :func:`ssh_exec` but creates a new event loop and executes :func:`ssh_exec` in that event loop. """ task = ssh_exec(server, cmd, timeout=timeout, **ssh_kwargs) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop)...
python
def ssh_exec_in_new_loop(server, cmd, timeout=10, **ssh_kwargs): """Same as :func:`ssh_exec` but creates a new event loop and executes :func:`ssh_exec` in that event loop. """ task = ssh_exec(server, cmd, timeout=timeout, **ssh_kwargs) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop)...
[ "def", "ssh_exec_in_new_loop", "(", "server", ",", "cmd", ",", "timeout", "=", "10", ",", "*", "*", "ssh_kwargs", ")", ":", "task", "=", "ssh_exec", "(", "server", ",", "cmd", ",", "timeout", "=", "timeout", ",", "*", "*", "ssh_kwargs", ")", "loop", ...
Same as :func:`ssh_exec` but creates a new event loop and executes :func:`ssh_exec` in that event loop.
[ "Same", "as", ":", "func", ":", "ssh_exec", "but", "creates", "a", "new", "event", "loop", "and", "executes", ":", "func", ":", "ssh_exec", "in", "that", "event", "loop", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L55-L62
train
Same as ssh_exec but creates a new event loop and executes it in that event loop.
assamite/creamas
creamas/ds.py
run_node
async def run_node(menv, log_folder): """Run :class:`~creamas.mp.MultiEnvironment` until its manager's :meth:`~aiomas.subproc.Manager.stop` is called. :param menv: :class:`~creamas.mp.MultiEnvironment` to wait for. :param str log_folder: Logging folder to be passed down to :meth:`~cream...
python
async def run_node(menv, log_folder): """Run :class:`~creamas.mp.MultiEnvironment` until its manager's :meth:`~aiomas.subproc.Manager.stop` is called. :param menv: :class:`~creamas.mp.MultiEnvironment` to wait for. :param str log_folder: Logging folder to be passed down to :meth:`~cream...
[ "async", "def", "run_node", "(", "menv", ",", "log_folder", ")", ":", "try", ":", "await", "menv", ".", "manager", ".", "stop_received", "except", "KeyboardInterrupt", ":", "pass", "finally", ":", "ret", "=", "await", "menv", ".", "destroy", "(", "log_fold...
Run :class:`~creamas.mp.MultiEnvironment` until its manager's :meth:`~aiomas.subproc.Manager.stop` is called. :param menv: :class:`~creamas.mp.MultiEnvironment` to wait for. :param str log_folder: Logging folder to be passed down to :meth:`~creamas.mp.MultiEnvironment.destroy` after :meth:`...
[ "Run", ":", "class", ":", "~creamas", ".", "mp", ".", "MultiEnvironment", "until", "its", "manager", "s", ":", "meth", ":", "~aiomas", ".", "subproc", ".", "Manager", ".", "stop", "is", "called", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L65-L94
train
Runs the node in the multi - environment.
assamite/creamas
creamas/ds.py
DistributedEnvironment.wait_nodes
async def wait_nodes(self, timeout, check_ready=True): """Wait until all nodes are online (their managers accept connections) or timeout expires. Should be called after :meth:`spawn_nodes`. This is an alias for :meth:`~creamas.mp.MultiEnvironment.wait_slaves`. """ return await s...
python
async def wait_nodes(self, timeout, check_ready=True): """Wait until all nodes are online (their managers accept connections) or timeout expires. Should be called after :meth:`spawn_nodes`. This is an alias for :meth:`~creamas.mp.MultiEnvironment.wait_slaves`. """ return await s...
[ "async", "def", "wait_nodes", "(", "self", ",", "timeout", ",", "check_ready", "=", "True", ")", ":", "return", "await", "self", ".", "wait_slaves", "(", "timeout", ",", "check_ready", "=", "check_ready", ")" ]
Wait until all nodes are online (their managers accept connections) or timeout expires. Should be called after :meth:`spawn_nodes`. This is an alias for :meth:`~creamas.mp.MultiEnvironment.wait_slaves`.
[ "Wait", "until", "all", "nodes", "are", "online", "(", "their", "managers", "accept", "connections", ")", "or", "timeout", "expires", ".", "Should", "be", "called", "after", ":", "meth", ":", "spawn_nodes", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L190-L196
train
Wait until all nodes are online or timeout expires. Should be called after spawn_nodes.
assamite/creamas
creamas/ds.py
DistributedEnvironment.spawn_nodes
async def spawn_nodes(self, spawn_cmd, ports=None, **ssh_kwargs): """An alias for :meth:`creamas.ds.DistributedEnvironment.spawn_slaves`. """ return await self.spawn_slaves(spawn_cmd, ports=ports, **ssh_kwargs)
python
async def spawn_nodes(self, spawn_cmd, ports=None, **ssh_kwargs): """An alias for :meth:`creamas.ds.DistributedEnvironment.spawn_slaves`. """ return await self.spawn_slaves(spawn_cmd, ports=ports, **ssh_kwargs)
[ "async", "def", "spawn_nodes", "(", "self", ",", "spawn_cmd", ",", "ports", "=", "None", ",", "*", "*", "ssh_kwargs", ")", ":", "return", "await", "self", ".", "spawn_slaves", "(", "spawn_cmd", ",", "ports", "=", "ports", ",", "*", "*", "ssh_kwargs", "...
An alias for :meth:`creamas.ds.DistributedEnvironment.spawn_slaves`.
[ "An", "alias", "for", ":", "meth", ":", "creamas", ".", "ds", ".", "DistributedEnvironment", ".", "spawn_slaves", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L198-L201
train
Spawn nodes on the local machine.
assamite/creamas
creamas/ds.py
DistributedEnvironment.spawn_slaves
async def spawn_slaves(self, spawn_cmd, ports=None, **ssh_kwargs): """Spawn multi-environments on the nodes through SSH-connections. :param spawn_cmd: str or list, command(s) used to spawn the environment on each node. If *list*, it must contain one command for each node in ...
python
async def spawn_slaves(self, spawn_cmd, ports=None, **ssh_kwargs): """Spawn multi-environments on the nodes through SSH-connections. :param spawn_cmd: str or list, command(s) used to spawn the environment on each node. If *list*, it must contain one command for each node in ...
[ "async", "def", "spawn_slaves", "(", "self", ",", "spawn_cmd", ",", "ports", "=", "None", ",", "*", "*", "ssh_kwargs", ")", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "len", "(", "self", ".", "nodes", ")", ")", "rets", "=", "[", "]", "f...
Spawn multi-environments on the nodes through SSH-connections. :param spawn_cmd: str or list, command(s) used to spawn the environment on each node. If *list*, it must contain one command for each node in :attr:`nodes`. If *str*, the same command is used for each node. ...
[ "Spawn", "multi", "-", "environments", "on", "the", "nodes", "through", "SSH", "-", "connections", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L203-L251
train
Spawn multi - environments on the nodes through SSH - connections.
assamite/creamas
creamas/ds.py
DistributedEnvironment.get_slave_managers
def get_slave_managers(self, as_coro=False): """Return all slave environment manager addresses. :param bool as_coro: If ``True`` returns awaitable coroutine, otherwise runs the calls to the slave managers asynchoronously in the event loop. This method returns the addres...
python
def get_slave_managers(self, as_coro=False): """Return all slave environment manager addresses. :param bool as_coro: If ``True`` returns awaitable coroutine, otherwise runs the calls to the slave managers asynchoronously in the event loop. This method returns the addres...
[ "def", "get_slave_managers", "(", "self", ",", "as_coro", "=", "False", ")", ":", "async", "def", "slave_task", "(", "addr", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")", "return", "await", "r_manager", ".", ...
Return all slave environment manager addresses. :param bool as_coro: If ``True`` returns awaitable coroutine, otherwise runs the calls to the slave managers asynchoronously in the event loop. This method returns the addresses of the true slave environment managers, i.e....
[ "Return", "all", "slave", "environment", "manager", "addresses", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L262-L280
train
Return all slave environment manager addresses.
berkeley-cocosci/Wallace
wallace/models.py
Participant.nodes
def nodes(self, type=None, failed=False): """Get nodes associated with this participant. Return a list of nodes associated with the participant. If specified, ``type`` filters by class. By default failed nodes are excluded, to include only failed nodes use ``failed=True``, for all nodes...
python
def nodes(self, type=None, failed=False): """Get nodes associated with this participant. Return a list of nodes associated with the participant. If specified, ``type`` filters by class. By default failed nodes are excluded, to include only failed nodes use ``failed=True``, for all nodes...
[ "def", "nodes", "(", "self", ",", "type", "=", "None", ",", "failed", "=", "False", ")", ":", "if", "type", "is", "None", ":", "type", "=", "Node", "if", "not", "issubclass", "(", "type", ",", "Node", ")", ":", "raise", "(", "TypeError", "(", "\"...
Get nodes associated with this participant. Return a list of nodes associated with the participant. If specified, ``type`` filters by class. By default failed nodes are excluded, to include only failed nodes use ``failed=True``, for all nodes use ``failed=all``.
[ "Get", "nodes", "associated", "with", "this", "participant", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L152-L179
train
Get a list of nodes associated with this participant.
berkeley-cocosci/Wallace
wallace/models.py
Network.print_verbose
def print_verbose(self): """Print a verbose representation of a network.""" print "Nodes: " for a in (self.nodes(failed="all")): print a print "\nVectors: " for v in (self.vectors(failed="all")): print v print "\nInfos: " for i in (self.i...
python
def print_verbose(self): """Print a verbose representation of a network.""" print "Nodes: " for a in (self.nodes(failed="all")): print a print "\nVectors: " for v in (self.vectors(failed="all")): print v print "\nInfos: " for i in (self.i...
[ "def", "print_verbose", "(", "self", ")", ":", "print", "\"Nodes: \"", "for", "a", "in", "(", "self", ".", "nodes", "(", "failed", "=", "\"all\"", ")", ")", ":", "print", "a", "print", "\"\\nVectors: \"", "for", "v", "in", "(", "self", ".", "vectors", ...
Print a verbose representation of a network.
[ "Print", "a", "verbose", "representation", "of", "a", "network", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L559-L579
train
Print a verbose representation of a network.
berkeley-cocosci/Wallace
wallace/models.py
Node.vectors
def vectors(self, direction="all", failed=False): """Get vectors that connect at this node. Direction can be "incoming", "outgoing" or "all" (default). Failed can be True, False or all """ # check direction if direction not in ["all", "incoming", "outgoing"]: ...
python
def vectors(self, direction="all", failed=False): """Get vectors that connect at this node. Direction can be "incoming", "outgoing" or "all" (default). Failed can be True, False or all """ # check direction if direction not in ["all", "incoming", "outgoing"]: ...
[ "def", "vectors", "(", "self", ",", "direction", "=", "\"all\"", ",", "failed", "=", "False", ")", ":", "# check direction", "if", "direction", "not", "in", "[", "\"all\"", ",", "\"incoming\"", ",", "\"outgoing\"", "]", ":", "raise", "ValueError", "(", "\"...
Get vectors that connect at this node. Direction can be "incoming", "outgoing" or "all" (default). Failed can be True, False or all
[ "Get", "vectors", "that", "connect", "at", "this", "node", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L655-L703
train
Get the vectors that connect at this node.
berkeley-cocosci/Wallace
wallace/models.py
Node.transmissions
def transmissions(self, direction="outgoing", status="all", failed=False): """Get transmissions sent to or from this node. Direction can be "all", "incoming" or "outgoing" (default). Status can be "all" (default), "pending", or "received". failed can be True, False or "all" """ ...
python
def transmissions(self, direction="outgoing", status="all", failed=False): """Get transmissions sent to or from this node. Direction can be "all", "incoming" or "outgoing" (default). Status can be "all" (default), "pending", or "received". failed can be True, False or "all" """ ...
[ "def", "transmissions", "(", "self", ",", "direction", "=", "\"outgoing\"", ",", "status", "=", "\"all\"", ",", "failed", "=", "False", ")", ":", "# check parameters", "if", "direction", "not", "in", "[", "\"incoming\"", ",", "\"outgoing\"", ",", "\"all\"", ...
Get transmissions sent to or from this node. Direction can be "all", "incoming" or "outgoing" (default). Status can be "all" (default), "pending", or "received". failed can be True, False or "all"
[ "Get", "transmissions", "sent", "to", "or", "from", "this", "node", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L915-L973
train
Get all transmissions from this node.
berkeley-cocosci/Wallace
wallace/models.py
Node.flatten
def flatten(self, l): """Turn a list of lists into a list.""" if l == []: return l if isinstance(l[0], list): return self.flatten(l[0]) + self.flatten(l[1:]) return l[:1] + self.flatten(l[1:])
python
def flatten(self, l): """Turn a list of lists into a list.""" if l == []: return l if isinstance(l[0], list): return self.flatten(l[0]) + self.flatten(l[1:]) return l[:1] + self.flatten(l[1:])
[ "def", "flatten", "(", "self", ",", "l", ")", ":", "if", "l", "==", "[", "]", ":", "return", "l", "if", "isinstance", "(", "l", "[", "0", "]", ",", "list", ")", ":", "return", "self", ".", "flatten", "(", "l", "[", "0", "]", ")", "+", "self...
Turn a list of lists into a list.
[ "Turn", "a", "list", "of", "lists", "into", "a", "list", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L1092-L1098
train
Turn a list of lists into a list.
berkeley-cocosci/Wallace
wallace/models.py
Node.transmit
def transmit(self, what=None, to_whom=None): """Transmit one or more infos from one node to another. "what" dictates which infos are sent, it can be: (1) None (in which case the node's _what method is called). (2) an Info (in which case the node transmits the info) (...
python
def transmit(self, what=None, to_whom=None): """Transmit one or more infos from one node to another. "what" dictates which infos are sent, it can be: (1) None (in which case the node's _what method is called). (2) an Info (in which case the node transmits the info) (...
[ "def", "transmit", "(", "self", ",", "what", "=", "None", ",", "to_whom", "=", "None", ")", ":", "# make the list of what", "what", "=", "self", ".", "flatten", "(", "[", "what", "]", ")", "for", "i", "in", "range", "(", "len", "(", "what", ")", ")...
Transmit one or more infos from one node to another. "what" dictates which infos are sent, it can be: (1) None (in which case the node's _what method is called). (2) an Info (in which case the node transmits the info) (3) a subclass of Info (in which case the node transmits ...
[ "Transmit", "one", "or", "more", "infos", "from", "one", "node", "to", "another", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L1100-L1164
train
Transmit one or more infos from one node to another.
berkeley-cocosci/Wallace
wallace/models.py
Node.receive
def receive(self, what=None): """Receive some transmissions. Received transmissions are marked as received, then their infos are passed to update(). "what" can be: 1. None (the default) in which case all pending transmissions are received. 2. a s...
python
def receive(self, what=None): """Receive some transmissions. Received transmissions are marked as received, then their infos are passed to update(). "what" can be: 1. None (the default) in which case all pending transmissions are received. 2. a s...
[ "def", "receive", "(", "self", ",", "what", "=", "None", ")", ":", "# check self is not failed", "if", "self", ".", "failed", ":", "raise", "ValueError", "(", "\"{} cannot receive as it has failed.\"", ".", "format", "(", "self", ")", ")", "received_transmissions"...
Receive some transmissions. Received transmissions are marked as received, then their infos are passed to update(). "what" can be: 1. None (the default) in which case all pending transmissions are received. 2. a specific transmission. Will raise...
[ "Receive", "some", "transmissions", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L1186-L1229
train
Receive some transmissions and update the node s info.
berkeley-cocosci/Wallace
wallace/models.py
Node.replicate
def replicate(self, info_in): """Replicate an info.""" # check self is not failed if self.failed: raise ValueError("{} cannot replicate as it has failed." .format(self)) from transformations import Replication info_out = type(info_in)(ori...
python
def replicate(self, info_in): """Replicate an info.""" # check self is not failed if self.failed: raise ValueError("{} cannot replicate as it has failed." .format(self)) from transformations import Replication info_out = type(info_in)(ori...
[ "def", "replicate", "(", "self", ",", "info_in", ")", ":", "# check self is not failed", "if", "self", ".", "failed", ":", "raise", "ValueError", "(", "\"{} cannot replicate as it has failed.\"", ".", "format", "(", "self", ")", ")", "from", "transformations", "im...
Replicate an info.
[ "Replicate", "an", "info", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L1241-L1250
train
Replicate an info.
berkeley-cocosci/Wallace
wallace/models.py
Node.mutate
def mutate(self, info_in): """Replicate an info + mutation. To mutate an info, that info must have a method called ``_mutated_contents``. """ # check self is not failed if self.failed: raise ValueError("{} cannot mutate as it has failed.".format(self)) ...
python
def mutate(self, info_in): """Replicate an info + mutation. To mutate an info, that info must have a method called ``_mutated_contents``. """ # check self is not failed if self.failed: raise ValueError("{} cannot mutate as it has failed.".format(self)) ...
[ "def", "mutate", "(", "self", ",", "info_in", ")", ":", "# check self is not failed", "if", "self", ".", "failed", ":", "raise", "ValueError", "(", "\"{} cannot mutate as it has failed.\"", ".", "format", "(", "self", ")", ")", "from", "transformations", "import",...
Replicate an info + mutation. To mutate an info, that info must have a method called ``_mutated_contents``.
[ "Replicate", "an", "info", "+", "mutation", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L1252-L1266
train
Replicate an info + mutation.
berkeley-cocosci/Wallace
wallace/models.py
Vector.transmissions
def transmissions(self, status="all"): """Get transmissions sent along this Vector. Status can be "all" (the default), "pending", or "received". """ if status not in ["all", "pending", "received"]: raise(ValueError("You cannot get {} transmissions." ...
python
def transmissions(self, status="all"): """Get transmissions sent along this Vector. Status can be "all" (the default), "pending", or "received". """ if status not in ["all", "pending", "received"]: raise(ValueError("You cannot get {} transmissions." ...
[ "def", "transmissions", "(", "self", ",", "status", "=", "\"all\"", ")", ":", "if", "status", "not", "in", "[", "\"all\"", ",", "\"pending\"", ",", "\"received\"", "]", ":", "raise", "(", "ValueError", "(", "\"You cannot get {} transmissions.\"", ".", "format"...
Get transmissions sent along this Vector. Status can be "all" (the default), "pending", or "received".
[ "Get", "transmissions", "sent", "along", "this", "Vector", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L1358-L1380
train
Get all transmissions sent along this Vector.
Ceasar/twosheds
twosheds/shell.py
Shell.serve_forever
def serve_forever(self, banner=None): """Interact with the user. :param banner: (optional) the banner to print before the first interaction. Defaults to ``None``. """ if hasattr(readline, "read_history_file"): try: readline.read_history...
python
def serve_forever(self, banner=None): """Interact with the user. :param banner: (optional) the banner to print before the first interaction. Defaults to ``None``. """ if hasattr(readline, "read_history_file"): try: readline.read_history...
[ "def", "serve_forever", "(", "self", ",", "banner", "=", "None", ")", ":", "if", "hasattr", "(", "readline", ",", "\"read_history_file\"", ")", ":", "try", ":", "readline", ".", "read_history_file", "(", "self", ".", "histfile", ")", "except", "IOError", "...
Interact with the user. :param banner: (optional) the banner to print before the first interaction. Defaults to ``None``.
[ "Interact", "with", "the", "user", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/shell.py#L74-L86
train
Interact with the user.
Ceasar/twosheds
twosheds/completer.py
Completer.complete
def complete(self, word, state): """Return the next possible completion for ``word``. This is called successively with ``state == 0, 1, 2, ...`` until it returns ``None``. The completion should begin with ``word``. :param word: the word to complete :param state: an int...
python
def complete(self, word, state): """Return the next possible completion for ``word``. This is called successively with ``state == 0, 1, 2, ...`` until it returns ``None``. The completion should begin with ``word``. :param word: the word to complete :param state: an int...
[ "def", "complete", "(", "self", ",", "word", ",", "state", ")", ":", "try", ":", "import", "rl", "# TODO: doing this manually right now, but may make sense to", "# exploit", "rl", ".", "completion", ".", "suppress_append", "=", "True", "except", "ImportError", ":", ...
Return the next possible completion for ``word``. This is called successively with ``state == 0, 1, 2, ...`` until it returns ``None``. The completion should begin with ``word``. :param word: the word to complete :param state: an int, used to iterate over the choices
[ "Return", "the", "next", "possible", "completion", "for", "word", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L97-L125
train
Return the next possible completion for word.
Ceasar/twosheds
twosheds/completer.py
Completer.exclude_matches
def exclude_matches(self, matches): """Filter any matches that match an exclude pattern. :param matches: a list of possible completions """ for match in matches: for exclude_pattern in self.exclude_patterns: if re.match(exclude_pattern, match) is not None: ...
python
def exclude_matches(self, matches): """Filter any matches that match an exclude pattern. :param matches: a list of possible completions """ for match in matches: for exclude_pattern in self.exclude_patterns: if re.match(exclude_pattern, match) is not None: ...
[ "def", "exclude_matches", "(", "self", ",", "matches", ")", ":", "for", "match", "in", "matches", ":", "for", "exclude_pattern", "in", "self", ".", "exclude_patterns", ":", "if", "re", ".", "match", "(", "exclude_pattern", ",", "match", ")", "is", "not", ...
Filter any matches that match an exclude pattern. :param matches: a list of possible completions
[ "Filter", "any", "matches", "that", "match", "an", "exclude", "pattern", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L127-L137
train
Filter any matches that match an exclude pattern.
Ceasar/twosheds
twosheds/completer.py
Completer.gen_filename_completions
def gen_filename_completions(self, word, filenames): """Generate a sequence of filenames that match ``word``. :param word: the word to complete """ if not word: return filenames else: trie = pygtrie.CharTrie() for filename in filenames: ...
python
def gen_filename_completions(self, word, filenames): """Generate a sequence of filenames that match ``word``. :param word: the word to complete """ if not word: return filenames else: trie = pygtrie.CharTrie() for filename in filenames: ...
[ "def", "gen_filename_completions", "(", "self", ",", "word", ",", "filenames", ")", ":", "if", "not", "word", ":", "return", "filenames", "else", ":", "trie", "=", "pygtrie", ".", "CharTrie", "(", ")", "for", "filename", "in", "filenames", ":", "trie", "...
Generate a sequence of filenames that match ``word``. :param word: the word to complete
[ "Generate", "a", "sequence", "of", "filenames", "that", "match", "word", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L142-L153
train
Generate a sequence of filenames that match word.
Ceasar/twosheds
twosheds/completer.py
Completer.gen_matches
def gen_matches(self, word): """Generate a sequence of possible completions for ``word``. :param word: the word to complete """ if word.startswith("$"): for match in self.gen_variable_completions(word, os.environ): yield match else: head,...
python
def gen_matches(self, word): """Generate a sequence of possible completions for ``word``. :param word: the word to complete """ if word.startswith("$"): for match in self.gen_variable_completions(word, os.environ): yield match else: head,...
[ "def", "gen_matches", "(", "self", ",", "word", ")", ":", "if", "word", ".", "startswith", "(", "\"$\"", ")", ":", "for", "match", "in", "self", ".", "gen_variable_completions", "(", "word", ",", "os", ".", "environ", ")", ":", "yield", "match", "else"...
Generate a sequence of possible completions for ``word``. :param word: the word to complete
[ "Generate", "a", "sequence", "of", "possible", "completions", "for", "word", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L155-L172
train
Generate a sequence of possible completions for word.
Ceasar/twosheds
twosheds/completer.py
Completer.gen_variable_completions
def gen_variable_completions(self, word, env): """Generate a sequence of possible variable completions for ``word``. :param word: the word to complete :param env: the environment """ # ignore the first character, which is a dollar sign var = word[1:] for k in env...
python
def gen_variable_completions(self, word, env): """Generate a sequence of possible variable completions for ``word``. :param word: the word to complete :param env: the environment """ # ignore the first character, which is a dollar sign var = word[1:] for k in env...
[ "def", "gen_variable_completions", "(", "self", ",", "word", ",", "env", ")", ":", "# ignore the first character, which is a dollar sign", "var", "=", "word", "[", "1", ":", "]", "for", "k", "in", "env", ":", "if", "k", ".", "startswith", "(", "var", ")", ...
Generate a sequence of possible variable completions for ``word``. :param word: the word to complete :param env: the environment
[ "Generate", "a", "sequence", "of", "possible", "variable", "completions", "for", "word", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L174-L184
train
Generate a sequence of possible variable completions for word.
Ceasar/twosheds
twosheds/completer.py
Completer.get_matches
def get_matches(self, word): """ Get a list of filenames with match *word*. """ matches = self.gen_matches(word) # defend this against bad user input for regular expression patterns try: matches = self.exclude_matches(matches) except Exception: ...
python
def get_matches(self, word): """ Get a list of filenames with match *word*. """ matches = self.gen_matches(word) # defend this against bad user input for regular expression patterns try: matches = self.exclude_matches(matches) except Exception: ...
[ "def", "get_matches", "(", "self", ",", "word", ")", ":", "matches", "=", "self", ".", "gen_matches", "(", "word", ")", "# defend this against bad user input for regular expression patterns", "try", ":", "matches", "=", "self", ".", "exclude_matches", "(", "matches"...
Get a list of filenames with match *word*.
[ "Get", "a", "list", "of", "filenames", "with", "match", "*", "word", "*", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L186-L200
train
Get a list of filenames with match word.
Ceasar/twosheds
twosheds/completer.py
Completer.inflect
def inflect(self, filename): """Inflect a filename to indicate its type. If the file is a directory, the suffix "/" is appended, otherwise a space is appended. :param filename: the name of the file to inflect """ suffix = ("/" if os.path.isdir(filename) else " ") ...
python
def inflect(self, filename): """Inflect a filename to indicate its type. If the file is a directory, the suffix "/" is appended, otherwise a space is appended. :param filename: the name of the file to inflect """ suffix = ("/" if os.path.isdir(filename) else " ") ...
[ "def", "inflect", "(", "self", ",", "filename", ")", ":", "suffix", "=", "(", "\"/\"", "if", "os", ".", "path", ".", "isdir", "(", "filename", ")", "else", "\" \"", ")", "return", "self", ".", "_escape", "(", "filename", ")", "+", "suffix" ]
Inflect a filename to indicate its type. If the file is a directory, the suffix "/" is appended, otherwise a space is appended. :param filename: the name of the file to inflect
[ "Inflect", "a", "filename", "to", "indicate", "its", "type", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L202-L211
train
Inflect a filename to indicate its type.
berkeley-cocosci/Wallace
wallace/nodes.py
Environment.state
def state(self, time=None): """The most recently-created info of type State at the specfied time. If time is None then it returns the most recent state as of now. """ if time is None: return max(self.infos(type=State), key=attrgetter('creation_time')) else: ...
python
def state(self, time=None): """The most recently-created info of type State at the specfied time. If time is None then it returns the most recent state as of now. """ if time is None: return max(self.infos(type=State), key=attrgetter('creation_time')) else: ...
[ "def", "state", "(", "self", ",", "time", "=", "None", ")", ":", "if", "time", "is", "None", ":", "return", "max", "(", "self", ".", "infos", "(", "type", "=", "State", ")", ",", "key", "=", "attrgetter", "(", "'creation_time'", ")", ")", "else", ...
The most recently-created info of type State at the specfied time. If time is None then it returns the most recent state as of now.
[ "The", "most", "recently", "-", "created", "info", "of", "type", "State", "at", "the", "specfied", "time", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/nodes.py#L96-L106
train
Returns the most recently - created info of type State at the specified time.
projectshift/shift-boiler
boiler/feature/sentry.py
sentry_feature
def sentry_feature(app): """ Sentry feature Adds basic integration with Sentry via the raven library """ # get keys sentry_public_key = app.config.get('SENTRY_PUBLIC_KEY') sentry_project_id = app.config.get('SENTRY_PROJECT_ID') if not sentry_public_key or not sentry_project_id: ...
python
def sentry_feature(app): """ Sentry feature Adds basic integration with Sentry via the raven library """ # get keys sentry_public_key = app.config.get('SENTRY_PUBLIC_KEY') sentry_project_id = app.config.get('SENTRY_PROJECT_ID') if not sentry_public_key or not sentry_project_id: ...
[ "def", "sentry_feature", "(", "app", ")", ":", "# get keys", "sentry_public_key", "=", "app", ".", "config", ".", "get", "(", "'SENTRY_PUBLIC_KEY'", ")", "sentry_project_id", "=", "app", ".", "config", ".", "get", "(", "'SENTRY_PROJECT_ID'", ")", "if", "not", ...
Sentry feature Adds basic integration with Sentry via the raven library
[ "Sentry", "feature", "Adds", "basic", "integration", "with", "Sentry", "via", "the", "raven", "library" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/sentry.py#L6-L23
train
Sentry feature for the base app
20c/pluginmgr
pluginmgr/config.py
ConfigPluginManager.new_plugin
def new_plugin(self, config, *args, **kwargs): """ instantiate a plugin creates the object, stores it in _instance """ typ = None obj = None # if type is defined, create a new instance if 'type' in config: typ = config['type'] # singl...
python
def new_plugin(self, config, *args, **kwargs): """ instantiate a plugin creates the object, stores it in _instance """ typ = None obj = None # if type is defined, create a new instance if 'type' in config: typ = config['type'] # singl...
[ "def", "new_plugin", "(", "self", ",", "config", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "typ", "=", "None", "obj", "=", "None", "# if type is defined, create a new instance", "if", "'type'", "in", "config", ":", "typ", "=", "config", "[", "...
instantiate a plugin creates the object, stores it in _instance
[ "instantiate", "a", "plugin", "creates", "the", "object", "stores", "it", "in", "_instance" ]
ea19edab6d145f539641c304745acd4ab2c67eb7
https://github.com/20c/pluginmgr/blob/ea19edab6d145f539641c304745acd4ab2c67eb7/pluginmgr/config.py#L47-L73
train
instantiate a new plugin
20c/pluginmgr
pluginmgr/config.py
ConfigPluginManager.get_instance
def get_instance(self, node, *args, **kwargs): """ get plugin instance from config node *NOTE* returns an uninitialized instance if one isn't there *NOTE* instantiated plugins without names remain anonymous FIXME - why would instantiate() even process them """ ...
python
def get_instance(self, node, *args, **kwargs): """ get plugin instance from config node *NOTE* returns an uninitialized instance if one isn't there *NOTE* instantiated plugins without names remain anonymous FIXME - why would instantiate() even process them """ ...
[ "def", "get_instance", "(", "self", ",", "node", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# string is a ref to an existing plugin instance", "if", "isinstance", "(", "node", ",", "basestring", ")", ":", "if", "node", "in", "self", ".", "_instanc...
get plugin instance from config node *NOTE* returns an uninitialized instance if one isn't there *NOTE* instantiated plugins without names remain anonymous FIXME - why would instantiate() even process them
[ "get", "plugin", "instance", "from", "config", "node", "*", "NOTE", "*", "returns", "an", "uninitialized", "instance", "if", "one", "isn", "t", "there", "*", "NOTE", "*", "instantiated", "plugins", "without", "names", "remain", "anonymous", "FIXME", "-", "wh...
ea19edab6d145f539641c304745acd4ab2c67eb7
https://github.com/20c/pluginmgr/blob/ea19edab6d145f539641c304745acd4ab2c67eb7/pluginmgr/config.py#L75-L106
train
get an instance of a node from the config
20c/pluginmgr
pluginmgr/config.py
ConfigPluginManager.instantiate
def instantiate(self, config, *args, **kwargs): """ takes plugin config (list under 'plugin') and instantiates defined plugins """ for plugin_config in config: self.new_plugin(plugin_config, *args, **kwargs)
python
def instantiate(self, config, *args, **kwargs): """ takes plugin config (list under 'plugin') and instantiates defined plugins """ for plugin_config in config: self.new_plugin(plugin_config, *args, **kwargs)
[ "def", "instantiate", "(", "self", ",", "config", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "plugin_config", "in", "config", ":", "self", ".", "new_plugin", "(", "plugin_config", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
takes plugin config (list under 'plugin') and instantiates defined plugins
[ "takes", "plugin", "config", "(", "list", "under", "plugin", ")", "and", "instantiates", "defined", "plugins" ]
ea19edab6d145f539641c304745acd4ab2c67eb7
https://github.com/20c/pluginmgr/blob/ea19edab6d145f539641c304745acd4ab2c67eb7/pluginmgr/config.py#L108-L114
train
Instantiates all the available plugins and adds them to the internal cache.