code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def abort(message, *args):
if args:
raise _AbortException(message.format(*args))
raise _AbortException(message) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'abort'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'messag... | Raise an AbortException, halting task execution and exiting. |
def _get_gid(name):
if getgrnam is None or name is None:
return None
try:
result = getgrnam(name)
except KeyError:
result = None
if result is not None:
return result[2]
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_gid'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; ... | Returns a gid, given a group name. |
def map_to_precursor_biopython(seqs, names, loci, args):
precursor = precursor_sequence(loci, args.ref).upper()
dat = dict()
for s, n in itertools.izip(seqs, names):
res = _align(str(s), precursor)
if res:
dat[n] = res
logger.debug("mapped in %s: %s out of %s" % (loci, len(da... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_to_precursor_biopython'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', '... | map the sequences using biopython package |
def get(self):
namespaces = db.ConfigNamespace.order_by(
ConfigNamespace.sort_order,
ConfigNamespace.name
).all()
return self.make_response({
'message': None,
'namespaces': namespaces
}, HTTP.OK) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | List existing config namespaces and their items |
def create_index(group, chunk_size, compression=None, compression_opts=None):
dtype = np.int64
if chunk_size == 'auto':
chunks = True
else:
chunks = (nb_per_chunk(np.dtype(dtype).itemsize, 1, chunk_size),)
group.create_dataset(
'index', (0,), dtype=dtype,
chunks=chunks, m... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': []... | Create an empty index dataset in the given group. |
def _notification_callback(method, params):
def callback(future):
try:
future.result()
log.debug("Successfully handled async notification %s %s", method, params)
except Exception:
log.exception("Failed to handle async notification %s %s", m... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_notification_callback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | Construct a notification callback for the given request ID. |
def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement]) -> bool:
with self.sigint_protection:
if not sys.platform.startswith('win') and self.stdout.isatty():
import subprocess
proc = subprocess.Popen(['stty', 'sane'])
proc.comm... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_run_cmdfinalization_hooks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier',... | Run the command finalization hooks |
def _distance_matrix_generic(x, centering, exponent=1):
_check_valid_dcov_exponent(exponent)
x = _transform_to_2d(x)
a = distances.pairwise_distances(x, exponent=exponent)
a = centering(a, out=a)
return a | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_distance_matrix_generic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre... | Compute a centered distance matrix given a matrix. |
def ensure_default_namespace(self) -> Namespace:
namespace = self.get_namespace_by_keyword_version(BEL_DEFAULT_NAMESPACE, BEL_DEFAULT_NAMESPACE_VERSION)
if namespace is None:
namespace = Namespace(
name='BEL Default Namespace',
contact='charles.hoyt@scai.fraun... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ensure_default_namespace'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [... | Get or create the BEL default namespace. |
def deprecated(message=None):
def _decorator(func, message=message):
if message is None:
message = '%s is deprecated' % func.__name__
def newfunc(*args, **kwds):
warnings.warn(message, DeprecationWarning, stacklevel=2)
return func(*args, **kwds)
return new... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deprecated'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; ... | A decorator for deprecated functions |
def assign_perm(perm, group):
if not isinstance(perm, Permission):
try:
app_label, codename = perm.split('.', 1)
except ValueError:
raise ValueError("For global permissions, first argument must be in"
" format: 'app_label.codename' (is %r)" % perm... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assign_perm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Assigns a permission to a group |
def regular_subset(spikes, n_spikes_max=None, offset=0):
assert spikes is not None
if n_spikes_max is None or len(spikes) <= n_spikes_max:
return spikes
step = math.ceil(np.clip(1. / n_spikes_max * len(spikes),
1, len(spikes)))
step = int(step)
my_spikes = spikes... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'regular_subset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Prune the current selection to get at most n_spikes_max spikes. |
def do_edit(self, line):
self._split_args(line, 0, 0)
self._command_processor.get_operation_queue().edit()
self._print_info_if_verbose("The write operation queue was successfully edited") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_edit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | edit Edit the queue of write operations. |
def _calc_size_stats(self):
self.total_records = 0
self.total_length = 0
self.total_nodes = 0
if type(self.content['data']) is dict:
self.total_length += len(str(self.content['data']))
self.total_records += 1
self.total_nodes = sum(len(x) for x in self... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_calc_size_stats'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | get the size in bytes and num records of the content |
def _loadChildRules(context, xmlElement, attributeToFormatMap):
rules = []
for ruleElement in xmlElement.getchildren():
if not ruleElement.tag in _ruleClassDict:
raise ValueError("Not supported rule '%s'" % ruleElement.tag)
rule = _ruleClassDict[ruleElement.tag](context, ruleElement,... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_loadChildRules'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Extract rules from Context or Rule xml element |
def _get_request_fields_from_parent(self):
if not self.parent:
return None
if not getattr(self.parent, 'request_fields'):
return None
if not isinstance(self.parent.request_fields, dict):
return None
return self.parent.request_fields.get(self.field_name... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_request_fields_from_parent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':... | Get request fields from the parent serializer. |
def save(self, commit=True, **kwargs):
if self.post:
for form in self.forms:
form.instance.post = self.post
super().save(commit) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Saves the considered instances. |
def detach_model(vmssvm_model, lun):
data_disks = vmssvm_model['properties']['storageProfile']['dataDisks']
data_disks[:] = [disk for disk in data_disks if disk.get('lun') != lun]
vmssvm_model['properties']['storageProfile']['dataDisks'] = data_disks
return vmssvm_model | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'detach_model'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Detach a data disk from a VMSS VM model |
def list_lbaas_l7rules(self, l7policy, retrieve_all=True, **_params):
return self.list('rules', self.lbaas_l7rules_path % l7policy,
retrieve_all, **_params) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_lbaas_l7rules'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childre... | Fetches a list of all rules for L7 policy. |
def list_webhooks(self, scaling_group, policy):
uri = "/%s/%s/policies/%s/webhooks" % (self.uri_base,
utils.get_id(scaling_group), utils.get_id(policy))
resp, resp_body = self.api.method_get(uri)
return [AutoScaleWebhook(self, data, policy, scaling_group)
for data... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_webhooks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Returns a list of all webhooks for the specified policy. |
def _finalize_cwl_in(data, work_dir, passed_keys, output_cwl_keys, runtime):
data["dirs"] = {"work": work_dir}
if not tz.get_in(["config", "algorithm"], data):
if "config" not in data:
data["config"] = {}
data["config"]["algorithm"] = {}
if "rgnames" not in data and "description"... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_finalize_cwl_in'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'child... | Finalize data object with inputs from CWL. |
def package_name(self, PACKAGES_TXT):
packages = []
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
packages.append(split_package(line[14:].strip())[0])
return packages | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'package_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Returns list with all the names of packages repository |
def create_directory(self, filename):
path = os.path.join(self.path, filename)
makedirs(path)
return path | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_directory'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Create a subdirectory in the temporary directory. |
def render_filefield(field, attrs):
field.field.widget.attrs["style"] = "display:none"
if not "_no_label" in attrs:
attrs["_no_label"] = True
return wrappers.FILE_WRAPPER % {
"field": field,
"id": "id_" + field.name,
"style": pad(attrs.get("_style", "")),
"text": escape(attrs.get("_text", "Select File")),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_filefield'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Render a typical File Field. |
def render_word(self,word,size,color):
pygame.font.init()
font = pygame.font.Font(None,size)
self.rendered_word = font.render(word,0,color)
self.word_size = font.size(word) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_word'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Creates a surface that contains a word. |
def fmtval(value, colorstr=None, precision=None, spacing=True, trunc=True,
end=' '):
colwidth = opts.colwidth
if precision is None:
precision = opts.precision
fmt = '%%.%sf' % precision
result = locale.format(fmt, value, True)
if spacing:
result = '%%%ss' % colwidth % resu... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fmtval'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'childr... | Formats and returns a given number according to specifications. |
def _add_link(self, edge):
edge_data = self.data['probnet']['edges'][edge]
if isinstance(edge, six.string_types):
edge = eval(edge)
link = etree.SubElement(self.links, 'Link', attrib={'var1': edge[0], 'var2': edge[1],
'direc... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_link'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Adds an edge to the ProbModelXML. |
def dump_children(self, f, indent=''):
for child in self.__order:
child.dump(f, indent+' ') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump_children'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Dump the children of the current section to a file-like object |
def calculate_gru_output_shapes(operator):
check_input_and_output_numbers(operator, input_count_range=[1, 2], output_count_range=[1, 2])
check_input_and_output_types(operator, good_input_types=[FloatTensorType])
input_shape = operator.inputs[0].type.shape
if len(input_shape) not in [2, 4]:
raise... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_gru_output_shapes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],... | See GRU's conversion function for its output shapes. |
def _log_multivariate_normal_density_full(X, means, covars, min_covar=1.e-7):
n_samples, n_dim = X.shape
nmix = len(means)
log_prob = np.empty((n_samples, nmix))
for c, (mu, cv) in enumerate(zip(means, covars)):
try:
cv_chol = linalg.cholesky(cv, lower=True)
except linalg.Lin... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_log_multivariate_normal_density_full'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'id... | Log probability for full covariance matrices. |
def _to_json_type(obj, classkey=None):
if isinstance(obj, dict):
data = {}
for (k, v) in obj.items():
data[k] = _to_json_type(v, classkey)
return data
elif hasattr(obj, "_ast"):
return _to_json_type(obj._ast())
elif hasattr(obj, "__iter__"):
return [_to_js... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_to_json_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Recursively convert the object instance into a valid JSON type. |
def compute_bbox_with_margins(margin, x, y):
'Helper function to compute bounding box for the plot'
pos = np.asarray((x, y))
minxy, maxxy = pos.min(axis=1), pos.max(axis=1)
xy1 = minxy - margin*(maxxy - minxy)
xy2 = maxxy + margin*(maxxy - minxy)
return tuple(xy1), tuple(xy2) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_bbox_with_margins'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr... | Helper function to compute bounding box for the plot |
def _plot(self):
r_max = min(
self.view.x(1) - self.view.x(0),
(self.view.y(0) or 0) - self.view.y(1)
) / (2 * 1.05)
for serie in self.series:
self.dot(serie, r_max) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_plot'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Plot all dots for series |
def run_tornado(self, args):
server = self
import tornado.ioloop
import tornado.web
import tornado.websocket
ioloop = tornado.ioloop.IOLoop.current()
class DevWebSocketHandler(tornado.websocket.WebSocketHandler):
def open(self):
super(DevWebSoc... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_tornado'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Tornado dev server implementation |
def einsum_sequence(self, other_arrays, einsum_string=None):
if not isinstance(other_arrays, list):
raise ValueError("other tensors must be list of "
"tensors or tensor input")
other_arrays = [np.array(a) for a in other_arrays]
if not einsum_string:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'einsum_sequence'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Calculates the result of an einstein summation expression |
def exec_notebook_daemon_command(self, name, cmd, port=0):
cmd = self.get_notebook_daemon_command(name, cmd, port)
cmd = [str(arg) for arg in cmd]
logger.info("Running notebook command: %s", " ".join(cmd))
env = os.environ.copy()
env["PYTHONFAULTHANDLER"] = "true"
p = sub... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exec_notebook_daemon_command'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier'... | Run a daemon script command. |
def _make_value(self, value):
member = self.__new__(self, value)
member.__init__(value)
return member | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Instantiates an enum with an arbitrary value. |
def wait_condition_spec(self):
from harpoon.option_spec import image_objs
formatted_string = formatted(string_spec(), formatter=MergedOptionStringFormatter)
return create_spec(image_objs.WaitCondition
, harpoon = formatted(overridden("{harpoon}"), formatter=MergedOptionStringFormatte... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_condition_spec'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Spec for a wait_condition block |
def instance(cls, *args, **kwgs):
if not hasattr(cls, "_instance"):
cls._instance = cls(*args, **kwgs)
return cls._instance | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'instance'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Will be the only instance |
def _extra_compile_time_classpath(self):
def extra_compile_classpath_iter():
for conf in self._confs:
for jar in self.extra_compile_time_classpath_elements():
yield (conf, jar)
return list(extra_compile_classpath_iter()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_extra_compile_time_classpath'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [... | Compute any extra compile-time-only classpath elements. |
def append(self, node):
"Append a new subnode"
if not isinstance(node, self.__class__):
raise TypeError('Expected Node instance, got %r' % node)
self.nodes.append(node) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Append a new subnode |
def add_argument_group(self, title, description=None):
try:
groups = self.__groups
except AttributeError:
groups = self.__groups = {}
if title not in groups:
groups[title] = super().add_argument_group(
title=title, description=description)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_argument_group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | Add an argument group, or return a pre-existing one. |
def stop(self):
Global.LOGGER.info("stopping the flow manager")
self._stop_actions()
self.isrunning = False
Global.LOGGER.debug("flow manager stopped") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Stop all the processes |
def check_scan_process(self, scan_id):
scan_process = self.scan_processes[scan_id]
progress = self.get_scan_progress(scan_id)
if progress < 100 and not scan_process.is_alive():
self.set_scan_status(scan_id, ScanStatus.STOPPED)
self.add_scan_error(scan_id, name="", host=""... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_scan_process'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Check the scan's process, and terminate the scan if not alive. |
def filesize(self):
if self.kind == 'data':
return len(self._data.data)
return self._data.filesize | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filesize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | File size of the object. |
def _path_factory(check):
@functools.wraps(check)
def validator(paths):
if isinstance(paths, str):
check(paths)
elif isinstance(paths, collections.Sequence):
for path in paths:
check(path)
else:
raise Exception('expected either basestr ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_path_factory'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'che... | Create a function that checks paths. |
def find_time_base(self, gps, first_ms_stamp):
t = self._gpsTimeToTime(gps.Week, gps.TimeMS)
self.set_timebase(t - gps.T*0.001)
self.timestamp = self.timebase + first_ms_stamp*0.001 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_time_base'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | work out time basis for the log - new style |
def _get_role(rolename):
path = os.path.join('roles', rolename + '.json')
if not os.path.exists(path):
abort("Couldn't read role file {0}".format(path))
with open(path, 'r') as f:
try:
role = json.loads(f.read())
except ValueError as e:
msg = "Little Chef foun... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_role'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rolenam... | Reads and parses a file containing a role |
def do_alarm_history(mc, args):
fields = {}
fields['alarm_id'] = args.id
if args.limit:
fields['limit'] = args.limit
if args.offset:
fields['offset'] = args.offset
try:
alarm = mc.alarms.history(**fields)
except (osc_exc.ClientException, k_exc.HttpError) as he:
ra... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_alarm_history'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Alarm state transition history. |
def _create_injector(self, injector):
if injector == "block_info":
block_info_injector = importlib.import_module(
"sawtooth_validator.journal.block_info_injector")
return block_info_injector.BlockInfoInjector(
self._state_view_factory, self._signer)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_injector'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Returns a new batch injector |
def execution_engine_model_changed(self, model, prop_name, info):
if not self._view_initialized:
return
active_sm_id = rafcon.gui.singleton.state_machine_manager_model.state_machine_manager.active_state_machine_id
if active_sm_id is None:
self.disable()
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execution_engine_model_changed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier... | Active observation of state machine and show and hide widget. |
def data(self):
if self.is_obsolete():
data = self.get_data()
for datum in data:
if 'published_parsed' in datum:
datum['published_parsed'] = \
self.parse_time(datum['published_parsed'])
try:
dumped_da... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | load and cache data in json format |
def version_router(self, request, response, api_version=None, versions={}, not_found=None, **kwargs):
request_version = self.determine_version(request, api_version)
if request_version:
request_version = int(request_version)
versions.get(request_version or False, versions.get(None, no... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'version_router'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16']}; {'id': '4', 'type': 'identif... | Intelligently routes a request to the correct handler based on the version being requested |
def register(self, func, singleton=False, threadlocal=False, name=None):
func._giveme_singleton = singleton
func._giveme_threadlocal = threadlocal
if name is None:
name = func.__name__
self._registered[name] = func
return func | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': ... | Register a dependency function |
def _calibrate(self, radiance, coefs, channel, calibration):
if self._is_vis(channel):
if not calibration == 'reflectance':
raise ValueError('Cannot calibrate VIS channel to '
'{}'.format(calibration))
return self._calibrate_vis(radiance=r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_calibrate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': ... | Convert radiance to reflectance or brightness temperature |
def _add_region_params(region, out_file, items, gatk_type):
params = []
variant_regions = bedutils.population_variant_regions(items)
region = subset_variant_regions(variant_regions, region, out_file, items)
if region:
if gatk_type == "gatk4":
params += ["-L", bamprep.region_to_gatk(r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_region_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children... | Add parameters for selecting by region to command line. |
def validated_url(url):
try:
u = urlparse(url)
u.port
except Exception:
raise error.URLError(url)
else:
if not u.scheme or not u.netloc:
raise error.URLError(url)
return url | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validated_url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'url... | Return url if valid, raise URLError otherwise |
def _IncludeFields(encoded_message, message, include_fields):
if include_fields is None:
return encoded_message
result = json.loads(encoded_message)
for field_name in include_fields:
try:
value = _GetField(message, field_name.split('.'))
nullvalue = None
i... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_IncludeFields'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Add the requested fields to the encoded message. |
def isLevel2(edtf_candidate):
if "[" in edtf_candidate or "{" in edtf_candidate:
result = edtf_candidate == level2Expression
elif " " in edtf_candidate:
result = False
else:
result = edtf_candidate == level2Expression
return result | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'isLevel2'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'edtf_can... | Checks to see if the date is level 2 valid |
def pickle_loads(cls, s):
strio = StringIO()
strio.write(s)
strio.seek(0)
flow = pmg_pickle_load(strio)
return flow | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pickle_loads'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Reconstruct the flow from a string. |
def approve(self, filepath):
try:
signature_valid = self.validate_signature(filepath)
except ValueError:
signature_valid = False
if signature_valid:
self.leave_safe_mode()
post_command_event(self.main_window, self.SafeModeExitMsg)
statu... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'approve'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Sets safe mode if signature missing of invalid |
def find_uuid(es_url, index):
uid_field = None
res = requests.get('%s/%s/_search?size=1' % (es_url, index))
first_item = res.json()['hits']['hits'][0]['_source']
fields = first_item.keys()
if 'uuid' in fields:
uid_field = 'uuid'
else:
uuid_value = res.json()['hits']['hits'][0]['_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_uuid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'es... | Find the unique identifier field for a given index |
def check_fam_for_samples(required_samples, source, gold):
source_samples = set()
with open(source, 'r') as input_file:
for line in input_file:
sample = tuple(line.rstrip("\r\n").split(" ")[:2])
if sample in required_samples:
source_samples.add(sample)
gold_sa... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_fam_for_samples'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':... | Check fam files for required_samples. |
def init(directory):
username = click.prompt("Input your username")
password = click.prompt("Input your password", hide_input=True,
confirmation_prompt=True)
log_directory = click.prompt("Input your log directory")
if not path.exists(log_directory):
sys.exit("Invalid ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'directory'};... | Init the config fle. |
def dir_list(directory):
try:
content = listdir(directory)
return content
except WindowsError as winErr:
print("Directory error: " + str((winErr))) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dir_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'director... | Returns the list of all files in the directory. |
def RV_3(self):
return -self.orbpop_long.RV * (self.orbpop_long.M1 / (self.orbpop_long.M1 + self.orbpop_long.M2)) +\
self.orbpop_short.RV_com2 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'RV_3'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Instantaneous RV of star 3 with respect to system center-of-mass |
def update_dns(self, new_ip):
headers = None
if self.auth_type == 'T':
api_call_url = self._base_url.format(hostname=self.hostname,
token=self.auth.token,
ip=new_ip)
else:
ap... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_dns'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Call No-IP API based on dict login_info and return the status code. |
def run(self):
_date = None
while QA_util_if_tradetime(self.now):
for data in self.ingest_data:
date = data.date[0]
if self.market_type is MARKET_TYPE.STOCK_CN:
if _date != date:
try:
self... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | generator driven data flow |
def main(self):
self.secret_finder()
self.parse_access_token()
self.get_session_token()
self.parse_session_token()
self.get_route()
self.download_profile()
self.find_loci()
self.download_loci() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Run the appropriate methods in the correct order |
def connect_attenuator(self, connect=True):
if connect:
try:
pa5 = win32com.client.Dispatch("PA5.x")
success = pa5.ConnectPA5('GB', 1)
if success == 1:
print 'Connection to PA5 attenuator established'
pass
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect_attenuator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Establish a connection to the TDT PA5 attenuator |
def _recv(self):
prefix = self._read(self.prefix_len)
msg = self._read(self._extract_len(prefix))
return prefix + msg | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_recv'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Receives and returns a message from Scratch |
def _chunks(self, items, limit):
for i in range(0, len(items), limit):
yield items[i:i + limit] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_chunks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Yield successive chunks from list \a items with a minimum size \a limit |
def get(cls):
return {
SourceRootConfig,
Reporting,
Reproducer,
RunTracker,
Changed,
BinaryUtil.Factory,
Subprocess.Factory
} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id':... | Subsystems used outside of any task. |
def _open_ftp(self):
ftp = self.fs._open_ftp()
ftp.voidcmd(str("TYPE I"))
return ftp | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_open_ftp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Open an ftp object for the file. |
def unzoom(self, full=False, delay_draw=False):
if full:
self.zoom_lims = self.zoom_lims[:1]
self.zoom_lims = []
elif len(self.zoom_lims) > 0:
self.zoom_lims.pop()
self.set_viewlimits()
if not delay_draw:
self.canvas.draw() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unzoom'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | unzoom display 1 level or all the way |
def _get_common_cores(resources):
all_cores = []
for vs in resources.values():
cores = vs.get("cores")
if cores:
all_cores.append(int(vs["cores"]))
return collections.Counter(all_cores).most_common(1)[0][0] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_common_cores'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Retrieve the most common configured number of cores in the input file. |
def _wait_for_retransmit_thread(transaction):
if hasattr(transaction, 'retransmit_thread'):
while transaction.retransmit_thread is not None:
logger.debug("Waiting for retransmit thread to finish ...")
time.sleep(0.01)
continue | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_wait_for_retransmit_thread'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],... | Only one retransmit thread at a time, wait for other to finish |
def isHouse10MC(self):
house10 = self.getHouse(const.HOUSE10)
mc = self.getAngle(const.MC)
dist = angle.closestdistance(house10.lon, mc.lon)
return abs(dist) < 0.0003 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'isHouse10MC'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Returns true if House10 is the same as the MC. |
def identity_to_string(identity_dict):
result = []
if identity_dict.get('proto'):
result.append(identity_dict['proto'] + '://')
if identity_dict.get('user'):
result.append(identity_dict['user'] + '@')
result.append(identity_dict['host'])
if identity_dict.get('port'):
result.a... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'identity_to_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Dump Identity dictionary into its string representation. |
def arcball_constrain_to_axis(point, axis):
v = np.array(point, dtype=np.float64, copy=True)
a = np.array(axis, dtype=np.float64, copy=True)
v -= a * np.dot(a, v)
n = vector_norm(v)
if n > _EPS:
if v[2] < 0.0:
np.negative(v, v)
v /= n
return v
if a[2] == 1.0:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arcball_constrain_to_axis'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | Return sphere point perpendicular to axis. |
def modify_request(self, http_request=None):
if http_request is None:
http_request = HttpRequest()
if http_request.uri is None:
http_request.uri = Uri()
if self.scheme:
http_request.uri.scheme = self.scheme
if self.port:
http_request.uri.port = self.port
if self.host:
h... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'modify_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Sets HTTP request components based on the URI. |
def _define_array_view(data_type):
element_type = data_type.element_type
element_view = _resolve_view(element_type)
if element_view is None:
mixins = (_DirectArrayViewMixin,)
attributes = _get_mixin_attributes(mixins)
elif isinstance(element_type, _ATOMIC):
mixins = (_IndirectAto... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_define_array_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Define a new view object for a `Array` type. |
def authentication_validation(username, password, access_token):
if bool(username) is not bool(password):
raise Exception("Basic authentication requires a username AND"
" password.")
if (username and access_token) or (password and access_token):
raise Exception("Cannot us... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authentication_validation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr... | Only accept one form of authentication. |
def _get_start_end(parts, index=7):
start = parts[1]
end = [x.split("=")[-1] for x in parts[index].split(";") if x.startswith("END=")]
if end:
end = end[0]
return start, end
return None, None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_start_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Retrieve start and end for a VCF record, skips BNDs without END coords |
def save_json(obj, outfile, allow_nan=True, compression=False):
if compression:
with open(outfile, 'wb') as f:
dump(obj, f, allow_nan=allow_nan, compression=compression)
else:
with open(outfile, 'w') as f:
dump(obj, f, allow_nan=allow_nan, compression=compression)
log... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Save an ssbio object as a JSON file using json_tricks |
def update_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False):
res = fw_const.DCNM_OUT_PART_UPDATE_SUCCESS
tenant_name = fw_dict.get('tenant_name')
ret = True
try:
ret = self._update_partition_out_create(tenant_id, tenant_name)
if not ret:
r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_dcnm_out_part'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child... | Update DCNM OUT partition service node IP address and result. |
def vulnerability_section_header_element(feature, parent):
_ = feature, parent
header = vulnerability_section_header['string_format']
return header.capitalize() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vulnerability_section_header_element'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', '... | Retrieve vulnerability section header string from definitions. |
def consume(self, seq):
for kmer in iter_kmers(seq, self.k, canonical=self.canonical):
self._incr(kmer) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'consume'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Counts all k-mers in sequence. |
def jsonify_error(message_or_exception, status_code=400):
if isinstance(message_or_exception, Exception):
message = '%s: %s' % (
message_or_exception.__class__.__name__, message_or_exception)
else:
message = message_or_exception
logging.debug('Returning status=%s, error message: ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'jsonify_error'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Returns a JSON payload that indicates the request had an error. |
def _read_pdb(path):
r_mode = 'r'
openf = open
if path.endswith('.gz'):
r_mode = 'rb'
openf = gzip.open
with openf(path, r_mode) as f:
txt = f.read()
if path.endswith('.gz'):
if sys.version_info[0] >= 3:
txt = txt.de... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_pdb'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'};... | Read PDB file from local drive. |
def extract_bad_snapshot(e):
msg = e.response['Error']['Message']
error = e.response['Error']['Code']
e_snap_id = None
if error == 'InvalidSnapshot.NotFound':
e_snap_id = msg[msg.find("'") + 1:msg.rfind("'")]
log.warning("Snapshot not found %s" % e_snap_id)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_bad_snapshot'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Handle various client side errors when describing snapshots |
def main(option, problem):
if problem == 0 or option in {skip, verify_all}:
files = problem_glob()
problem = max(file.num for file in files) if files else 0
if problem == 0:
if option not in {cheat, preview, verify_all}:
msg = "No Project Euler files found in the ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'option'... | Python-based Project Euler command line tool. |
def check_virtualserver(self, name):
vs = self.bigIP.LocalLB.VirtualServer
for v in vs.get_list():
if v.split('/')[-1] == name:
return True
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_virtualserver'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Check to see if a virtual server exists |
def run_fixtures(self):
self.start_transaction()
version = self.fetchone("SELECT version FROM version")["version"]
current_version = 9
if version < 8:
self.execute("ALTER TABLE activities ADD COLUMN search_name varchar2")
activities = self.fetchall("select * from ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_fixtures'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | upgrade DB to hamster version |
def _store_result(self, task_id, result, status,
traceback=None, request=None):
self.TaskModel._default_manager.store_result(
task_id, result, status,
traceback=traceback, children=self.current_task_children(request),
)
return result | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_store_result'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', 'c... | Store return value and status of an executed task. |
def split_dae_alg(eqs: SYM, dx: SYM) -> Dict[str, SYM]:
dae = []
alg = []
for eq in ca.vertsplit(eqs):
if ca.depends_on(eq, dx):
dae.append(eq)
else:
alg.append(eq)
return {
'dae': ca.vertcat(*dae),
'alg': ca.vertcat(*alg)
} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_dae_alg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ... | Split equations into differential algebraic and algebraic only |
def flatten_phases_and_groups(phases_or_groups):
if isinstance(phases_or_groups, PhaseGroup):
phases_or_groups = [phases_or_groups]
ret = []
for phase in phases_or_groups:
if isinstance(phase, PhaseGroup):
ret.append(phase.flatten())
elif isinstance(phase, collections.Iterable):
ret.extend... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten_phases_and_groups'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Recursively flatten nested lists for the list of phases or groups. |
def haveSnapshots(self):
return os.path.islink(self.latestLink) and os.path.isdir(self.latestLink) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'haveSnapshots'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Check if we have at least one snapshot. |
def powerDown(self):
print '%s call powerDown' % self.port
if self.__sendCommand(WPANCTL_CMD + 'setprop Daemon:AutoAssociateAfterReset false')[0] != 'Fail':
time.sleep(0.5)
if self.__sendCommand(WPANCTL_CMD + 'reset')[0] != 'Fail':
self.isPowerDown = True
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'powerDown'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | power down the OpenThreadWpan |
def _cor_compile(rule, var, val, result_class, key, compilation_list):
compilation = compilation_list.get(key, None)
if compilation:
if isinstance(val, ListRule):
result = []
for itemv in val.value:
result.append(compilation['callback'](ite... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cor_compile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chi... | Actual compilation worker method. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.