repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
tanghaibao/goatools
goatools/parsers/david_chart.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L70-L72
def wr_xlsx(self, fout_xlsx, nts): """Write specified namedtuples into an Excel spreadsheet.""" wr_xlsx(fout_xlsx, nts, prt_flds=self.prt_flds, fld2col_widths=self.fld2col_widths)
[ "def", "wr_xlsx", "(", "self", ",", "fout_xlsx", ",", "nts", ")", ":", "wr_xlsx", "(", "fout_xlsx", ",", "nts", ",", "prt_flds", "=", "self", ".", "prt_flds", ",", "fld2col_widths", "=", "self", ".", "fld2col_widths", ")" ]
Write specified namedtuples into an Excel spreadsheet.
[ "Write", "specified", "namedtuples", "into", "an", "Excel", "spreadsheet", "." ]
python
train
64.333333
twisted/twistedchecker
twistedchecker/core/runner.py
https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/core/runner.py#L368-L385
def generateDiff(self, oldWarnings, newWarnings): """ Generate diff between given two lists of warnings. @param oldWarnings: parsed old warnings @param newWarnings: parsed new warnings @return: a dict object of diff """ diffWarnings = {} for modulename i...
[ "def", "generateDiff", "(", "self", ",", "oldWarnings", ",", "newWarnings", ")", ":", "diffWarnings", "=", "{", "}", "for", "modulename", "in", "newWarnings", ":", "diffInModule", "=", "(", "newWarnings", "[", "modulename", "]", "-", "oldWarnings", ".", "get...
Generate diff between given two lists of warnings. @param oldWarnings: parsed old warnings @param newWarnings: parsed new warnings @return: a dict object of diff
[ "Generate", "diff", "between", "given", "two", "lists", "of", "warnings", "." ]
python
train
30.777778
jlmadurga/permabots
permabots/views/api/bot.py
https://github.com/jlmadurga/permabots/blob/781a91702529a23fe7bc2aa84c5d88e961412466/permabots/views/api/bot.py#L245-L256
def put(self, request, bot_id, id, format=None): """ Update existing KikBot --- serializer: KikBotUpdateSerializer responseMessages: - code: 401 message: Not authenticated - code: 400 message: Not valid request """ ...
[ "def", "put", "(", "self", ",", "request", ",", "bot_id", ",", "id", ",", "format", "=", "None", ")", ":", "return", "super", "(", "KikBotDetail", ",", "self", ")", ".", "put", "(", "request", ",", "bot_id", ",", "id", ",", "format", ")" ]
Update existing KikBot --- serializer: KikBotUpdateSerializer responseMessages: - code: 401 message: Not authenticated - code: 400 message: Not valid request
[ "Update", "existing", "KikBot", "---", "serializer", ":", "KikBotUpdateSerializer", "responseMessages", ":", "-", "code", ":", "401", "message", ":", "Not", "authenticated", "-", "code", ":", "400", "message", ":", "Not", "valid", "request" ]
python
train
31.916667
hazelcast/hazelcast-python-client
hazelcast/protocol/codec/set_contains_all_codec.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/protocol/codec/set_contains_all_codec.py#L10-L17
def calculate_size(name, items): """ Calculates the request payload size""" data_size = 0 data_size += calculate_size_str(name) data_size += INT_SIZE_IN_BYTES for items_item in items: data_size += calculate_size_data(items_item) return data_size
[ "def", "calculate_size", "(", "name", ",", "items", ")", ":", "data_size", "=", "0", "data_size", "+=", "calculate_size_str", "(", "name", ")", "data_size", "+=", "INT_SIZE_IN_BYTES", "for", "items_item", "in", "items", ":", "data_size", "+=", "calculate_size_da...
Calculates the request payload size
[ "Calculates", "the", "request", "payload", "size" ]
python
train
33.75
MatterMiners/cobald
cobald/daemon/core/config.py
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/core/config.py#L10-L23
def load(config_path: str): """ Load a configuration and keep it alive for the given context :param config_path: path to a configuration file """ # we bind the config to _ to keep it alive if os.path.splitext(config_path)[1] in ('.yaml', '.yml'): _ = load_yaml_configuration(config_path,...
[ "def", "load", "(", "config_path", ":", "str", ")", ":", "# we bind the config to _ to keep it alive", "if", "os", ".", "path", ".", "splitext", "(", "config_path", ")", "[", "1", "]", "in", "(", "'.yaml'", ",", "'.yml'", ")", ":", "_", "=", "load_yaml_con...
Load a configuration and keep it alive for the given context :param config_path: path to a configuration file
[ "Load", "a", "configuration", "and", "keep", "it", "alive", "for", "the", "given", "context" ]
python
train
40.142857
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/oinspect.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/oinspect.py#L461-L479
def _format_fields(self, fields, title_width=12): """Formats a list of fields for display. Parameters ---------- fields : list A list of 2-tuples: (field_title, field_content) title_width : int How many characters to pad titles to. Default 12. """ ...
[ "def", "_format_fields", "(", "self", ",", "fields", ",", "title_width", "=", "12", ")", ":", "out", "=", "[", "]", "header", "=", "self", ".", "__head", "for", "title", ",", "content", "in", "fields", ":", "if", "len", "(", "content", ".", "splitlin...
Formats a list of fields for display. Parameters ---------- fields : list A list of 2-tuples: (field_title, field_content) title_width : int How many characters to pad titles to. Default 12.
[ "Formats", "a", "list", "of", "fields", "for", "display", "." ]
python
test
33.157895
angr/angr
angr/simos/javavm.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/simos/javavm.py#L194-L258
def state_call(self, addr, *args, **kwargs): """ Create a native or a Java call state. :param addr: Soot or native addr of the invoke target. :param args: List of SootArgument values. """ state = kwargs.pop('base_state', None) # check if we need to setup a n...
[ "def", "state_call", "(", "self", ",", "addr", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "state", "=", "kwargs", ".", "pop", "(", "'base_state'", ",", "None", ")", "# check if we need to setup a native or a java callsite", "if", "isinstance", "(", ...
Create a native or a Java call state. :param addr: Soot or native addr of the invoke target. :param args: List of SootArgument values.
[ "Create", "a", "native", "or", "a", "Java", "call", "state", "." ]
python
train
49.061538
Ezhil-Language-Foundation/open-tamil
tamil/txt2unicode/encode2unicode.py
https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/tamil/txt2unicode/encode2unicode.py#L292-L330
def auto2unicode(text): """ This function tries to identify encode in available encodings. If it finds, then it will convert text into unicode string. Author : Arulalan.T 04.08.2014 """ _all_unique_encodes_, _all_common_encodes_ = _get_unique_common_encodes() # get unique...
[ "def", "auto2unicode", "(", "text", ")", ":", "_all_unique_encodes_", ",", "_all_common_encodes_", "=", "_get_unique_common_encodes", "(", ")", "# get unique word which falls under any one of available encodes from\r", "# user passed text lines\r", "unique_chars", "=", "_get_unique...
This function tries to identify encode in available encodings. If it finds, then it will convert text into unicode string. Author : Arulalan.T 04.08.2014
[ "This", "function", "tries", "to", "identify", "encode", "in", "available", "encodings", ".", "If", "it", "finds", "then", "it", "will", "convert", "text", "into", "unicode", "string", ".", "Author", ":", "Arulalan", ".", "T", "04", ".", "08", ".", "2014...
python
train
34.102564
PolyJIT/benchbuild
benchbuild/utils/wrapping.py
https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/wrapping.py#L86-L136
def wrap(name, project, sprefix=None, python=sys.executable): """ Wrap the binary :name: with the runtime extension of the project. This module generates a python tool that replaces :name: The function in runner only accepts the replaced binaries name as argument. We use the cloudpickle package to ...
[ "def", "wrap", "(", "name", ",", "project", ",", "sprefix", "=", "None", ",", "python", "=", "sys", ".", "executable", ")", ":", "env", "=", "__create_jinja_env", "(", ")", "template", "=", "env", ".", "get_template", "(", "'run_static.py.inc'", ")", "na...
Wrap the binary :name: with the runtime extension of the project. This module generates a python tool that replaces :name: The function in runner only accepts the replaced binaries name as argument. We use the cloudpickle package to perform the serialization, make sure :runner: can be serialized wi...
[ "Wrap", "the", "binary", ":", "name", ":", "with", "the", "runtime", "extension", "of", "the", "project", "." ]
python
train
34.490196
spacetelescope/acstools
acstools/calacs.py
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/calacs.py#L28-L104
def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False, verbose=False, debug=False, quiet=False, single_core=False, exe_args=None): """ Run the calacs.e executable as from the shell. By default this will run the calacs given by 'calacs.e'. Parameters -----...
[ "def", "calacs", "(", "input_file", ",", "exec_path", "=", "None", ",", "time_stamps", "=", "False", ",", "temp_files", "=", "False", ",", "verbose", "=", "False", ",", "debug", "=", "False", ",", "quiet", "=", "False", ",", "single_core", "=", "False", ...
Run the calacs.e executable as from the shell. By default this will run the calacs given by 'calacs.e'. Parameters ---------- input_file : str Name of input file. exec_path : str, optional The complete path to a calacs executable. time_stamps : bool, optional Set to T...
[ "Run", "the", "calacs", ".", "e", "executable", "as", "from", "the", "shell", "." ]
python
train
25.064935
totalgood/pugnlp
src/pugnlp/stats.py
https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/stats.py#L788-L798
def json_from_cov_df(df, threshold=.5, gain=2., n=None, indent=1): """Produce a json string describing the graph (list of edges) from a square auto-correlation/covariance matrix { "nodes": [{"group": 1, "name": "the"}, {"group": 1, "name": "and"}, {"group": 1, "name": "our"}, ...
[ "def", "json_from_cov_df", "(", "df", ",", "threshold", "=", ".5", ",", "gain", "=", "2.", ",", "n", "=", "None", ",", "indent", "=", "1", ")", ":", "nodes", ",", "edges", "=", "graph_from_cov_df", "(", "df", "=", "df", ",", "threshold", "=", "thre...
Produce a json string describing the graph (list of edges) from a square auto-correlation/covariance matrix { "nodes": [{"group": 1, "name": "the"}, {"group": 1, "name": "and"}, {"group": 1, "name": "our"}, {"group": 2, "name": "that"},... "links": [{"sour...
[ "Produce", "a", "json", "string", "describing", "the", "graph", "(", "list", "of", "edges", ")", "from", "a", "square", "auto", "-", "correlation", "/", "covariance", "matrix", "{", "nodes", ":", "[", "{", "group", ":", "1", "name", ":", "the", "}", ...
python
train
61.090909
saltstack/salt
salt/states/dracr.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/dracr.py#L41-L96
def property_present(properties, admin_username='root', admin_password='calvin', host=None, **kwargs): ''' properties = {} ''' ret = {'name': host, 'context': {'Host': host}, 'result': True, 'changes': {}, 'comment': ''} if host is None: output =...
[ "def", "property_present", "(", "properties", ",", "admin_username", "=", "'root'", ",", "admin_password", "=", "'calvin'", ",", "host", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "host", ",", "'context'", ":", "{", ...
properties = {}
[ "properties", "=", "{}" ]
python
train
35.625
tcalmant/ipopo
pelix/shell/report.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/report.py#L547-L559
def ipopo_factories(self): """ List of iPOPO factories """ try: with use_ipopo(self.__context) as ipopo: return { name: ipopo.get_factory_details(name) for name in ipopo.get_factories() } except B...
[ "def", "ipopo_factories", "(", "self", ")", ":", "try", ":", "with", "use_ipopo", "(", "self", ".", "__context", ")", "as", "ipopo", ":", "return", "{", "name", ":", "ipopo", ".", "get_factory_details", "(", "name", ")", "for", "name", "in", "ipopo", "...
List of iPOPO factories
[ "List", "of", "iPOPO", "factories" ]
python
train
29.615385
OpenHydrology/floodestimation
floodestimation/fehdata.py
https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L176-L184
def amax_files(): """ Return all annual maximum flow (`*.am`) files in cache folder and sub folders. :return: List of file paths :rtype: list """ return [os.path.join(dp, f) for dp, dn, filenames in os.walk(CACHE_FOLDER) for f in filenames if os.path.splitext(f)[1].lower() == '.am']
[ "def", "amax_files", "(", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "dp", ",", "f", ")", "for", "dp", ",", "dn", ",", "filenames", "in", "os", ".", "walk", "(", "CACHE_FOLDER", ")", "for", "f", "in", "filenames", "if", "os", ...
Return all annual maximum flow (`*.am`) files in cache folder and sub folders. :return: List of file paths :rtype: list
[ "Return", "all", "annual", "maximum", "flow", "(", "*", ".", "am", ")", "files", "in", "cache", "folder", "and", "sub", "folders", "." ]
python
train
34.666667
dtmilano/AndroidViewClient
src/com/dtmilano/android/viewclient.py
https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/viewclient.py#L1061-L1107
def writeImageToFile(self, filename, _format="PNG"): ''' Write the View image to the specified filename in the specified format. @type filename: str @param filename: Absolute path and optional filename receiving the image. If this points to a directory, then the...
[ "def", "writeImageToFile", "(", "self", ",", "filename", ",", "_format", "=", "\"PNG\"", ")", ":", "filename", "=", "self", ".", "device", ".", "substituteDeviceTemplate", "(", "filename", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "filename",...
Write the View image to the specified filename in the specified format. @type filename: str @param filename: Absolute path and optional filename receiving the image. If this points to a directory, then the filename is determined by this View unique ID and ...
[ "Write", "the", "View", "image", "to", "the", "specified", "filename", "in", "the", "specified", "format", "." ]
python
train
48.06383
minhhoit/yacms
yacms/blog/management/base.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L106-L121
def add_comment(self, post=None, name=None, email=None, pub_date=None, website=None, body=None): """ Adds a comment to the post provided. """ if post is None: if not self.posts: raise CommandError("Cannot add comments without posts") ...
[ "def", "add_comment", "(", "self", ",", "post", "=", "None", ",", "name", "=", "None", ",", "email", "=", "None", ",", "pub_date", "=", "None", ",", "website", "=", "None", ",", "body", "=", "None", ")", ":", "if", "post", "is", "None", ":", "if"...
Adds a comment to the post provided.
[ "Adds", "a", "comment", "to", "the", "post", "provided", "." ]
python
train
33.75
edx/edx-enterprise
enterprise/management/commands/assign_enterprise_user_roles.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/management/commands/assign_enterprise_user_roles.py#L92-L97
def _get_enterprise_admin_users_batch(self, start, end): """ Returns a batched queryset of User objects. """ LOGGER.info('Fetching new batch of enterprise admin users from indexes: %s to %s', start, end) return User.objects.filter(groups__name=ENTERPRISE_DATA_API_ACCESS_GROUP, is...
[ "def", "_get_enterprise_admin_users_batch", "(", "self", ",", "start", ",", "end", ")", ":", "LOGGER", ".", "info", "(", "'Fetching new batch of enterprise admin users from indexes: %s to %s'", ",", "start", ",", "end", ")", "return", "User", ".", "objects", ".", "f...
Returns a batched queryset of User objects.
[ "Returns", "a", "batched", "queryset", "of", "User", "objects", "." ]
python
valid
56.5
blockcypher/blockcypher-python
blockcypher/utils.py
https://github.com/blockcypher/blockcypher-python/blob/7601ea21916957ff279384fd699527ff9c28a56e/blockcypher/utils.py#L433-L443
def _long_to_bytes(n, length, byteorder): """Convert a long to a bytestring For use in python version prior to 3.2 Source: http://bugs.python.org/issue16580#msg177208 """ if byteorder == 'little': indexes = range(length) else: indexes = reversed(range(length)) return byte...
[ "def", "_long_to_bytes", "(", "n", ",", "length", ",", "byteorder", ")", ":", "if", "byteorder", "==", "'little'", ":", "indexes", "=", "range", "(", "length", ")", "else", ":", "indexes", "=", "reversed", "(", "range", "(", "length", ")", ")", "return...
Convert a long to a bytestring For use in python version prior to 3.2 Source: http://bugs.python.org/issue16580#msg177208
[ "Convert", "a", "long", "to", "a", "bytestring", "For", "use", "in", "python", "version", "prior", "to", "3", ".", "2", "Source", ":", "http", ":", "//", "bugs", ".", "python", ".", "org", "/", "issue16580#msg177208" ]
python
train
32.090909
macbre/phantomas-python
phantomas/utils.py
https://github.com/macbre/phantomas-python/blob/63b1b1bd3fc97feb460beb6ae509bfb5cccf04f5/phantomas/utils.py#L11-L34
def format_args(options): """ Convert hash/key options into arguments list """ args = list() for key, value in options.items(): # convert foo_bar key into --foo-bar option key = key.replace('_', '-') if value is True: # key: True # --key args.app...
[ "def", "format_args", "(", "options", ")", ":", "args", "=", "list", "(", ")", "for", "key", ",", "value", "in", "options", ".", "items", "(", ")", ":", "# convert foo_bar key into --foo-bar option", "key", "=", "key", ".", "replace", "(", "'_'", ",", "'...
Convert hash/key options into arguments list
[ "Convert", "hash", "/", "key", "options", "into", "arguments", "list" ]
python
train
30.208333
osrg/ryu
ryu/lib/ovs/bridge.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/ovs/bridge.py#L318-L328
def db_get_map(self, table, record, column): """ Gets dict type value of 'column' in 'record' in 'table'. This method is corresponding to the following ovs-vsctl command:: $ ovs-vsctl get TBL REC COL """ val = self.db_get_val(table, record, column) assert is...
[ "def", "db_get_map", "(", "self", ",", "table", ",", "record", ",", "column", ")", ":", "val", "=", "self", ".", "db_get_val", "(", "table", ",", "record", ",", "column", ")", "assert", "isinstance", "(", "val", ",", "dict", ")", "return", "val" ]
Gets dict type value of 'column' in 'record' in 'table'. This method is corresponding to the following ovs-vsctl command:: $ ovs-vsctl get TBL REC COL
[ "Gets", "dict", "type", "value", "of", "column", "in", "record", "in", "table", "." ]
python
train
31.636364
proteanhq/protean
src/protean/utils/query.py
https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/utils/query.py#L68-L75
def _unregister_lookup(cls, lookup, lookup_name=None): """ Remove given lookup from cls lookups. For use in tests only as it's not thread-safe. """ if lookup_name is None: lookup_name = lookup.lookup_name del cls.class_lookups[lookup_name]
[ "def", "_unregister_lookup", "(", "cls", ",", "lookup", ",", "lookup_name", "=", "None", ")", ":", "if", "lookup_name", "is", "None", ":", "lookup_name", "=", "lookup", ".", "lookup_name", "del", "cls", ".", "class_lookups", "[", "lookup_name", "]" ]
Remove given lookup from cls lookups. For use in tests only as it's not thread-safe.
[ "Remove", "given", "lookup", "from", "cls", "lookups", ".", "For", "use", "in", "tests", "only", "as", "it", "s", "not", "thread", "-", "safe", "." ]
python
train
36.5
bethgelab/foolbox
foolbox/adversarial.py
https://github.com/bethgelab/foolbox/blob/8ab54248c70e45d8580a7d9ee44c9c0fb5755c4a/foolbox/adversarial.py#L290-L314
def predictions(self, image, strict=True, return_details=False): """Interface to model.predictions for attacks. Parameters ---------- image : `numpy.ndarray` Single input with shape as expected by the model (without the batch dimension). strict : bool ...
[ "def", "predictions", "(", "self", ",", "image", ",", "strict", "=", "True", ",", "return_details", "=", "False", ")", ":", "in_bounds", "=", "self", ".", "in_bounds", "(", "image", ")", "assert", "not", "strict", "or", "in_bounds", "self", ".", "_total_...
Interface to model.predictions for attacks. Parameters ---------- image : `numpy.ndarray` Single input with shape as expected by the model (without the batch dimension). strict : bool Controls if the bounds for the pixel values should be checked.
[ "Interface", "to", "model", ".", "predictions", "for", "attacks", "." ]
python
valid
34.4
petl-developers/petl
petl/util/random.py
https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/util/random.py#L15-L45
def randomtable(numflds=5, numrows=100, wait=0, seed=None): """ Construct a table with random numerical data. Use `numflds` and `numrows` to specify the number of fields and rows respectively. Set `wait` to a float greater than zero to simulate a delay on each row generation (number of seconds per r...
[ "def", "randomtable", "(", "numflds", "=", "5", ",", "numrows", "=", "100", ",", "wait", "=", "0", ",", "seed", "=", "None", ")", ":", "return", "RandomTable", "(", "numflds", ",", "numrows", ",", "wait", "=", "wait", ",", "seed", "=", "seed", ")" ...
Construct a table with random numerical data. Use `numflds` and `numrows` to specify the number of fields and rows respectively. Set `wait` to a float greater than zero to simulate a delay on each row generation (number of seconds per row). E.g.:: >>> import petl as etl >>> table = etl.rand...
[ "Construct", "a", "table", "with", "random", "numerical", "data", ".", "Use", "numflds", "and", "numrows", "to", "specify", "the", "number", "of", "fields", "and", "rows", "respectively", ".", "Set", "wait", "to", "a", "float", "greater", "than", "zero", "...
python
train
53.096774
LuqueDaniel/pybooru
pybooru/api_moebooru.py
https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_moebooru.py#L126-L135
def post_revert_tags(self, post_id, history_id): """Function to reverts a post to a previous set of tags (Requires login) (UNTESTED). Parameters: post_id (int): The post id number to update. history_id (int): The id number of the tag history. """ params =...
[ "def", "post_revert_tags", "(", "self", ",", "post_id", ",", "history_id", ")", ":", "params", "=", "{", "'id'", ":", "post_id", ",", "'history_id'", ":", "history_id", "}", "return", "self", ".", "_get", "(", "'post/revert_tags'", ",", "params", ",", "'PU...
Function to reverts a post to a previous set of tags (Requires login) (UNTESTED). Parameters: post_id (int): The post id number to update. history_id (int): The id number of the tag history.
[ "Function", "to", "reverts", "a", "post", "to", "a", "previous", "set", "of", "tags", "(", "Requires", "login", ")", "(", "UNTESTED", ")", "." ]
python
train
41.3
chrisspen/burlap
burlap/apache.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/apache.py#L558-L570
def configure_modrpaf(self): """ Installs the mod-rpaf Apache module. https://github.com/gnif/mod_rpaf """ r = self.local_renderer if r.env.modrpaf_enabled: self.install_packages() self.enable_mod('rpaf') else: if self.last_man...
[ "def", "configure_modrpaf", "(", "self", ")", ":", "r", "=", "self", ".", "local_renderer", "if", "r", ".", "env", ".", "modrpaf_enabled", ":", "self", ".", "install_packages", "(", ")", "self", ".", "enable_mod", "(", "'rpaf'", ")", "else", ":", "if", ...
Installs the mod-rpaf Apache module. https://github.com/gnif/mod_rpaf
[ "Installs", "the", "mod", "-", "rpaf", "Apache", "module", "." ]
python
valid
28.846154
vlasovskikh/funcparserlib
funcparserlib/util.py
https://github.com/vlasovskikh/funcparserlib/blob/0b689920babcf6079a4b3e8721cc10bbc089d81c/funcparserlib/util.py#L25-L49
def pretty_tree(x, kids, show): """(a, (a -> list(a)), (a -> str)) -> str Returns a pseudographic tree representation of x similar to the tree command in Unix. """ (MID, END, CONT, LAST, ROOT) = (u'|-- ', u'`-- ', u'| ', u' ', u'') def rec(x, indent, sym): line = indent + sym + sh...
[ "def", "pretty_tree", "(", "x", ",", "kids", ",", "show", ")", ":", "(", "MID", ",", "END", ",", "CONT", ",", "LAST", ",", "ROOT", ")", "=", "(", "u'|-- '", ",", "u'`-- '", ",", "u'| '", ",", "u' '", ",", "u''", ")", "def", "rec", "(", "x"...
(a, (a -> list(a)), (a -> str)) -> str Returns a pseudographic tree representation of x similar to the tree command in Unix.
[ "(", "a", "(", "a", "-", ">", "list", "(", "a", "))", "(", "a", "-", ">", "str", "))", "-", ">", "str" ]
python
train
31.68
iblancasa/GitHubCity
src/githubcity/ghcity.py
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L178-L198
def getConfig(self): """Return the configuration of the city. :return: configuration of the city. :rtype: dict. """ config = {} config["name"] = self.city config["intervals"] = self.__intervals config["last_date"] = self.__lastDay config["excluded...
[ "def", "getConfig", "(", "self", ")", ":", "config", "=", "{", "}", "config", "[", "\"name\"", "]", "=", "self", ".", "city", "config", "[", "\"intervals\"", "]", "=", "self", ".", "__intervals", "config", "[", "\"last_date\"", "]", "=", "self", ".", ...
Return the configuration of the city. :return: configuration of the city. :rtype: dict.
[ "Return", "the", "configuration", "of", "the", "city", "." ]
python
train
28.714286
mattloper/chumpy
chumpy/ch.py
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/ch.py#L185-L189
def sid(self): """Semantic id.""" pnames = list(self.terms)+list(self.dterms) pnames.sort() return (self.__class__, tuple([(k, id(self.__dict__[k])) for k in pnames if k in self.__dict__]))
[ "def", "sid", "(", "self", ")", ":", "pnames", "=", "list", "(", "self", ".", "terms", ")", "+", "list", "(", "self", ".", "dterms", ")", "pnames", ".", "sort", "(", ")", "return", "(", "self", ".", "__class__", ",", "tuple", "(", "[", "(", "k"...
Semantic id.
[ "Semantic", "id", "." ]
python
train
43.4
CybOXProject/mixbox
mixbox/signals.py
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L75-L89
def __live_receivers(signal): """Return all signal handlers that are currently still alive for the input `signal`. Args: signal: A signal name. Returns: A list of callable receivers for the input signal. """ with __lock: __purge() receivers = [funcref() for func...
[ "def", "__live_receivers", "(", "signal", ")", ":", "with", "__lock", ":", "__purge", "(", ")", "receivers", "=", "[", "funcref", "(", ")", "for", "funcref", "in", "__receivers", "[", "signal", "]", "]", "return", "receivers" ]
Return all signal handlers that are currently still alive for the input `signal`. Args: signal: A signal name. Returns: A list of callable receivers for the input signal.
[ "Return", "all", "signal", "handlers", "that", "are", "currently", "still", "alive", "for", "the", "input", "signal", "." ]
python
train
23.666667
mlenzen/collections-extended
collections_extended/bags.py
https://github.com/mlenzen/collections-extended/blob/ee9e86f6bbef442dbebcb3a5970642c5c969e2cf/collections_extended/bags.py#L238-L252
def is_subset(self, other): """Check that every element in self has a count <= in other. Args: other (Set) """ if isinstance(other, _basebag): for elem, count in self.counts(): if not count <= other.count(elem): return False else: for elem in self: if self.count(elem) > 1 or elem not in...
[ "def", "is_subset", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "_basebag", ")", ":", "for", "elem", ",", "count", "in", "self", ".", "counts", "(", ")", ":", "if", "not", "count", "<=", "other", ".", "count", "(", ...
Check that every element in self has a count <= in other. Args: other (Set)
[ "Check", "that", "every", "element", "in", "self", "has", "a", "count", "<", "=", "in", "other", "." ]
python
train
23
rlabbe/filterpy
filterpy/examples/radar_sim.py
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/examples/radar_sim.py#L39-L53
def get_range(self, process_err_pct=0.05): """ Returns slant range to the object. Call once for each new measurement at dt time from last call. """ vel = self.vel + 5 * randn() alt = self.alt + 10 * randn() self.pos += vel*self.dt err = (self.pos * proc...
[ "def", "get_range", "(", "self", ",", "process_err_pct", "=", "0.05", ")", ":", "vel", "=", "self", ".", "vel", "+", "5", "*", "randn", "(", ")", "alt", "=", "self", ".", "alt", "+", "10", "*", "randn", "(", ")", "self", ".", "pos", "+=", "vel"...
Returns slant range to the object. Call once for each new measurement at dt time from last call.
[ "Returns", "slant", "range", "to", "the", "object", ".", "Call", "once", "for", "each", "new", "measurement", "at", "dt", "time", "from", "last", "call", "." ]
python
train
27.4
pyblish/pyblish-lite
pyblish_lite/control.py
https://github.com/pyblish/pyblish-lite/blob/9172b81c7ae19a36e99c89dd16e102201992dc20/pyblish_lite/control.py#L255-L276
def cleanup(self): """Forcefully delete objects from memory In an ideal world, this shouldn't be necessary. Garbage collection guarantees that anything without reference is automatically removed. However, because this application is designed to be run multiple times fro...
[ "def", "cleanup", "(", "self", ")", ":", "for", "instance", "in", "self", ".", "context", ":", "del", "(", "instance", ")", "for", "plugin", "in", "self", ".", "plugins", ":", "del", "(", "plugin", ")" ]
Forcefully delete objects from memory In an ideal world, this shouldn't be necessary. Garbage collection guarantees that anything without reference is automatically removed. However, because this application is designed to be run multiple times from the same interpreter process...
[ "Forcefully", "delete", "objects", "from", "memory" ]
python
train
32.954545
ambitioninc/rabbitmq-admin
rabbitmq_admin/base.py
https://github.com/ambitioninc/rabbitmq-admin/blob/ff65054115f19991da153f0e4f4e45e526545fea/rabbitmq_admin/base.py#L125-L133
def _delete(self, *args, **kwargs): """ A wrapper for deleting things :returns: The response of your delete :rtype: dict """ response = requests.delete(*args, **kwargs) response.raise_for_status()
[ "def", "_delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "requests", ".", "delete", "(", "*", "args", ",", "*", "*", "kwargs", ")", "response", ".", "raise_for_status", "(", ")" ]
A wrapper for deleting things :returns: The response of your delete :rtype: dict
[ "A", "wrapper", "for", "deleting", "things" ]
python
train
27.222222
aiidateam/aiida-nwchem
aiida_nwchem/parsers/basic.py
https://github.com/aiidateam/aiida-nwchem/blob/21034e7f8ea8249948065c28030f4b572a6ecf05/aiida_nwchem/parsers/basic.py#L32-L78
def _get_output_nodes(self, output_path, error_path): """ Extracts output nodes from the standard output and standard error files. """ from aiida.orm.data.array.trajectory import TrajectoryData import re state = None step = None scale = None ...
[ "def", "_get_output_nodes", "(", "self", ",", "output_path", ",", "error_path", ")", ":", "from", "aiida", ".", "orm", ".", "data", ".", "array", ".", "trajectory", "import", "TrajectoryData", "import", "re", "state", "=", "None", "step", "=", "None", "sca...
Extracts output nodes from the standard output and standard error files.
[ "Extracts", "output", "nodes", "from", "the", "standard", "output", "and", "standard", "error", "files", "." ]
python
train
42.638298
redhat-cip/python-dciclient
dciclient/v1/shell_commands/feeder.py
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/feeder.py#L148-L160
def reset_api_secret(context, id, etag): """reset_api_secret(context, id, etag) Reset a Feeder api_secret. >>> dcictl feeder-reset-api-secret [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required] """ result = feeder.reset_...
[ "def", "reset_api_secret", "(", "context", ",", "id", ",", "etag", ")", ":", "result", "=", "feeder", ".", "reset_api_secret", "(", "context", ",", "id", "=", "id", ",", "etag", "=", "etag", ")", "utils", ".", "format_output", "(", "result", ",", "cont...
reset_api_secret(context, id, etag) Reset a Feeder api_secret. >>> dcictl feeder-reset-api-secret [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required]
[ "reset_api_secret", "(", "context", "id", "etag", ")" ]
python
train
35
NeuroML/pyNeuroML
pyneuroml/tune/NeuroMLController.py
https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLController.py#L154-L323
def run_individual(sim_var, reference, neuroml_file, nml_doc, still_included, generate_dir, target, sim_time, dt, simulator, cl...
[ "def", "run_individual", "(", "sim_var", ",", "reference", ",", "neuroml_file", ",", "nml_doc", ",", "still_included", ",", "generate_dir", ",", "target", ",", "sim_time", ",", "dt", ",", "simulator", ",", "cleanup", "=", "True", ",", "show", "=", "False", ...
Run an individual simulation. The candidate data has been flattened into the sim_var dict. The sim_var dict contains parameter:value key value pairs, which are applied to the model before it is simulated.
[ "Run", "an", "individual", "simulation", "." ]
python
train
38.311765
oasiswork/zimsoap
zimsoap/client.py
https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/client.py#L2016-L2040
def apply_filter_rule(self, _filter, query='in:inbox', way='in'): """ :param: _filter _filter a zobjects.FilterRule or the filter name :param: query on what will the filter be applied :param: way string discribing if filter is for 'in' or 'out' messages :returns: list of impacted...
[ "def", "apply_filter_rule", "(", "self", ",", "_filter", ",", "query", "=", "'in:inbox'", ",", "way", "=", "'in'", ")", ":", "if", "isinstance", "(", "_filter", ",", "zobjects", ".", "FilterRule", ")", ":", "_filter", "=", "_filter", ".", "name", "conten...
:param: _filter _filter a zobjects.FilterRule or the filter name :param: query on what will the filter be applied :param: way string discribing if filter is for 'in' or 'out' messages :returns: list of impacted message's ids
[ ":", "param", ":", "_filter", "_filter", "a", "zobjects", ".", "FilterRule", "or", "the", "filter", "name", ":", "param", ":", "query", "on", "what", "will", "the", "filter", "be", "applied", ":", "param", ":", "way", "string", "discribing", "if", "filte...
python
train
34.96
SFDO-Tooling/CumulusCI
cumulusci/core/keychain/BaseProjectKeychain.py
https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/keychain/BaseProjectKeychain.py#L158-L164
def unset_default_org(self): """ unset the default orgs for tasks """ for org in self.list_orgs(): org_config = self.get_org(org) if org_config.default: del org_config.config["default"] self.set_org(org_config)
[ "def", "unset_default_org", "(", "self", ")", ":", "for", "org", "in", "self", ".", "list_orgs", "(", ")", ":", "org_config", "=", "self", ".", "get_org", "(", "org", ")", "if", "org_config", ".", "default", ":", "del", "org_config", ".", "config", "["...
unset the default orgs for tasks
[ "unset", "the", "default", "orgs", "for", "tasks" ]
python
train
39.428571
datastax/python-driver
cassandra/io/twistedreactor.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/io/twistedreactor.py#L283-L300
def close(self): """ Disconnect and error-out all requests. """ with self.lock: if self.is_closed: return self.is_closed = True log.debug("Closing connection (%s) to %s", id(self), self.endpoint) reactor.callFromThread(self.connect...
[ "def", "close", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "if", "self", ".", "is_closed", ":", "return", "self", ".", "is_closed", "=", "True", "log", ".", "debug", "(", "\"Closing connection (%s) to %s\"", ",", "id", "(", "self", ")", "...
Disconnect and error-out all requests.
[ "Disconnect", "and", "error", "-", "out", "all", "requests", "." ]
python
train
34.555556
gwastro/pycbc-glue
pycbc_glue/datafind.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/datafind.py#L324-L392
def find_frame_urls(self, site, frametype, gpsstart, gpsend, match=None, urltype=None, on_gaps="warn"): """Find the framefiles for the given type in the [start, end) interval frame @param site: single-character name of site to match @param frametype: ...
[ "def", "find_frame_urls", "(", "self", ",", "site", ",", "frametype", ",", "gpsstart", ",", "gpsend", ",", "match", "=", "None", ",", "urltype", "=", "None", ",", "on_gaps", "=", "\"warn\"", ")", ":", "if", "on_gaps", "not", "in", "(", "\"warn\"", ",",...
Find the framefiles for the given type in the [start, end) interval frame @param site: single-character name of site to match @param frametype: name of frametype to match @param gpsstart: integer GPS start time of query @param gpsend: ...
[ "Find", "the", "framefiles", "for", "the", "given", "type", "in", "the", "[", "start", "end", ")", "interval", "frame" ]
python
train
36.898551
Kortemme-Lab/klab
klab/bio/pdb.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdb.py#L1719-L1741
def get_atom_sequence_to_rosetta_map(self): '''Uses the Rosetta->ATOM injective map to construct an injective mapping from ATOM->Rosetta. We do not extend the injection to include ATOM residues which have no corresponding Rosetta residue. e.g. atom_sequence_to_rosetta_mapping[c].map.get(...
[ "def", "get_atom_sequence_to_rosetta_map", "(", "self", ")", ":", "if", "not", "self", ".", "rosetta_to_atom_sequence_maps", "and", "self", ".", "rosetta_sequences", ":", "raise", "Exception", "(", "'The PDB to Rosetta mapping has not been determined. Please call construct_pdb_...
Uses the Rosetta->ATOM injective map to construct an injective mapping from ATOM->Rosetta. We do not extend the injection to include ATOM residues which have no corresponding Rosetta residue. e.g. atom_sequence_to_rosetta_mapping[c].map.get('A 45 ') will return None if there is no corresponding...
[ "Uses", "the", "Rosetta", "-", ">", "ATOM", "injective", "map", "to", "construct", "an", "injective", "mapping", "from", "ATOM", "-", ">", "Rosetta", ".", "We", "do", "not", "extend", "the", "injection", "to", "include", "ATOM", "residues", "which", "have"...
python
train
60.956522
pypa/pipenv
pipenv/vendor/distlib/index.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/index.py#L466-L507
def encode_request(self, fields, files): """ Encode fields and files for posting to an HTTP server. :param fields: The fields to send as a list of (fieldname, value) tuples. :param files: The files to send as a list of (fieldname, filename, f...
[ "def", "encode_request", "(", "self", ",", "fields", ",", "files", ")", ":", "# Adapted from packaging, which in turn was adapted from", "# http://code.activestate.com/recipes/146306", "parts", "=", "[", "]", "boundary", "=", "self", ".", "boundary", "for", "k", ",", ...
Encode fields and files for posting to an HTTP server. :param fields: The fields to send as a list of (fieldname, value) tuples. :param files: The files to send as a list of (fieldname, filename, file_bytes) tuple.
[ "Encode", "fields", "and", "files", "for", "posting", "to", "an", "HTTP", "server", "." ]
python
train
34.619048
by46/simplekit
simplekit/objson/dolphin2.py
https://github.com/by46/simplekit/blob/33f3ce6de33accc185e1057f096af41859db5976/simplekit/objson/dolphin2.py#L78-L95
def dumps(obj, *args, **kwargs): """Serialize a object to string Basic Usage: >>> import simplekit.objson >>> obj = {'name':'wendy'} >>> print simplekit.objson.dumps(obj) :param obj: a object which need to dump :param args: Optional arguments that :func:`json.dumps` takes. :param kwa...
[ "def", "dumps", "(", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'default'", "]", "=", "object2dict", "return", "json", ".", "dumps", "(", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Serialize a object to string Basic Usage: >>> import simplekit.objson >>> obj = {'name':'wendy'} >>> print simplekit.objson.dumps(obj) :param obj: a object which need to dump :param args: Optional arguments that :func:`json.dumps` takes. :param kwargs: Keys arguments that :py:func:`json....
[ "Serialize", "a", "object", "to", "string" ]
python
train
25.833333
sassoo/goldman
goldman/deserializers/jsonapi.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L144-L189
def _parse_relationships(self, relationships): """ Ensure compliance with the spec's relationships section Specifically, the relationships object of the single resource object. For modifications we only support relationships via the `data` key referred to as Resource Linkage. :...
[ "def", "_parse_relationships", "(", "self", ",", "relationships", ")", ":", "link", "=", "'jsonapi.org/format/#document-resource-object-relationships'", "if", "not", "isinstance", "(", "relationships", ",", "dict", ")", ":", "self", ".", "fail", "(", "'The JSON API re...
Ensure compliance with the spec's relationships section Specifically, the relationships object of the single resource object. For modifications we only support relationships via the `data` key referred to as Resource Linkage. :param relationships: dict JSON API relationship...
[ "Ensure", "compliance", "with", "the", "spec", "s", "relationships", "section" ]
python
train
50.630435
vertexproject/synapse
synapse/lib/urlhelp.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/urlhelp.py#L3-L69
def chopurl(url): ''' A sane "stand alone" url parser. Example: info = chopurl(url) ''' ret = {} if url.find('://') == -1: raise s_exc.BadUrl(':// not found in [{}]!'.format(url)) scheme, remain = url.split('://', 1) ret['scheme'] = scheme.lower() # carve query pa...
[ "def", "chopurl", "(", "url", ")", ":", "ret", "=", "{", "}", "if", "url", ".", "find", "(", "'://'", ")", "==", "-", "1", ":", "raise", "s_exc", ".", "BadUrl", "(", "':// not found in [{}]!'", ".", "format", "(", "url", ")", ")", "scheme", ",", ...
A sane "stand alone" url parser. Example: info = chopurl(url)
[ "A", "sane", "stand", "alone", "url", "parser", "." ]
python
train
23.447761
yhat/ggpy
ggplot/colors/palettes.py
https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L67-L165
def color_palette(name=None, n_colors=6, desat=None): """Return a list of colors defining a color palette. Availible seaborn palette names: deep, muted, bright, pastel, dark, colorblind Other options: hls, husl, any matplotlib palette Matplotlib paletes can be specified as reversed pa...
[ "def", "color_palette", "(", "name", "=", "None", ",", "n_colors", "=", "6", ",", "desat", "=", "None", ")", ":", "seaborn_palettes", "=", "dict", "(", "deep", "=", "[", "\"#4C72B0\"", ",", "\"#55A868\"", ",", "\"#C44E52\"", ",", "\"#8172B2\"", ",", "\"#...
Return a list of colors defining a color palette. Availible seaborn palette names: deep, muted, bright, pastel, dark, colorblind Other options: hls, husl, any matplotlib palette Matplotlib paletes can be specified as reversed palettes by appending "_r" to the name or as dark palettes ...
[ "Return", "a", "list", "of", "colors", "defining", "a", "color", "palette", "." ]
python
train
32.252525
openstack/proliantutils
proliantutils/ilo/ris.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ris.py#L1800-L1810
def _get_cpu_virtualization(self): """get cpu virtualization status.""" try: cpu_vt = self._get_bios_setting('ProcVirtualization') except exception.IloCommandNotSupportedError: return False if cpu_vt == 'Enabled': vt_status = True else: ...
[ "def", "_get_cpu_virtualization", "(", "self", ")", ":", "try", ":", "cpu_vt", "=", "self", ".", "_get_bios_setting", "(", "'ProcVirtualization'", ")", "except", "exception", ".", "IloCommandNotSupportedError", ":", "return", "False", "if", "cpu_vt", "==", "'Enabl...
get cpu virtualization status.
[ "get", "cpu", "virtualization", "status", "." ]
python
train
32.454545
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L30-L38
def getGroundResolution(self, latitude, level): ''' returns the ground resolution for based on latitude and zoom level. ''' latitude = self.clipValue(latitude, self.min_lat, self.max_lat); mapSize = self.getMapDimensionsByZoomLevel(level) return math.cos( lati...
[ "def", "getGroundResolution", "(", "self", ",", "latitude", ",", "level", ")", ":", "latitude", "=", "self", ".", "clipValue", "(", "latitude", ",", "self", ".", "min_lat", ",", "self", ".", "max_lat", ")", "mapSize", "=", "self", ".", "getMapDimensionsByZ...
returns the ground resolution for based on latitude and zoom level.
[ "returns", "the", "ground", "resolution", "for", "based", "on", "latitude", "and", "zoom", "level", "." ]
python
train
43.777778
proteanhq/protean
src/protean/utils/importlib.py
https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/utils/importlib.py#L6-L17
def perform_import(val): """ If the given setting is a string import notation, then perform the necessary import or imports. """ if val is None: return None elif isinstance(val, str): return import_from_string(val) elif isinstance(val, (list, tuple)): return [import_f...
[ "def", "perform_import", "(", "val", ")", ":", "if", "val", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "val", ",", "str", ")", ":", "return", "import_from_string", "(", "val", ")", "elif", "isinstance", "(", "val", ",", "(", "list"...
If the given setting is a string import notation, then perform the necessary import or imports.
[ "If", "the", "given", "setting", "is", "a", "string", "import", "notation", "then", "perform", "the", "necessary", "import", "or", "imports", "." ]
python
train
29.75
kivy/buildozer
buildozer/targets/android.py
https://github.com/kivy/buildozer/blob/586152c6ce2b6cde4d5a081d9711f9cb037a901c/buildozer/targets/android.py#L1159-L1174
def cmd_adb(self, *args): ''' Run adb from the Android SDK. Args must come after --, or use --alias to make an alias ''' self.check_requirements() self.install_platform() args = args[0] if args and args[0] == '--alias': print('To set up...
[ "def", "cmd_adb", "(", "self", ",", "*", "args", ")", ":", "self", ".", "check_requirements", "(", ")", "self", ".", "install_platform", "(", ")", "args", "=", "args", "[", "0", "]", "if", "args", "and", "args", "[", "0", "]", "==", "'--alias'", ":...
Run adb from the Android SDK. Args must come after --, or use --alias to make an alias
[ "Run", "adb", "from", "the", "Android", "SDK", ".", "Args", "must", "come", "after", "--", "or", "use", "--", "alias", "to", "make", "an", "alias" ]
python
train
37.0625
ChristianTremblay/BAC0
BAC0/core/io/Simulate.py
https://github.com/ChristianTremblay/BAC0/blob/8d95b065ea068524a08f5b0c34322ebeeba95d06/BAC0/core/io/Simulate.py#L87-L111
def release(self, args): """ Set the Out_Of_Service property to False - to release the I/O point back to the controller's control. :param args: String with <addr> <type> <inst> """ if not self._started: raise ApplicationNotStarted("BACnet stack not...
[ "def", "release", "(", "self", ",", "args", ")", ":", "if", "not", "self", ".", "_started", ":", "raise", "ApplicationNotStarted", "(", "\"BACnet stack not running - use startApp()\"", ")", "args", "=", "args", ".", "split", "(", ")", "addr", ",", "obj_type", ...
Set the Out_Of_Service property to False - to release the I/O point back to the controller's control. :param args: String with <addr> <type> <inst>
[ "Set", "the", "Out_Of_Service", "property", "to", "False", "-", "to", "release", "the", "I", "/", "O", "point", "back", "to", "the", "controller", "s", "control", ".", ":", "param", "args", ":", "String", "with", "<addr", ">", "<type", ">", "<inst", ">...
python
train
33
jtambasco/modesolverpy
modesolverpy/mode_solver.py
https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/mode_solver.py#L548-L610
def write_modes_to_file(self, filename="mode.dat", plot=True, analyse=True): """ Writes the mode fields to a file and optionally plots them. Args: filename (str): The nominal filename to use for the saved data. The suffix will be automatically be changed to ...
[ "def", "write_modes_to_file", "(", "self", ",", "filename", "=", "\"mode.dat\"", ",", "plot", "=", "True", ",", "analyse", "=", "True", ")", ":", "modes_directory", "=", "\"./modes_semi_vec/\"", "if", "not", "os", ".", "path", ".", "isdir", "(", "modes_direc...
Writes the mode fields to a file and optionally plots them. Args: filename (str): The nominal filename to use for the saved data. The suffix will be automatically be changed to identifiy each mode number. Default is 'mode.dat' plot (bool): `True` if plo...
[ "Writes", "the", "mode", "fields", "to", "a", "file", "and", "optionally", "plots", "them", "." ]
python
train
41.269841
tensorflow/hub
tensorflow_hub/keras_layer.py
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/keras_layer.py#L138-L142
def _add_existing_weight(self, weight, trainable=None): """Calls add_weight() to register but not create an existing weight.""" if trainable is None: trainable = weight.trainable self.add_weight(name=weight.name, shape=weight.shape, dtype=weight.dtype, trainable=trainable, getter=lambda ...
[ "def", "_add_existing_weight", "(", "self", ",", "weight", ",", "trainable", "=", "None", ")", ":", "if", "trainable", "is", "None", ":", "trainable", "=", "weight", ".", "trainable", "self", ".", "add_weight", "(", "name", "=", "weight", ".", "name", ",...
Calls add_weight() to register but not create an existing weight.
[ "Calls", "add_weight", "()", "to", "register", "but", "not", "create", "an", "existing", "weight", "." ]
python
train
66.6
OCHA-DAP/hdx-python-country
setup.py
https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/setup.py#L11-L27
def script_dir(pyobject, follow_symlinks=True): """Get current script's directory Args: pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True. Returns: str: Current script's directory """ if getattr(sys, '...
[ "def", "script_dir", "(", "pyobject", ",", "follow_symlinks", "=", "True", ")", ":", "if", "getattr", "(", "sys", ",", "'frozen'", ",", "False", ")", ":", "# py2exe, PyInstaller, cx_Freeze", "path", "=", "abspath", "(", "sys", ".", "executable", ")", "else",...
Get current script's directory Args: pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True. Returns: str: Current script's directory
[ "Get", "current", "script", "s", "directory" ]
python
train
30.941176
saltstack/salt
salt/cloud/clouds/opennebula.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L3511-L3551
def vm_monitoring(name, call=None): ''' Returns the monitoring records for a given virtual machine. A VM name must be supplied. The monitoring information returned is a list of VM elements. Each VM element contains the complete dictionary of the VM with the updated information returned by the p...
[ "def", "vm_monitoring", "(", "name", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The vm_monitoring action must be called with -a or --action.'", ")", "server", ",", "user", ",", "password", "=", "...
Returns the monitoring records for a given virtual machine. A VM name must be supplied. The monitoring information returned is a list of VM elements. Each VM element contains the complete dictionary of the VM with the updated information returned by the poll action. .. versionadded:: 2016.3.0 ...
[ "Returns", "the", "monitoring", "records", "for", "a", "given", "virtual", "machine", ".", "A", "VM", "name", "must", "be", "supplied", "." ]
python
train
28.146341
materialsproject/pymatgen
pymatgen/io/abinit/qadapters.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/qadapters.py#L1100-L1120
def get_njobs_in_queue(self, username=None): """ returns the number of jobs in the queue, probably using subprocess or shutil to call a command like 'qstat'. returns None when the number of jobs cannot be determined. Args: username: (str) the username of the jobs to count (d...
[ "def", "get_njobs_in_queue", "(", "self", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", ":", "username", "=", "getpass", ".", "getuser", "(", ")", "njobs", ",", "process", "=", "self", ".", "_get_njobs_in_queue", "(", "username", ...
returns the number of jobs in the queue, probably using subprocess or shutil to call a command like 'qstat'. returns None when the number of jobs cannot be determined. Args: username: (str) the username of the jobs to count (default is to autodetect)
[ "returns", "the", "number", "of", "jobs", "in", "the", "queue", "probably", "using", "subprocess", "or", "shutil", "to", "call", "a", "command", "like", "qstat", ".", "returns", "None", "when", "the", "number", "of", "jobs", "cannot", "be", "determined", "...
python
train
45
Dynatrace/OneAgent-SDK-for-Python
src/oneagent/sdk/__init__.py
https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L357-L369
def trace_in_process_link(self, link_bytes): '''Creates a tracer for tracing asynchronous related processing in the same process. For more information see :meth:`create_in_process_link`. :param bytes link_bytes: An in-process link created using :meth:`create_in_process_link`. :rtype: ...
[ "def", "trace_in_process_link", "(", "self", ",", "link_bytes", ")", ":", "return", "tracers", ".", "InProcessLinkTracer", "(", "self", ".", "_nsdk", ",", "self", ".", "_nsdk", ".", "trace_in_process_link", "(", "link_bytes", ")", ")" ]
Creates a tracer for tracing asynchronous related processing in the same process. For more information see :meth:`create_in_process_link`. :param bytes link_bytes: An in-process link created using :meth:`create_in_process_link`. :rtype: tracers.InProcessLinkTracer .. versionadded:: 1...
[ "Creates", "a", "tracer", "for", "tracing", "asynchronous", "related", "processing", "in", "the", "same", "process", "." ]
python
train
40.307692
deepmind/sonnet
sonnet/examples/ptb_reader.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/ptb_reader.py#L55-L82
def ptb_raw_data(data_path): """Load PTB raw data from data directory "data_path". Reads PTB text files, converts strings to integer ids, and performs mini-batching of the inputs. The PTB dataset comes from Tomas Mikolov's webpage: http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz Args: da...
[ "def", "ptb_raw_data", "(", "data_path", ")", ":", "train_path", "=", "os", ".", "path", ".", "join", "(", "data_path", ",", "\"ptb.train.txt\"", ")", "valid_path", "=", "os", ".", "path", ".", "join", "(", "data_path", ",", "\"ptb.valid.txt\"", ")", "test...
Load PTB raw data from data directory "data_path". Reads PTB text files, converts strings to integer ids, and performs mini-batching of the inputs. The PTB dataset comes from Tomas Mikolov's webpage: http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz Args: data_path: string path to the direct...
[ "Load", "PTB", "raw", "data", "from", "data", "directory", "data_path", "." ]
python
train
34.107143
django-py/django-doberman
doberman/contrib/captcha/client.py
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/contrib/captcha/client.py#L42-L71
def displayhtml(public_key, attrs, use_ssl=False, error=None): """Gets the HTML to display for reCAPTCHA public_key -- The public api key use_ssl -- Should the request be sent over ssl? error -- An error message to display (from RecaptchaResponse.error_co...
[ "def", "displayhtml", "(", "public_key", ",", "attrs", ",", "use_ssl", "=", "False", ",", "error", "=", "None", ")", ":", "error_param", "=", "''", "if", "error", ":", "error_param", "=", "'&error=%s'", "%", "error", "if", "use_ssl", ":", "server", "=", ...
Gets the HTML to display for reCAPTCHA public_key -- The public api key use_ssl -- Should the request be sent over ssl? error -- An error message to display (from RecaptchaResponse.error_code)
[ "Gets", "the", "HTML", "to", "display", "for", "reCAPTCHA" ]
python
train
26.5
hollenstein/maspy
maspy/_proteindb_refactoring.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/_proteindb_refactoring.py#L512-L528
def _nameFromHeaderInfo(headerInfo, isDecoy, decoyTag): """Generates a protein name from headerInfo. If "isDecoy" is True, the "decoyTag" is added to beginning of the generated protein name. :param headerInfo: dict, must contain a key "name" or "id" :param isDecoy: bool, determines if the "decoyTag" is...
[ "def", "_nameFromHeaderInfo", "(", "headerInfo", ",", "isDecoy", ",", "decoyTag", ")", ":", "if", "'name'", "in", "headerInfo", ":", "proteinName", "=", "headerInfo", "[", "'name'", "]", "else", ":", "proteinName", "=", "headerInfo", "[", "'id'", "]", "if", ...
Generates a protein name from headerInfo. If "isDecoy" is True, the "decoyTag" is added to beginning of the generated protein name. :param headerInfo: dict, must contain a key "name" or "id" :param isDecoy: bool, determines if the "decoyTag" is added or not. :param decoyTag: str, a tag that identifies ...
[ "Generates", "a", "protein", "name", "from", "headerInfo", ".", "If", "isDecoy", "is", "True", "the", "decoyTag", "is", "added", "to", "beginning", "of", "the", "generated", "protein", "name", "." ]
python
train
38.411765
oemof/oemof.db
oemof/db/tools.py
https://github.com/oemof/oemof.db/blob/d51ac50187f03a875bd7ce5991ed4772e8b77b93/oemof/db/tools.py#L294-L330
def create_empty_table_serial_primary(conn, schema, table, columns=None, id_col='id'): r"""New database table with primary key type serial and empty columns Parameters ---------- conn : sqlalchemy connection object A valid connection to a database schem...
[ "def", "create_empty_table_serial_primary", "(", "conn", ",", "schema", ",", "table", ",", "columns", "=", "None", ",", "id_col", "=", "'id'", ")", ":", "sql_str", "=", "\"\"\"CREATE TABLE {schema}.{table} ({id_col} SERIAL PRIMARY KEY\n NOT NULL)\n \"\"\"", "....
r"""New database table with primary key type serial and empty columns Parameters ---------- conn : sqlalchemy connection object A valid connection to a database schema : str The database schema table : str The database table columns : list, optional Columns that ...
[ "r", "New", "database", "table", "with", "primary", "key", "type", "serial", "and", "empty", "columns" ]
python
train
31.243243
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/job.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/job.py#L1658-L1685
def to_api_repr(self): """Generate a resource for :meth:`_begin`.""" source_refs = [ { "projectId": table.project, "datasetId": table.dataset_id, "tableId": table.table_id, } for table in self.sources ] ...
[ "def", "to_api_repr", "(", "self", ")", ":", "source_refs", "=", "[", "{", "\"projectId\"", ":", "table", ".", "project", ",", "\"datasetId\"", ":", "table", ".", "dataset_id", ",", "\"tableId\"", ":", "table", ".", "table_id", ",", "}", "for", "table", ...
Generate a resource for :meth:`_begin`.
[ "Generate", "a", "resource", "for", ":", "meth", ":", "_begin", "." ]
python
train
31.035714
mitsei/dlkit
dlkit/records/osid/base_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/osid/base_records.py#L2245-L2258
def set_asset(self, asset_id, asset_content_type=None): """stub""" if asset_id is None: raise NullArgument('asset_id cannot be None') if not isinstance(asset_id, Id): raise InvalidArgument('asset_id must be an instance of Id') if asset_content_type is not None and...
[ "def", "set_asset", "(", "self", ",", "asset_id", ",", "asset_content_type", "=", "None", ")", ":", "if", "asset_id", "is", "None", ":", "raise", "NullArgument", "(", "'asset_id cannot be None'", ")", "if", "not", "isinstance", "(", "asset_id", ",", "Id", ")...
stub
[ "stub" ]
python
train
47.571429
open-mmlab/mmcv
mmcv/runner/runner.py
https://github.com/open-mmlab/mmcv/blob/0d77f61450aab4dde8b8585a577cc496acb95d7f/mmcv/runner/runner.py#L315-L359
def run(self, data_loaders, workflow, max_epochs, **kwargs): """Start running. Args: data_loaders (list[:obj:`DataLoader`]): Dataloaders for training and validation. workflow (list[tuple]): A list of (phase, epochs) to specify the running order an...
[ "def", "run", "(", "self", ",", "data_loaders", ",", "workflow", ",", "max_epochs", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "data_loaders", ",", "list", ")", "assert", "mmcv", ".", "is_list_of", "(", "workflow", ",", "tuple", ")",...
Start running. Args: data_loaders (list[:obj:`DataLoader`]): Dataloaders for training and validation. workflow (list[tuple]): A list of (phase, epochs) to specify the running order and epochs. E.g, [('train', 2), ('val', 1)] means running ...
[ "Start", "running", "." ]
python
test
45.555556
PySimpleGUI/PySimpleGUI
PySimpleGUIWx/PySimpleGUIWx.py
https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L2817-L2847
def Read(self, timeout=None): ''' Reads the context menu :param timeout: Optional. Any value other than None indicates a non-blocking read :return: ''' # if not self.Shown: # self.Shown = True # self.TrayIcon.show() timeout1 = timeout ...
[ "def", "Read", "(", "self", ",", "timeout", "=", "None", ")", ":", "# if not self.Shown:", "# self.Shown = True", "# self.TrayIcon.show()", "timeout1", "=", "timeout", "# if timeout1 == 0:", "# timeout1 = 1", "# if wx.GetApp():", "# wx.GetApp().ProcessPendingEve...
Reads the context menu :param timeout: Optional. Any value other than None indicates a non-blocking read :return:
[ "Reads", "the", "context", "menu", ":", "param", "timeout", ":", "Optional", ".", "Any", "value", "other", "than", "None", "indicates", "a", "non", "-", "blocking", "read", ":", "return", ":" ]
python
train
36.516129
MillionIntegrals/vel
vel/api/learner.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/learner.py#L58-L74
def train_epoch(self, epoch_info, source: 'vel.api.Source', interactive=True): """ Run a single training epoch """ self.train() if interactive: iterator = tqdm.tqdm(source.train_loader(), desc="Training", unit="iter", file=sys.stdout) else: iterator = source.trai...
[ "def", "train_epoch", "(", "self", ",", "epoch_info", ",", "source", ":", "'vel.api.Source'", ",", "interactive", "=", "True", ")", ":", "self", ".", "train", "(", ")", "if", "interactive", ":", "iterator", "=", "tqdm", ".", "tqdm", "(", "source", ".", ...
Run a single training epoch
[ "Run", "a", "single", "training", "epoch" ]
python
train
39.176471
Unity-Technologies/ml-agents
ml-agents-envs/mlagents/envs/brain.py
https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents-envs/mlagents/envs/brain.py#L206-L224
def from_proto(brain_param_proto): """ Converts brain parameter proto to BrainParameter object. :param brain_param_proto: protobuf object. :return: BrainParameter object. """ resolution = [{ "height": x.height, "width": x.width, "blackA...
[ "def", "from_proto", "(", "brain_param_proto", ")", ":", "resolution", "=", "[", "{", "\"height\"", ":", "x", ".", "height", ",", "\"width\"", ":", "x", ".", "width", ",", "\"blackAndWhite\"", ":", "x", ".", "gray_scale", "}", "for", "x", "in", "brain_pa...
Converts brain parameter proto to BrainParameter object. :param brain_param_proto: protobuf object. :return: BrainParameter object.
[ "Converts", "brain", "parameter", "proto", "to", "BrainParameter", "object", ".", ":", "param", "brain_param_proto", ":", "protobuf", "object", ".", ":", "return", ":", "BrainParameter", "object", "." ]
python
train
50.421053
dossier/dossier.store
dossier/store/elastic.py
https://github.com/dossier/dossier.store/blob/b22ffe2470bba9fcc98a30cb55b437bfa1521e7f/dossier/store/elastic.py#L368-L393
def fulltext_scan_ids(self, query_id=None, query_fc=None, preserve_order=True, indexes=None): '''Fulltext search for identifiers. Yields an iterable of triples (score, identifier) corresponding to the search results of the fulltext search in ``query``. This wil...
[ "def", "fulltext_scan_ids", "(", "self", ",", "query_id", "=", "None", ",", "query_fc", "=", "None", ",", "preserve_order", "=", "True", ",", "indexes", "=", "None", ")", ":", "it", "=", "self", ".", "_fulltext_scan", "(", "query_id", ",", "query_fc", ",...
Fulltext search for identifiers. Yields an iterable of triples (score, identifier) corresponding to the search results of the fulltext search in ``query``. This will only search text indexed under the given feature named ``fname``. Note that, unless ``preserve_order`` is set to...
[ "Fulltext", "search", "for", "identifiers", "." ]
python
test
42.923077
MolSSI-BSE/basis_set_exchange
basis_set_exchange/fileio.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/fileio.py#L232-L243
def read_notes_file(file_path): """ Returns the contents of a notes file. If the notes file does not exist, None is returned """ if not os.path.isfile(file_path): return None with open(file_path, 'r', encoding=_default_encoding) as f: return f.read()
[ "def", "read_notes_file", "(", "file_path", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file_path", ")", ":", "return", "None", "with", "open", "(", "file_path", ",", "'r'", ",", "encoding", "=", "_default_encoding", ")", "as", "f", ...
Returns the contents of a notes file. If the notes file does not exist, None is returned
[ "Returns", "the", "contents", "of", "a", "notes", "file", "." ]
python
train
23.5
Qiskit/qiskit-terra
qiskit/providers/basicaer/qasm_simulator.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L334-L372
def _validate_measure_sampling(self, experiment): """Determine if measure sampling is allowed for an experiment Args: experiment (QobjExperiment): a qobj experiment. """ # If shots=1 we should disable measure sampling. # This is also required for statevector simulato...
[ "def", "_validate_measure_sampling", "(", "self", ",", "experiment", ")", ":", "# If shots=1 we should disable measure sampling.", "# This is also required for statevector simulator to return the", "# correct final statevector without silently dropping final measurements.", "if", "self", "...
Determine if measure sampling is allowed for an experiment Args: experiment (QobjExperiment): a qobj experiment.
[ "Determine", "if", "measure", "sampling", "is", "allowed", "for", "an", "experiment" ]
python
test
46.358974
useblocks/groundwork
groundwork/pluginmanager.py
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L255-L265
def is_active(self, name): """ Returns True if plugin exists and is active. If plugin does not exist, it returns None :param name: plugin name :return: boolean or None """ if name in self._plugins.keys(): return self._plugins["name"].active re...
[ "def", "is_active", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_plugins", ".", "keys", "(", ")", ":", "return", "self", ".", "_plugins", "[", "\"name\"", "]", ".", "active", "return", "None" ]
Returns True if plugin exists and is active. If plugin does not exist, it returns None :param name: plugin name :return: boolean or None
[ "Returns", "True", "if", "plugin", "exists", "and", "is", "active", ".", "If", "plugin", "does", "not", "exist", "it", "returns", "None" ]
python
train
29
Jajcus/pyxmpp2
pyxmpp2/ext/disco.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/disco.py#L464-L474
def get_items(self): """Get the items contained in `self`. :return: the items contained. :returntype: `list` of `DiscoItem`""" ret=[] l=self.xpath_ctxt.xpathEval("d:item") if l is not None: for i in l: ret.append(DiscoItem(self, i)) re...
[ "def", "get_items", "(", "self", ")", ":", "ret", "=", "[", "]", "l", "=", "self", ".", "xpath_ctxt", ".", "xpathEval", "(", "\"d:item\"", ")", "if", "l", "is", "not", "None", ":", "for", "i", "in", "l", ":", "ret", ".", "append", "(", "DiscoItem...
Get the items contained in `self`. :return: the items contained. :returntype: `list` of `DiscoItem`
[ "Get", "the", "items", "contained", "in", "self", "." ]
python
valid
28.909091
vladsaveliev/TargQC
targqc/utilz/jsontemplate/_jsontemplate.py
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/_jsontemplate.py#L741-L744
def _Pairs(data): """dictionary -> list of pairs""" keys = sorted(data) return [{'@key': k, '@value': data[k]} for k in keys]
[ "def", "_Pairs", "(", "data", ")", ":", "keys", "=", "sorted", "(", "data", ")", "return", "[", "{", "'@key'", ":", "k", ",", "'@value'", ":", "data", "[", "k", "]", "}", "for", "k", "in", "keys", "]" ]
dictionary -> list of pairs
[ "dictionary", "-", ">", "list", "of", "pairs" ]
python
train
33.5
UDST/urbansim
urbansim/models/dcm.py
https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L474-L560
def probabilities(self, choosers, alternatives, filter_tables=True): """ Returns the probabilities for a set of choosers to choose from among a set of alternatives. Parameters ---------- choosers : pandas.DataFrame Table describing the agents making choices, ...
[ "def", "probabilities", "(", "self", ",", "choosers", ",", "alternatives", ",", "filter_tables", "=", "True", ")", ":", "logger", ".", "debug", "(", "'start: calculate probabilities for LCM model {}'", ".", "format", "(", "self", ".", "name", ")", ")", "self", ...
Returns the probabilities for a set of choosers to choose from among a set of alternatives. Parameters ---------- choosers : pandas.DataFrame Table describing the agents making choices, e.g. households. alternatives : pandas.DataFrame Table describing the...
[ "Returns", "the", "probabilities", "for", "a", "set", "of", "choosers", "to", "choose", "from", "among", "a", "set", "of", "alternatives", "." ]
python
train
39.885057
msuozzo/Lector
lector/reader.py
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L410-L424
def get_book_progress(self, asin): """Returns the progress data available for a book. NOTE: A summary of the two progress formats can be found in the docstring for `ReadingProgress`. Args: asin: The asin of the book to be queried. Returns: A `ReadingProgress` instance corresponding to...
[ "def", "get_book_progress", "(", "self", ",", "asin", ")", ":", "kbp", "=", "self", ".", "_get_api_call", "(", "'get_book_progress'", ",", "'\"%s\"'", "%", "asin", ")", "return", "KindleCloudReaderAPI", ".", "_kbp_to_progress", "(", "kbp", ")" ]
Returns the progress data available for a book. NOTE: A summary of the two progress formats can be found in the docstring for `ReadingProgress`. Args: asin: The asin of the book to be queried. Returns: A `ReadingProgress` instance corresponding to the book associated with `asin`.
[ "Returns", "the", "progress", "data", "available", "for", "a", "book", "." ]
python
train
31.466667
datadotworld/data.world-py
datadotworld/__init__.py
https://github.com/datadotworld/data.world-py/blob/ffaeb115f358731ab0b805b0c43b7ff2e3cf0a77/datadotworld/__init__.py#L104-L143
def query(dataset_key, query, query_type='sql', profile='default', parameters=None, **kwargs): """Query an existing dataset :param dataset_key: Dataset identifier, in the form of owner/id or of a url :type dataset_key: str :param query: SQL or SPARQL query :type query: str :param quer...
[ "def", "query", "(", "dataset_key", ",", "query", ",", "query_type", "=", "'sql'", ",", "profile", "=", "'default'", ",", "parameters", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "_get_instance", "(", "profile", ",", "*", "*", "kwargs", ...
Query an existing dataset :param dataset_key: Dataset identifier, in the form of owner/id or of a url :type dataset_key: str :param query: SQL or SPARQL query :type query: str :param query_type: The type of the query. Must be either 'sql' or 'sparql'. (Default value = 'sql') :type query...
[ "Query", "an", "existing", "dataset" ]
python
train
44.975
smartfile/client-python
smartfile/sync.py
https://github.com/smartfile/client-python/blob/f9ccc40a2870df447c65b53dc0747e37cab62d63/smartfile/sync.py#L116-L121
def download(self, local, remote): """ Performs synchronization from a remote file to a local file. The remote path is the source and the local path is the destination. """ self.sync(RemoteFile(remote, self.api), LocalFile(local))
[ "def", "download", "(", "self", ",", "local", ",", "remote", ")", ":", "self", ".", "sync", "(", "RemoteFile", "(", "remote", ",", "self", ".", "api", ")", ",", "LocalFile", "(", "local", ")", ")" ]
Performs synchronization from a remote file to a local file. The remote path is the source and the local path is the destination.
[ "Performs", "synchronization", "from", "a", "remote", "file", "to", "a", "local", "file", ".", "The", "remote", "path", "is", "the", "source", "and", "the", "local", "path", "is", "the", "destination", "." ]
python
train
44.166667
cokelaer/spectrum
doc/sphinxext/sphinx_gallery/gen_gallery.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/doc/sphinxext/sphinx_gallery/gen_gallery.py#L114-L123
def setup(app): """Setup sphinx-gallery sphinx extension""" app.add_config_value('plot_gallery', True, 'html') app.add_config_value('abort_on_example_error', False, 'html') app.add_config_value('sphinx_gallery_conf', gallery_conf, 'html') app.add_stylesheet('gallery.css') app.connect('builder-i...
[ "def", "setup", "(", "app", ")", ":", "app", ".", "add_config_value", "(", "'plot_gallery'", ",", "True", ",", "'html'", ")", "app", ".", "add_config_value", "(", "'abort_on_example_error'", ",", "False", ",", "'html'", ")", "app", ".", "add_config_value", "...
Setup sphinx-gallery sphinx extension
[ "Setup", "sphinx", "-", "gallery", "sphinx", "extension" ]
python
valid
39.3
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L88-L144
def rmp_pixel_deg_xys(vecX, vecY, vecPrfSd, tplPngSize, varExtXmin, varExtXmax, varExtYmin, varExtYmax): """Remap x, y, sigma parameters from pixel to degree. Parameters ---------- vecX : 1D numpy array Array with possible x parametrs in pixels vecY : 1D numpy array ...
[ "def", "rmp_pixel_deg_xys", "(", "vecX", ",", "vecY", ",", "vecPrfSd", ",", "tplPngSize", ",", "varExtXmin", ",", "varExtXmax", ",", "varExtYmin", ",", "varExtYmax", ")", ":", "# Remap modelled x-positions of the pRFs:", "vecXdgr", "=", "rmp_rng", "(", "vecX", ","...
Remap x, y, sigma parameters from pixel to degree. Parameters ---------- vecX : 1D numpy array Array with possible x parametrs in pixels vecY : 1D numpy array Array with possible y parametrs in pixels vecPrfSd : 1D numpy array Array with possible sd parametrs in pixels t...
[ "Remap", "x", "y", "sigma", "parameters", "from", "pixel", "to", "degree", "." ]
python
train
39.017544
twilio/twilio-python
twilio/rest/api/v2010/account/message/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/message/__init__.py#L162-L199
def page(self, to=values.unset, from_=values.unset, date_sent_before=values.unset, date_sent=values.unset, date_sent_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInstance record...
[ "def", "page", "(", "self", ",", "to", "=", "values", ".", "unset", ",", "from_", "=", "values", ".", "unset", ",", "date_sent_before", "=", "values", ".", "unset", ",", "date_sent", "=", "values", ".", "unset", ",", "date_sent_after", "=", "values", "...
Retrieve a single page of MessageInstance records from the API. Request is executed immediately :param unicode to: Filter by messages sent to this number :param unicode from_: Filter by from number :param datetime date_sent_before: Filter by date sent :param datetime date_sent: ...
[ "Retrieve", "a", "single", "page", "of", "MessageInstance", "records", "from", "the", "API", ".", "Request", "is", "executed", "immediately" ]
python
train
41.052632
edaniszewski/colorutils
colorutils/colorutils.py
https://github.com/edaniszewski/colorutils/blob/bdff54091cb5d62aa8628ce39bc09abd40fb8dd0/colorutils/colorutils.py#L230-L248
def offset_random_rgb(seed, amount=1): """ Given a seed color, generate a specified number of random colors (1 color by default) determined by a randomized offset from the seed. :param seed: :param amount: :return: """ r, g, b = seed results = [] for _ in range(amount): ...
[ "def", "offset_random_rgb", "(", "seed", ",", "amount", "=", "1", ")", ":", "r", ",", "g", ",", "b", "=", "seed", "results", "=", "[", "]", "for", "_", "in", "range", "(", "amount", ")", ":", "base_val", "=", "(", "(", "r", "+", "g", "+", "b"...
Given a seed color, generate a specified number of random colors (1 color by default) determined by a randomized offset from the seed. :param seed: :param amount: :return:
[ "Given", "a", "seed", "color", "generate", "a", "specified", "number", "of", "random", "colors", "(", "1", "color", "by", "default", ")", "determined", "by", "a", "randomized", "offset", "from", "the", "seed", "." ]
python
valid
38.473684
b3j0f/task
b3j0f/task/condition.py
https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L168-L197
def condition(condition=None, statement=None, _else=None, **kwargs): """ Run an statement if input condition is checked and return statement result. :param condition: condition to check. :type condition: str or dict :param statement: statement to process if condition is checked. :type statement...
[ "def", "condition", "(", "condition", "=", "None", ",", "statement", "=", "None", ",", "_else", "=", "None", ",", "*", "*", "kwargs", ")", ":", "result", "=", "None", "checked", "=", "False", "if", "condition", "is", "not", "None", ":", "checked", "=...
Run an statement if input condition is checked and return statement result. :param condition: condition to check. :type condition: str or dict :param statement: statement to process if condition is checked. :type statement: str or dict :param _else: else statement. :type _else: str or dict ...
[ "Run", "an", "statement", "if", "input", "condition", "is", "checked", "and", "return", "statement", "result", "." ]
python
train
28.333333
deepmind/sonnet
sonnet/python/modules/rnn_core.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/rnn_core.py#L331-L349
def _build(self): """Connects the module to the graph. Returns: The learnable state, which has the same type, structure and shape as the `initial_state` passed to the constructor. """ flat_initial_state = nest.flatten(self._initial_state) if self._mask is not None: flat_mask = n...
[ "def", "_build", "(", "self", ")", ":", "flat_initial_state", "=", "nest", ".", "flatten", "(", "self", ".", "_initial_state", ")", "if", "self", ".", "_mask", "is", "not", "None", ":", "flat_mask", "=", "nest", ".", "flatten", "(", "self", ".", "_mask...
Connects the module to the graph. Returns: The learnable state, which has the same type, structure and shape as the `initial_state` passed to the constructor.
[ "Connects", "the", "module", "to", "the", "graph", "." ]
python
train
42.105263
codelv/enaml-native
src/enamlnative/android/android_fragment.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L73-L81
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidFragment, self).init_widget() f = self.fragment f.setFragmentListener(f.getId()) f.onCreateView.connect(self.on_create_view) f.onDestroyView.connect(self.on_destroy_view)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidFragment", ",", "self", ")", ".", "init_widget", "(", ")", "f", "=", "self", ".", "fragment", "f", ".", "setFragmentListener", "(", "f", ".", "getId", "(", ")", ")", "f", ".", "onCrea...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
python
train
33
bitly/asyncmongo
asyncmongo/cursor.py
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/cursor.py#L157-L253
def update(self, spec, document, upsert=False, manipulate=False, safe=True, multi=False, callback=None, **kwargs): """Update a document(s) in this collection. Raises :class:`TypeError` if either `spec` or `document` is not an instance of ``dict`` or `upsert` is not an ins...
[ "def", "update", "(", "self", ",", "spec", ",", "document", ",", "upsert", "=", "False", ",", "manipulate", "=", "False", ",", "safe", "=", "True", ",", "multi", "=", "False", ",", "callback", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", ...
Update a document(s) in this collection. Raises :class:`TypeError` if either `spec` or `document` is not an instance of ``dict`` or `upsert` is not an instance of ``bool``. If `safe` is ``True`` then the update will be checked for errors, raising :class:`~pymongo.errors....
[ "Update", "a", "document", "(", "s", ")", "in", "this", "collection", ".", "Raises", ":", "class", ":", "TypeError", "if", "either", "spec", "or", "document", "is", "not", "an", "instance", "of", "dict", "or", "upsert", "is", "not", "an", "instance", "...
python
train
45.43299
genialis/resolwe
resolwe/elastic/builder.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L397-L416
def _connect_signal(self, index): """Create signals for building indexes.""" post_save_signal = ElasticSignal(index, 'build') post_save_signal.connect(post_save, sender=index.object_type) self.signals.append(post_save_signal) post_delete_signal = ElasticSignal(index, 'remove_obj...
[ "def", "_connect_signal", "(", "self", ",", "index", ")", ":", "post_save_signal", "=", "ElasticSignal", "(", "index", ",", "'build'", ")", "post_save_signal", ".", "connect", "(", "post_save", ",", "sender", "=", "index", ".", "object_type", ")", "self", "....
Create signals for building indexes.
[ "Create", "signals", "for", "building", "indexes", "." ]
python
train
48.95
dgomes/pymediaroom
pymediaroom/notify.py
https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L60-L69
def tune(self): """XML node representing tune.""" if self._node.get('activities'): tune = self._node['activities'].get('tune') if type(tune) is collections.OrderedDict: return tune elif type(tune) is list: return tune[0] ret...
[ "def", "tune", "(", "self", ")", ":", "if", "self", ".", "_node", ".", "get", "(", "'activities'", ")", ":", "tune", "=", "self", ".", "_node", "[", "'activities'", "]", ".", "get", "(", "'tune'", ")", "if", "type", "(", "tune", ")", "is", "colle...
XML node representing tune.
[ "XML", "node", "representing", "tune", "." ]
python
train
33.9
spyder-ide/spyder
spyder/app/mainwindow.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2282-L2289
def moveEvent(self, event): """Reimplement Qt method""" if not self.isMaximized() and not self.fullscreen_flag: self.window_position = self.pos() QMainWindow.moveEvent(self, event) # To be used by the tour to be able to move self.sig_moved.emit(event)
[ "def", "moveEvent", "(", "self", ",", "event", ")", ":", "if", "not", "self", ".", "isMaximized", "(", ")", "and", "not", "self", ".", "fullscreen_flag", ":", "self", ".", "window_position", "=", "self", ".", "pos", "(", ")", "QMainWindow", ".", "moveE...
Reimplement Qt method
[ "Reimplement", "Qt", "method" ]
python
train
38
pyblish/pyblish-qml
pyblish_qml/models.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/models.py#L798-L807
def add_inclusion(self, role, value): """Include item if `role` equals `value` Attributes: role (int): Qt role to compare `value` to value (object): Value to exclude """ self._add_rule(self.includes, role, value)
[ "def", "add_inclusion", "(", "self", ",", "role", ",", "value", ")", ":", "self", ".", "_add_rule", "(", "self", ".", "includes", ",", "role", ",", "value", ")" ]
Include item if `role` equals `value` Attributes: role (int): Qt role to compare `value` to value (object): Value to exclude
[ "Include", "item", "if", "role", "equals", "value" ]
python
train
26.2
totalgood/nlpia
src/nlpia/utils.py
https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/utils.py#L14-L23
def stdout_logging(loglevel=logging.INFO): """Setup basic logging Args: loglevel (int): minimum loglevel for emitting messages """ logformat = "[%(asctime)s] %(levelname)s:%(name)s:%(lineno)d: %(message)s" logging.config.dictConfig(level=loglevel, stream=sys.stdout, ...
[ "def", "stdout_logging", "(", "loglevel", "=", "logging", ".", "INFO", ")", ":", "logformat", "=", "\"[%(asctime)s] %(levelname)s:%(name)s:%(lineno)d: %(message)s\"", "logging", ".", "config", ".", "dictConfig", "(", "level", "=", "loglevel", ",", "stream", "=", "sy...
Setup basic logging Args: loglevel (int): minimum loglevel for emitting messages
[ "Setup", "basic", "logging" ]
python
train
36.2
materialsproject/pymatgen
pymatgen/core/structure.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/structure.py#L1402-L1602
def get_primitive_structure(self, tolerance=0.25, use_site_props=False, constrain_latt=None): """ This finds a smaller unit cell than the input. Sometimes it doesn"t find the smallest possible one, so this method is recursively called until it is unable to...
[ "def", "get_primitive_structure", "(", "self", ",", "tolerance", "=", "0.25", ",", "use_site_props", "=", "False", ",", "constrain_latt", "=", "None", ")", ":", "if", "constrain_latt", "is", "None", ":", "constrain_latt", "=", "[", "]", "def", "site_label", ...
This finds a smaller unit cell than the input. Sometimes it doesn"t find the smallest possible one, so this method is recursively called until it is unable to find a smaller cell. NOTE: if the tolerance is greater than 1/2 the minimum inter-site distance in the primitive cell, the algor...
[ "This", "finds", "a", "smaller", "unit", "cell", "than", "the", "input", ".", "Sometimes", "it", "doesn", "t", "find", "the", "smallest", "possible", "one", "so", "this", "method", "is", "recursively", "called", "until", "it", "is", "unable", "to", "find",...
python
train
44.597015
xeroc/python-graphenelib
graphenecommon/account.py
https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/account.py#L51-L77
def refresh(self): """ Refresh/Obtain an account's data from the API server """ import re if re.match(r"^1\.2\.[0-9]*$", self.identifier): account = self.blockchain.rpc.get_objects([self.identifier])[0] else: account = self.blockchain.rpc.lookup_account_n...
[ "def", "refresh", "(", "self", ")", ":", "import", "re", "if", "re", ".", "match", "(", "r\"^1\\.2\\.[0-9]*$\"", ",", "self", ".", "identifier", ")", ":", "account", "=", "self", ".", "blockchain", ".", "rpc", ".", "get_objects", "(", "[", "self", ".",...
Refresh/Obtain an account's data from the API server
[ "Refresh", "/", "Obtain", "an", "account", "s", "data", "from", "the", "API", "server" ]
python
valid
40.592593
DMSC-Instrument-Data/lewis
src/lewis/core/devices.py
https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/core/devices.py#L93-L102
def is_device(obj): """ Returns True if obj is a device type (derived from DeviceBase), but not defined in :mod:`lewis.core.devices` or :mod:`lewis.devices`. :param obj: Object to test. :return: True if obj is a device type. """ return isinstance(obj, type) and issubclass( obj, Devi...
[ "def", "is_device", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "type", ")", "and", "issubclass", "(", "obj", ",", "DeviceBase", ")", "and", "obj", ".", "__module__", "not", "in", "(", "'lewis.devices'", ",", "'lewis.core.devices'", ")" ...
Returns True if obj is a device type (derived from DeviceBase), but not defined in :mod:`lewis.core.devices` or :mod:`lewis.devices`. :param obj: Object to test. :return: True if obj is a device type.
[ "Returns", "True", "if", "obj", "is", "a", "device", "type", "(", "derived", "from", "DeviceBase", ")", "but", "not", "defined", "in", ":", "mod", ":", "lewis", ".", "core", ".", "devices", "or", ":", "mod", ":", "lewis", ".", "devices", "." ]
python
train
38.4
thiezn/iperf3-python
iperf3/iperf3.py
https://github.com/thiezn/iperf3-python/blob/094a6e043f44fb154988348603661b1473c23a50/iperf3/iperf3.py#L586-L598
def reverse(self): """Toggles direction of test :rtype: bool """ enabled = self.lib.iperf_get_test_reverse(self._test) if enabled: self._reverse = True else: self._reverse = False return self._reverse
[ "def", "reverse", "(", "self", ")", ":", "enabled", "=", "self", ".", "lib", ".", "iperf_get_test_reverse", "(", "self", ".", "_test", ")", "if", "enabled", ":", "self", ".", "_reverse", "=", "True", "else", ":", "self", ".", "_reverse", "=", "False", ...
Toggles direction of test :rtype: bool
[ "Toggles", "direction", "of", "test" ]
python
train
20.846154
titusjan/argos
argos/repo/repotreemodel.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/repotreemodel.py#L53-L113
def itemData(self, treeItem, column, role=Qt.DisplayRole): """ Returns the data stored under the given role for the item. O """ if role == Qt.DisplayRole: if column == self.COL_NODE_NAME: return treeItem.nodeName elif column == self.COL_NODE_PATH: ...
[ "def", "itemData", "(", "self", ",", "treeItem", ",", "column", ",", "role", "=", "Qt", ".", "DisplayRole", ")", ":", "if", "role", "==", "Qt", ".", "DisplayRole", ":", "if", "column", "==", "self", ".", "COL_NODE_NAME", ":", "return", "treeItem", ".",...
Returns the data stored under the given role for the item. O
[ "Returns", "the", "data", "stored", "under", "the", "given", "role", "for", "the", "item", ".", "O" ]
python
train
46.704918
phoebe-project/phoebe2
phoebe/distortions/roche.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/distortions/roche.py#L170-L179
def dBinaryRochedz(r, D, q, F): """ Computes a derivative of the potential with respect to z. @param r: relative radius vector (3 components) @param D: instantaneous separation @param q: mass ratio @param F: synchronicity parameter """ return -r[2]*(r[0]*r[0]+r[1]*r...
[ "def", "dBinaryRochedz", "(", "r", ",", "D", ",", "q", ",", "F", ")", ":", "return", "-", "r", "[", "2", "]", "*", "(", "r", "[", "0", "]", "*", "r", "[", "0", "]", "+", "r", "[", "1", "]", "*", "r", "[", "1", "]", "+", "r", "[", "2...
Computes a derivative of the potential with respect to z. @param r: relative radius vector (3 components) @param D: instantaneous separation @param q: mass ratio @param F: synchronicity parameter
[ "Computes", "a", "derivative", "of", "the", "potential", "with", "respect", "to", "z", "." ]
python
train
38.5
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8672-L8725
def read_micromanager_metadata(fh): """Read MicroManager non-TIFF settings from open file and return as dict. The settings can be used to read image data without parsing the TIFF file. Raise ValueError if the file does not contain valid MicroManager metadata. """ fh.seek(0) try: byteo...
[ "def", "read_micromanager_metadata", "(", "fh", ")", ":", "fh", ".", "seek", "(", "0", ")", "try", ":", "byteorder", "=", "{", "b'II'", ":", "'<'", ",", "b'MM'", ":", "'>'", "}", "[", "fh", ".", "read", "(", "2", ")", "]", "except", "IndexError", ...
Read MicroManager non-TIFF settings from open file and return as dict. The settings can be used to read image data without parsing the TIFF file. Raise ValueError if the file does not contain valid MicroManager metadata.
[ "Read", "MicroManager", "non", "-", "TIFF", "settings", "from", "open", "file", "and", "return", "as", "dict", "." ]
python
train
39.148148
mozilla/puente
puente/commands.py
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/commands.py#L67-L129
def extract_command(outputdir, domain_methods, text_domain, keywords, comment_tags, base_dir, project, version, msgid_bugs_address): """Extracts strings into .pot files :arg domain: domains to generate strings for or 'all' for all domains :arg outputdir: output dir f...
[ "def", "extract_command", "(", "outputdir", ",", "domain_methods", ",", "text_domain", ",", "keywords", ",", "comment_tags", ",", "base_dir", ",", "project", ",", "version", ",", "msgid_bugs_address", ")", ":", "# Must monkeypatch first to fix i18n extensions stomping iss...
Extracts strings into .pot files :arg domain: domains to generate strings for or 'all' for all domains :arg outputdir: output dir for .pot files; usually locale/templates/LC_MESSAGES/ :arg domain_methods: DOMAIN_METHODS setting :arg text_domain: TEXT_DOMAIN settings :arg keywords: KEYWORDS ...
[ "Extracts", "strings", "into", ".", "pot", "files" ]
python
train
32.714286
peopledoc/workalendar
workalendar/registry.py
https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/registry.py#L69-L88
def items(self, region_codes, include_subregions=False): """ Returns calendar classes for regions :param region_codes list of ISO codes for selected regions :param include_subregions boolean if subregions of selected regions should be included in result :rtype dict ...
[ "def", "items", "(", "self", ",", "region_codes", ",", "include_subregions", "=", "False", ")", ":", "items", "=", "OrderedDict", "(", ")", "for", "code", "in", "region_codes", ":", "try", ":", "items", "[", "code", "]", "=", "self", ".", "region_registr...
Returns calendar classes for regions :param region_codes list of ISO codes for selected regions :param include_subregions boolean if subregions of selected regions should be included in result :rtype dict :return dict where keys are ISO codes strings and values are calen...
[ "Returns", "calendar", "classes", "for", "regions" ]
python
train
35.25
anti1869/sunhead
src/sunhead/utils.py
https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/utils.py#L99-L113
async def parallel_results(future_map: Sequence[Tuple]) -> Dict: """ Run parallel execution of futures and return mapping of their results to the provided keys. Just a neat shortcut around ``asyncio.gather()`` :param future_map: Keys to futures mapping, e.g.: ( ('nav', get_nav()), ('content, get_conten...
[ "async", "def", "parallel_results", "(", "future_map", ":", "Sequence", "[", "Tuple", "]", ")", "->", "Dict", ":", "ctx_methods", "=", "OrderedDict", "(", "future_map", ")", "fs", "=", "list", "(", "ctx_methods", ".", "values", "(", ")", ")", "results", ...
Run parallel execution of futures and return mapping of their results to the provided keys. Just a neat shortcut around ``asyncio.gather()`` :param future_map: Keys to futures mapping, e.g.: ( ('nav', get_nav()), ('content, get_content()) ) :return: Dict with futures results mapped to keys {'nav': {1:2}, '...
[ "Run", "parallel", "execution", "of", "futures", "and", "return", "mapping", "of", "their", "results", "to", "the", "provided", "keys", ".", "Just", "a", "neat", "shortcut", "around", "asyncio", ".", "gather", "()" ]
python
train
42.533333