repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
serge-sans-paille/pythran
pythran/types/types.py
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L106-L112
def register(self, ptype): """register ptype as a local typedef""" # Too many of them leads to memory burst if len(self.typedefs) < cfg.getint('typing', 'max_combiner'): self.typedefs.append(ptype) return True return False
[ "def", "register", "(", "self", ",", "ptype", ")", ":", "# Too many of them leads to memory burst", "if", "len", "(", "self", ".", "typedefs", ")", "<", "cfg", ".", "getint", "(", "'typing'", ",", "'max_combiner'", ")", ":", "self", ".", "typedefs", ".", "...
register ptype as a local typedef
[ "register", "ptype", "as", "a", "local", "typedef" ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/process.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L943-L1062
def get_image_name(self): """ @rtype: int @return: Filename of the process main module. This method does it's best to retrieve the filename. However sometimes this is not possible, so C{None} may be returned instead. """ # Method 1: Module.f...
[ "def", "get_image_name", "(", "self", ")", ":", "# Method 1: Module.fileName", "# It's cached if the filename was already found by the other methods,", "# if it came with the corresponding debug event, or it was found by the", "# toolhelp API.", "mainModule", "=", "None", "try", ":", "...
@rtype: int @return: Filename of the process main module. This method does it's best to retrieve the filename. However sometimes this is not possible, so C{None} may be returned instead.
[ "@rtype", ":", "int", "@return", ":", "Filename", "of", "the", "process", "main", "module", "." ]
python
train
quantmind/pulsar
pulsar/apps/rpc/jsonrpc.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/rpc/jsonrpc.py#L253-L265
def get_params(self, *args, **kwargs): ''' Create an array or positional or named parameters Mixing positional and named parameters in one call is not possible. ''' kwargs.update(self._data) if args and kwargs: raise ValueError('Cannot mix positional a...
[ "def", "get_params", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_data", ")", "if", "args", "and", "kwargs", ":", "raise", "ValueError", "(", "'Cannot mix positional and named parameters'", ...
Create an array or positional or named parameters Mixing positional and named parameters in one call is not possible.
[ "Create", "an", "array", "or", "positional", "or", "named", "parameters", "Mixing", "positional", "and", "named", "parameters", "in", "one", "call", "is", "not", "possible", "." ]
python
train
coleifer/huey
huey/api.py
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/api.py#L913-L990
def crontab(minute='*', hour='*', day='*', month='*', day_of_week='*'): """ Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable input...
[ "def", "crontab", "(", "minute", "=", "'*'", ",", "hour", "=", "'*'", ",", "day", "=", "'*'", ",", "month", "=", "'*'", ",", "day_of_week", "=", "'*'", ")", ":", "validation", "=", "(", "(", "'m'", ",", "month", ",", "range", "(", "1", ",", "13...
Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable inputs: * = every distinct value */n = run every "n" times, i.e. hours='*/4' == 0...
[ "Convert", "a", "crontab", "-", "style", "set", "of", "parameters", "into", "a", "test", "function", "that", "will", "return", "True", "when", "the", "given", "datetime", "matches", "the", "parameters", "set", "forth", "in", "the", "crontab", "." ]
python
train
silver-castle/mach9
mach9/config.py
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/config.py#L193-L201
def load_environment_vars(self): """ Looks for any MACH9_ prefixed environment variables and applies them to the configuration if present. """ for k, v in os.environ.items(): if k.startswith(MACH9_PREFIX): _, config_key = k.split(MACH9_PREFIX, 1) ...
[ "def", "load_environment_vars", "(", "self", ")", ":", "for", "k", ",", "v", "in", "os", ".", "environ", ".", "items", "(", ")", ":", "if", "k", ".", "startswith", "(", "MACH9_PREFIX", ")", ":", "_", ",", "config_key", "=", "k", ".", "split", "(", ...
Looks for any MACH9_ prefixed environment variables and applies them to the configuration if present.
[ "Looks", "for", "any", "MACH9_", "prefixed", "environment", "variables", "and", "applies", "them", "to", "the", "configuration", "if", "present", "." ]
python
train
exhuma/config_resolver
config_resolver/core.py
https://github.com/exhuma/config_resolver/blob/2614ae3d7a49e437954254846b2963ad249b418c/config_resolver/core.py#L222-L232
def get_xdg_home(self): # type: () -> str """ Returns the value specified in the XDG_CONFIG_HOME environment variable or the appropriate default. """ config_home = getenv('XDG_CONFIG_HOME', '') if config_home: self._log.debug('XDG_CONFIG_HOME is set to...
[ "def", "get_xdg_home", "(", "self", ")", ":", "# type: () -> str", "config_home", "=", "getenv", "(", "'XDG_CONFIG_HOME'", ",", "''", ")", "if", "config_home", ":", "self", ".", "_log", ".", "debug", "(", "'XDG_CONFIG_HOME is set to %r'", ",", "config_home", ")"...
Returns the value specified in the XDG_CONFIG_HOME environment variable or the appropriate default.
[ "Returns", "the", "value", "specified", "in", "the", "XDG_CONFIG_HOME", "environment", "variable", "or", "the", "appropriate", "default", "." ]
python
valid
campaignmonitor/createsend-python
lib/createsend/person.py
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/person.py#L24-L33
def add(self, client_id, email_address, name, access_level, password): """Adds a person to a client. Password is optional and if not supplied, an invitation will be emailed to the person""" body = { "EmailAddress": email_address, "Name": name, "AccessLevel": access_le...
[ "def", "add", "(", "self", ",", "client_id", ",", "email_address", ",", "name", ",", "access_level", ",", "password", ")", ":", "body", "=", "{", "\"EmailAddress\"", ":", "email_address", ",", "\"Name\"", ":", "name", ",", "\"AccessLevel\"", ":", "access_lev...
Adds a person to a client. Password is optional and if not supplied, an invitation will be emailed to the person
[ "Adds", "a", "person", "to", "a", "client", ".", "Password", "is", "optional", "and", "if", "not", "supplied", "an", "invitation", "will", "be", "emailed", "to", "the", "person" ]
python
train
maljovec/topopy
topopy/MorseComplex.py
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseComplex.py#L263-L298
def get_partitions(self, persistence=None): """ Returns the partitioned data based on a specified persistence level. @ In, persistence, a floating point value specifying the size of the smallest feature we want to track. Default = None means consider all features....
[ "def", "get_partitions", "(", "self", ",", "persistence", "=", "None", ")", ":", "if", "persistence", "is", "None", ":", "persistence", "=", "self", ".", "persistence", "partitions", "=", "{", "}", "# TODO: Possibly cache at the critical persistence values,", "# pre...
Returns the partitioned data based on a specified persistence level. @ In, persistence, a floating point value specifying the size of the smallest feature we want to track. Default = None means consider all features. @ Out, a dictionary lists where each key is...
[ "Returns", "the", "partitioned", "data", "based", "on", "a", "specified", "persistence", "level", "." ]
python
train
python-gitlab/python-gitlab
gitlab/__init__.py
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/__init__.py#L192-L203
def auth(self): """Performs an authentication. Uses either the private token, or the email/password pair. The `user` attribute will hold a `gitlab.objects.CurrentUser` object on success. """ if self.private_token or self.oauth_token: self._token_auth() ...
[ "def", "auth", "(", "self", ")", ":", "if", "self", ".", "private_token", "or", "self", ".", "oauth_token", ":", "self", ".", "_token_auth", "(", ")", "else", ":", "self", ".", "_credentials_auth", "(", ")" ]
Performs an authentication. Uses either the private token, or the email/password pair. The `user` attribute will hold a `gitlab.objects.CurrentUser` object on success.
[ "Performs", "an", "authentication", "." ]
python
train
newville/wxmplot
examples/tifffile.py
https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1447-L1452
def read_cz_lsm_info(fd, byte_order, dtype, count): """Read CS_LSM_INFO tag from file and return as numpy.rec.array.""" result = numpy.rec.fromfile(fd, CZ_LSM_INFO, 1, byteorder=byte_order)[0] {50350412: '1.3', 67127628: '2.0'}[result.magic_number] # validation return re...
[ "def", "read_cz_lsm_info", "(", "fd", ",", "byte_order", ",", "dtype", ",", "count", ")", ":", "result", "=", "numpy", ".", "rec", ".", "fromfile", "(", "fd", ",", "CZ_LSM_INFO", ",", "1", ",", "byteorder", "=", "byte_order", ")", "[", "0", "]", "{",...
Read CS_LSM_INFO tag from file and return as numpy.rec.array.
[ "Read", "CS_LSM_INFO", "tag", "from", "file", "and", "return", "as", "numpy", ".", "rec", ".", "array", "." ]
python
train
ONSdigital/sdc-rabbit
sdc/rabbit/consumers.py
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/consumers.py#L318-L325
def stop_consuming(self): """Tell RabbitMQ that you would like to stop consuming by sending the Basic.Cancel RPC command. """ if self._channel: logger.info('Sending a Basic.Cancel RPC command to RabbitMQ') self._channel.basic_cancel(self.on_cancelok, self._consum...
[ "def", "stop_consuming", "(", "self", ")", ":", "if", "self", ".", "_channel", ":", "logger", ".", "info", "(", "'Sending a Basic.Cancel RPC command to RabbitMQ'", ")", "self", ".", "_channel", ".", "basic_cancel", "(", "self", ".", "on_cancelok", ",", "self", ...
Tell RabbitMQ that you would like to stop consuming by sending the Basic.Cancel RPC command.
[ "Tell", "RabbitMQ", "that", "you", "would", "like", "to", "stop", "consuming", "by", "sending", "the", "Basic", ".", "Cancel", "RPC", "command", "." ]
python
train
explosion/thinc
thinc/neural/_classes/rnn.py
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/_classes/rnn.py#L12-L14
def BiLSTM(nO, nI): """Create a bidirectional LSTM layer. Args: number out, number in""" return Bidirectional(LSTM(nO // 2, nI), LSTM(nO // 2, nI))
[ "def", "BiLSTM", "(", "nO", ",", "nI", ")", ":", "return", "Bidirectional", "(", "LSTM", "(", "nO", "//", "2", ",", "nI", ")", ",", "LSTM", "(", "nO", "//", "2", ",", "nI", ")", ")" ]
Create a bidirectional LSTM layer. Args: number out, number in
[ "Create", "a", "bidirectional", "LSTM", "layer", ".", "Args", ":", "number", "out", "number", "in" ]
python
train
digidotcom/python-wvalib
wva/cli.py
https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/cli.py#L344-L348
def list(ctx): """List short name of all current subscriptions""" wva = get_wva(ctx) for subscription in wva.get_subscriptions(): print(subscription.short_name)
[ "def", "list", "(", "ctx", ")", ":", "wva", "=", "get_wva", "(", "ctx", ")", "for", "subscription", "in", "wva", ".", "get_subscriptions", "(", ")", ":", "print", "(", "subscription", ".", "short_name", ")" ]
List short name of all current subscriptions
[ "List", "short", "name", "of", "all", "current", "subscriptions" ]
python
train
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/directory.py
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/directory.py#L2135-L2169
def del_ip_address(self, ip_address, sync=True): """ delete ip address from this OS instance :param ip_address: the ip address to be deleted from this OS instance :param sync: If sync=True(default) synchronize with Ariane server. If sync=False, add the ipAddress object on list to...
[ "def", "del_ip_address", "(", "self", ",", "ip_address", ",", "sync", "=", "True", ")", ":", "LOGGER", ".", "debug", "(", "\"OSInstance.del_ip_address\"", ")", "if", "not", "sync", ":", "self", ".", "ip_address_2_rm", ".", "append", "(", "ip_address", ")", ...
delete ip address from this OS instance :param ip_address: the ip address to be deleted from this OS instance :param sync: If sync=True(default) synchronize with Ariane server. If sync=False, add the ipAddress object on list to be removed on next save(). :return:
[ "delete", "ip", "address", "from", "this", "OS", "instance", ":", "param", "ip_address", ":", "the", "ip", "address", "to", "be", "deleted", "from", "this", "OS", "instance", ":", "param", "sync", ":", "If", "sync", "=", "True", "(", "default", ")", "s...
python
train
python-odin/odinweb
odinweb/data_structures.py
https://github.com/python-odin/odinweb/blob/198424133584acc18cb41c8d18d91f803abc810f/odinweb/data_structures.py#L760-L787
def getlist(self, key, type_=None): # type: (Hashable, Callable) -> List[Any] """ Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just as `get` `getlist` accepts a `type` parameter. All items will be conve...
[ "def", "getlist", "(", "self", ",", "key", ",", "type_", "=", "None", ")", ":", "# type: (Hashable, Callable) -> List[Any]", "try", ":", "rv", "=", "dict", ".", "__getitem__", "(", "self", ",", "key", ")", "except", "KeyError", ":", "return", "[", "]", "...
Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just as `get` `getlist` accepts a `type` parameter. All items will be converted with the callable defined there. :param key: The key to be looked up. :param...
[ "Return", "the", "list", "of", "items", "for", "a", "given", "key", ".", "If", "that", "key", "is", "not", "in", "the", "MultiDict", "the", "return", "value", "will", "be", "an", "empty", "list", ".", "Just", "as", "get", "getlist", "accepts", "a", "...
python
train
basecrm/basecrm-python
basecrm/services.py
https://github.com/basecrm/basecrm-python/blob/7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6/basecrm/services.py#L1299-L1321
def create(self, *args, **kwargs): """ Create an order Create a new order for a deal User needs to have access to the deal to create an order Each deal can have at most one order and error is returned when attempting to create more :calls: ``post /orders`` :para...
[ "def", "create", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", "and", "not", "kwargs", ":", "raise", "Exception", "(", "'attributes for Order are missing'", ")", "attributes", "=", "args", "[", "0", "]", "if", "...
Create an order Create a new order for a deal User needs to have access to the deal to create an order Each deal can have at most one order and error is returned when attempting to create more :calls: ``post /orders`` :param tuple *args: (optional) Single object representing Or...
[ "Create", "an", "order" ]
python
train
cltl/KafNafParserPy
KafNafParserPy/KafNafParserMod.py
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/KafNafParserMod.py#L1045-L1072
def create_term(self, lemma, pos, morphofeat, tokens, id=None): """ Create a new term and add it to the term layer @type lemma: string @param lemma: The lemma of the term @type pos: string @param pos: The postrag(rst letter) of the POS attribute @type morphofeat: ...
[ "def", "create_term", "(", "self", ",", "lemma", ",", "pos", ",", "morphofeat", ",", "tokens", ",", "id", "=", "None", ")", ":", "if", "id", "is", "None", ":", "n", "=", "1", "if", "self", ".", "term_layer", "is", "None", "else", "len", "(", "sel...
Create a new term and add it to the term layer @type lemma: string @param lemma: The lemma of the term @type pos: string @param pos: The postrag(rst letter) of the POS attribute @type morphofeat: string @param morphofeat: The morphofeat (full morphological features) of th...
[ "Create", "a", "new", "term", "and", "add", "it", "to", "the", "term", "layer" ]
python
train
gem/oq-engine
openquake/hmtk/seismicity/selector.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/selector.py#L92-L106
def _get_decimal_from_datetime(time): ''' As the decimal time function requires inputs in the form of numpy arrays need to convert each value in the datetime object to a single numpy array ''' # Get decimal seconds from seconds + microseconds temp_seconds = np.float(time.second) + (np.floa...
[ "def", "_get_decimal_from_datetime", "(", "time", ")", ":", "# Get decimal seconds from seconds + microseconds", "temp_seconds", "=", "np", ".", "float", "(", "time", ".", "second", ")", "+", "(", "np", ".", "float", "(", "time", ".", "microsecond", ")", "/", ...
As the decimal time function requires inputs in the form of numpy arrays need to convert each value in the datetime object to a single numpy array
[ "As", "the", "decimal", "time", "function", "requires", "inputs", "in", "the", "form", "of", "numpy", "arrays", "need", "to", "convert", "each", "value", "in", "the", "datetime", "object", "to", "a", "single", "numpy", "array" ]
python
train
saltstack/salt
salt/states/pkg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pkg.py#L3329-L3349
def mod_watch(name, **kwargs): ''' Install/reinstall a package based on a watch requisite .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for this function should be set by the stat...
[ "def", "mod_watch", "(", "name", ",", "*", "*", "kwargs", ")", ":", "sfun", "=", "kwargs", ".", "pop", "(", "'sfun'", ",", "None", ")", "mapfun", "=", "{", "'purged'", ":", "purged", ",", "'latest'", ":", "latest", ",", "'removed'", ":", "removed", ...
Install/reinstall a package based on a watch requisite .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for this function should be set by the state being triggered.
[ "Install", "/", "reinstall", "a", "package", "based", "on", "a", "watch", "requisite" ]
python
train
dwavesystems/dwave_networkx
dwave_networkx/algorithms/coloring.py
https://github.com/dwavesystems/dwave_networkx/blob/9ea1223ddbc7e86db2f90b8b23e250e6642c3d68/dwave_networkx/algorithms/coloring.py#L339-L378
def is_cycle(G): """Determines whether the given graph is a cycle or circle graph. A cycle graph or circular graph is a graph that consists of a single cycle. https://en.wikipedia.org/wiki/Cycle_graph Parameters ---------- G : NetworkX graph Returns ------- is_cycle : bool ...
[ "def", "is_cycle", "(", "G", ")", ":", "trailing", ",", "leading", "=", "next", "(", "iter", "(", "G", ".", "edges", ")", ")", "start_node", "=", "trailing", "# travel around the graph, checking that each node has degree exactly two", "# also track how many nodes were v...
Determines whether the given graph is a cycle or circle graph. A cycle graph or circular graph is a graph that consists of a single cycle. https://en.wikipedia.org/wiki/Cycle_graph Parameters ---------- G : NetworkX graph Returns ------- is_cycle : bool True if the graph cons...
[ "Determines", "whether", "the", "given", "graph", "is", "a", "cycle", "or", "circle", "graph", "." ]
python
train
ploneintranet/ploneintranet.workspace
src/ploneintranet/workspace/browser/roster.py
https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/roster.py#L43-L82
def update_users(self, entries): """Update user properties on the roster """ ws = IWorkspace(self.context) members = ws.members # check user permissions against join policy join_policy = self.context.join_policy if (join_policy == "admin" and not checkPermiss...
[ "def", "update_users", "(", "self", ",", "entries", ")", ":", "ws", "=", "IWorkspace", "(", "self", ".", "context", ")", "members", "=", "ws", ".", "members", "# check user permissions against join policy", "join_policy", "=", "self", ".", "context", ".", "joi...
Update user properties on the roster
[ "Update", "user", "properties", "on", "the", "roster" ]
python
train
mozilla/treeherder
treeherder/webapp/api/job_log_url.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/webapp/api/job_log_url.py#L23-L28
def retrieve(self, request, project, pk=None): """ Returns a job_log_url object given its ID """ log = JobLog.objects.get(id=pk) return Response(self._log_as_dict(log))
[ "def", "retrieve", "(", "self", ",", "request", ",", "project", ",", "pk", "=", "None", ")", ":", "log", "=", "JobLog", ".", "objects", ".", "get", "(", "id", "=", "pk", ")", "return", "Response", "(", "self", ".", "_log_as_dict", "(", "log", ")", ...
Returns a job_log_url object given its ID
[ "Returns", "a", "job_log_url", "object", "given", "its", "ID" ]
python
train
tensorflow/tensorboard
tensorboard/compat/tensorflow_stub/io/gfile.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/compat/tensorflow_stub/io/gfile.py#L61-L71
def get_filesystem(filename): """Return the registered filesystem for the given file.""" filename = compat.as_str_any(filename) prefix = "" index = filename.find("://") if index >= 0: prefix = filename[:index] fs = _REGISTERED_FILESYSTEMS.get(prefix, None) if fs is None: rais...
[ "def", "get_filesystem", "(", "filename", ")", ":", "filename", "=", "compat", ".", "as_str_any", "(", "filename", ")", "prefix", "=", "\"\"", "index", "=", "filename", ".", "find", "(", "\"://\"", ")", "if", "index", ">=", "0", ":", "prefix", "=", "fi...
Return the registered filesystem for the given file.
[ "Return", "the", "registered", "filesystem", "for", "the", "given", "file", "." ]
python
train
satellogic/telluric
telluric/georaster.py
https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L286-L329
def _fill_pixels(one, other): # type: (_Raster, _Raster) -> _Raster """Merges two single band rasters with the same band by filling the pixels according to depth. """ assert len(one.band_names) == len(other.band_names) == 1, "Rasters are not single band" # We raise an error in the intersection is ...
[ "def", "_fill_pixels", "(", "one", ",", "other", ")", ":", "# type: (_Raster, _Raster) -> _Raster", "assert", "len", "(", "one", ".", "band_names", ")", "==", "len", "(", "other", ".", "band_names", ")", "==", "1", ",", "\"Rasters are not single band\"", "# We r...
Merges two single band rasters with the same band by filling the pixels according to depth.
[ "Merges", "two", "single", "band", "rasters", "with", "the", "same", "band", "by", "filling", "the", "pixels", "according", "to", "depth", "." ]
python
train
dwavesystems/dimod
dimod/binary_quadratic_model.py
https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/binary_quadratic_model.py#L826-L890
def scale(self, scalar, ignored_variables=None, ignored_interactions=None, ignore_offset=False): """Multiply by the specified scalar all the biases and offset of a binary quadratic model. Args: scalar (number): Value by which to scale the energy range of the bi...
[ "def", "scale", "(", "self", ",", "scalar", ",", "ignored_variables", "=", "None", ",", "ignored_interactions", "=", "None", ",", "ignore_offset", "=", "False", ")", ":", "if", "ignored_variables", "is", "None", ":", "ignored_variables", "=", "set", "(", ")"...
Multiply by the specified scalar all the biases and offset of a binary quadratic model. Args: scalar (number): Value by which to scale the energy range of the binary quadratic model. ignored_variables (iterable, optional): Biases associated with these va...
[ "Multiply", "by", "the", "specified", "scalar", "all", "the", "biases", "and", "offset", "of", "a", "binary", "quadratic", "model", "." ]
python
train
pyrapt/rapt
rapt/treebrd/attributes.py
https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/attributes.py#L156-L181
def rename(self, names, prefix): """ Rename the Attributes' names, prefixes, or both. If names or prefix evaluates to None, the old version is used. Resulting names must be unambiguous. :param names: A list of new names for each attribute or an empty list. :param prefix: ...
[ "def", "rename", "(", "self", ",", "names", ",", "prefix", ")", ":", "if", "names", ":", "if", "len", "(", "names", ")", "!=", "len", "(", "self", ".", "_contents", ")", ":", "raise", "InputError", "(", "'Attribute count mismatch.'", ")", "if", "self",...
Rename the Attributes' names, prefixes, or both. If names or prefix evaluates to None, the old version is used. Resulting names must be unambiguous. :param names: A list of new names for each attribute or an empty list. :param prefix: A new prefix for the name or None
[ "Rename", "the", "Attributes", "names", "prefixes", "or", "both", ".", "If", "names", "or", "prefix", "evaluates", "to", "None", "the", "old", "version", "is", "used", ".", "Resulting", "names", "must", "be", "unambiguous", ".", ":", "param", "names", ":",...
python
train
hyperledger/indy-node
indy_node/server/upgrader.py
https://github.com/hyperledger/indy-node/blob/8fabd364eaf7d940a56df2911d9215b1e512a2de/indy_node/server/upgrader.py#L363-L399
def _cancelScheduledUpgrade(self, justification=None) -> None: """ Cancels scheduled upgrade :param when: time upgrade was scheduled to :param version: version upgrade scheduled for """ if self.scheduledAction: why_prefix = ": " why = justificati...
[ "def", "_cancelScheduledUpgrade", "(", "self", ",", "justification", "=", "None", ")", "->", "None", ":", "if", "self", ".", "scheduledAction", ":", "why_prefix", "=", "\": \"", "why", "=", "justification", "if", "justification", "is", "None", ":", "why_prefix...
Cancels scheduled upgrade :param when: time upgrade was scheduled to :param version: version upgrade scheduled for
[ "Cancels", "scheduled", "upgrade" ]
python
train
WojciechMula/canvas2svg
canvasvg.py
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L318-L331
def SVGdocument(): "Create default SVG document" import xml.dom.minidom implementation = xml.dom.minidom.getDOMImplementation() doctype = implementation.createDocumentType( "svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" ) document= implementation.createDocument(None, "sv...
[ "def", "SVGdocument", "(", ")", ":", "import", "xml", ".", "dom", ".", "minidom", "implementation", "=", "xml", ".", "dom", ".", "minidom", ".", "getDOMImplementation", "(", ")", "doctype", "=", "implementation", ".", "createDocumentType", "(", "\"svg\"", ",...
Create default SVG document
[ "Create", "default", "SVG", "document" ]
python
train
sjkingo/virtualenv-api
virtualenvapi/manage.py
https://github.com/sjkingo/virtualenv-api/blob/146a181e540ae2ae89c2542497dea0cedbc78839/virtualenvapi/manage.py#L166-L170
def _write_to_error(self, s, truncate=False): """Writes the given output to the error file, appending unless `truncate` is True.""" # if truncate is True, set write mode to truncate with open(self._errorfile, 'w' if truncate else 'a') as fp: fp.writelines((to_text(s)), )
[ "def", "_write_to_error", "(", "self", ",", "s", ",", "truncate", "=", "False", ")", ":", "# if truncate is True, set write mode to truncate", "with", "open", "(", "self", ".", "_errorfile", ",", "'w'", "if", "truncate", "else", "'a'", ")", "as", "fp", ":", ...
Writes the given output to the error file, appending unless `truncate` is True.
[ "Writes", "the", "given", "output", "to", "the", "error", "file", "appending", "unless", "truncate", "is", "True", "." ]
python
train
vintasoftware/django-role-permissions
rolepermissions/permissions.py
https://github.com/vintasoftware/django-role-permissions/blob/28924361e689e994e0c3575e18104a1a5abd8de6/rolepermissions/permissions.py#L73-L91
def grant_permission(user, permission_name): """ Grant a user a specified permission. Permissions are only granted if they are in the scope any of the user's roles. If the permission is out of scope, a RolePermissionScopeException is raised. """ roles = get_user_roles(user) for role in...
[ "def", "grant_permission", "(", "user", ",", "permission_name", ")", ":", "roles", "=", "get_user_roles", "(", "user", ")", "for", "role", "in", "roles", ":", "if", "permission_name", "in", "role", ".", "permission_names_list", "(", ")", ":", "permission", "...
Grant a user a specified permission. Permissions are only granted if they are in the scope any of the user's roles. If the permission is out of scope, a RolePermissionScopeException is raised.
[ "Grant", "a", "user", "a", "specified", "permission", "." ]
python
train
fred49/argtoolbox
argtoolbox/argtoolbox.py
https://github.com/fred49/argtoolbox/blob/e32ad6265567d5a1891df3c3425423774dafab41/argtoolbox/argtoolbox.py#L228-L242
def get_parser(self, **kwargs): """This method will create and return a new parser with prog_name, description, and a config file argument. """ self.parser = argparse.ArgumentParser(prog=self.prog_name, description=self._desc, ...
[ "def", "get_parser", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "self", ".", "prog_name", ",", "description", "=", "self", ".", "_desc", ",", "add_help", "=", "False"...
This method will create and return a new parser with prog_name, description, and a config file argument.
[ "This", "method", "will", "create", "and", "return", "a", "new", "parser", "with", "prog_name", "description", "and", "a", "config", "file", "argument", "." ]
python
train
telminov/sw-django-utils
djutils/date_utils.py
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/date_utils.py#L48-L57
def random_date(dt_from, dt_to): """ This function will return a random datetime between two datetime objects. :param start: :param end: """ delta = dt_to - dt_from int_delta = (delta.days * 24 * 60 * 60) + delta.seconds random_second = randrange(int_delta) return dt_from + datetime....
[ "def", "random_date", "(", "dt_from", ",", "dt_to", ")", ":", "delta", "=", "dt_to", "-", "dt_from", "int_delta", "=", "(", "delta", ".", "days", "*", "24", "*", "60", "*", "60", ")", "+", "delta", ".", "seconds", "random_second", "=", "randrange", "...
This function will return a random datetime between two datetime objects. :param start: :param end:
[ "This", "function", "will", "return", "a", "random", "datetime", "between", "two", "datetime", "objects", ".", ":", "param", "start", ":", ":", "param", "end", ":" ]
python
train
tensorforce/tensorforce
tensorforce/execution/base_runner.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/base_runner.py#L53-L67
def reset(self, history=None): """ Resets the Runner's internal stats counters. If history is empty, use default values in history.get(). Args: history (dict): A dictionary containing an already run experiment's results. Keys should be: episode_rewards (list ...
[ "def", "reset", "(", "self", ",", "history", "=", "None", ")", ":", "if", "not", "history", ":", "history", "=", "dict", "(", ")", "self", ".", "episode_rewards", "=", "history", ".", "get", "(", "\"episode_rewards\"", ",", "list", "(", ")", ")", "se...
Resets the Runner's internal stats counters. If history is empty, use default values in history.get(). Args: history (dict): A dictionary containing an already run experiment's results. Keys should be: episode_rewards (list of rewards), episode_timesteps (lengths of episodes...
[ "Resets", "the", "Runner", "s", "internal", "stats", "counters", ".", "If", "history", "is", "empty", "use", "default", "values", "in", "history", ".", "get", "()", "." ]
python
valid
michael-lazar/rtv
rtv/page.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/page.py#L773-L846
def _draw_content(self): """ Loop through submissions and fill up the content page. """ n_rows, n_cols = self.term.stdscr.getmaxyx() window = self.term.stdscr.derwin(n_rows - self._row - 1, n_cols, self._row, 0) window.erase() win_n_rows, win_n_cols = window.getma...
[ "def", "_draw_content", "(", "self", ")", ":", "n_rows", ",", "n_cols", "=", "self", ".", "term", ".", "stdscr", ".", "getmaxyx", "(", ")", "window", "=", "self", ".", "term", ".", "stdscr", ".", "derwin", "(", "n_rows", "-", "self", ".", "_row", "...
Loop through submissions and fill up the content page.
[ "Loop", "through", "submissions", "and", "fill", "up", "the", "content", "page", "." ]
python
train
DataBiosphere/toil
src/toil/provisioners/aws/__init__.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/provisioners/aws/__init__.py#L71-L125
def choose_spot_zone(zones, bid, spot_history): """ Returns the zone to put the spot request based on, in order of priority: 1) zones with prices currently under the bid 2) zones with the most stable price :param list[boto.ec2.zone.Zone] zones: :param float bid: :param list[boto.ec2...
[ "def", "choose_spot_zone", "(", "zones", ",", "bid", ",", "spot_history", ")", ":", "# Create two lists of tuples of form: [(zone.name, std_deviation), ...] one for zones", "# over the bid price and one for zones under bid price. Each are sorted by increasing", "# standard deviation values."...
Returns the zone to put the spot request based on, in order of priority: 1) zones with prices currently under the bid 2) zones with the most stable price :param list[boto.ec2.zone.Zone] zones: :param float bid: :param list[boto.ec2.spotpricehistory.SpotPriceHistory] spot_history: :rtyp...
[ "Returns", "the", "zone", "to", "put", "the", "spot", "request", "based", "on", "in", "order", "of", "priority", ":" ]
python
train
scanny/python-pptx
lab/cust-elm-classes/main.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/lab/cust-elm-classes/main.py#L40-L46
def _child_list(element, child_tagname): """ Return list containing the direct children of *element* having *child_tagname*. """ xpath = './%s' % child_tagname return element.xpath(xpath, namespaces=nsmap)
[ "def", "_child_list", "(", "element", ",", "child_tagname", ")", ":", "xpath", "=", "'./%s'", "%", "child_tagname", "return", "element", ".", "xpath", "(", "xpath", ",", "namespaces", "=", "nsmap", ")" ]
Return list containing the direct children of *element* having *child_tagname*.
[ "Return", "list", "containing", "the", "direct", "children", "of", "*", "element", "*", "having", "*", "child_tagname", "*", "." ]
python
train
securestate/termineter
lib/termineter/core.py
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/core.py#L376-L405
def serial_login(self): """ Attempt to log into the meter over the C12.18 protocol. Returns True on success, False on a failure. This can be called by modules in order to login with a username and password configured within the framework instance. """ if not self._serial_connected: raise termineter.errors....
[ "def", "serial_login", "(", "self", ")", ":", "if", "not", "self", ".", "_serial_connected", ":", "raise", "termineter", ".", "errors", ".", "FrameworkRuntimeError", "(", "'the serial interface is disconnected'", ")", "username", "=", "self", ".", "options", "[", ...
Attempt to log into the meter over the C12.18 protocol. Returns True on success, False on a failure. This can be called by modules in order to login with a username and password configured within the framework instance.
[ "Attempt", "to", "log", "into", "the", "meter", "over", "the", "C12", ".", "18", "protocol", ".", "Returns", "True", "on", "success", "False", "on", "a", "failure", ".", "This", "can", "be", "called", "by", "modules", "in", "order", "to", "login", "wit...
python
train
inasafe/inasafe
safe/utilities/memory_checker.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/memory_checker.py#L162-L180
def memory_error(): """Display an error when there is not enough memory.""" warning_heading = m.Heading( tr('Memory issue'), **WARNING_STYLE) warning_message = tr( 'There is not enough free memory to run this analysis.') suggestion_heading = m.Heading( tr('Suggestion'), **SUGGEST...
[ "def", "memory_error", "(", ")", ":", "warning_heading", "=", "m", ".", "Heading", "(", "tr", "(", "'Memory issue'", ")", ",", "*", "*", "WARNING_STYLE", ")", "warning_message", "=", "tr", "(", "'There is not enough free memory to run this analysis.'", ")", "sugge...
Display an error when there is not enough memory.
[ "Display", "an", "error", "when", "there", "is", "not", "enough", "memory", "." ]
python
train
paramiko/paramiko
paramiko/sftp_file.py
https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/sftp_file.py#L343-L356
def truncate(self, size): """ Change the size of this file. This usually extends or shrinks the size of the file, just like the ``truncate()`` method on Python file objects. :param size: the new size of the file """ self.sftp._log( DEBUG, "truncate({...
[ "def", "truncate", "(", "self", ",", "size", ")", ":", "self", ".", "sftp", ".", "_log", "(", "DEBUG", ",", "\"truncate({}, {!r})\"", ".", "format", "(", "hexlify", "(", "self", ".", "handle", ")", ",", "size", ")", ")", "attr", "=", "SFTPAttributes", ...
Change the size of this file. This usually extends or shrinks the size of the file, just like the ``truncate()`` method on Python file objects. :param size: the new size of the file
[ "Change", "the", "size", "of", "this", "file", ".", "This", "usually", "extends", "or", "shrinks", "the", "size", "of", "the", "file", "just", "like", "the", "truncate", "()", "method", "on", "Python", "file", "objects", "." ]
python
train
iron-io/iron_core_python
iron_core.py
https://github.com/iron-io/iron_core_python/blob/f09a160a854912efcb75a810702686bc25b74fa8/iron_core.py#L287-L303
def post(self, url, body="", headers={}, retry=True): """Execute an HTTP POST request and return a dict containing the response and the response status code. Keyword arguments: url -- The path to execute the result against, not including the API version or project ID, wit...
[ "def", "post", "(", "self", ",", "url", ",", "body", "=", "\"\"", ",", "headers", "=", "{", "}", ",", "retry", "=", "True", ")", ":", "headers", "[", "\"Content-Length\"", "]", "=", "str", "(", "len", "(", "body", ")", ")", "return", "self", ".",...
Execute an HTTP POST request and return a dict containing the response and the response status code. Keyword arguments: url -- The path to execute the result against, not including the API version or project ID, with no leading /. Required. body -- A string or file object...
[ "Execute", "an", "HTTP", "POST", "request", "and", "return", "a", "dict", "containing", "the", "response", "and", "the", "response", "status", "code", "." ]
python
train
mdgoldberg/sportsref
sportsref/nba/seasons.py
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/seasons.py#L90-L95
def team_names_to_ids(self): """Mapping from full team names to 3-letter team IDs. :returns: Dictionary with tean names as keys and team IDs as values. """ d = self.team_ids_to_names() return {v: k for k, v in d.items()}
[ "def", "team_names_to_ids", "(", "self", ")", ":", "d", "=", "self", ".", "team_ids_to_names", "(", ")", "return", "{", "v", ":", "k", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", "}" ]
Mapping from full team names to 3-letter team IDs. :returns: Dictionary with tean names as keys and team IDs as values.
[ "Mapping", "from", "full", "team", "names", "to", "3", "-", "letter", "team", "IDs", ".", ":", "returns", ":", "Dictionary", "with", "tean", "names", "as", "keys", "and", "team", "IDs", "as", "values", "." ]
python
test
materialsproject/pymatgen
pymatgen/electronic_structure/plotter.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/plotter.py#L3963-L3999
def fold_point(p, lattice, coords_are_cartesian=False): """ Folds a point with coordinates p inside the first Brillouin zone of the lattice. Args: p: coordinates of one point lattice: Lattice object used to convert from reciprocal to cartesian coordinates coords_are_cartesian: Set t...
[ "def", "fold_point", "(", "p", ",", "lattice", ",", "coords_are_cartesian", "=", "False", ")", ":", "if", "coords_are_cartesian", ":", "p", "=", "lattice", ".", "get_fractional_coords", "(", "p", ")", "else", ":", "p", "=", "np", ".", "array", "(", "p", ...
Folds a point with coordinates p inside the first Brillouin zone of the lattice. Args: p: coordinates of one point lattice: Lattice object used to convert from reciprocal to cartesian coordinates coords_are_cartesian: Set to True if you are providing coordinates in cartesian coo...
[ "Folds", "a", "point", "with", "coordinates", "p", "inside", "the", "first", "Brillouin", "zone", "of", "the", "lattice", "." ]
python
train
theiviaxx/python-perforce
perforce/models.py
https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L377-L394
def canAdd(self, filename): """Determines if a filename can be added to the depot under the current client :param filename: File path to add :type filename: str """ try: result = self.run(['add', '-n', '-t', 'text', filename])[0] except errors.CommandError as...
[ "def", "canAdd", "(", "self", ",", "filename", ")", ":", "try", ":", "result", "=", "self", ".", "run", "(", "[", "'add'", ",", "'-n'", ",", "'-t'", ",", "'text'", ",", "filename", "]", ")", "[", "0", "]", "except", "errors", ".", "CommandError", ...
Determines if a filename can be added to the depot under the current client :param filename: File path to add :type filename: str
[ "Determines", "if", "a", "filename", "can", "be", "added", "to", "the", "depot", "under", "the", "current", "client" ]
python
train
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/base_handler.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/base_handler.py#L189-L206
def base_path(self): """Base path for all mapreduce-related urls. JSON handlers are mapped to /base_path/command/command_name thus they require special treatment. Raises: BadRequestPathError: if the path does not end with "/command". Returns: The base path. """ path = self.req...
[ "def", "base_path", "(", "self", ")", ":", "path", "=", "self", ".", "request", ".", "path", "base_path", "=", "path", "[", ":", "path", ".", "rfind", "(", "\"/\"", ")", "]", "if", "not", "base_path", ".", "endswith", "(", "\"/command\"", ")", ":", ...
Base path for all mapreduce-related urls. JSON handlers are mapped to /base_path/command/command_name thus they require special treatment. Raises: BadRequestPathError: if the path does not end with "/command". Returns: The base path.
[ "Base", "path", "for", "all", "mapreduce", "-", "related", "urls", "." ]
python
train
pazz/alot
alot/settings/manager.py
https://github.com/pazz/alot/blob/d0297605c0ec1c6b65f541d0fd5b69ac5a0f4ded/alot/settings/manager.py#L397-L429
def get_keybindings(self, mode): """look up keybindings from `MODE-maps` sections :param mode: mode identifier :type mode: str :returns: dictionaries of key-cmd for global and specific mode :rtype: 2-tuple of dicts """ globalmaps, modemaps = {}, {} bindin...
[ "def", "get_keybindings", "(", "self", ",", "mode", ")", ":", "globalmaps", ",", "modemaps", "=", "{", "}", ",", "{", "}", "bindings", "=", "self", ".", "_bindings", "# get bindings for mode `mode`", "# retain empty assignations to silence corresponding global mappings"...
look up keybindings from `MODE-maps` sections :param mode: mode identifier :type mode: str :returns: dictionaries of key-cmd for global and specific mode :rtype: 2-tuple of dicts
[ "look", "up", "keybindings", "from", "MODE", "-", "maps", "sections" ]
python
train
grigi/talkey
talkey/base.py
https://github.com/grigi/talkey/blob/5d2d4a1f7001744c4fd9a79a883a3f2001522329/talkey/base.py#L234-L264
def play(self, filename, translate=False): # pragma: no cover ''' Plays the sounds. :filename: The input file name :translate: If True, it runs it through audioread which will translate from common compression formats to raw WAV. ''' # FIXME: Use platform-independent an...
[ "def", "play", "(", "self", ",", "filename", ",", "translate", "=", "False", ")", ":", "# pragma: no cover", "# FIXME: Use platform-independent and async audio-output here", "# PyAudio looks most promising, too bad about:", "# --allow-external PyAudio --allow-unverified PyAudio", "i...
Plays the sounds. :filename: The input file name :translate: If True, it runs it through audioread which will translate from common compression formats to raw WAV.
[ "Plays", "the", "sounds", "." ]
python
train
horazont/aioxmpp
aioxmpp/muc/self_ping.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/self_ping.py#L156-L189
def _interpret_result(self, task): """ Interpret the result of a ping. :param task: The pinger task. The result or exception of the `task` is interpreted as follows: * :data:`None` result: *positive* * :class:`aioxmpp.errors.XMPPError`, ``service-unavailable``: ...
[ "def", "_interpret_result", "(", "self", ",", "task", ")", ":", "if", "task", ".", "exception", "(", ")", "is", "None", ":", "self", ".", "_on_fresh", "(", ")", "return", "exc", "=", "task", ".", "exception", "(", ")", "if", "isinstance", "(", "exc",...
Interpret the result of a ping. :param task: The pinger task. The result or exception of the `task` is interpreted as follows: * :data:`None` result: *positive* * :class:`aioxmpp.errors.XMPPError`, ``service-unavailable``: *positive* * :class:`aioxmpp.errors.XMPPErro...
[ "Interpret", "the", "result", "of", "a", "ping", "." ]
python
train
txamqp/txamqp
src/txamqp/endpoint.py
https://github.com/txamqp/txamqp/blob/10caf998dd8c05a7321cd10c24a83832bf58bd0c/src/txamqp/endpoint.py#L103-L123
def connect(self, protocol_factory): """ Connect to the C{protocolFactory} to the AMQP broker specified by the URI of this endpoint. @param protocol_factory: An L{AMQFactory} building L{AMQClient} objects. @return: A L{Deferred} that results in an L{AMQClient} upon successful ...
[ "def", "connect", "(", "self", ",", "protocol_factory", ")", ":", "# XXX Since AMQClient requires these parameters at __init__ time, we", "# need to override them in the provided factory.", "protocol_factory", ".", "set_vhost", "(", "self", ".", "_vhost", ")", "protocol_facto...
Connect to the C{protocolFactory} to the AMQP broker specified by the URI of this endpoint. @param protocol_factory: An L{AMQFactory} building L{AMQClient} objects. @return: A L{Deferred} that results in an L{AMQClient} upon successful connection otherwise a L{Failure} wrapping L{Co...
[ "Connect", "to", "the", "C", "{", "protocolFactory", "}", "to", "the", "AMQP", "broker", "specified", "by", "the", "URI", "of", "this", "endpoint", "." ]
python
train
bokeh/bokeh
bokeh/application/handlers/code_runner.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/application/handlers/code_runner.py#L129-L145
def new_module(self): ''' Make a fresh module to run in. Returns: Module ''' self.reset_run_errors() if self._code is None: return None module_name = 'bk_script_' + make_id().replace('-', '') module = ModuleType(str(module_name)) # str ...
[ "def", "new_module", "(", "self", ")", ":", "self", ".", "reset_run_errors", "(", ")", "if", "self", ".", "_code", "is", "None", ":", "return", "None", "module_name", "=", "'bk_script_'", "+", "make_id", "(", ")", ".", "replace", "(", "'-'", ",", "''",...
Make a fresh module to run in. Returns: Module
[ "Make", "a", "fresh", "module", "to", "run", "in", "." ]
python
train
SmokinCaterpillar/pypet
pypet/brian2/network.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/brian2/network.py#L541-L563
def add_parameters(self, traj): """Adds parameters for a network simulation. Calls :func:`~pypet.brian2.network.NetworkComponent.add_parameters` for all components, analyser, and the network runner (in this order). :param traj: Trajectory container """ self._logger.in...
[ "def", "add_parameters", "(", "self", ",", "traj", ")", ":", "self", ".", "_logger", ".", "info", "(", "'Adding Parameters of Components'", ")", "for", "component", "in", "self", ".", "components", ":", "component", ".", "add_parameters", "(", "traj", ")", "...
Adds parameters for a network simulation. Calls :func:`~pypet.brian2.network.NetworkComponent.add_parameters` for all components, analyser, and the network runner (in this order). :param traj: Trajectory container
[ "Adds", "parameters", "for", "a", "network", "simulation", "." ]
python
test
apache/incubator-mxnet
python/mxnet/metric.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L194-L207
def get_name_value(self): """Returns zipped name and value pairs. Returns ------- list of tuples A (name, value) tuple list. """ name, value = self.get() if not isinstance(name, list): name = [name] if not isinstance(value, list): ...
[ "def", "get_name_value", "(", "self", ")", ":", "name", ",", "value", "=", "self", ".", "get", "(", ")", "if", "not", "isinstance", "(", "name", ",", "list", ")", ":", "name", "=", "[", "name", "]", "if", "not", "isinstance", "(", "value", ",", "...
Returns zipped name and value pairs. Returns ------- list of tuples A (name, value) tuple list.
[ "Returns", "zipped", "name", "and", "value", "pairs", "." ]
python
train
watson-developer-cloud/python-sdk
ibm_watson/compare_comply_v1.py
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/compare_comply_v1.py#L4975-L4997
def _from_dict(cls, _dict): """Initialize a UnalignedElement object from a json dictionary.""" args = {} if 'document_label' in _dict: args['document_label'] = _dict.get('document_label') if 'location' in _dict: args['location'] = Location._from_dict(_dict.get('lo...
[ "def", "_from_dict", "(", "cls", ",", "_dict", ")", ":", "args", "=", "{", "}", "if", "'document_label'", "in", "_dict", ":", "args", "[", "'document_label'", "]", "=", "_dict", ".", "get", "(", "'document_label'", ")", "if", "'location'", "in", "_dict",...
Initialize a UnalignedElement object from a json dictionary.
[ "Initialize", "a", "UnalignedElement", "object", "from", "a", "json", "dictionary", "." ]
python
train
sanger-pathogens/circlator
circlator/merge.py
https://github.com/sanger-pathogens/circlator/blob/a4befb8c9dbbcd4b3ad1899a95aa3e689d58b638/circlator/merge.py#L732-L737
def _contigs_dict_to_file(self, contigs, fname): '''Writes dictionary of contigs to file''' f = pyfastaq.utils.open_file_write(fname) for contig in sorted(contigs, key=lambda x:len(contigs[x]), reverse=True): print(contigs[contig], file=f) pyfastaq.utils.close(f)
[ "def", "_contigs_dict_to_file", "(", "self", ",", "contigs", ",", "fname", ")", ":", "f", "=", "pyfastaq", ".", "utils", ".", "open_file_write", "(", "fname", ")", "for", "contig", "in", "sorted", "(", "contigs", ",", "key", "=", "lambda", "x", ":", "l...
Writes dictionary of contigs to file
[ "Writes", "dictionary", "of", "contigs", "to", "file" ]
python
train
alpha-xone/xbbg
xbbg/blp.py
https://github.com/alpha-xone/xbbg/blob/70226eb19a72a08144b5d8cea9db4913200f7bc5/xbbg/blp.py#L607-L634
def check_hours(tickers, tz_exch, tz_loc=DEFAULT_TZ) -> pd.DataFrame: """ Check exchange hours vs local hours Args: tickers: list of tickers tz_exch: exchange timezone tz_loc: local timezone Returns: Local and exchange hours """ cols = ['Trading_Day_Start_Time_E...
[ "def", "check_hours", "(", "tickers", ",", "tz_exch", ",", "tz_loc", "=", "DEFAULT_TZ", ")", "->", "pd", ".", "DataFrame", ":", "cols", "=", "[", "'Trading_Day_Start_Time_EOD'", ",", "'Trading_Day_End_Time_EOD'", "]", "con", ",", "_", "=", "create_connection", ...
Check exchange hours vs local hours Args: tickers: list of tickers tz_exch: exchange timezone tz_loc: local timezone Returns: Local and exchange hours
[ "Check", "exchange", "hours", "vs", "local", "hours" ]
python
valid
saltstack/salt
salt/modules/consul.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/consul.py#L1629-L1656
def catalog_datacenters(consul_url=None, token=None): ''' Return list of available datacenters from catalog. :param consul_url: The Consul server URL. :return: The list of available datacenters. CLI Example: .. code-block:: bash salt '*' consul.catalog_datacenters ''' ret = ...
[ "def", "catalog_datacenters", "(", "consul_url", "=", "None", ",", "token", "=", "None", ")", ":", "ret", "=", "{", "}", "if", "not", "consul_url", ":", "consul_url", "=", "_get_config", "(", ")", "if", "not", "consul_url", ":", "log", ".", "error", "(...
Return list of available datacenters from catalog. :param consul_url: The Consul server URL. :return: The list of available datacenters. CLI Example: .. code-block:: bash salt '*' consul.catalog_datacenters
[ "Return", "list", "of", "available", "datacenters", "from", "catalog", "." ]
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/runsnake.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/runsnake.py#L750-L791
def LoadState( self, config_parser ): """Set our window state from the given config_parser instance""" if not config_parser: return if ( not config_parser.has_section( 'window' ) or ( config_parser.has_option( 'window','maximized' ) and co...
[ "def", "LoadState", "(", "self", ",", "config_parser", ")", ":", "if", "not", "config_parser", ":", "return", "if", "(", "not", "config_parser", ".", "has_section", "(", "'window'", ")", "or", "(", "config_parser", ".", "has_option", "(", "'window'", ",", ...
Set our window state from the given config_parser instance
[ "Set", "our", "window", "state", "from", "the", "given", "config_parser", "instance" ]
python
train
hearsaycorp/normalize
normalize/record/json.py
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/record/json.py#L291-L296
def json_to_initkwargs(self, json_data, kwargs): """Subclassing hook to specialize how JSON data is converted to keyword arguments""" if isinstance(json_data, basestring): json_data = json.loads(json_data) return json_to_initkwargs(self, json_data, kwargs)
[ "def", "json_to_initkwargs", "(", "self", ",", "json_data", ",", "kwargs", ")", ":", "if", "isinstance", "(", "json_data", ",", "basestring", ")", ":", "json_data", "=", "json", ".", "loads", "(", "json_data", ")", "return", "json_to_initkwargs", "(", "self"...
Subclassing hook to specialize how JSON data is converted to keyword arguments
[ "Subclassing", "hook", "to", "specialize", "how", "JSON", "data", "is", "converted", "to", "keyword", "arguments" ]
python
train
trolldbois/ctypeslib
ctypeslib/codegen/typehandler.py
https://github.com/trolldbois/ctypeslib/blob/2aeb1942a5a32a5cc798c287cd0d9e684a0181a8/ctypeslib/codegen/typehandler.py#L154-L187
def _array_handler(self, _cursor_type): """ Handles all array types. Resolves it's element type and makes a Array typedesc. """ # The element type has been previously declared # we need to get the canonical typedef, in some cases _type = _cursor_type.get_canonical...
[ "def", "_array_handler", "(", "self", ",", "_cursor_type", ")", ":", "# The element type has been previously declared", "# we need to get the canonical typedef, in some cases", "_type", "=", "_cursor_type", ".", "get_canonical", "(", ")", "size", "=", "_type", ".", "get_arr...
Handles all array types. Resolves it's element type and makes a Array typedesc.
[ "Handles", "all", "array", "types", ".", "Resolves", "it", "s", "element", "type", "and", "makes", "a", "Array", "typedesc", "." ]
python
train
tensorlayer/tensorlayer
tensorlayer/prepro.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2432-L2459
def obj_box_coord_rescale(coord=None, shape=None): """Scale down one coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1]. It is the reverse process of ``obj_box_coord_scale_to_pixelunit``. Parameters ------------ coords : list of 4 int or None One coordinates ...
[ "def", "obj_box_coord_rescale", "(", "coord", "=", "None", ",", "shape", "=", "None", ")", ":", "if", "coord", "is", "None", ":", "coord", "=", "[", "]", "if", "shape", "is", "None", ":", "shape", "=", "[", "100", ",", "200", "]", "return", "obj_bo...
Scale down one coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1]. It is the reverse process of ``obj_box_coord_scale_to_pixelunit``. Parameters ------------ coords : list of 4 int or None One coordinates of one image e.g. [x, y, w, h]. shape : list of 2 int ...
[ "Scale", "down", "one", "coordinates", "from", "pixel", "unit", "to", "the", "ratio", "of", "image", "size", "i", ".", "e", ".", "in", "the", "range", "of", "[", "0", "1", "]", ".", "It", "is", "the", "reverse", "process", "of", "obj_box_coord_scale_to...
python
valid
mozilla/configman
configman/def_sources/for_argparse.py
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L39-L52
def find_action_name_by_value(registry, target_action_instance): """the association of a name of an action class with a human readable string is exposed externally only at the time of argument definitions. This routine, when given a reference to argparse's internal action registry and an action, will fi...
[ "def", "find_action_name_by_value", "(", "registry", ",", "target_action_instance", ")", ":", "target_type", "=", "type", "(", "target_action_instance", ")", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "registry", "[", "'action'", "]", ")", ...
the association of a name of an action class with a human readable string is exposed externally only at the time of argument definitions. This routine, when given a reference to argparse's internal action registry and an action, will find that action and return the name under which it was registered.
[ "the", "association", "of", "a", "name", "of", "an", "action", "class", "with", "a", "human", "readable", "string", "is", "exposed", "externally", "only", "at", "the", "time", "of", "argument", "definitions", ".", "This", "routine", "when", "given", "a", "...
python
train
tamasgal/km3pipe
km3pipe/db.py
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L553-L557
def streams(self): """A list of available streams""" if self._streams is None: self._streams = list(self._stream_df["STREAM"].values) return self._streams
[ "def", "streams", "(", "self", ")", ":", "if", "self", ".", "_streams", "is", "None", ":", "self", ".", "_streams", "=", "list", "(", "self", ".", "_stream_df", "[", "\"STREAM\"", "]", ".", "values", ")", "return", "self", ".", "_streams" ]
A list of available streams
[ "A", "list", "of", "available", "streams" ]
python
train
ramrod-project/database-brain
schema/brain/binary/data.py
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/binary/data.py#L44-L55
def put_buffer(filename, content, conn=None): """ helper function for put :param filename: <str> :param content: <bytes> :param conn: <rethinkdb.DefaultConnection> :return: <dict> """ obj_dict = {PRIMARY_FIELD: filename, CONTENT_FIELD: content, TIMESTAMP_F...
[ "def", "put_buffer", "(", "filename", ",", "content", ",", "conn", "=", "None", ")", ":", "obj_dict", "=", "{", "PRIMARY_FIELD", ":", "filename", ",", "CONTENT_FIELD", ":", "content", ",", "TIMESTAMP_FIELD", ":", "time", "(", ")", "}", "return", "put", "...
helper function for put :param filename: <str> :param content: <bytes> :param conn: <rethinkdb.DefaultConnection> :return: <dict>
[ "helper", "function", "for", "put", ":", "param", "filename", ":", "<str", ">", ":", "param", "content", ":", "<bytes", ">", ":", "param", "conn", ":", "<rethinkdb", ".", "DefaultConnection", ">", ":", "return", ":", "<dict", ">" ]
python
train
gwww/elkm1
elkm1_lib/elements.py
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elements.py#L90-L100
def get_descriptions(self, description_type): """ Gets the descriptions for specified type. When complete the callback is called with a list of descriptions """ (desc_type, max_units) = description_type results = [None] * max_units self.elk._descriptions_in_progre...
[ "def", "get_descriptions", "(", "self", ",", "description_type", ")", ":", "(", "desc_type", ",", "max_units", ")", "=", "description_type", "results", "=", "[", "None", "]", "*", "max_units", "self", ".", "elk", ".", "_descriptions_in_progress", "[", "desc_ty...
Gets the descriptions for specified type. When complete the callback is called with a list of descriptions
[ "Gets", "the", "descriptions", "for", "specified", "type", ".", "When", "complete", "the", "callback", "is", "called", "with", "a", "list", "of", "descriptions" ]
python
train
numenta/htmresearch
htmresearch/algorithms/lateral_pooler.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/lateral_pooler.py#L116-L128
def _updateLateralConnections(self, epsilon, avgActivityPairs): """ Sets the weights of the lateral connections based on average pairwise activity of the SP's columns. Intuitively: The more two columns fire together on average the stronger the inhibitory connection gets. """ oldL = self.l...
[ "def", "_updateLateralConnections", "(", "self", ",", "epsilon", ",", "avgActivityPairs", ")", ":", "oldL", "=", "self", ".", "lateralConnections", "newL", "=", "avgActivityPairs", ".", "copy", "(", ")", "np", ".", "fill_diagonal", "(", "newL", ",", "0.0", "...
Sets the weights of the lateral connections based on average pairwise activity of the SP's columns. Intuitively: The more two columns fire together on average the stronger the inhibitory connection gets.
[ "Sets", "the", "weights", "of", "the", "lateral", "connections", "based", "on", "average", "pairwise", "activity", "of", "the", "SP", "s", "columns", ".", "Intuitively", ":", "The", "more", "two", "columns", "fire", "together", "on", "average", "the", "stron...
python
train
ianclegg/winrmlib
winrmlib/client.py
https://github.com/ianclegg/winrmlib/blob/489b3ce5d0e6a9a7301ba5d345ba82fa824c1431/winrmlib/client.py#L53-L64
def create_session(): """ shell = CommandShell('http://192.168.145.132:5985/wsman', 'Administrator', 'Pa55w0rd') """ shell = CommandShell('http://192.168.137.238:5985/wsman', 'Administrator', 'Pa55w0rd') shell.open() command_id = shell.run('ipconfig', ['/all']) (s...
[ "def", "create_session", "(", ")", ":", "shell", "=", "CommandShell", "(", "'http://192.168.137.238:5985/wsman'", ",", "'Administrator'", ",", "'Pa55w0rd'", ")", "shell", ".", "open", "(", ")", "command_id", "=", "shell", ".", "run", "(", "'ipconfig'", ",", "[...
shell = CommandShell('http://192.168.145.132:5985/wsman', 'Administrator', 'Pa55w0rd')
[ "shell", "=", "CommandShell", "(", "http", ":", "//", "192", ".", "168", ".", "145", ".", "132", ":", "5985", "/", "wsman", "Administrator", "Pa55w0rd", ")" ]
python
train
ibis-project/ibis
ibis/client.py
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/client.py#L73-L90
def table(self, name, database=None): """ Create a table expression that references a particular table in the database Parameters ---------- name : string database : string, optional Returns ------- table : TableExpr """ q...
[ "def", "table", "(", "self", ",", "name", ",", "database", "=", "None", ")", ":", "qualified_name", "=", "self", ".", "_fully_qualified_name", "(", "name", ",", "database", ")", "schema", "=", "self", ".", "_get_table_schema", "(", "qualified_name", ")", "...
Create a table expression that references a particular table in the database Parameters ---------- name : string database : string, optional Returns ------- table : TableExpr
[ "Create", "a", "table", "expression", "that", "references", "a", "particular", "table", "in", "the", "database" ]
python
train
tensorflow/tensor2tensor
tensor2tensor/utils/learning_rate.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/learning_rate.py#L186-L202
def _learning_rate_warmup(warmup_steps, warmup_schedule="exp", hparams=None): """Learning rate warmup multiplier.""" if not warmup_steps: return tf.constant(1.) tf.logging.info("Applying %s learning rate warmup for %d steps", warmup_schedule, warmup_steps) warmup_steps = tf.to_float(warm...
[ "def", "_learning_rate_warmup", "(", "warmup_steps", ",", "warmup_schedule", "=", "\"exp\"", ",", "hparams", "=", "None", ")", ":", "if", "not", "warmup_steps", ":", "return", "tf", ".", "constant", "(", "1.", ")", "tf", ".", "logging", ".", "info", "(", ...
Learning rate warmup multiplier.
[ "Learning", "rate", "warmup", "multiplier", "." ]
python
train
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L113-L117
def p_pragma(self, p): 'pragma : LPAREN TIMES ID TIMES RPAREN' p[0] = Pragma(PragmaEntry(p[3], lineno=p.lineno(1)), lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_pragma", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "Pragma", "(", "PragmaEntry", "(", "p", "[", "3", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", ",", "lineno", "=", "p", ".", "lineno", "(", "1"...
pragma : LPAREN TIMES ID TIMES RPAREN
[ "pragma", ":", "LPAREN", "TIMES", "ID", "TIMES", "RPAREN" ]
python
train
pjamesjoyce/lcopt
lcopt/model.py
https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/model.py#L338-L352
def create_product (self, name, location='GLO', unit='kg', **kwargs): """ Create a new product in the model database """ new_product = item_factory(name=name, location=location, unit=unit, type='product', **kwargs) if not self.exists_in_database(new_product['code']): ...
[ "def", "create_product", "(", "self", ",", "name", ",", "location", "=", "'GLO'", ",", "unit", "=", "'kg'", ",", "*", "*", "kwargs", ")", ":", "new_product", "=", "item_factory", "(", "name", "=", "name", ",", "location", "=", "location", ",", "unit", ...
Create a new product in the model database
[ "Create", "a", "new", "product", "in", "the", "model", "database" ]
python
train
mesbahamin/chronophore
chronophore/tkview.py
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L136-L155
def _show_feedback_label(self, message, seconds=None): """Display a message in lbl_feedback, which then times out after some number of seconds. Use after() to schedule a callback to hide the feedback message. This works better than using threads, which can cause problems in Tk. "...
[ "def", "_show_feedback_label", "(", "self", ",", "message", ",", "seconds", "=", "None", ")", ":", "if", "seconds", "is", "None", ":", "seconds", "=", "CONFIG", "[", "'MESSAGE_DURATION'", "]", "# cancel any existing callback to clear the feedback", "# label. this prev...
Display a message in lbl_feedback, which then times out after some number of seconds. Use after() to schedule a callback to hide the feedback message. This works better than using threads, which can cause problems in Tk.
[ "Display", "a", "message", "in", "lbl_feedback", "which", "then", "times", "out", "after", "some", "number", "of", "seconds", ".", "Use", "after", "()", "to", "schedule", "a", "callback", "to", "hide", "the", "feedback", "message", ".", "This", "works", "b...
python
train
dmlc/gluon-nlp
scripts/word_embeddings/evaluation.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/word_embeddings/evaluation.py#L145-L197
def evaluate_similarity(args, token_embedding, ctx, logfile=None, global_step=0): """Evaluate on specified similarity datasets.""" results = [] for similarity_function in args.similarity_functions: evaluator = nlp.embedding.evaluation.WordEmbeddingSimilarity( idx...
[ "def", "evaluate_similarity", "(", "args", ",", "token_embedding", ",", "ctx", ",", "logfile", "=", "None", ",", "global_step", "=", "0", ")", ":", "results", "=", "[", "]", "for", "similarity_function", "in", "args", ".", "similarity_functions", ":", "evalu...
Evaluate on specified similarity datasets.
[ "Evaluate", "on", "specified", "similarity", "datasets", "." ]
python
train
dahlia/wikidata
wikidata/client.py
https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/client.py#L142-L165
def guess_entity_type(self, entity_id: EntityId) -> Optional[EntityType]: r"""Guess :class:`~.entity.EntityType` from the given :class:`~.entity.EntityId`. It could return :const:`None` when it fails to guess. .. note:: It always fails to guess when :attr:`entity_type_guess...
[ "def", "guess_entity_type", "(", "self", ",", "entity_id", ":", "EntityId", ")", "->", "Optional", "[", "EntityType", "]", ":", "if", "not", "self", ".", "entity_type_guess", ":", "return", "None", "if", "entity_id", "[", "0", "]", "==", "'Q'", ":", "ret...
r"""Guess :class:`~.entity.EntityType` from the given :class:`~.entity.EntityId`. It could return :const:`None` when it fails to guess. .. note:: It always fails to guess when :attr:`entity_type_guess` is configued to :const:`False`. :return: The guessed :class:...
[ "r", "Guess", ":", "class", ":", "~", ".", "entity", ".", "EntityType", "from", "the", "given", ":", "class", ":", "~", ".", "entity", ".", "EntityId", ".", "It", "could", "return", ":", "const", ":", "None", "when", "it", "fails", "to", "guess", "...
python
train
lemieuxl/pyGenClean
pyGenClean/SexCheck/sex_check.py
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L488-L504
def createPedChr24UsingPlink(options): """Run plink to create a ped format. :param options: the options. :type options: argparse.Namespace Uses Plink to create a ``ped`` file of markers on the chromosome ``24``. It uses the ``recodeA`` options to use additive coding. It also subsets the data ...
[ "def", "createPedChr24UsingPlink", "(", "options", ")", ":", "plinkCommand", "=", "[", "\"plink\"", ",", "\"--noweb\"", ",", "\"--bfile\"", ",", "options", ".", "bfile", ",", "\"--chr\"", ",", "\"24\"", ",", "\"--recodeA\"", ",", "\"--keep\"", ",", "options", ...
Run plink to create a ped format. :param options: the options. :type options: argparse.Namespace Uses Plink to create a ``ped`` file of markers on the chromosome ``24``. It uses the ``recodeA`` options to use additive coding. It also subsets the data to keep only samples with sex problems.
[ "Run", "plink", "to", "create", "a", "ped", "format", "." ]
python
train
trevisanj/a99
a99/parts.py
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/parts.py#L101-L106
def one_liner_str(self): """Returns string (supposed to be) shorter than str() and not contain newline""" assert self.less_attrs is not None, "Forgot to set attrs class variable" s_format = "{}={}" s = "; ".join([s_format.format(x, self.__getattribute__(x)) for x in self.less_attrs])...
[ "def", "one_liner_str", "(", "self", ")", ":", "assert", "self", ".", "less_attrs", "is", "not", "None", ",", "\"Forgot to set attrs class variable\"", "s_format", "=", "\"{}={}\"", "s", "=", "\"; \"", ".", "join", "(", "[", "s_format", ".", "format", "(", "...
Returns string (supposed to be) shorter than str() and not contain newline
[ "Returns", "string", "(", "supposed", "to", "be", ")", "shorter", "than", "str", "()", "and", "not", "contain", "newline" ]
python
train
horazont/aioxmpp
aioxmpp/callbacks.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/callbacks.py#L472-L503
def connect(self, f, mode=None): """ Connect an object `f` to the signal. The type the object needs to have depends on `mode`, but usually it needs to be a callable. :meth:`connect` returns an opaque token which can be used with :meth:`disconnect` to disconnect the object from t...
[ "def", "connect", "(", "self", ",", "f", ",", "mode", "=", "None", ")", ":", "mode", "=", "mode", "or", "self", ".", "STRONG", "self", ".", "logger", ".", "debug", "(", "\"connecting %r with mode %r\"", ",", "f", ",", "mode", ")", "return", "self", "...
Connect an object `f` to the signal. The type the object needs to have depends on `mode`, but usually it needs to be a callable. :meth:`connect` returns an opaque token which can be used with :meth:`disconnect` to disconnect the object from the signal. The default value for `mode` is :...
[ "Connect", "an", "object", "f", "to", "the", "signal", ".", "The", "type", "the", "object", "needs", "to", "have", "depends", "on", "mode", "but", "usually", "it", "needs", "to", "be", "a", "callable", "." ]
python
train
tanghaibao/goatools
goatools/wr_tbl_class.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L155-L174
def _init_fmtname2wbfmtobj(self, workbook, **kws): """Initialize fmtname2wbfmtobj.""" wbfmtdict = [ kws.get('format_txt0', self.dflt_wbfmtdict[0]), kws.get('format_txt1', self.dflt_wbfmtdict[1]), kws.get('format_txt2', self.dflt_wbfmtdict[2]), kws.get('for...
[ "def", "_init_fmtname2wbfmtobj", "(", "self", ",", "workbook", ",", "*", "*", "kws", ")", ":", "wbfmtdict", "=", "[", "kws", ".", "get", "(", "'format_txt0'", ",", "self", ".", "dflt_wbfmtdict", "[", "0", "]", ")", ",", "kws", ".", "get", "(", "'form...
Initialize fmtname2wbfmtobj.
[ "Initialize", "fmtname2wbfmtobj", "." ]
python
train
mozilla-iot/webthing-python
webthing/thing.py
https://github.com/mozilla-iot/webthing-python/blob/65d467c89ed79d0bbc42b8b3c8f9e5a320edd237/webthing/thing.py#L298-L305
def add_event(self, event): """ Add a new event and notify subscribers. event -- the event that occurred """ self.events.append(event) self.event_notify(event)
[ "def", "add_event", "(", "self", ",", "event", ")", ":", "self", ".", "events", ".", "append", "(", "event", ")", "self", ".", "event_notify", "(", "event", ")" ]
Add a new event and notify subscribers. event -- the event that occurred
[ "Add", "a", "new", "event", "and", "notify", "subscribers", "." ]
python
test
Titan-C/slaveparticles
slaveparticles/spins.py
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/spins.py#L154-L166
def update_H(self, mean_field, l): """Updates the spin hamiltonian and recalculates its eigenbasis""" self.H_s = self.spin_hamiltonian(mean_field, l) try: self.eig_energies, self.eig_states = diagonalize(self.H_s) except np.linalg.linalg.LinAlgError: np.savez('er...
[ "def", "update_H", "(", "self", ",", "mean_field", ",", "l", ")", ":", "self", ".", "H_s", "=", "self", ".", "spin_hamiltonian", "(", "mean_field", ",", "l", ")", "try", ":", "self", ".", "eig_energies", ",", "self", ".", "eig_states", "=", "diagonaliz...
Updates the spin hamiltonian and recalculates its eigenbasis
[ "Updates", "the", "spin", "hamiltonian", "and", "recalculates", "its", "eigenbasis" ]
python
train
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L179-L185
def users_set_avatar(self, avatar_url, **kwargs): """Set a user’s avatar""" if avatar_url.startswith('http://') or avatar_url.startswith('https://'): return self.__call_api_post('users.setAvatar', avatarUrl=avatar_url, kwargs=kwargs) else: avatar_file = {"image": open(ava...
[ "def", "users_set_avatar", "(", "self", ",", "avatar_url", ",", "*", "*", "kwargs", ")", ":", "if", "avatar_url", ".", "startswith", "(", "'http://'", ")", "or", "avatar_url", ".", "startswith", "(", "'https://'", ")", ":", "return", "self", ".", "__call_a...
Set a user’s avatar
[ "Set", "a", "user’s", "avatar" ]
python
train
fishtown-analytics/dbt
core/dbt/graph/selector.py
https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/graph/selector.py#L93-L114
def _node_is_match(qualified_name, package_names, fqn): """Determine if a qualfied name matches an fqn, given the set of package names in the graph. :param List[str] qualified_name: The components of the selector or node name, split on '.'. :param Set[str] package_names: The set of pacakge name...
[ "def", "_node_is_match", "(", "qualified_name", ",", "package_names", ",", "fqn", ")", ":", "if", "len", "(", "qualified_name", ")", "==", "1", "and", "fqn", "[", "-", "1", "]", "==", "qualified_name", "[", "0", "]", ":", "return", "True", "if", "quali...
Determine if a qualfied name matches an fqn, given the set of package names in the graph. :param List[str] qualified_name: The components of the selector or node name, split on '.'. :param Set[str] package_names: The set of pacakge names in the graph. :param List[str] fqn: The node's fully qual...
[ "Determine", "if", "a", "qualfied", "name", "matches", "an", "fqn", "given", "the", "set", "of", "package", "names", "in", "the", "graph", "." ]
python
train
pyhys/minimalmodbus
minimalmodbus.py
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1219-L1277
def _numToTwoByteString(value, numberOfDecimals=0, LsbFirst=False, signed=False): """Convert a numerical value to a two-byte string, possibly scaling it. Args: * value (float or int): The numerical value to be converted. * numberOfDecimals (int): Number of decimals, 0 or more, for scaling. ...
[ "def", "_numToTwoByteString", "(", "value", ",", "numberOfDecimals", "=", "0", ",", "LsbFirst", "=", "False", ",", "signed", "=", "False", ")", ":", "_checkNumerical", "(", "value", ",", "description", "=", "'inputvalue'", ")", "_checkInt", "(", "numberOfDecim...
Convert a numerical value to a two-byte string, possibly scaling it. Args: * value (float or int): The numerical value to be converted. * numberOfDecimals (int): Number of decimals, 0 or more, for scaling. * LsbFirst (bol): Whether the least significant byte should be first in the resulting...
[ "Convert", "a", "numerical", "value", "to", "a", "two", "-", "byte", "string", "possibly", "scaling", "it", "." ]
python
train
juju/python-libjuju
juju/client/connection.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L280-L348
async def rpc(self, msg, encoder=None): '''Make an RPC to the API. The message is encoded as JSON using the given encoder if any. :param msg: Parameters for the call (will be encoded as JSON). :param encoder: Encoder to be used when encoding the message. :return: The result of th...
[ "async", "def", "rpc", "(", "self", ",", "msg", ",", "encoder", "=", "None", ")", ":", "self", ".", "__request_id__", "+=", "1", "msg", "[", "'request-id'", "]", "=", "self", ".", "__request_id__", "if", "'params'", "not", "in", "msg", ":", "msg", "[...
Make an RPC to the API. The message is encoded as JSON using the given encoder if any. :param msg: Parameters for the call (will be encoded as JSON). :param encoder: Encoder to be used when encoding the message. :return: The result of the call. :raises JujuAPIError: When there's ...
[ "Make", "an", "RPC", "to", "the", "API", ".", "The", "message", "is", "encoded", "as", "JSON", "using", "the", "given", "encoder", "if", "any", ".", ":", "param", "msg", ":", "Parameters", "for", "the", "call", "(", "will", "be", "encoded", "as", "JS...
python
train
mozilla/mozilla-django-oidc
mozilla_django_oidc/auth.py
https://github.com/mozilla/mozilla-django-oidc/blob/e780130deacccbafc85a92f48d1407e042f5f955/mozilla_django_oidc/auth.py#L301-L330
def get_or_create_user(self, access_token, id_token, payload): """Returns a User instance if 1 user is found. Creates a user if not found and configured to do so. Returns nothing if multiple users are matched.""" user_info = self.get_userinfo(access_token, id_token, payload) email = us...
[ "def", "get_or_create_user", "(", "self", ",", "access_token", ",", "id_token", ",", "payload", ")", ":", "user_info", "=", "self", ".", "get_userinfo", "(", "access_token", ",", "id_token", ",", "payload", ")", "email", "=", "user_info", ".", "get", "(", ...
Returns a User instance if 1 user is found. Creates a user if not found and configured to do so. Returns nothing if multiple users are matched.
[ "Returns", "a", "User", "instance", "if", "1", "user", "is", "found", ".", "Creates", "a", "user", "if", "not", "found", "and", "configured", "to", "do", "so", ".", "Returns", "nothing", "if", "multiple", "users", "are", "matched", "." ]
python
train
SiLab-Bonn/online_monitor
online_monitor/converter/transceiver.py
https://github.com/SiLab-Bonn/online_monitor/blob/113c7d33e9ea4bc18520cefa329462faa406cc08/online_monitor/converter/transceiver.py#L192-L202
def send_data(self, data): ''' This function can be overwritten in derived class Std. function is to broadcast all receiver data to all backends ''' for frontend_data in data: serialized_data = self.serialize_data(frontend_data) if sys.version_info >= (3, 0):...
[ "def", "send_data", "(", "self", ",", "data", ")", ":", "for", "frontend_data", "in", "data", ":", "serialized_data", "=", "self", ".", "serialize_data", "(", "frontend_data", ")", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ":", "...
This function can be overwritten in derived class Std. function is to broadcast all receiver data to all backends
[ "This", "function", "can", "be", "overwritten", "in", "derived", "class" ]
python
train
galactics/beyond
beyond/orbits/orbit.py
https://github.com/galactics/beyond/blob/7a7590ff0fd4c0bac3e8e383ecca03caa98e5742/beyond/orbits/orbit.py#L440-L443
def va(self): """Velocity at apocenter """ return np.sqrt(self.mu * (2 / (self.ra) - 1 / self.kep.a))
[ "def", "va", "(", "self", ")", ":", "return", "np", ".", "sqrt", "(", "self", ".", "mu", "*", "(", "2", "/", "(", "self", ".", "ra", ")", "-", "1", "/", "self", ".", "kep", ".", "a", ")", ")" ]
Velocity at apocenter
[ "Velocity", "at", "apocenter" ]
python
train
pytroll/satpy
satpy/readers/eps_l1b.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/eps_l1b.py#L180-L186
def keys(self): """List of reader's keys. """ keys = [] for val in self.form.scales.values(): keys += val.dtype.fields.keys() return keys
[ "def", "keys", "(", "self", ")", ":", "keys", "=", "[", "]", "for", "val", "in", "self", ".", "form", ".", "scales", ".", "values", "(", ")", ":", "keys", "+=", "val", ".", "dtype", ".", "fields", ".", "keys", "(", ")", "return", "keys" ]
List of reader's keys.
[ "List", "of", "reader", "s", "keys", "." ]
python
train
pysal/giddy
giddy/markov.py
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L832-L855
def _maybe_classify(self, y, k, cutoffs): '''Helper method for classifying continuous data. ''' rows, cols = y.shape if cutoffs is None: if self.fixed: mcyb = mc.Quantiles(y.flatten(), k=k) yb = mcyb.yb.reshape(y.shape) cutoff...
[ "def", "_maybe_classify", "(", "self", ",", "y", ",", "k", ",", "cutoffs", ")", ":", "rows", ",", "cols", "=", "y", ".", "shape", "if", "cutoffs", "is", "None", ":", "if", "self", ".", "fixed", ":", "mcyb", "=", "mc", ".", "Quantiles", "(", "y", ...
Helper method for classifying continuous data.
[ "Helper", "method", "for", "classifying", "continuous", "data", "." ]
python
train
mwgielen/jackal
jackal/core.py
https://github.com/mwgielen/jackal/blob/7fe62732eb5194b7246215d5277fb37c398097bf/jackal/core.py#L55-L76
def search(self, number=None, *args, **kwargs): """ Searches the elasticsearch instance to retrieve the requested documents. """ search = self.create_search(*args, **kwargs) try: if number: response = search[0:number] else: ...
[ "def", "search", "(", "self", ",", "number", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "search", "=", "self", ".", "create_search", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "if", "number", ":", "response...
Searches the elasticsearch instance to retrieve the requested documents.
[ "Searches", "the", "elasticsearch", "instance", "to", "retrieve", "the", "requested", "documents", "." ]
python
valid
pytroll/trollimage
trollimage/image.py
https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/image.py#L603-L625
def _rgb2l(self, mode): """Convert from RGB to monochrome L. """ self._check_modes(("RGB", "RGBA")) kb_ = 0.114 kr_ = 0.299 r__ = self.channels[0] g__ = self.channels[1] b__ = self.channels[2] y__ = kr_ * r__ + (1 - kr_ - kb_) * g__ + kb_ * b__ ...
[ "def", "_rgb2l", "(", "self", ",", "mode", ")", ":", "self", ".", "_check_modes", "(", "(", "\"RGB\"", ",", "\"RGBA\"", ")", ")", "kb_", "=", "0.114", "kr_", "=", "0.299", "r__", "=", "self", ".", "channels", "[", "0", "]", "g__", "=", "self", "....
Convert from RGB to monochrome L.
[ "Convert", "from", "RGB", "to", "monochrome", "L", "." ]
python
train
wuher/devil
devil/fields/factory.py
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/factory.py#L171-L184
def _create_value(self, data, name, spec): """ Create the value for a field. :param data: the whole data for the entity (all fields). :param name: name of the initialized field. :param spec: spec for the whole entity. """ field = getattr(self, 'create_' + name, None) ...
[ "def", "_create_value", "(", "self", ",", "data", ",", "name", ",", "spec", ")", ":", "field", "=", "getattr", "(", "self", ",", "'create_'", "+", "name", ",", "None", ")", "if", "field", ":", "# this factory has a special creator function for this field", "re...
Create the value for a field. :param data: the whole data for the entity (all fields). :param name: name of the initialized field. :param spec: spec for the whole entity.
[ "Create", "the", "value", "for", "a", "field", "." ]
python
train
junaruga/rpm-py-installer
install.py
https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1707-L1758
def sh_e(cls, cmd, **kwargs): """Run the command. It behaves like "sh -e". It raises InstallError if the command failed. """ Log.debug('CMD: {0}'.format(cmd)) cmd_kwargs = { 'shell': True, } cmd_kwargs.update(kwargs) env = os.environ.copy() ...
[ "def", "sh_e", "(", "cls", ",", "cmd", ",", "*", "*", "kwargs", ")", ":", "Log", ".", "debug", "(", "'CMD: {0}'", ".", "format", "(", "cmd", ")", ")", "cmd_kwargs", "=", "{", "'shell'", ":", "True", ",", "}", "cmd_kwargs", ".", "update", "(", "kw...
Run the command. It behaves like "sh -e". It raises InstallError if the command failed.
[ "Run", "the", "command", ".", "It", "behaves", "like", "sh", "-", "e", "." ]
python
train
LonamiWebs/Telethon
telethon_generator/docswriter.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon_generator/docswriter.py#L42-L68
def write_head(self, title, css_path, default_css): """Writes the head part for the generated document, with the given title and CSS """ self.title = title self.write( '''<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=...
[ "def", "write_head", "(", "self", ",", "title", ",", "css_path", ",", "default_css", ")", ":", "self", ".", "title", "=", "title", "self", ".", "write", "(", "'''<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n ...
Writes the head part for the generated document, with the given title and CSS
[ "Writes", "the", "head", "part", "for", "the", "generated", "document", "with", "the", "given", "title", "and", "CSS" ]
python
train
bitesofcode/projex
projex/plugin.py
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/plugin.py#L303-L331
def addPluginPath(cls, pluginpath): """ Adds the plugin path for this class to the given path. The inputted pluginpath value can either be a list of strings, or a string containing paths separated by the OS specific path separator (':' on Mac & Linux, ';' on Windows) ...
[ "def", "addPluginPath", "(", "cls", ",", "pluginpath", ")", ":", "prop_key", "=", "'_%s__pluginpath'", "%", "cls", ".", "__name__", "curr_path", "=", "getattr", "(", "cls", ",", "prop_key", ",", "None", ")", "if", "not", "curr_path", ":", "curr_path", "=",...
Adds the plugin path for this class to the given path. The inputted pluginpath value can either be a list of strings, or a string containing paths separated by the OS specific path separator (':' on Mac & Linux, ';' on Windows) :param pluginpath | [<str>, ..] || <str>
[ "Adds", "the", "plugin", "path", "for", "this", "class", "to", "the", "given", "path", ".", "The", "inputted", "pluginpath", "value", "can", "either", "be", "a", "list", "of", "strings", "or", "a", "string", "containing", "paths", "separated", "by", "the",...
python
train
gwpy/gwpy
gwpy/timeseries/io/nds2.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/timeseries/io/nds2.py#L204-L213
def _create_series(ndschan, value, start, end, series_class=TimeSeries): """Create a timeseries to cover the specified [start, end) limits To cover a gap in data returned from NDS """ channel = Channel.from_nds2(ndschan) nsamp = int((end - start) * channel.sample_rate.value) return series_class...
[ "def", "_create_series", "(", "ndschan", ",", "value", ",", "start", ",", "end", ",", "series_class", "=", "TimeSeries", ")", ":", "channel", "=", "Channel", ".", "from_nds2", "(", "ndschan", ")", "nsamp", "=", "int", "(", "(", "end", "-", "start", ")"...
Create a timeseries to cover the specified [start, end) limits To cover a gap in data returned from NDS
[ "Create", "a", "timeseries", "to", "cover", "the", "specified", "[", "start", "end", ")", "limits" ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/interface/management/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/interface/management/__init__.py#L414-L437
def _set_shutdown_management_oper(self, v, load=False): """ Setter method for shutdown_management_oper, mapped from YANG variable /interface/management/shutdown_management_oper (string) If this variable is read-only (config: false) in the source YANG file, then _set_shutdown_management_oper is considere...
[ "def", "_set_shutdown_management_oper", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v",...
Setter method for shutdown_management_oper, mapped from YANG variable /interface/management/shutdown_management_oper (string) If this variable is read-only (config: false) in the source YANG file, then _set_shutdown_management_oper is considered as a private method. Backends looking to populate this variabl...
[ "Setter", "method", "for", "shutdown_management_oper", "mapped", "from", "YANG", "variable", "/", "interface", "/", "management", "/", "shutdown_management_oper", "(", "string", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false...
python
train
veltzer/pydmt
pydmt/core/pydmt.py
https://github.com/veltzer/pydmt/blob/11d3db7ea079756c1e4137d3dd8a2cabbcc98bf7/pydmt/core/pydmt.py#L119-L130
def build_all(self) -> BuildProcessStats: """ Build all the targets, very high level method :return: """ stats = BuildProcessStats() for builder in self.builders: self.build_by_builder( builder=builder, stats=stats, ...
[ "def", "build_all", "(", "self", ")", "->", "BuildProcessStats", ":", "stats", "=", "BuildProcessStats", "(", ")", "for", "builder", "in", "self", ".", "builders", ":", "self", ".", "build_by_builder", "(", "builder", "=", "builder", ",", "stats", "=", "st...
Build all the targets, very high level method :return:
[ "Build", "all", "the", "targets", "very", "high", "level", "method", ":", "return", ":" ]
python
train
googleapis/google-cloud-python
datastore/google/cloud/datastore/helpers.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/helpers.py#L270-L299
def key_from_protobuf(pb): """Factory method for creating a key based on a protobuf. The protobuf should be one returned from the Cloud Datastore Protobuf API. :type pb: :class:`.entity_pb2.Key` :param pb: The Protobuf representing the key. :rtype: :class:`google.cloud.datastore.key.Key` ...
[ "def", "key_from_protobuf", "(", "pb", ")", ":", "path_args", "=", "[", "]", "for", "element", "in", "pb", ".", "path", ":", "path_args", ".", "append", "(", "element", ".", "kind", ")", "if", "element", ".", "id", ":", "# Simple field (int64)", "path_ar...
Factory method for creating a key based on a protobuf. The protobuf should be one returned from the Cloud Datastore Protobuf API. :type pb: :class:`.entity_pb2.Key` :param pb: The Protobuf representing the key. :rtype: :class:`google.cloud.datastore.key.Key` :returns: a new `Key` instance
[ "Factory", "method", "for", "creating", "a", "key", "based", "on", "a", "protobuf", "." ]
python
train
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L1617-L1623
def help_center_articles_labels_list(self, locale=None, **kwargs): "https://developer.zendesk.com/rest_api/docs/help_center/labels#list-all-labels" api_path = "/api/v2/help_center/articles/labels.json" if locale: api_opt_path = "/api/v2/help_center/{locale}/articles/labels.json" ...
[ "def", "help_center_articles_labels_list", "(", "self", ",", "locale", "=", "None", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/help_center/articles/labels.json\"", "if", "locale", ":", "api_opt_path", "=", "\"/api/v2/help_center/{locale}/articles/label...
https://developer.zendesk.com/rest_api/docs/help_center/labels#list-all-labels
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "help_center", "/", "labels#list", "-", "all", "-", "labels" ]
python
train
numenta/htmresearch
htmresearch/frameworks/layers/physical_objects.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/layers/physical_objects.py#L316-L337
def plot(self, numPoints=100): """ Specific plotting method for cylinders. """ fig = plt.figure() ax = fig.add_subplot(111, projection='3d') # generate cylinder x = np.linspace(- self.radius, self.radius, numPoints) z = np.linspace(- self.height / 2., self.height / 2., numPoints) Xc...
[ "def", "plot", "(", "self", ",", "numPoints", "=", "100", ")", ":", "fig", "=", "plt", ".", "figure", "(", ")", "ax", "=", "fig", ".", "add_subplot", "(", "111", ",", "projection", "=", "'3d'", ")", "# generate cylinder", "x", "=", "np", ".", "lins...
Specific plotting method for cylinders.
[ "Specific", "plotting", "method", "for", "cylinders", "." ]
python
train
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/request.py
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/request.py#L133-L149
def with_aad_user_password_authentication(cls, connection_string, user_id, password, authority_id="common"): """Creates a KustoConnection string builder that will authenticate with AAD user name and password. :param str connection_string: Kusto connection string should by of the format: https...
[ "def", "with_aad_user_password_authentication", "(", "cls", ",", "connection_string", ",", "user_id", ",", "password", ",", "authority_id", "=", "\"common\"", ")", ":", "_assert_value_is_valid", "(", "user_id", ")", "_assert_value_is_valid", "(", "password", ")", "kcs...
Creates a KustoConnection string builder that will authenticate with AAD user name and password. :param str connection_string: Kusto connection string should by of the format: https://<clusterName>.kusto.windows.net :param str user_id: AAD user ID. :param str password: Corresponding ...
[ "Creates", "a", "KustoConnection", "string", "builder", "that", "will", "authenticate", "with", "AAD", "user", "name", "and", "password", ".", ":", "param", "str", "connection_string", ":", "Kusto", "connection", "string", "should", "by", "of", "the", "format", ...
python
train