repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
nerdvegas/rez
src/rez/vendor/pygraph/readwrite/markup.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/readwrite/markup.py#L91-L132
def read(string): """ Read a graph from a XML document and return it. Nodes and edges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: graph @return: Graph """ dom = parseS...
[ "def", "read", "(", "string", ")", ":", "dom", "=", "parseString", "(", "string", ")", "if", "dom", ".", "getElementsByTagName", "(", "\"graph\"", ")", ":", "G", "=", "graph", "(", ")", "elif", "dom", ".", "getElementsByTagName", "(", "\"digraph\"", ")",...
Read a graph from a XML document and return it. Nodes and edges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: graph @return: Graph
[ "Read", "a", "graph", "from", "a", "XML", "document", "and", "return", "it", ".", "Nodes", "and", "edges", "specified", "in", "the", "input", "will", "be", "added", "to", "the", "current", "graph", "." ]
python
train
41.428571
tradenity/python-sdk
tradenity/resources/order_line_item.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/order_line_item.py#L851-L872
def replace_order_line_item_by_id(cls, order_line_item_id, order_line_item, **kwargs): """Replace OrderLineItem Replace all attributes of OrderLineItem This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> threa...
[ "def", "replace_order_line_item_by_id", "(", "cls", ",", "order_line_item_id", ",", "order_line_item", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return...
Replace OrderLineItem Replace all attributes of OrderLineItem This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.replace_order_line_item_by_id(order_line_item_id, order_line_item, async=True) >>>...
[ "Replace", "OrderLineItem" ]
python
train
50.909091
monarch-initiative/dipper
dipper/models/Genotype.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/Genotype.py#L256-L280
def addParts(self, part_id, parent_id, part_relationship=None): """ This will add a has_part (or subproperty) relationship between a parent_id and the supplied part. By default the relationship will be BFO:has_part, but any relationship could be given here. :param part_id...
[ "def", "addParts", "(", "self", ",", "part_id", ",", "parent_id", ",", "part_relationship", "=", "None", ")", ":", "if", "part_relationship", "is", "None", ":", "part_relationship", "=", "self", ".", "globaltt", "[", "'has_part'", "]", "# Fail loudly if parent o...
This will add a has_part (or subproperty) relationship between a parent_id and the supplied part. By default the relationship will be BFO:has_part, but any relationship could be given here. :param part_id: :param parent_id: :param part_relationship: :return:
[ "This", "will", "add", "a", "has_part", "(", "or", "subproperty", ")", "relationship", "between", "a", "parent_id", "and", "the", "supplied", "part", ".", "By", "default", "the", "relationship", "will", "be", "BFO", ":", "has_part", "but", "any", "relationsh...
python
train
36.44
adrn/gala
gala/dynamics/_genfunc/solver.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/solver.py#L81-L89
def unroll_angles(A,sign): """ Unrolls the angles, A, so they increase continuously """ n = np.array([0,0,0]) P = np.zeros(np.shape(A)) P[0]=A[0] for i in range(1,len(A)): n = n+((A[i]-A[i-1]+0.5*sign*np.pi)*sign<0)*np.ones(3)*2.*np.pi P[i] = A[i]+sign*n return P
[ "def", "unroll_angles", "(", "A", ",", "sign", ")", ":", "n", "=", "np", ".", "array", "(", "[", "0", ",", "0", ",", "0", "]", ")", "P", "=", "np", ".", "zeros", "(", "np", ".", "shape", "(", "A", ")", ")", "P", "[", "0", "]", "=", "A",...
Unrolls the angles, A, so they increase continuously
[ "Unrolls", "the", "angles", "A", "so", "they", "increase", "continuously" ]
python
train
32.777778
Koed00/django-q
django_q/admin.py
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L35-L37
def get_readonly_fields(self, request, obj=None): """Set all fields readonly.""" return list(self.readonly_fields) + [field.name for field in obj._meta.fields]
[ "def", "get_readonly_fields", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "return", "list", "(", "self", ".", "readonly_fields", ")", "+", "[", "field", ".", "name", "for", "field", "in", "obj", ".", "_meta", ".", "fields", "]" ]
Set all fields readonly.
[ "Set", "all", "fields", "readonly", "." ]
python
train
57.666667
CivicSpleen/ambry
ambry/identity.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/identity.py#L829-L849
def base62_encode(cls, num): """Encode a number in Base X. `num`: The number to encode `alphabet`: The alphabet to use for encoding Stolen from: http://stackoverflow.com/a/1119769/1144479 """ alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ...
[ "def", "base62_encode", "(", "cls", ",", "num", ")", ":", "alphabet", "=", "\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"", "if", "num", "==", "0", ":", "return", "alphabet", "[", "0", "]", "arr", "=", "[", "]", "base", "=", "len", "(", ...
Encode a number in Base X. `num`: The number to encode `alphabet`: The alphabet to use for encoding Stolen from: http://stackoverflow.com/a/1119769/1144479
[ "Encode", "a", "number", "in", "Base", "X", "." ]
python
train
26.809524
python-wink/python-wink
src/pywink/devices/piggy_bank.py
https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/piggy_bank.py#L22-L34
def set_state(self, color_hex): """ :param color_hex: a hex string indicating the color of the porkfolio nose :return: nothing From the api... "the color of the nose is not in the desired_state but on the object itself." """ root_name = self.json_s...
[ "def", "set_state", "(", "self", ",", "color_hex", ")", ":", "root_name", "=", "self", ".", "json_state", ".", "get", "(", "'piggy_bank_id'", ",", "self", ".", "name", "(", ")", ")", "response", "=", "self", ".", "api_interface", ".", "set_device_state", ...
:param color_hex: a hex string indicating the color of the porkfolio nose :return: nothing From the api... "the color of the nose is not in the desired_state but on the object itself."
[ ":", "param", "color_hex", ":", "a", "hex", "string", "indicating", "the", "color", "of", "the", "porkfolio", "nose", ":", "return", ":", "nothing", "From", "the", "api", "...", "the", "color", "of", "the", "nose", "is", "not", "in", "the", "desired_stat...
python
train
40.153846
Jarn/jarn.viewdoc
jarn/viewdoc/viewdoc.py
https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L294-L303
def read_file(self, infile): """Read a reST file into a string. """ try: with open(infile, 'rt') as file: return file.read() except UnicodeDecodeError as e: err_exit('Error reading %s: %s' % (infile, e)) except (IOError, OSError) as e: ...
[ "def", "read_file", "(", "self", ",", "infile", ")", ":", "try", ":", "with", "open", "(", "infile", ",", "'rt'", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")", "except", "UnicodeDecodeError", "as", "e", ":", "err_exit", "(", "'Erro...
Read a reST file into a string.
[ "Read", "a", "reST", "file", "into", "a", "string", "." ]
python
train
37.9
tensorflow/hub
examples/text_embeddings/export.py
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L93-L177
def make_module_spec(vocabulary_file, vocab_size, embeddings_dim, num_oov_buckets, preprocess_text): """Makes a module spec to simply perform token to embedding lookups. Input of this module is a 1-D list of string tokens. For T tokens input and an M dimensional embedding table, the lookup r...
[ "def", "make_module_spec", "(", "vocabulary_file", ",", "vocab_size", ",", "embeddings_dim", ",", "num_oov_buckets", ",", "preprocess_text", ")", ":", "def", "module_fn", "(", ")", ":", "\"\"\"Spec function for a token embedding module.\"\"\"", "tokens", "=", "tf", ".",...
Makes a module spec to simply perform token to embedding lookups. Input of this module is a 1-D list of string tokens. For T tokens input and an M dimensional embedding table, the lookup result is a [T, M] shaped Tensor. Args: vocabulary_file: Text file where each line is a key in the vocabulary. vocab_...
[ "Makes", "a", "module", "spec", "to", "simply", "perform", "token", "to", "embedding", "lookups", "." ]
python
train
41.741176
tchellomello/python-amcrest
src/amcrest/network.py
https://github.com/tchellomello/python-amcrest/blob/ed842139e234de2eaf6ee8fb480214711cde1249/src/amcrest/network.py#L219-L235
def ntp_config(self, ntp_opt): """ ntp_opt is the NTP options listed as example below: NTP.Address=clock.isc.org NTP.Enable=false NTP.Port=38 NTP.TimeZone=9 NTP.UpdatePeriod=31 ntp_opt format: <paramName>=<paramValue>[&<paramName>=<paramValue>......
[ "def", "ntp_config", "(", "self", ",", "ntp_opt", ")", ":", "ret", "=", "self", ".", "command", "(", "'configManager.cgi?action=setConfig&{0}'", ".", "format", "(", "ntp_opt", ")", ")", "return", "ret", ".", "content", ".", "decode", "(", "'utf-8'", ")" ]
ntp_opt is the NTP options listed as example below: NTP.Address=clock.isc.org NTP.Enable=false NTP.Port=38 NTP.TimeZone=9 NTP.UpdatePeriod=31 ntp_opt format: <paramName>=<paramValue>[&<paramName>=<paramValue>...]
[ "ntp_opt", "is", "the", "NTP", "options", "listed", "as", "example", "below", ":" ]
python
train
27.470588
ergo/ziggurat_foundations
ziggurat_foundations/models/user.py
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L59-L65
def last_login_date(self): """ Date of user's last login """ return sa.Column( sa.TIMESTAMP(timezone=False), default=lambda x: datetime.utcnow(), server_default=sa.func.now(), )
[ "def", "last_login_date", "(", "self", ")", ":", "return", "sa", ".", "Column", "(", "sa", ".", "TIMESTAMP", "(", "timezone", "=", "False", ")", ",", "default", "=", "lambda", "x", ":", "datetime", ".", "utcnow", "(", ")", ",", "server_default", "=", ...
Date of user's last login
[ "Date", "of", "user", "s", "last", "login" ]
python
train
33
wummel/linkchecker
third_party/miniboa-r42/miniboa/telnet.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/miniboa-r42/miniboa/telnet.py#L171-L177
def send(self, text): """ Send raw text to the distant end. """ if text: self.send_buffer += text.replace('\n', '\r\n') self.send_pending = True
[ "def", "send", "(", "self", ",", "text", ")", ":", "if", "text", ":", "self", ".", "send_buffer", "+=", "text", ".", "replace", "(", "'\\n'", ",", "'\\r\\n'", ")", "self", ".", "send_pending", "=", "True" ]
Send raw text to the distant end.
[ "Send", "raw", "text", "to", "the", "distant", "end", "." ]
python
train
27.714286
foremast/foremast
src/foremast/s3/s3apps.py
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/s3/s3apps.py#L234-L247
def _put_bucket_versioning(self): """Adds bucket versioning policy to bucket""" status = 'Suspended' if self.s3props['versioning']['enabled']: status = 'Enabled' versioning_config = { 'MFADelete': self.s3props['versioning']['mfa_delete'], 'Status': st...
[ "def", "_put_bucket_versioning", "(", "self", ")", ":", "status", "=", "'Suspended'", "if", "self", ".", "s3props", "[", "'versioning'", "]", "[", "'enabled'", "]", ":", "status", "=", "'Enabled'", "versioning_config", "=", "{", "'MFADelete'", ":", "self", "...
Adds bucket versioning policy to bucket
[ "Adds", "bucket", "versioning", "policy", "to", "bucket" ]
python
train
40.5
BerkeleyAutomation/perception
perception/detector.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/detector.py#L435-L599
def detect(self, color_im, depth_im, cfg, camera_intr, T_camera_world, vis_foreground=False, vis_segmentation=False, segmask=None): """Detects all relevant objects in an rgbd image pair using foreground masking. Parameters ---------- color_im : :obj:`ColorI...
[ "def", "detect", "(", "self", ",", "color_im", ",", "depth_im", ",", "cfg", ",", "camera_intr", ",", "T_camera_world", ",", "vis_foreground", "=", "False", ",", "vis_segmentation", "=", "False", ",", "segmask", "=", "None", ")", ":", "# read params", "min_pt...
Detects all relevant objects in an rgbd image pair using foreground masking. Parameters ---------- color_im : :obj:`ColorImage` color image for detection depth_im : :obj:`DepthImage` depth image for detection (corresponds to color image) cfg : :obj:`YamlC...
[ "Detects", "all", "relevant", "objects", "in", "an", "rgbd", "image", "pair", "using", "foreground", "masking", "." ]
python
train
44.957576
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L1471-L1474
def list_pools_on_lbaas_agent(self, lbaas_agent, **_params): """Fetches a list of pools hosted by the loadbalancer agent.""" return self.get((self.agent_path + self.LOADBALANCER_POOLS) % lbaas_agent, params=_params)
[ "def", "list_pools_on_lbaas_agent", "(", "self", ",", "lbaas_agent", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "(", "self", ".", "agent_path", "+", "self", ".", "LOADBALANCER_POOLS", ")", "%", "lbaas_agent", ",", "params", "=",...
Fetches a list of pools hosted by the loadbalancer agent.
[ "Fetches", "a", "list", "of", "pools", "hosted", "by", "the", "loadbalancer", "agent", "." ]
python
train
63
rigetti/pyquil
pyquil/noise.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/noise.py#L231-L262
def pauli_kraus_map(probabilities): r""" Generate the Kraus operators corresponding to a pauli channel. :params list|floats probabilities: The 4^num_qubits list of probabilities specifying the desired pauli channel. There should be either 4 or 16 probabilities specified in the order I, X, Y, Z for 1 qu...
[ "def", "pauli_kraus_map", "(", "probabilities", ")", ":", "if", "len", "(", "probabilities", ")", "not", "in", "[", "4", ",", "16", "]", ":", "raise", "ValueError", "(", "\"Currently we only support one or two qubits, \"", "\"so the provided list of probabilities must h...
r""" Generate the Kraus operators corresponding to a pauli channel. :params list|floats probabilities: The 4^num_qubits list of probabilities specifying the desired pauli channel. There should be either 4 or 16 probabilities specified in the order I, X, Y, Z for 1 qubit or II, IX, IY, IZ, XI, XX, XY, e...
[ "r", "Generate", "the", "Kraus", "operators", "corresponding", "to", "a", "pauli", "channel", "." ]
python
train
42.84375
NASA-AMMOS/AIT-Core
ait/core/server/stream.py
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/server/stream.py#L70-L85
def valid_workflow(self): """ Return true if each handler's output type is the same as the next handler's input type. Return False if not. Returns: boolean - True if workflow is valid, False if not """ for ix, handler in enumerate(self.handlers[:-1]): next...
[ "def", "valid_workflow", "(", "self", ")", ":", "for", "ix", ",", "handler", "in", "enumerate", "(", "self", ".", "handlers", "[", ":", "-", "1", "]", ")", ":", "next_input_type", "=", "self", ".", "handlers", "[", "ix", "+", "1", "]", ".", "input_...
Return true if each handler's output type is the same as the next handler's input type. Return False if not. Returns: boolean - True if workflow is valid, False if not
[ "Return", "true", "if", "each", "handler", "s", "output", "type", "is", "the", "same", "as", "the", "next", "handler", "s", "input", "type", ".", "Return", "False", "if", "not", "." ]
python
train
35.4375
numba/llvmlite
llvmlite/ir/builder.py
https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/builder.py#L220-L234
def goto_block(self, block): """ A context manager which temporarily positions the builder at the end of basic block *bb* (but before any terminator). """ old_block = self.basic_block term = block.terminator if term is not None: self.position_before(te...
[ "def", "goto_block", "(", "self", ",", "block", ")", ":", "old_block", "=", "self", ".", "basic_block", "term", "=", "block", ".", "terminator", "if", "term", "is", "not", "None", ":", "self", ".", "position_before", "(", "term", ")", "else", ":", "sel...
A context manager which temporarily positions the builder at the end of basic block *bb* (but before any terminator).
[ "A", "context", "manager", "which", "temporarily", "positions", "the", "builder", "at", "the", "end", "of", "basic", "block", "*", "bb", "*", "(", "but", "before", "any", "terminator", ")", "." ]
python
train
30.333333
tensorflow/tensor2tensor
tensor2tensor/data_generators/problem.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/problem.py#L583-L698
def dataset(self, mode, data_dir=None, num_threads=None, output_buffer_size=None, shuffle_files=None, hparams=None, preprocess=True, dataset_split=None, shard=None, partition_id=0,...
[ "def", "dataset", "(", "self", ",", "mode", ",", "data_dir", "=", "None", ",", "num_threads", "=", "None", ",", "output_buffer_size", "=", "None", ",", "shuffle_files", "=", "None", ",", "hparams", "=", "None", ",", "preprocess", "=", "True", ",", "datas...
Build a Dataset for this problem. Args: mode: tf.estimator.ModeKeys; determines which files to read from. data_dir: directory that contains data files. num_threads: int, number of threads to use for decode and preprocess Dataset.map calls. output_buffer_size: int, how many elements ...
[ "Build", "a", "Dataset", "for", "this", "problem", "." ]
python
train
41.5
MrMinimal64/timezonefinder
timezonefinder/helpers_numba.py
https://github.com/MrMinimal64/timezonefinder/blob/96cc43afb3bae57ffd002ab4cf104fe15eda2257/timezonefinder/helpers_numba.py#L27-L98
def inside_polygon(x, y, coordinates): """ Implementing the ray casting point in polygon test algorithm cf. https://en.wikipedia.org/wiki/Point_in_polygon#Ray_casting_algorithm :param x: :param y: :param coordinates: a polygon represented by a list containing two lists (x and y coordinates): ...
[ "def", "inside_polygon", "(", "x", ",", "y", ",", "coordinates", ")", ":", "contained", "=", "False", "# the edge from the last to the first point is checked first", "i", "=", "-", "1", "y1", "=", "coordinates", "[", "1", "]", "[", "-", "1", "]", "y_gt_y1", ...
Implementing the ray casting point in polygon test algorithm cf. https://en.wikipedia.org/wiki/Point_in_polygon#Ray_casting_algorithm :param x: :param y: :param coordinates: a polygon represented by a list containing two lists (x and y coordinates): [ [x1,x2,x3...], [y1,y2,y3...]] those ...
[ "Implementing", "the", "ray", "casting", "point", "in", "polygon", "test", "algorithm", "cf", ".", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Point_in_polygon#Ray_casting_algorithm", ":", "param", "x", ":", ":", "param", "y", ...
python
train
45.388889
StanfordBioinformatics/loom
client/loomengine/common.py
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/common.py#L110-L120
def get_server_type(): """Checks server.ini for server type.""" server_location_file = os.path.expanduser(SERVER_LOCATION_FILE) if not os.path.exists(server_location_file): raise Exception( "%s not found. Please run 'loom server set " "<servertype>' first." % server_location_...
[ "def", "get_server_type", "(", ")", ":", "server_location_file", "=", "os", ".", "path", ".", "expanduser", "(", "SERVER_LOCATION_FILE", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "server_location_file", ")", ":", "raise", "Exception", "(", "\"...
Checks server.ini for server type.
[ "Checks", "server", ".", "ini", "for", "server", "type", "." ]
python
train
42.545455
log2timeline/plaso
plaso/parsers/winreg_plugins/interface.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/interface.py#L91-L95
def key_paths(self): """List of key paths defined by the filter.""" if self._wow64_key_path: return [self._key_path, self._wow64_key_path] return [self._key_path]
[ "def", "key_paths", "(", "self", ")", ":", "if", "self", ".", "_wow64_key_path", ":", "return", "[", "self", ".", "_key_path", ",", "self", ".", "_wow64_key_path", "]", "return", "[", "self", ".", "_key_path", "]" ]
List of key paths defined by the filter.
[ "List", "of", "key", "paths", "defined", "by", "the", "filter", "." ]
python
train
35.2
wandb/client
wandb/vendor/prompt_toolkit/buffer.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/buffer.py#L608-L622
def auto_down(self, count=1, go_to_start_of_line_if_history_changes=False): """ If we're not on the last line (of a multiline input) go a line down, otherwise go forward in history. (If nothing is selected.) """ if self.complete_state: self.complete_next(count=count) ...
[ "def", "auto_down", "(", "self", ",", "count", "=", "1", ",", "go_to_start_of_line_if_history_changes", "=", "False", ")", ":", "if", "self", ".", "complete_state", ":", "self", ".", "complete_next", "(", "count", "=", "count", ")", "elif", "self", ".", "d...
If we're not on the last line (of a multiline input) go a line down, otherwise go forward in history. (If nothing is selected.)
[ "If", "we", "re", "not", "on", "the", "last", "line", "(", "of", "a", "multiline", "input", ")", "go", "a", "line", "down", "otherwise", "go", "forward", "in", "history", ".", "(", "If", "nothing", "is", "selected", ".", ")" ]
python
train
46.2
chop-dbhi/varify-data-warehouse
vdw/samples/utils.py
https://github.com/chop-dbhi/varify-data-warehouse/blob/1600ee1bc5fae6c68fd03b23624467298570cca8/vdw/samples/utils.py#L4-L12
def file_md5(f, size=8192): "Calculates the MD5 of a file." md5 = hashlib.md5() while True: data = f.read(size) if not data: break md5.update(data) return md5.hexdigest()
[ "def", "file_md5", "(", "f", ",", "size", "=", "8192", ")", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "while", "True", ":", "data", "=", "f", ".", "read", "(", "size", ")", "if", "not", "data", ":", "break", "md5", ".", "update", "(", ...
Calculates the MD5 of a file.
[ "Calculates", "the", "MD5", "of", "a", "file", "." ]
python
train
23.777778
python-rope/rope
rope/refactor/extract.py
https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/refactor/extract.py#L188-L193
def returned(self): """Does the extracted piece contain return statement""" if self._returned is None: node = _parse_text(self.extracted) self._returned = usefunction._returns_last(node) return self._returned
[ "def", "returned", "(", "self", ")", ":", "if", "self", ".", "_returned", "is", "None", ":", "node", "=", "_parse_text", "(", "self", ".", "extracted", ")", "self", ".", "_returned", "=", "usefunction", ".", "_returns_last", "(", "node", ")", "return", ...
Does the extracted piece contain return statement
[ "Does", "the", "extracted", "piece", "contain", "return", "statement" ]
python
train
41.833333
Ouranosinc/xclim
xclim/indices.py
https://github.com/Ouranosinc/xclim/blob/2080d139188bd8de2aeca097a025c2d89d6e0e09/xclim/indices.py#L352-L389
def maximum_consecutive_dry_days(pr, thresh='1 mm/day', freq='YS'): r"""Maximum number of consecutive dry days Return the maximum number of consecutive days within the period where precipitation is below a certain threshold. Parameters ---------- pr : xarray.DataArray Mean daily precipit...
[ "def", "maximum_consecutive_dry_days", "(", "pr", ",", "thresh", "=", "'1 mm/day'", ",", "freq", "=", "'YS'", ")", ":", "t", "=", "utils", ".", "convert_units_to", "(", "thresh", ",", "pr", ",", "'hydro'", ")", "group", "=", "(", "pr", "<", "t", ")", ...
r"""Maximum number of consecutive dry days Return the maximum number of consecutive days within the period where precipitation is below a certain threshold. Parameters ---------- pr : xarray.DataArray Mean daily precipitation flux [mm] thresh : str Threshold precipitation on which ...
[ "r", "Maximum", "number", "of", "consecutive", "dry", "days" ]
python
train
37.578947
wedi/PyMediaRSS2Gen
PyMediaRSS2Gen.py
https://github.com/wedi/PyMediaRSS2Gen/blob/11c3d0f57386906394e303cb31f2e02be2c4fadf/PyMediaRSS2Gen.py#L185-L230
def check_complicance(self): """Check compliance with Media RSS Specification, Version 1.5.1. see http://www.rssboard.org/media-rss Raises AttributeError on error. """ # check Media RSS requirement: one of the following elements is # required: media_group | media_content...
[ "def", "check_complicance", "(", "self", ")", ":", "# check Media RSS requirement: one of the following elements is", "# required: media_group | media_content | media_player | media_peerLink", "# | media_location. We do the check only if any media_... element is", "# set to allow non media feeds",...
Check compliance with Media RSS Specification, Version 1.5.1. see http://www.rssboard.org/media-rss Raises AttributeError on error.
[ "Check", "compliance", "with", "Media", "RSS", "Specification", "Version", "1", ".", "5", ".", "1", "." ]
python
train
48.76087
mottosso/be
be/vendor/click/core.py
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L25-L35
def _bashcomplete(cmd, prog_name, complete_var=None): """Internal handler for the bash completion support.""" if complete_var is None: complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper() complete_instr = os.environ.get(complete_var) if not complete_instr: return fr...
[ "def", "_bashcomplete", "(", "cmd", ",", "prog_name", ",", "complete_var", "=", "None", ")", ":", "if", "complete_var", "is", "None", ":", "complete_var", "=", "'_%s_COMPLETE'", "%", "(", "prog_name", ".", "replace", "(", "'-'", ",", "'_'", ")", ")", "."...
Internal handler for the bash completion support.
[ "Internal", "handler", "for", "the", "bash", "completion", "support", "." ]
python
train
39.454545
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L467-L542
def update_intent(self, intent, language_code, update_mask=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
[ "def", "update_intent", "(", "self", ",", "intent", ",", "language_code", ",", "update_mask", "=", "None", ",", "intent_view", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", ...
Updates the specified intent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.IntentsClient() >>> >>> # TODO: Initialize ``intent``: >>> intent = {} >>> >>> # TODO: Initialize ``language_code``: ...
[ "Updates", "the", "specified", "intent", "." ]
python
train
49.75
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L25586-L25596
def complete_vhwa_command(self, command): """Signals that the Video HW Acceleration command has completed. in command of type str Pointer to VBOXVHWACMD containing the completed command. """ if not isinstance(command, basestring): raise TypeError("command can on...
[ "def", "complete_vhwa_command", "(", "self", ",", "command", ")", ":", "if", "not", "isinstance", "(", "command", ",", "basestring", ")", ":", "raise", "TypeError", "(", "\"command can only be an instance of type basestring\"", ")", "self", ".", "_call", "(", "\"c...
Signals that the Video HW Acceleration command has completed. in command of type str Pointer to VBOXVHWACMD containing the completed command.
[ "Signals", "that", "the", "Video", "HW", "Acceleration", "command", "has", "completed", "." ]
python
train
38.818182
CTPUG/wafer
wafer/context_processors.py
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L37-L49
def registration_settings(request): '''Expose selected settings to templates''' context = {} for setting in ( 'WAFER_SSO', 'WAFER_HIDE_LOGIN', 'WAFER_REGISTRATION_OPEN', 'WAFER_REGISTRATION_MODE', 'WAFER_TALKS_OPEN', 'WAFER_VIDEO_LICENS...
[ "def", "registration_settings", "(", "request", ")", ":", "context", "=", "{", "}", "for", "setting", "in", "(", "'WAFER_SSO'", ",", "'WAFER_HIDE_LOGIN'", ",", "'WAFER_REGISTRATION_OPEN'", ",", "'WAFER_REGISTRATION_MODE'", ",", "'WAFER_TALKS_OPEN'", ",", "'WAFER_VIDEO...
Expose selected settings to templates
[ "Expose", "selected", "settings", "to", "templates" ]
python
train
30.538462
Parsl/parsl
parsl/dataflow/dflow.py
https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/dataflow/dflow.py#L776-L790
def wait_for_current_tasks(self): """Waits for all tasks in the task list to be completed, by waiting for their AppFuture to be completed. This method will not necessarily wait for any tasks added after cleanup has started (such as data stageout?) """ logger.info("Waiting for al...
[ "def", "wait_for_current_tasks", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Waiting for all remaining tasks to complete\"", ")", "for", "task_id", "in", "self", ".", "tasks", ":", "# .exception() is a less exception throwing way of", "# waiting for completion than ...
Waits for all tasks in the task list to be completed, by waiting for their AppFuture to be completed. This method will not necessarily wait for any tasks added after cleanup has started (such as data stageout?)
[ "Waits", "for", "all", "tasks", "in", "the", "task", "list", "to", "be", "completed", "by", "waiting", "for", "their", "AppFuture", "to", "be", "completed", ".", "This", "method", "will", "not", "necessarily", "wait", "for", "any", "tasks", "added", "after...
python
valid
48.733333
edx/edx-submissions
submissions/serializers.py
https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/serializers.py#L61-L75
def validate_answer(self, value): """ Check that the answer is JSON-serializable and not too long. """ # Check that the answer is JSON-serializable try: serialized = json.dumps(value) except (ValueError, TypeError): raise serializers.ValidationErro...
[ "def", "validate_answer", "(", "self", ",", "value", ")", ":", "# Check that the answer is JSON-serializable", "try", ":", "serialized", "=", "json", ".", "dumps", "(", "value", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "raise", "serializers"...
Check that the answer is JSON-serializable and not too long.
[ "Check", "that", "the", "answer", "is", "JSON", "-", "serializable", "and", "not", "too", "long", "." ]
python
train
37.333333
aleju/imgaug
imgaug/external/poly_point_isect_py2py3.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/external/poly_point_isect_py2py3.py#L862-L900
def succ_item(self, key, default=_sentinel): """Get successor (k,v) pair of key, raises KeyError if key is max key or key does not exist. optimized for pypy. """ # removed graingets version, because it was little slower on CPython and much slower on pypy # this version runs about...
[ "def", "succ_item", "(", "self", ",", "key", ",", "default", "=", "_sentinel", ")", ":", "# removed graingets version, because it was little slower on CPython and much slower on pypy", "# this version runs about 4x faster with pypy than the Cython version", "# Note: Code sharing of succ_...
Get successor (k,v) pair of key, raises KeyError if key is max key or key does not exist. optimized for pypy.
[ "Get", "successor", "(", "k", "v", ")", "pair", "of", "key", "raises", "KeyError", "if", "key", "is", "max", "key", "or", "key", "does", "not", "exist", ".", "optimized", "for", "pypy", "." ]
python
valid
41.666667
quantopian/zipline
zipline/utils/date_utils.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/date_utils.py#L4-L42
def compute_date_range_chunks(sessions, start_date, end_date, chunksize): """Compute the start and end dates to run a pipeline for. Parameters ---------- sessions : DatetimeIndex The available dates. start_date : pd.Timestamp The first date in the pipeline. end_date : pd.Timesta...
[ "def", "compute_date_range_chunks", "(", "sessions", ",", "start_date", ",", "end_date", ",", "chunksize", ")", ":", "if", "start_date", "not", "in", "sessions", ":", "raise", "KeyError", "(", "\"Start date %s is not found in calendar.\"", "%", "(", "start_date", "....
Compute the start and end dates to run a pipeline for. Parameters ---------- sessions : DatetimeIndex The available dates. start_date : pd.Timestamp The first date in the pipeline. end_date : pd.Timestamp The last date in the pipeline. chunksize : int or None The...
[ "Compute", "the", "start", "and", "end", "dates", "to", "run", "a", "pipeline", "for", "." ]
python
train
35.25641
pkgw/pwkit
pwkit/cli/__init__.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L413-L447
def check_usage (docstring, argv=None, usageifnoargs=False): """Check if the program has been run with a --help argument; if so, print usage information and exit. :arg str docstring: the program help text :arg argv: the program arguments; taken as :data:`sys.argv` if given as :const:`None` (the...
[ "def", "check_usage", "(", "docstring", ",", "argv", "=", "None", ",", "usageifnoargs", "=", "False", ")", ":", "if", "argv", "is", "None", ":", "from", "sys", "import", "argv", "if", "len", "(", "argv", ")", "==", "1", "and", "usageifnoargs", ":", "...
Check if the program has been run with a --help argument; if so, print usage information and exit. :arg str docstring: the program help text :arg argv: the program arguments; taken as :data:`sys.argv` if given as :const:`None` (the default). (Note that this implies ``argv[0]`` should be the...
[ "Check", "if", "the", "program", "has", "been", "run", "with", "a", "--", "help", "argument", ";", "if", "so", "print", "usage", "information", "and", "exit", "." ]
python
train
41.314286
log2timeline/dfdatetime
dfdatetime/interface.py
https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/interface.py#L897-L908
def CopyToDateTimeStringISO8601(self): """Copies the date time value to an ISO 8601 date and time string. Returns: str: date and time value formatted as an ISO 8601 date and time string or None if the timestamp cannot be copied to a date and time string. """ date_time_string = self.Copy...
[ "def", "CopyToDateTimeStringISO8601", "(", "self", ")", ":", "date_time_string", "=", "self", ".", "CopyToDateTimeString", "(", ")", "if", "date_time_string", ":", "date_time_string", "=", "date_time_string", ".", "replace", "(", "' '", ",", "'T'", ")", "date_time...
Copies the date time value to an ISO 8601 date and time string. Returns: str: date and time value formatted as an ISO 8601 date and time string or None if the timestamp cannot be copied to a date and time string.
[ "Copies", "the", "date", "time", "value", "to", "an", "ISO", "8601", "date", "and", "time", "string", "." ]
python
train
41.583333
hazelcast/hazelcast-python-client
hazelcast/proxy/replicated_map.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/replicated_map.py#L27-L77
def add_entry_listener(self, key=None, predicate=None, added_func=None, removed_func=None, updated_func=None, evicted_func=None, clear_all_func=None): """ Adds a continuous entry listener for this map. Listener will get notified for map events filtered with given param...
[ "def", "add_entry_listener", "(", "self", ",", "key", "=", "None", ",", "predicate", "=", "None", ",", "added_func", "=", "None", ",", "removed_func", "=", "None", ",", "updated_func", "=", "None", ",", "evicted_func", "=", "None", ",", "clear_all_func", "...
Adds a continuous entry listener for this map. Listener will get notified for map events filtered with given parameters. :param key: (object), key for filtering the events (optional). :param predicate: (Predicate), predicate for filtering the events (optional). :param added_func: Functi...
[ "Adds", "a", "continuous", "entry", "listener", "for", "this", "map", ".", "Listener", "will", "get", "notified", "for", "map", "events", "filtered", "with", "given", "parameters", "." ]
python
train
64.117647
beerfactory/hbmqtt
hbmqtt/broker.py
https://github.com/beerfactory/hbmqtt/blob/4aa6fe982141abc3c54e9f4d7b981ab3eba0a13c/hbmqtt/broker.py#L300-L331
def shutdown(self): """ Stop broker instance. Closes all connected session, stop listening on network socket and free resources. """ try: self._sessions = dict() self._subscriptions = dict() self._retained_messages = dict() ...
[ "def", "shutdown", "(", "self", ")", ":", "try", ":", "self", ".", "_sessions", "=", "dict", "(", ")", "self", ".", "_subscriptions", "=", "dict", "(", ")", "self", ".", "_retained_messages", "=", "dict", "(", ")", "self", ".", "transitions", ".", "s...
Stop broker instance. Closes all connected session, stop listening on network socket and free resources.
[ "Stop", "broker", "instance", "." ]
python
train
41.53125
richardkiss/pycoin
pycoin/key/BIP32Node.py
https://github.com/richardkiss/pycoin/blob/1e8d0d9fe20ce0347b97847bb529cd1bd84c7442/pycoin/key/BIP32Node.py#L120-L125
def public_copy(self): """Yield the corresponding public node for this node.""" d = dict(chain_code=self._chain_code, depth=self._depth, parent_fingerprint=self._parent_fingerprint, child_index=self._child_index, public_pair=self.public_pair()) return self.__cla...
[ "def", "public_copy", "(", "self", ")", ":", "d", "=", "dict", "(", "chain_code", "=", "self", ".", "_chain_code", ",", "depth", "=", "self", ".", "_depth", ",", "parent_fingerprint", "=", "self", ".", "_parent_fingerprint", ",", "child_index", "=", "self"...
Yield the corresponding public node for this node.
[ "Yield", "the", "corresponding", "public", "node", "for", "this", "node", "." ]
python
train
54
odlgroup/odl
odl/set/space.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/set/space.py#L937-L946
def divide(self, other, out=None): """Return ``out = self / other``. If ``out`` is provided, the result is written to it. See Also -------- LinearSpace.divide """ return self.space.divide(self, other, out=out)
[ "def", "divide", "(", "self", ",", "other", ",", "out", "=", "None", ")", ":", "return", "self", ".", "space", ".", "divide", "(", "self", ",", "other", ",", "out", "=", "out", ")" ]
Return ``out = self / other``. If ``out`` is provided, the result is written to it. See Also -------- LinearSpace.divide
[ "Return", "out", "=", "self", "/", "other", "." ]
python
train
25.8
PaulHancock/Aegean
AegeanTools/angle_tools.py
https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L90-L115
def dec2hms(x): """ Convert decimal degrees into a sexagessimal string in hours. Parameters ---------- x : float Angle in degrees Returns ------- dms : string String of format HH:MM:SS.SS or XX:XX:XX.XX if x is not finite. """ if not np.isfinite(x): ...
[ "def", "dec2hms", "(", "x", ")", ":", "if", "not", "np", ".", "isfinite", "(", "x", ")", ":", "return", "'XX:XX:XX.XX'", "# wrap negative RA's", "if", "x", "<", "0", ":", "x", "+=", "360", "x", "/=", "15.0", "h", "=", "int", "(", "x", ")", "x", ...
Convert decimal degrees into a sexagessimal string in hours. Parameters ---------- x : float Angle in degrees Returns ------- dms : string String of format HH:MM:SS.SS or XX:XX:XX.XX if x is not finite.
[ "Convert", "decimal", "degrees", "into", "a", "sexagessimal", "string", "in", "hours", "." ]
python
train
19.846154
pytroll/python-geotiepoints
geotiepoints/modisinterpolator.py
https://github.com/pytroll/python-geotiepoints/blob/7c5cc8a887f8534cc2839c716c2c560aeaf77659/geotiepoints/modisinterpolator.py#L51-L73
def compute_expansion_alignment(satz_a, satz_b, satz_c, satz_d): """All angles in radians.""" zeta_a = satz_a zeta_b = satz_b phi_a = compute_phi(zeta_a) phi_b = compute_phi(zeta_b) theta_a = compute_theta(zeta_a, phi_a) theta_b = compute_theta(zeta_b, phi_b) phi = (phi_a + phi_b) / 2 ...
[ "def", "compute_expansion_alignment", "(", "satz_a", ",", "satz_b", ",", "satz_c", ",", "satz_d", ")", ":", "zeta_a", "=", "satz_a", "zeta_b", "=", "satz_b", "phi_a", "=", "compute_phi", "(", "zeta_a", ")", "phi_b", "=", "compute_phi", "(", "zeta_b", ")", ...
All angles in radians.
[ "All", "angles", "in", "radians", "." ]
python
train
30.652174
mitsei/dlkit
dlkit/aws_adapter/repository/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/aws_adapter/repository/sessions.py#L251-L268
def get_assets_by_record_type(self, asset_record_type=None): """Gets an ``AssetList`` containing the given asset record ``Type``. In plenary mode, the returned list contains all known assets or an error results. Otherwise, the returned list may contain only those assets that are accessi...
[ "def", "get_assets_by_record_type", "(", "self", ",", "asset_record_type", "=", "None", ")", ":", "return", "AssetList", "(", "self", ".", "_provider_session", ".", "get_assets_by_record_type", "(", "asset_record_type", ")", ",", "self", ".", "_config_map", ")" ]
Gets an ``AssetList`` containing the given asset record ``Type``. In plenary mode, the returned list contains all known assets or an error results. Otherwise, the returned list may contain only those assets that are accessible through this session. arg: asset_record_type (osid.type....
[ "Gets", "an", "AssetList", "containing", "the", "given", "asset", "record", "Type", "." ]
python
train
49.611111
nosegae/NoseGAE
nosegae.py
https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/nosegae.py#L251-L253
def _init_stub(self, stub_init, **stub_kwargs): """Initializes all other stubs for consistency's sake""" getattr(self.testbed, stub_init, lambda **kwargs: None)(**stub_kwargs)
[ "def", "_init_stub", "(", "self", ",", "stub_init", ",", "*", "*", "stub_kwargs", ")", ":", "getattr", "(", "self", ".", "testbed", ",", "stub_init", ",", "lambda", "*", "*", "kwargs", ":", "None", ")", "(", "*", "*", "stub_kwargs", ")" ]
Initializes all other stubs for consistency's sake
[ "Initializes", "all", "other", "stubs", "for", "consistency", "s", "sake" ]
python
train
63
TeamHG-Memex/eli5
eli5/xgboost.py
https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/xgboost.py#L291-L305
def _indexed_leafs(parent): """ Return a leaf nodeid -> node dictionary with "parent" and "leaf" (average child "leaf" value) added to all nodes. """ if not parent.get('children'): return {parent['nodeid']: parent} indexed = {} for child in parent['children']: child['parent'] = p...
[ "def", "_indexed_leafs", "(", "parent", ")", ":", "if", "not", "parent", ".", "get", "(", "'children'", ")", ":", "return", "{", "parent", "[", "'nodeid'", "]", ":", "parent", "}", "indexed", "=", "{", "}", "for", "child", "in", "parent", "[", "'chil...
Return a leaf nodeid -> node dictionary with "parent" and "leaf" (average child "leaf" value) added to all nodes.
[ "Return", "a", "leaf", "nodeid", "-", ">", "node", "dictionary", "with", "parent", "and", "leaf", "(", "average", "child", "leaf", "value", ")", "added", "to", "all", "nodes", "." ]
python
train
34.8
SheffieldML/GPy
GPy/kern/src/psi_comp/rbf_psi_gpucomp.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/kern/src/psi_comp/rbf_psi_gpucomp.py#L328-L364
def _psicomputations(self, kern, Z, variational_posterior, return_psi2_n=False): """ Z - MxQ mu - NxQ S - NxQ """ variance, lengthscale = kern.variance, kern.lengthscale N,M,Q = self.get_dimensions(Z, variational_posterior) self._initGPUCache(N,M,Q) ...
[ "def", "_psicomputations", "(", "self", ",", "kern", ",", "Z", ",", "variational_posterior", ",", "return_psi2_n", "=", "False", ")", ":", "variance", ",", "lengthscale", "=", "kern", ".", "variance", ",", "kern", ".", "lengthscale", "N", ",", "M", ",", ...
Z - MxQ mu - NxQ S - NxQ
[ "Z", "-", "MxQ", "mu", "-", "NxQ", "S", "-", "NxQ" ]
python
train
58.567568
splunk/splunk-sdk-python
splunklib/client.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2940-L2984
def export(self, query, **params): """Runs a search and immediately starts streaming preview events. This method returns a streaming handle to this job's events as an XML document from the server. To parse this stream into usable Python objects, pass the handle to :class:`splunklib.resul...
[ "def", "export", "(", "self", ",", "query", ",", "*", "*", "params", ")", ":", "if", "\"exec_mode\"", "in", "params", ":", "raise", "TypeError", "(", "\"Cannot specify an exec_mode to export.\"", ")", "params", "[", "'segmentation'", "]", "=", "params", ".", ...
Runs a search and immediately starts streaming preview events. This method returns a streaming handle to this job's events as an XML document from the server. To parse this stream into usable Python objects, pass the handle to :class:`splunklib.results.ResultsReader`:: import splunk...
[ "Runs", "a", "search", "and", "immediately", "starts", "streaming", "preview", "events", ".", "This", "method", "returns", "a", "streaming", "handle", "to", "this", "job", "s", "events", "as", "an", "XML", "document", "from", "the", "server", ".", "To", "p...
python
train
49.688889
semiversus/python-broqer
broqer/publisher.py
https://github.com/semiversus/python-broqer/blob/8957110b034f982451392072d9fa16761adc9c9e/broqer/publisher.py#L96-L116
def notify(self, value: Any) -> asyncio.Future: """ Calling .emit(value) on all subscribers. A synchronouse subscriber will just return None, a asynchronous one may returns a future. Futures will be collected. If no future was returned None will be returned by this method. If one futrue ...
[ "def", "notify", "(", "self", ",", "value", ":", "Any", ")", "->", "asyncio", ".", "Future", ":", "results", "=", "(", "s", ".", "emit", "(", "value", ",", "who", "=", "self", ")", "for", "s", "in", "self", ".", "_subscriptions", ")", "futures", ...
Calling .emit(value) on all subscribers. A synchronouse subscriber will just return None, a asynchronous one may returns a future. Futures will be collected. If no future was returned None will be returned by this method. If one futrue was returned that future will be returned. When mult...
[ "Calling", ".", "emit", "(", "value", ")", "on", "all", "subscribers", ".", "A", "synchronouse", "subscriber", "will", "just", "return", "None", "a", "asynchronous", "one", "may", "returns", "a", "future", ".", "Futures", "will", "be", "collected", ".", "I...
python
train
43.666667
delfick/harpoon
harpoon/collector.py
https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/collector.py#L185-L246
def add_configuration(self, configuration, collect_another_source, done, result, src): """ Used to add a file to the configuration, result here is the yaml.load of the src. If the configuration we're reading in has ``harpoon.extra_files`` then this is treated as a list of string...
[ "def", "add_configuration", "(", "self", ",", "configuration", ",", "collect_another_source", ",", "done", ",", "result", ",", "src", ")", ":", "# Make sure to maintain the original config_root", "if", "\"config_root\"", "in", "configuration", ":", "# if we already have a...
Used to add a file to the configuration, result here is the yaml.load of the src. If the configuration we're reading in has ``harpoon.extra_files`` then this is treated as a list of strings of other files to collect. We also take extra files to collector from result["images"]["__images...
[ "Used", "to", "add", "a", "file", "to", "the", "configuration", "result", "here", "is", "the", "yaml", ".", "load", "of", "the", "src", "." ]
python
train
50.435484
has2k1/plotnine
plotnine/guides/guides.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guides.py#L267-L286
def draw(self, gdefs, theme): """ Draw out each guide definition Parameters ---------- gdefs : list of guide_legend|guide_colorbar guide definitions theme : theme Plot theme Returns ------- out : list of matplotlib.offsetb...
[ "def", "draw", "(", "self", ",", "gdefs", ",", "theme", ")", ":", "for", "g", "in", "gdefs", ":", "g", ".", "theme", "=", "theme", "g", ".", "_set_defaults", "(", ")", "return", "[", "g", ".", "draw", "(", ")", "for", "g", "in", "gdefs", "]" ]
Draw out each guide definition Parameters ---------- gdefs : list of guide_legend|guide_colorbar guide definitions theme : theme Plot theme Returns ------- out : list of matplotlib.offsetbox.Offsetbox A drawing of each legend
[ "Draw", "out", "each", "guide", "definition" ]
python
train
24.25
pyQode/pyqode-uic
pyqode_uic.py
https://github.com/pyQode/pyqode-uic/blob/e8b7a1e275dbb5d76031f197d93ede1ea505fdcb/pyqode_uic.py#L17-L33
def fix_imports(script): """ Replace "from PyQt5 import" by "from pyqode.qt import". :param script: script path """ with open(script, 'r') as f_script: lines = f_script.read().splitlines() new_lines = [] for l in lines: if l.startswith("import "): l = "from . " +...
[ "def", "fix_imports", "(", "script", ")", ":", "with", "open", "(", "script", ",", "'r'", ")", "as", "f_script", ":", "lines", "=", "f_script", ".", "read", "(", ")", ".", "splitlines", "(", ")", "new_lines", "=", "[", "]", "for", "l", "in", "lines...
Replace "from PyQt5 import" by "from pyqode.qt import". :param script: script path
[ "Replace", "from", "PyQt5", "import", "by", "from", "pyqode", ".", "qt", "import", "." ]
python
train
31.058824
ml4ai/delphi
delphi/analysis/comparison/utils.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/analysis/comparison/utils.py#L23-L25
def nx_graph_from_dotfile(filename: str) -> nx.DiGraph: """ Get a networkx graph from a DOT file, and reverse the edges. """ return nx.DiGraph(read_dot(filename).reverse())
[ "def", "nx_graph_from_dotfile", "(", "filename", ":", "str", ")", "->", "nx", ".", "DiGraph", ":", "return", "nx", ".", "DiGraph", "(", "read_dot", "(", "filename", ")", ".", "reverse", "(", ")", ")" ]
Get a networkx graph from a DOT file, and reverse the edges.
[ "Get", "a", "networkx", "graph", "from", "a", "DOT", "file", "and", "reverse", "the", "edges", "." ]
python
train
59.333333
tdegeus/GooseMPL
GooseMPL/__init__.py
https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L367-L397
def subplots(scale_x=None, scale_y=None, scale=None, **kwargs): r''' Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default. :additional options: **scale, scale_x, scale_y** (``<float>``) Scale the figure-size (along one of the dimensions). ''' if 'figsize' in kwar...
[ "def", "subplots", "(", "scale_x", "=", "None", ",", "scale_y", "=", "None", ",", "scale", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'figsize'", "in", "kwargs", ":", "return", "plt", ".", "subplots", "(", "*", "*", "kwargs", ")", "widt...
r''' Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default. :additional options: **scale, scale_x, scale_y** (``<float>``) Scale the figure-size (along one of the dimensions).
[ "r", "Run", "matplotlib", ".", "pyplot", ".", "subplots", "with", "figsize", "set", "to", "the", "correct", "multiple", "of", "the", "default", "." ]
python
train
23.774194
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/egl.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/egl.py#L233-L239
def eglGetDisplay(display=EGL_DEFAULT_DISPLAY): """ Connect to the EGL display server. """ res = _lib.eglGetDisplay(display) if not res or res == EGL_NO_DISPLAY: raise RuntimeError('Could not create display') return res
[ "def", "eglGetDisplay", "(", "display", "=", "EGL_DEFAULT_DISPLAY", ")", ":", "res", "=", "_lib", ".", "eglGetDisplay", "(", "display", ")", "if", "not", "res", "or", "res", "==", "EGL_NO_DISPLAY", ":", "raise", "RuntimeError", "(", "'Could not create display'",...
Connect to the EGL display server.
[ "Connect", "to", "the", "EGL", "display", "server", "." ]
python
train
34.428571
yyuu/botornado
boto/sdb/connection.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sdb/connection.py#L226-L238
def print_usage(self): """ Print the BoxUsage and approximate costs of all requests made on this specific SDBConnection instance. .. tip:: This can be out of date, and should only be treated as a rough estimate. Also note that this estimate only applies to the ...
[ "def", "print_usage", "(", "self", ")", ":", "print", "'Total Usage: %f compute seconds'", "%", "self", ".", "box_usage", "cost", "=", "self", ".", "box_usage", "*", "0.14", "print", "'Approximate Cost: $%f'", "%", "cost" ]
Print the BoxUsage and approximate costs of all requests made on this specific SDBConnection instance. .. tip:: This can be out of date, and should only be treated as a rough estimate. Also note that this estimate only applies to the requests made on this specific connec...
[ "Print", "the", "BoxUsage", "and", "approximate", "costs", "of", "all", "requests", "made", "on", "this", "specific", "SDBConnection", "instance", ".", "..", "tip", "::", "This", "can", "be", "out", "of", "date", "and", "should", "only", "be", "treated", "...
python
train
44.615385
poppy-project/pypot
pypot/dynamixel/__init__.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/__init__.py#L58-L71
def get_port_vendor_info(port=None): """ Return vendor informations of a usb2serial device. It may depends on the Operating System. :param string port: port of the usb2serial device :Example: Result with a USB2Dynamixel on Linux: In [1]: import pypot.dynamixel In [2...
[ "def", "get_port_vendor_info", "(", "port", "=", "None", ")", ":", "port_info_dict", "=", "dict", "(", "(", "x", "[", "0", "]", ",", "x", "[", "2", "]", ")", "for", "x", "in", "serial", ".", "tools", ".", "list_ports", ".", "comports", "(", ")", ...
Return vendor informations of a usb2serial device. It may depends on the Operating System. :param string port: port of the usb2serial device :Example: Result with a USB2Dynamixel on Linux: In [1]: import pypot.dynamixel In [2]: pypot.dynamixel.get_port_vendor_info('/dev...
[ "Return", "vendor", "informations", "of", "a", "usb2serial", "device", ".", "It", "may", "depends", "on", "the", "Operating", "System", ".", ":", "param", "string", "port", ":", "port", "of", "the", "usb2serial", "device" ]
python
train
41.142857
mwickert/scikit-dsp-comm
sk_dsp_comm/fir_design_helper.py
https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/fir_design_helper.py#L373-L396
def fir_remez_bsf(f_pass1, f_stop1, f_stop2, f_pass2, d_pass, d_stop, fs = 1.0, N_bump=5): """ Design an FIR bandstop filter using remez with order determination. The filter order is determined based on f_pass1 Hz, f_stop1 Hz, f_stop2 Hz, f_pass2 Hz, and the desired passba...
[ "def", "fir_remez_bsf", "(", "f_pass1", ",", "f_stop1", ",", "f_stop2", ",", "f_pass2", ",", "d_pass", ",", "d_stop", ",", "fs", "=", "1.0", ",", "N_bump", "=", "5", ")", ":", "n", ",", "ff", ",", "aa", ",", "wts", "=", "bandstop_order", "(", "f_pa...
Design an FIR bandstop filter using remez with order determination. The filter order is determined based on f_pass1 Hz, f_stop1 Hz, f_stop2 Hz, f_pass2 Hz, and the desired passband ripple d_pass dB and stopband attenuation d_stop dB all relative to a sampling rate of fs Hz. Mark Wickert Oct...
[ "Design", "an", "FIR", "bandstop", "filter", "using", "remez", "with", "order", "determination", ".", "The", "filter", "order", "is", "determined", "based", "on", "f_pass1", "Hz", "f_stop1", "Hz", "f_stop2", "Hz", "f_pass2", "Hz", "and", "the", "desired", "p...
python
valid
44.5
aequitas/python-rflink
rflink/parser.py
https://github.com/aequitas/python-rflink/blob/46759ce8daf95cfc7cdb608ae17bc5501be9f6d8/rflink/parser.py#L297-L316
def encode_packet(packet: dict) -> str: """Construct packet string from packet dictionary. >>> encode_packet({ ... 'protocol': 'newkaku', ... 'id': '000001', ... 'switch': '01', ... 'command': 'on', ... }) '10;newkaku;000001;01;on;' """ if packet['protocol'] == '...
[ "def", "encode_packet", "(", "packet", ":", "dict", ")", "->", "str", ":", "if", "packet", "[", "'protocol'", "]", "==", "'rfdebug'", ":", "return", "'10;RFDEBUG='", "+", "packet", "[", "'command'", "]", "+", "';'", "elif", "packet", "[", "'protocol'", "...
Construct packet string from packet dictionary. >>> encode_packet({ ... 'protocol': 'newkaku', ... 'id': '000001', ... 'switch': '01', ... 'command': 'on', ... }) '10;newkaku;000001;01;on;'
[ "Construct", "packet", "string", "from", "packet", "dictionary", "." ]
python
train
29.75
spyder-ide/spyder
spyder/plugins/variableexplorer/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/plugin.py#L125-L143
def add_shellwidget(self, shellwidget): """ Register shell with variable explorer. This function opens a new NamespaceBrowser for browsing the variables in the shell. """ shellwidget_id = id(shellwidget) if shellwidget_id not in self.shellwidgets: ...
[ "def", "add_shellwidget", "(", "self", ",", "shellwidget", ")", ":", "shellwidget_id", "=", "id", "(", "shellwidget", ")", "if", "shellwidget_id", "not", "in", "self", ".", "shellwidgets", ":", "self", ".", "options_button", ".", "setVisible", "(", "True", "...
Register shell with variable explorer. This function opens a new NamespaceBrowser for browsing the variables in the shell.
[ "Register", "shell", "with", "variable", "explorer", ".", "This", "function", "opens", "a", "new", "NamespaceBrowser", "for", "browsing", "the", "variables", "in", "the", "shell", "." ]
python
train
42.421053
mila-iqia/fuel
fuel/utils/parallel.py
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/parallel.py#L14-L36
def _producer_wrapper(f, port, addr='tcp://127.0.0.1'): """A shim that sets up a socket and starts the producer callable. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. port : int The port on wh...
[ "def", "_producer_wrapper", "(", "f", ",", "port", ",", "addr", "=", "'tcp://127.0.0.1'", ")", ":", "try", ":", "context", "=", "zmq", ".", "Context", "(", ")", "socket", "=", "context", ".", "socket", "(", "zmq", ".", "PUSH", ")", "socket", ".", "co...
A shim that sets up a socket and starts the producer callable. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. port : int The port on which the socket should connect. addr : str, optional ...
[ "A", "shim", "that", "sets", "up", "a", "socket", "and", "starts", "the", "producer", "callable", "." ]
python
train
30.347826
saltstack/salt
salt/cloud/clouds/gce.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L1231-L1286
def create_address(kwargs=None, call=None): ''' Create a static address in a region. CLI Example: .. code-block:: bash salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP ''' if call != 'function': raise SaltCloudSystemExit( 'The create_addres...
[ "def", "create_address", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The create_address function must be called with -f or --function.'", ")", "if", "not", "kwargs", "o...
Create a static address in a region. CLI Example: .. code-block:: bash salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP
[ "Create", "a", "static", "address", "in", "a", "region", "." ]
python
train
26.285714
sentinel-hub/eo-learn
io/eolearn/io/sentinelhub_service.py
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/io/eolearn/io/sentinelhub_service.py#L104-L128
def _prepare_request_data(self, eopatch, bbox, time_interval): """ Collects all parameters used for DataRequest, each one is taken either from initialization parameters or from EOPatch """ service_type = ServiceType(self._get_parameter('service_type', eopatch)) if time_interval ...
[ "def", "_prepare_request_data", "(", "self", ",", "eopatch", ",", "bbox", ",", "time_interval", ")", ":", "service_type", "=", "ServiceType", "(", "self", ".", "_get_parameter", "(", "'service_type'", ",", "eopatch", ")", ")", "if", "time_interval", "is", "Non...
Collects all parameters used for DataRequest, each one is taken either from initialization parameters or from EOPatch
[ "Collects", "all", "parameters", "used", "for", "DataRequest", "each", "one", "is", "taken", "either", "from", "initialization", "parameters", "or", "from", "EOPatch" ]
python
train
48.28
Riffstation/flask-philo
flask_philo/db/redis/connection.py
https://github.com/Riffstation/flask-philo/blob/76c9d562edb4a77010c8da6dfdb6489fa29cbc9e/flask_philo/db/redis/connection.py#L62-L71
def init_db_conn( connection_name, HOST=None, PORT=None, DB=None, PASSWORD=None): """ Initialize a redis connection by each connection string defined in the configuration file """ rpool = redis.ConnectionPool( host=HOST, port=PORT, db=DB, password=PASSWORD) r = redis.Redis(connec...
[ "def", "init_db_conn", "(", "connection_name", ",", "HOST", "=", "None", ",", "PORT", "=", "None", ",", "DB", "=", "None", ",", "PASSWORD", "=", "None", ")", ":", "rpool", "=", "redis", ".", "ConnectionPool", "(", "host", "=", "HOST", ",", "port", "=...
Initialize a redis connection by each connection string defined in the configuration file
[ "Initialize", "a", "redis", "connection", "by", "each", "connection", "string", "defined", "in", "the", "configuration", "file" ]
python
train
38.8
python-bugzilla/python-bugzilla
bugzilla/base.py
https://github.com/python-bugzilla/python-bugzilla/blob/7de8b225104f24a1eee3e837bf1e02d60aefe69f/bugzilla/base.py#L429-L504
def readconfig(self, configpath=None): """ :param configpath: Optional bugzillarc path to read, instead of the default list. This function is called automatically from Bugzilla connect(), which is called at __init__ if a URL is passed. Calling it manually is just for...
[ "def", "readconfig", "(", "self", ",", "configpath", "=", "None", ")", ":", "cfg", "=", "_open_bugzillarc", "(", "configpath", "or", "self", ".", "configpath", ")", "if", "not", "cfg", ":", "return", "section", "=", "\"\"", "log", ".", "debug", "(", "\...
:param configpath: Optional bugzillarc path to read, instead of the default list. This function is called automatically from Bugzilla connect(), which is called at __init__ if a URL is passed. Calling it manually is just for passing in a non-standard configpath. The locatio...
[ ":", "param", "configpath", ":", "Optional", "bugzillarc", "path", "to", "read", "instead", "of", "the", "default", "list", "." ]
python
train
36.210526
jochym/Elastic
parcalc/parcalc.py
https://github.com/jochym/Elastic/blob/8daae37d0c48aab8dfb1de2839dab02314817f95/parcalc/parcalc.py#L394-L404
def write_input(self, atoms=None, properties=['energy'], system_changes=all_changes): '''Write input file(s).''' with work_dir(self.directory): self.calc.write_input(self, atoms, properties, system_changes) self.write_pbs_in(properties) subprocess.call(self.copy_out_c...
[ "def", "write_input", "(", "self", ",", "atoms", "=", "None", ",", "properties", "=", "[", "'energy'", "]", ",", "system_changes", "=", "all_changes", ")", ":", "with", "work_dir", "(", "self", ".", "directory", ")", ":", "self", ".", "calc", ".", "wri...
Write input file(s).
[ "Write", "input", "file", "(", "s", ")", "." ]
python
train
55.363636
gem/oq-engine
openquake/baselib/slots.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/slots.py#L23-L58
def with_slots(cls): """ Decorator for a class with _slots_. It automatically defines the methods __eq__, __ne__, assert_equal. """ def _compare(self, other): for slot in self.__class__._slots_: attr = operator.attrgetter(slot) source = attr(self) target =...
[ "def", "with_slots", "(", "cls", ")", ":", "def", "_compare", "(", "self", ",", "other", ")", ":", "for", "slot", "in", "self", ".", "__class__", ".", "_slots_", ":", "attr", "=", "operator", ".", "attrgetter", "(", "slot", ")", "source", "=", "attr"...
Decorator for a class with _slots_. It automatically defines the methods __eq__, __ne__, assert_equal.
[ "Decorator", "for", "a", "class", "with", "_slots_", ".", "It", "automatically", "defines", "the", "methods", "__eq__", "__ne__", "assert_equal", "." ]
python
train
34.527778
Titan-C/slaveparticles
slaveparticles/spins.py
https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/spins.py#L25-L32
def fermion_avg(efermi, norm_hopping, func): """calcules for every slave it's average over the desired observable""" if func == 'ekin': func = bethe_ekin_zeroT elif func == 'ocupation': func = bethe_filling_zeroT return np.asarray([func(ef, tz) for ef, tz in zip(efermi, norm_hopping)])
[ "def", "fermion_avg", "(", "efermi", ",", "norm_hopping", ",", "func", ")", ":", "if", "func", "==", "'ekin'", ":", "func", "=", "bethe_ekin_zeroT", "elif", "func", "==", "'ocupation'", ":", "func", "=", "bethe_filling_zeroT", "return", "np", ".", "asarray",...
calcules for every slave it's average over the desired observable
[ "calcules", "for", "every", "slave", "it", "s", "average", "over", "the", "desired", "observable" ]
python
train
39
wbond/vat_moss-python
vat_moss/billing_address.py
https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/billing_address.py#L17-L104
def calculate_rate(country_code, postal_code, city): """ Calculates the VAT rate that should be collected based on address information provided :param country_code: The two-character country code :param postal_code: The postal code for the user :param city: The city na...
[ "def", "calculate_rate", "(", "country_code", ",", "postal_code", ",", "city", ")", ":", "if", "not", "country_code", "or", "not", "isinstance", "(", "country_code", ",", "str_cls", ")", ":", "raise", "ValueError", "(", "'Invalidly formatted country code'", ")", ...
Calculates the VAT rate that should be collected based on address information provided :param country_code: The two-character country code :param postal_code: The postal code for the user :param city: The city name for the user :raises: ValueError - If country cod...
[ "Calculates", "the", "VAT", "rate", "that", "should", "be", "collected", "based", "on", "address", "information", "provided" ]
python
train
33.897727
refenv/cijoe
deprecated/modules/cij/struct/chunk_info.py
https://github.com/refenv/cijoe/blob/21d7b2ed4ff68e0a1457e7df2db27f6334f1a379/deprecated/modules/cij/struct/chunk_info.py#L53-L64
def get_sizeof_descriptor_table(version="Denali"): """ Get sizeof DescriptorTable """ if version == "Denali": return sizeof(DescriptorTableDenali) elif version == "Spec20": return sizeof(DescriptorTableSpec20) elif version == "Spec12": return 0 else: ...
[ "def", "get_sizeof_descriptor_table", "(", "version", "=", "\"Denali\"", ")", ":", "if", "version", "==", "\"Denali\"", ":", "return", "sizeof", "(", "DescriptorTableDenali", ")", "elif", "version", "==", "\"Spec20\"", ":", "return", "sizeof", "(", "DescriptorTabl...
Get sizeof DescriptorTable
[ "Get", "sizeof", "DescriptorTable" ]
python
valid
28.916667
log2timeline/dfvfs
dfvfs/lib/sqlite_database.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/lib/sqlite_database.py#L136-L170
def HasTable(self, table_name): """Determines if a specific table exists. Args: table_name (str): name of the table. Returns: bool: True if the column exists. Raises: IOError: if the database file is not opened. OSError: if the database file is not opened. """ if not s...
[ "def", "HasTable", "(", "self", ",", "table_name", ")", ":", "if", "not", "self", ".", "_connection", ":", "raise", "IOError", "(", "'Not opened.'", ")", "if", "not", "table_name", ":", "return", "False", "if", "self", ".", "_table_names", "is", "None", ...
Determines if a specific table exists. Args: table_name (str): name of the table. Returns: bool: True if the column exists. Raises: IOError: if the database file is not opened. OSError: if the database file is not opened.
[ "Determines", "if", "a", "specific", "table", "exists", "." ]
python
train
24.4
rootpy/rootpy
rootpy/plotting/base.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/base.py#L252-L261
def SetLineColor(self, color): """ *color* may be any color understood by ROOT or matplotlib. For full documentation of accepted *color* arguments, see :class:`rootpy.plotting.style.Color`. """ self._linecolor = Color(color) if isinstance(self, ROOT.TAttLine): ...
[ "def", "SetLineColor", "(", "self", ",", "color", ")", ":", "self", ".", "_linecolor", "=", "Color", "(", "color", ")", "if", "isinstance", "(", "self", ",", "ROOT", ".", "TAttLine", ")", ":", "ROOT", ".", "TAttLine", ".", "SetLineColor", "(", "self", ...
*color* may be any color understood by ROOT or matplotlib. For full documentation of accepted *color* arguments, see :class:`rootpy.plotting.style.Color`.
[ "*", "color", "*", "may", "be", "any", "color", "understood", "by", "ROOT", "or", "matplotlib", "." ]
python
train
37.8
KeplerGO/K2fov
K2fov/fields.py
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/fields.py#L15-L22
def _getCampaignDict(): """Returns a dictionary specifying the details of all campaigns.""" global _campaign_dict_cache if _campaign_dict_cache is None: # All pointing parameters and dates are stored in a JSON file fn = os.path.join(PACKAGEDIR, "data", "k2-campaign-parameters.json") ...
[ "def", "_getCampaignDict", "(", ")", ":", "global", "_campaign_dict_cache", "if", "_campaign_dict_cache", "is", "None", ":", "# All pointing parameters and dates are stored in a JSON file", "fn", "=", "os", ".", "path", ".", "join", "(", "PACKAGEDIR", ",", "\"data\"", ...
Returns a dictionary specifying the details of all campaigns.
[ "Returns", "a", "dictionary", "specifying", "the", "details", "of", "all", "campaigns", "." ]
python
train
48.375
jamieleshaw/lurklib
lurklib/channel.py
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L121-L137
def part(self, channel, reason=''): """ Part a channel. Required arguments: * channel - Channel to part. Optional arguments: * reason='' - Reason for parting. """ with self.lock: self.is_in_channel(channel) self.send('PART %s :%s' ...
[ "def", "part", "(", "self", ",", "channel", ",", "reason", "=", "''", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "is_in_channel", "(", "channel", ")", "self", ".", "send", "(", "'PART %s :%s'", "%", "(", "channel", ",", "reason", ")", ...
Part a channel. Required arguments: * channel - Channel to part. Optional arguments: * reason='' - Reason for parting.
[ "Part", "a", "channel", ".", "Required", "arguments", ":", "*", "channel", "-", "Channel", "to", "part", ".", "Optional", "arguments", ":", "*", "reason", "=", "-", "Reason", "for", "parting", "." ]
python
train
31.764706
SHTOOLS/SHTOOLS
pyshtools/shclasses/shcoeffsgrid.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shcoeffsgrid.py#L178-L252
def from_array(self, coeffs, normalization='4pi', csphase=1, lmax=None, copy=True): """ Initialize the class with spherical harmonic coefficients from an input array. Usage ----- x = SHCoeffs.from_array(array, [normalization, csphase, lmax, copy]) ...
[ "def", "from_array", "(", "self", ",", "coeffs", ",", "normalization", "=", "'4pi'", ",", "csphase", "=", "1", ",", "lmax", "=", "None", ",", "copy", "=", "True", ")", ":", "if", "_np", ".", "iscomplexobj", "(", "coeffs", ")", ":", "kind", "=", "'c...
Initialize the class with spherical harmonic coefficients from an input array. Usage ----- x = SHCoeffs.from_array(array, [normalization, csphase, lmax, copy]) Returns ------- x : SHCoeffs class instance. Parameters ---------- array : nd...
[ "Initialize", "the", "class", "with", "spherical", "harmonic", "coefficients", "from", "an", "input", "array", "." ]
python
train
39.413333
dade-ai/snipy
snipy/imageme.py
https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L74-L172
def _create_index_file( root_dir, location, image_files, dirs, force_no_processing=False): """ Create an index file in the given location, supplying known lists of present image files and subdirectories. @param {String} root_dir - The root directory of the entire crawl. Used to ascertain...
[ "def", "_create_index_file", "(", "root_dir", ",", "location", ",", "image_files", ",", "dirs", ",", "force_no_processing", "=", "False", ")", ":", "# Put together HTML as a list of the lines we'll want to include", "# Issue #2 exists to do this better than HTML in-code", "header...
Create an index file in the given location, supplying known lists of present image files and subdirectories. @param {String} root_dir - The root directory of the entire crawl. Used to ascertain whether the given location is the top level. @param {String} location - The current directory of the crawl...
[ "Create", "an", "index", "file", "in", "the", "given", "location", "supplying", "known", "lists", "of", "present", "image", "files", "and", "subdirectories", "." ]
python
valid
40.040404
proycon/clam
clam/clamservice.py
https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/clamservice.py#L1311-L1322
def reset(project, user): """Reset system, delete all output files and prepare for a new run""" d = Project.path(project, user) + "output" if os.path.isdir(d): shutil.rmtree(d) os.makedirs(d) else: raise flask.abort(404) if os.path.exists(Proje...
[ "def", "reset", "(", "project", ",", "user", ")", ":", "d", "=", "Project", ".", "path", "(", "project", ",", "user", ")", "+", "\"output\"", "if", "os", ".", "path", ".", "isdir", "(", "d", ")", ":", "shutil", ".", "rmtree", "(", "d", ")", "os...
Reset system, delete all output files and prepare for a new run
[ "Reset", "system", "delete", "all", "output", "files", "and", "prepare", "for", "a", "new", "run" ]
python
train
44.583333
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L75-L81
def define_parameters(**parameters): """Get a list of parameters to pass to AWS boto call.""" params = [] for key, value in parameters.items(): param = dict(ParameterKey=key, ParameterValue=value) params.append(param) return params
[ "def", "define_parameters", "(", "*", "*", "parameters", ")", ":", "params", "=", "[", "]", "for", "key", ",", "value", "in", "parameters", ".", "items", "(", ")", ":", "param", "=", "dict", "(", "ParameterKey", "=", "key", ",", "ParameterValue", "=", ...
Get a list of parameters to pass to AWS boto call.
[ "Get", "a", "list", "of", "parameters", "to", "pass", "to", "AWS", "boto", "call", "." ]
python
train
36.714286
a1ezzz/wasp-general
wasp_general/network/web/service.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L773-L786
def connect(self, pattern, presenter, **kwargs): """ Shortcut for self.route_map().connect() method. It is possible to pass presenter class instead of its name - in that case such class will be saved in presenter collection and it will be available in route matching. :param pattern: same as pattern in :meth:`....
[ "def", "connect", "(", "self", ",", "pattern", ",", "presenter", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "presenter", ",", "type", ")", "and", "issubclass", "(", "presenter", ",", "WWebPresenter", ")", "is", "True", ":", "self", "."...
Shortcut for self.route_map().connect() method. It is possible to pass presenter class instead of its name - in that case such class will be saved in presenter collection and it will be available in route matching. :param pattern: same as pattern in :meth:`.WWebRouteMap.connect` method :param presenter: presen...
[ "Shortcut", "for", "self", ".", "route_map", "()", ".", "connect", "()", "method", ".", "It", "is", "possible", "to", "pass", "presenter", "class", "instead", "of", "its", "name", "-", "in", "that", "case", "such", "class", "will", "be", "saved", "in", ...
python
train
51.071429
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/extensions_v1beta1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/extensions_v1beta1_api.py#L1631-L1658
def delete_namespaced_daemon_set(self, name, namespace, **kwargs): # noqa: E501 """delete_namespaced_daemon_set # noqa: E501 delete a DaemonSet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True ...
[ "def", "delete_namespaced_daemon_set", "(", "self", ",", "name", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "retu...
delete_namespaced_daemon_set # noqa: E501 delete a DaemonSet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_namespaced_daemon_set(name, namespace, async_req=True) >>...
[ "delete_namespaced_daemon_set", "#", "noqa", ":", "E501" ]
python
train
94.785714
yodle/docker-registry-client
docker_registry_client/_BaseClient.py
https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L73-L77
def search(self, q=''): """GET /v1/search""" if q: q = '?q=' + q return self._http_call('/v1/search' + q, get)
[ "def", "search", "(", "self", ",", "q", "=", "''", ")", ":", "if", "q", ":", "q", "=", "'?q='", "+", "q", "return", "self", ".", "_http_call", "(", "'/v1/search'", "+", "q", ",", "get", ")" ]
GET /v1/search
[ "GET", "/", "v1", "/", "search" ]
python
train
28.4
kgori/treeCl
treeCl/alignment.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/alignment.py#L418-L422
def sequences_to_string(self): """ Convert state indices to a string of characters """ return {k: ''.join(self.states[v]) for (k, v) in self.sequences.items()}
[ "def", "sequences_to_string", "(", "self", ")", ":", "return", "{", "k", ":", "''", ".", "join", "(", "self", ".", "states", "[", "v", "]", ")", "for", "(", "k", ",", "v", ")", "in", "self", ".", "sequences", ".", "items", "(", ")", "}" ]
Convert state indices to a string of characters
[ "Convert", "state", "indices", "to", "a", "string", "of", "characters" ]
python
train
37.4
opendatateam/udata
udata/theme/__init__.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/theme/__init__.py#L141-L148
def render(template, **context): ''' Render a template with uData frontend specifics * Theme ''' theme = current_app.config['THEME'] return render_theme_template(get_theme(theme), template, **context)
[ "def", "render", "(", "template", ",", "*", "*", "context", ")", ":", "theme", "=", "current_app", ".", "config", "[", "'THEME'", "]", "return", "render_theme_template", "(", "get_theme", "(", "theme", ")", ",", "template", ",", "*", "*", "context", ")" ...
Render a template with uData frontend specifics * Theme
[ "Render", "a", "template", "with", "uData", "frontend", "specifics" ]
python
train
27.75
JNRowe/upoints
upoints/edist.py
https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/edist.py#L544-L562
def main(): """Main script handler. Returns: int: 0 for success, >1 error code """ logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s') try: cli() return 0 except LocationsError as error: print(error) return 2 except RuntimeError as er...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "'%(asctime)s %(levelname)s:%(message)s'", ")", "try", ":", "cli", "(", ")", "return", "0", "except", "LocationsError", "as", "error", ":", "print", "(", "error", ")", "return",...
Main script handler. Returns: int: 0 for success, >1 error code
[ "Main", "script", "handler", "." ]
python
train
21.157895
tensorflow/tensorboard
tensorboard/plugins/audio/audio_demo.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/audio/audio_demo.py#L139-L143
def sine_wave(frequency): """Emit a sine wave at the given frequency.""" xs = tf.reshape(tf.range(_samples(), dtype=tf.float32), [1, _samples(), 1]) ts = xs / FLAGS.sample_rate return tf.sin(2 * math.pi * frequency * ts)
[ "def", "sine_wave", "(", "frequency", ")", ":", "xs", "=", "tf", ".", "reshape", "(", "tf", ".", "range", "(", "_samples", "(", ")", ",", "dtype", "=", "tf", ".", "float32", ")", ",", "[", "1", ",", "_samples", "(", ")", ",", "1", "]", ")", "...
Emit a sine wave at the given frequency.
[ "Emit", "a", "sine", "wave", "at", "the", "given", "frequency", "." ]
python
train
44.8
silver-castle/mach9
mach9/app.py
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L248-L263
def blueprint(self, blueprint, **options): '''Register a blueprint on the application. :param blueprint: Blueprint object :param options: option dictionary with blueprint defaults :return: Nothing ''' if blueprint.name in self.blueprints: assert self.blueprin...
[ "def", "blueprint", "(", "self", ",", "blueprint", ",", "*", "*", "options", ")", ":", "if", "blueprint", ".", "name", "in", "self", ".", "blueprints", ":", "assert", "self", ".", "blueprints", "[", "blueprint", ".", "name", "]", "is", "blueprint", ","...
Register a blueprint on the application. :param blueprint: Blueprint object :param options: option dictionary with blueprint defaults :return: Nothing
[ "Register", "a", "blueprint", "on", "the", "application", "." ]
python
train
41.6875
zerotk/easyfs
zerotk/easyfs/_easyfs.py
https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1519-L1542
def ReadLink(path): ''' Read the target of the symbolic link at `path`. :param unicode path: Path to a symbolic link :returns unicode: Target of a symbolic link ''' _AssertIsLocal(path) if sys.platform != 'win32': return os.readlink(path) # @UndefinedVariable ...
[ "def", "ReadLink", "(", "path", ")", ":", "_AssertIsLocal", "(", "path", ")", "if", "sys", ".", "platform", "!=", "'win32'", ":", "return", "os", ".", "readlink", "(", "path", ")", "# @UndefinedVariable", "if", "not", "IsLink", "(", "path", ")", ":", "...
Read the target of the symbolic link at `path`. :param unicode path: Path to a symbolic link :returns unicode: Target of a symbolic link
[ "Read", "the", "target", "of", "the", "symbolic", "link", "at", "path", "." ]
python
valid
24.458333
h2oai/datatable
setup.py
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/setup.py#L61-L76
def get_c_sources(folder, include_headers=False): """Find all C/C++ source files in the `folder` directory.""" allowed_extensions = [".c", ".C", ".cc", ".cpp", ".cxx", ".c++"] if include_headers: allowed_extensions += [".h", ".hpp"] sources = [] for root, _, files in os.walk(folder): ...
[ "def", "get_c_sources", "(", "folder", ",", "include_headers", "=", "False", ")", ":", "allowed_extensions", "=", "[", "\".c\"", ",", "\".C\"", ",", "\".cc\"", ",", "\".cpp\"", ",", "\".cxx\"", ",", "\".c++\"", "]", "if", "include_headers", ":", "allowed_exten...
Find all C/C++ source files in the `folder` directory.
[ "Find", "all", "C", "/", "C", "++", "source", "files", "in", "the", "folder", "directory", "." ]
python
train
44
saltstack/salt
salt/grains/core.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/core.py#L262-L290
def _netbsd_gpu_data(): ''' num_gpus: int gpus: - vendor: nvidia|amd|ati|... model: string ''' known_vendors = ['nvidia', 'amd', 'ati', 'intel', 'cirrus logic', 'vmware', 'matrox', 'aspeed'] gpus = [] try: pcictl_out = __salt__['cmd.run']('pcictl pci0 list') f...
[ "def", "_netbsd_gpu_data", "(", ")", ":", "known_vendors", "=", "[", "'nvidia'", ",", "'amd'", ",", "'ati'", ",", "'intel'", ",", "'cirrus logic'", ",", "'vmware'", ",", "'matrox'", ",", "'aspeed'", "]", "gpus", "=", "[", "]", "try", ":", "pcictl_out", "...
num_gpus: int gpus: - vendor: nvidia|amd|ati|... model: string
[ "num_gpus", ":", "int", "gpus", ":", "-", "vendor", ":", "nvidia|amd|ati|", "...", "model", ":", "string" ]
python
train
28.172414
pytroll/satpy
satpy/resample.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/resample.py#L466-L476
def resample(self, *args, **kwargs): """Run precompute and compute methods. .. note:: This sets the default of 'mask_area' to False since it is not needed in EWA resampling currently. """ kwargs.setdefault('mask_area', False) return super(EWAResampler, ...
[ "def", "resample", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'mask_area'", ",", "False", ")", "return", "super", "(", "EWAResampler", ",", "self", ")", ".", "resample", "(", "*", "args", ",",...
Run precompute and compute methods. .. note:: This sets the default of 'mask_area' to False since it is not needed in EWA resampling currently.
[ "Run", "precompute", "and", "compute", "methods", "." ]
python
train
31
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8535-L8544
def rosen_nesterov(self, x, rho=100): """needs exponential number of steps in a non-increasing f-sequence. x_0 = (-1,1,...,1) See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function" """ f = 0.25 * (x[0] - 1)**2 f += rho * sum((x[1:] - 2 * x[:-1]**2 + 1)**2...
[ "def", "rosen_nesterov", "(", "self", ",", "x", ",", "rho", "=", "100", ")", ":", "f", "=", "0.25", "*", "(", "x", "[", "0", "]", "-", "1", ")", "**", "2", "f", "+=", "rho", "*", "sum", "(", "(", "x", "[", "1", ":", "]", "-", "2", "*", ...
needs exponential number of steps in a non-increasing f-sequence. x_0 = (-1,1,...,1) See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function"
[ "needs", "exponential", "number", "of", "steps", "in", "a", "non", "-", "increasing", "f", "-", "sequence", "." ]
python
train
32.9
apache/airflow
airflow/hooks/webhdfs_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/webhdfs_hook.py#L56-L79
def get_conn(self): """ Establishes a connection depending on the security mode set via config or environment variable. :return: a hdfscli InsecureClient or KerberosClient object. :rtype: hdfs.InsecureClient or hdfs.ext.kerberos.KerberosClient """ connections = self.get_...
[ "def", "get_conn", "(", "self", ")", ":", "connections", "=", "self", ".", "get_connections", "(", "self", ".", "webhdfs_conn_id", ")", "for", "connection", "in", "connections", ":", "try", ":", "self", ".", "log", ".", "debug", "(", "'Trying namenode %s'", ...
Establishes a connection depending on the security mode set via config or environment variable. :return: a hdfscli InsecureClient or KerberosClient object. :rtype: hdfs.InsecureClient or hdfs.ext.kerberos.KerberosClient
[ "Establishes", "a", "connection", "depending", "on", "the", "security", "mode", "set", "via", "config", "or", "environment", "variable", "." ]
python
test
45.5
serkanyersen/underscore.py
src/underscore.py
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L653-L661
def difference(self, *args): """ Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain. """ setobj = set(self.obj) for i, v in enumerate(args): setobj = setobj - set(args[i]) r...
[ "def", "difference", "(", "self", ",", "*", "args", ")", ":", "setobj", "=", "set", "(", "self", ".", "obj", ")", "for", "i", ",", "v", "in", "enumerate", "(", "args", ")", ":", "setobj", "=", "setobj", "-", "set", "(", "args", "[", "i", "]", ...
Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain.
[ "Take", "the", "difference", "between", "one", "array", "and", "a", "number", "of", "other", "arrays", ".", "Only", "the", "elements", "present", "in", "just", "the", "first", "array", "will", "remain", "." ]
python
train
40.111111
michaelpb/omnic
omnic/conversion/graph.py
https://github.com/michaelpb/omnic/blob/1111cfd73c9dc1955afe42d9cf2a468c46f83cd6/omnic/conversion/graph.py#L106-L146
def find_path(self, in_, out): ''' Given an input and output TypeString, produce a graph traversal, keeping in mind special options like Conversion Profiles, Preferred Paths, and Direct Conversions. ''' if in_.arguments: raise ValueError('Cannot originate path...
[ "def", "find_path", "(", "self", ",", "in_", ",", "out", ")", ":", "if", "in_", ".", "arguments", ":", "raise", "ValueError", "(", "'Cannot originate path in argumented TypeString'", ")", "# Determine conversion profile. This is either simply the output, OR,", "# if a custo...
Given an input and output TypeString, produce a graph traversal, keeping in mind special options like Conversion Profiles, Preferred Paths, and Direct Conversions.
[ "Given", "an", "input", "and", "output", "TypeString", "produce", "a", "graph", "traversal", "keeping", "in", "mind", "special", "options", "like", "Conversion", "Profiles", "Preferred", "Paths", "and", "Direct", "Conversions", "." ]
python
train
45.804878
internetarchive/brozzler
brozzler/__init__.py
https://github.com/internetarchive/brozzler/blob/411b3f266a38b9bb942021c0121ebd8e5ca66447/brozzler/__init__.py#L112-L131
def behavior_script(url, template_parameters=None, behaviors_dir=None): ''' Returns the javascript behavior string populated with template_parameters. ''' import re, logging, json for behavior in behaviors(behaviors_dir=behaviors_dir): if re.match(behavior['url_regex'], url): par...
[ "def", "behavior_script", "(", "url", ",", "template_parameters", "=", "None", ",", "behaviors_dir", "=", "None", ")", ":", "import", "re", ",", "logging", ",", "json", "for", "behavior", "in", "behaviors", "(", "behaviors_dir", "=", "behaviors_dir", ")", ":...
Returns the javascript behavior string populated with template_parameters.
[ "Returns", "the", "javascript", "behavior", "string", "populated", "with", "template_parameters", "." ]
python
train
46.25
soundcloud/soundcloud-python
soundcloud/hashconversions.py
https://github.com/soundcloud/soundcloud-python/blob/d77f6e5a7ce4852244e653cb67bb20a8a5f04849/soundcloud/hashconversions.py#L16-L67
def normalize_param(key, value): """Convert a set of key, value parameters into a dictionary suitable for passing into requests. This will convert lists into the syntax required by SoundCloud. Heavily lifted from HTTParty. >>> normalize_param('playlist', { ... 'title': 'foo', ... 'sharing': '...
[ "def", "normalize_param", "(", "key", ",", "value", ")", ":", "params", "=", "{", "}", "stack", "=", "[", "]", "if", "isinstance", "(", "value", ",", "list", ")", ":", "normalized", "=", "[", "normalize_param", "(", "u\"{0[key]}[]\"", ".", "format", "(...
Convert a set of key, value parameters into a dictionary suitable for passing into requests. This will convert lists into the syntax required by SoundCloud. Heavily lifted from HTTParty. >>> normalize_param('playlist', { ... 'title': 'foo', ... 'sharing': 'private', ... 'tracks': [ ... ...
[ "Convert", "a", "set", "of", "key", "value", "parameters", "into", "a", "dictionary", "suitable", "for", "passing", "into", "requests", ".", "This", "will", "convert", "lists", "into", "the", "syntax", "required", "by", "SoundCloud", ".", "Heavily", "lifted", ...
python
train
36.538462
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxworkflow.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxworkflow.py#L245-L255
def get_stage(self, stage, **kwargs): ''' :param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID :type stage: int or string :returns: Hash of stage descriptor in workflow ''' stage_id = self._get_stage_...
[ "def", "get_stage", "(", "self", ",", "stage", ",", "*", "*", "kwargs", ")", ":", "stage_id", "=", "self", ".", "_get_stage_id", "(", "stage", ")", "result", "=", "next", "(", "(", "stage", "for", "stage", "in", "self", ".", "stages", "if", "stage", ...
:param stage: A number for the stage index (for the nth stage, starting from 0), or a string of the stage index, name, or ID :type stage: int or string :returns: Hash of stage descriptor in workflow
[ ":", "param", "stage", ":", "A", "number", "for", "the", "stage", "index", "(", "for", "the", "nth", "stage", "starting", "from", "0", ")", "or", "a", "string", "of", "the", "stage", "index", "name", "or", "ID", ":", "type", "stage", ":", "int", "o...
python
train
48.636364
pip-services3-python/pip-services3-commons-python
pip_services3_commons/commands/CommandSet.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/commands/CommandSet.py#L227-L253
def validate(self, command, args): """ Validates Parameters args for command specified by its name using defined schema. If validation schema is not defined than the methods returns no errors. It returns validation error if the command is not found. :param command: the n...
[ "def", "validate", "(", "self", ",", "command", ",", "args", ")", ":", "cref", "=", "self", ".", "find_command", "(", "command", ")", "if", "cref", "==", "None", ":", "results", "=", "[", "]", "results", ".", "append", "(", "ValidationResult", "(", "...
Validates Parameters args for command specified by its name using defined schema. If validation schema is not defined than the methods returns no errors. It returns validation error if the command is not found. :param command: the name of the command for which the 'args' must be validat...
[ "Validates", "Parameters", "args", "for", "command", "specified", "by", "its", "name", "using", "defined", "schema", ".", "If", "validation", "schema", "is", "not", "defined", "than", "the", "methods", "returns", "no", "errors", ".", "It", "returns", "validati...
python
train
39.925926
apache/airflow
airflow/contrib/operators/jenkins_job_trigger_operator.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/jenkins_job_trigger_operator.py#L149-L183
def poll_job_in_queue(self, location, jenkins_server): """ This method poll the jenkins queue until the job is executed. When we trigger a job through an API call, the job is first put in the queue without having a build number assigned. Thus we have to wait the job exit the queu...
[ "def", "poll_job_in_queue", "(", "self", ",", "location", ",", "jenkins_server", ")", ":", "try_count", "=", "0", "location", "=", "location", "+", "'/api/json'", "# TODO Use get_queue_info instead", "# once it will be available in python-jenkins (v > 0.4.15)", "self", ".",...
This method poll the jenkins queue until the job is executed. When we trigger a job through an API call, the job is first put in the queue without having a build number assigned. Thus we have to wait the job exit the queue to know its build number. To do so, we have to add /api/json (or ...
[ "This", "method", "poll", "the", "jenkins", "queue", "until", "the", "job", "is", "executed", ".", "When", "we", "trigger", "a", "job", "through", "an", "API", "call", "the", "job", "is", "first", "put", "in", "the", "queue", "without", "having", "a", ...
python
test
55.914286
vlukes/dicom2fem
dicom2fem/ioutils.py
https://github.com/vlukes/dicom2fem/blob/3056c977ca7119e01984d3aa0c4448a1c6c2430f/dicom2fem/ioutils.py#L97-L123
def get_print_info(n_step, fill=None): """ Returns the max. number of digits in range(n_step) and the corresponding format string. Examples: >>> get_print_info(11) (2, '%2d') >>> get_print_info(8) (1, '%1d') >>> get_print_info(100) (2, '%2d') >>> get_print_info(101) (3,...
[ "def", "get_print_info", "(", "n_step", ",", "fill", "=", "None", ")", ":", "if", "n_step", ">", "1", ":", "n_digit", "=", "int", "(", "nm", ".", "log10", "(", "n_step", "-", "1", ")", "+", "1", ")", "if", "fill", "is", "None", ":", "format", "...
Returns the max. number of digits in range(n_step) and the corresponding format string. Examples: >>> get_print_info(11) (2, '%2d') >>> get_print_info(8) (1, '%1d') >>> get_print_info(100) (2, '%2d') >>> get_print_info(101) (3, '%3d') >>> get_print_info(101, fill='0') (...
[ "Returns", "the", "max", ".", "number", "of", "digits", "in", "range", "(", "n_step", ")", "and", "the", "corresponding", "format", "string", "." ]
python
train
23.259259