code
stringlengths 51
2.34k
| sequence
stringlengths 186
3.94k
| docstring
stringlengths 11
171
|
|---|---|---|
def shell(ctx):
shell = code.InteractiveConsole({"engineer": getattr(ctx.parent, "widget", None)})
shell.interact("\n".join([
"Engineer connected to %s" % ctx.parent.params["host"],
"Dispatch available through the 'engineer' object"
]))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end none expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list list binary_operator string string_start string_content string_end subscript attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end
|
open an engineer shell
|
def getOverlayFlag(self, ulOverlayHandle, eOverlayFlag):
fn = self.function_table.getOverlayFlag
pbEnabled = openvr_bool()
result = fn(ulOverlayHandle, eOverlayFlag, byref(pbEnabled))
return result, pbEnabled
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier call identifier argument_list identifier return_statement expression_list identifier identifier
|
Sets flag setting for a given overlay
|
def draw(self):
if self.state > 0:
self.renderer.draw_background(self.surface, self.layout.position, self.layout.size)
for row in self.layout.rows:
for key in row.keys:
self.renderer.draw_key(self.surface, key)
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier for_statement identifier attribute attribute identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
|
Draw the virtual keyboard into the delegate surface object if enabled.
|
def surviors_are_inconsistent(survivor_mapping: Mapping[BaseEntity, Set[BaseEntity]]) -> Set[BaseEntity]:
victim_mapping = set()
for victim in itt.chain.from_iterable(survivor_mapping.values()):
if victim in survivor_mapping:
victim_mapping.add(victim)
return victim_mapping
|
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Check that there's no transitive shit going on.
|
def const(const):
try:
return getattr(_c, const)
except AttributeError:
raise FSQEnvError(errno.EINVAL, u'No such constant:'\
u' {0}'.format(const))
except TypeError:
raise TypeError(errno.EINVAL, u'const name must be a string or'\
u' unicode object, not:'\
u' {0}'.format(const.__class__.__name__))
|
module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list identifier identifier except_clause identifier block raise_statement call identifier argument_list attribute identifier identifier call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list attribute identifier identifier call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier
|
Convenience wrapper to yield the value of a constant
|
def install_plugin(username, repo):
print("Installing plugin from " + username + "/" + repo)
pip.main(['install', '-U', "git+git://github.com/" +
username + "/" + repo + ".git"])
|
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end
|
Installs a Blended plugin from GitHub
|
def _convert_number(self, number):
number = float(number)
return int(number) if number.is_integer() else float(number)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement conditional_expression call identifier argument_list identifier call attribute identifier identifier argument_list call identifier argument_list identifier
|
Converts a number to float or int as appropriate
|
def write(self, s):
for line in re.split(r'\n+', s):
if line != '':
self._logger.log(self._level, line)
|
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier block if_statement comparison_operator identifier string string_start string_end block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
|
Write message to logger.
|
def _preloading_env(self):
ctx = self.env.globals
try:
ctx['random_model'] = lambda *a, **kw: None
ctx['random_models'] = lambda *a, **kw: None
yield self.env
finally:
ctx['random_model'] = jinja2.contextfunction(random_model)
ctx['random_models'] = jinja2.contextfunction(random_models)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier try_statement block expression_statement assignment subscript identifier string string_start string_content string_end lambda lambda_parameters list_splat_pattern identifier dictionary_splat_pattern identifier none expression_statement assignment subscript identifier string string_start string_content string_end lambda lambda_parameters list_splat_pattern identifier dictionary_splat_pattern identifier none expression_statement yield attribute identifier identifier finally_clause block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier
|
A "stripped" jinja environment.
|
def _calc_footprint(self):
corners = [self.corner(corner) for corner in self.corner_types()]
coords = []
for corner in corners:
shape = corner.get_shape(corner.crs)
coords.append([shape.x, shape.y])
shp = Polygon(coords)
self._footprint = GeoVector(shp, self.crs)
return self._footprint
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier attribute identifier identifier return_statement attribute identifier identifier
|
Return rectangle in world coordinates, as GeoVector.
|
def _get_filepaths(self):
self._printer(str(self.__len__()) + " file paths have been parsed in " + str(self.timer.end))
if self._hash_files:
return pool_hash(self.filepaths)
else:
return self.filepaths
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier if_statement attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier else_clause block return_statement attribute identifier identifier
|
Filters list of file paths to remove non-included, remove excluded files and concatenate full paths.
|
def sha256sum(filename):
sha256 = hashlib.sha256()
mem_view = memoryview(bytearray(128*1024))
with open(filename, 'rb', buffering=0) as stream:
for i in iter(lambda: stream.readinto(mem_view), 0):
sha256.update(mem_view[:i])
return sha256.hexdigest()
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator integer integer with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier integer as_pattern_target identifier block for_statement identifier call identifier argument_list lambda call attribute identifier identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list subscript identifier slice identifier return_statement call attribute identifier identifier argument_list
|
Return SHA256 hash of file.
|
def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
filter_type=None, **kwds):
func = getattr(self, name, None)
if func is None:
raise TypeError("{klass} cannot perform the operation {op}".format(
klass=self.__class__.__name__, op=name))
return func(skipna=skipna, **kwds)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier true default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier identifier none if_statement comparison_operator identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier dictionary_splat identifier
|
perform the reduction type operation if we can
|
def increase_last(self, k):
idx = self._last_idx
if idx is not None:
self.results[idx] += k
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment subscript attribute identifier identifier identifier identifier
|
Increase the last result by k.
|
def parameters(self):
parameters = {}
for name in self.PARAMETERS:
try:
parameters[name] = self.get_parameter(name)
except AttributeError:
pass
return parameters
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement identifier
|
Get dict with all set parameters.
|
def exists_query(expression):
def _exists(index, expression=expression):
ev = expression() if callable(expression) else expression
if ev:
return [
store_key
for store_keys
in index.get_index().values()
for store_key in store_keys
]
else:
return index.get_undefined_keys()
return _exists
|
module function_definition identifier parameters identifier block function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier conditional_expression call identifier argument_list call identifier argument_list identifier identifier if_statement identifier block return_statement list_comprehension identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier argument_list for_in_clause identifier identifier else_clause block return_statement call attribute identifier identifier argument_list return_statement identifier
|
Check that documents have a key that satisfies expression.
|
def _active_cli(self):
cli = self.cli
while cli._sub_cli:
cli = cli._sub_cli
return cli
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier while_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier return_statement identifier
|
Return the active `CommandLineInterface`.
|
def _new_from_cdata(cls, cdata: Any) -> "Color":
return cls(cdata.r, cdata.g, cdata.b)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type string string_start string_content string_end block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
|
new in libtcod-cffi
|
def unpad(cls, data):
if sys.version_info > (3, 0):
return data[:-ord(data[len(data)-1:])].decode()
else:
return data[:-ord(data[len(data)-1:])]
|
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier tuple integer integer block return_statement call attribute subscript identifier slice unary_operator call identifier argument_list subscript identifier slice binary_operator call identifier argument_list identifier integer identifier argument_list else_clause block return_statement subscript identifier slice unary_operator call identifier argument_list subscript identifier slice binary_operator call identifier argument_list identifier integer
|
Unpads data that has been padded
|
def usage(title, message, tutorial_message, tutorial, css_path=CSS_PATH):
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
usage = env.get_template("usage.html")
return usage.render(css_path=css_path, title=title, intro_message=message,
tutorial_message=tutorial_message, tutorial=tutorial)
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Print a usage message on the rich text view
|
def json(self):
if self.search_results is None:
return None
result = []
for row in self.search_results['rows']:
obj = {}
for index in range(0, len(self.search_results['fields'])):
obj[self.search_results['fields'][index]] = row[index]
result.append(obj)
return result
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement none expression_statement assignment identifier list for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list integer call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier subscript subscript attribute identifier identifier string string_start string_content string_end identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Returns the search results as a list of JSON objects.
|
def _make_read_func(file_obj):
@ffi.callback("cairo_read_func_t", error=constants.STATUS_READ_ERROR)
def read_func(_closure, data, length):
string = file_obj.read(length)
if len(string) < length:
return constants.STATUS_READ_ERROR
ffi.buffer(data, length)[:len(string)] = string
return constants.STATUS_SUCCESS
return read_func
|
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block return_statement attribute identifier identifier expression_statement assignment subscript call attribute identifier identifier argument_list identifier identifier slice call identifier argument_list identifier identifier return_statement attribute identifier identifier return_statement identifier
|
Return a CFFI callback that reads from a file-like object.
|
def cli(env, identifier, enable):
mgr = SoftLayer.HardwareManager(env.client)
hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
result = env.client['Hardware_Server'].toggleManagementInterface(enable, id=hw_id)
env.fout(result)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
|
Toggle the IPMI interface on and off
|
def draw_image(self, image, item, source):
top, left = item['top'], item['left']
width, height = item['width'], item['height']
image_file = item['image']
img = Image.open(source)
img = self.rotate(img)
iwidth, iheight = img.size
wratio = width / iwidth
hratio = height / iheight
ratio = min(wratio, hratio)
img = img.resize((int(iwidth * ratio),
int(iheight * ratio)),
Image.ANTIALIAS)
iwidth, iheight = img.size
top += (height - iheight) // 2
left += (width - iwidth) // 2
image.paste(img, (left, top))
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier expression_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple call identifier argument_list binary_operator identifier identifier call identifier argument_list binary_operator identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement augmented_assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier tuple identifier identifier
|
Add an image to the image
|
def should_reschedule(self, iteration, bracket_iteration):
bracket = self.get_bracket(iteration=iteration)
if bracket_iteration < bracket:
return False
return self.get_bracket(iteration=iteration + 1) >= 0
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier identifier block return_statement false return_statement comparison_operator call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier integer integer
|
Return a boolean to indicate if we need to reschedule another iteration.
|
def db_for_write(self, model, **hints):
if model._meta.app_label in self._apps:
return getattr(model, '_db_alias', model._meta.app_label)
return None
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier block return_statement call identifier argument_list identifier string string_start string_content string_end attribute attribute identifier identifier identifier return_statement none
|
If the app has its own database, use it for writes
|
def _valid_numpy_subdtype(x, numpy_types):
for t in numpy_types:
assert not np.issubdtype(np.generic, t)
return any(np.issubdtype(x.dtype, t) for t in numpy_types)
|
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block assert_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement call identifier generator_expression call attribute identifier identifier argument_list attribute identifier identifier identifier for_in_clause identifier identifier
|
Is any dtype from numpy_types superior to the dtype of x?
|
def section(title, bar=OVERLINE, strm=sys.stdout):
width = utils.term.width
printy(bold(title.center(width)))
printy(bold((bar * width)[:width]))
|
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call identifier argument_list subscript parenthesized_expression binary_operator identifier identifier slice identifier
|
Helper function for testing demo routines
|
def validate_response(self):
if self.response is None:
logger.error("Failed to submit")
return False
if not self.response:
logger.error(
"HTTP status %d: failed to submit to %s",
self.response.status_code,
self.response.url,
)
return False
if not self.parsed_response:
logger.error("Submit to %s failed, invalid response received", self.response.url)
return False
error_message = self.get_error_message()
if error_message:
logger.error("Submit to %s failed with error", self.response.url)
logger.debug("Error message: %s", error_message)
return False
if not self.job_ids:
logger.error("Submit to %s failed to get job id", self.response.url)
return False
logger.info("Results received by the Importer (HTTP status %d)", self.response.status_code)
logger.info("Job IDs: %s", self.job_ids)
return True
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement false if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement false if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier return_statement false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement true
|
Checks that the response is valid and import succeeded.
|
def import_eit_fzj(self, filename, configfile, correction_file=None,
timestep=None, **kwargs):
df_emd, dummy1, dummy2 = eit_fzj.read_3p_data(
filename,
configfile,
**kwargs
)
if correction_file is not None:
eit_fzj_utils.apply_correction_factors(df_emd, correction_file)
if timestep is not None:
df_emd['timestep'] = timestep
self._add_to_container(df_emd)
print('Summary:')
self._describe_data(df_emd)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
|
EIT data import for FZJ Medusa systems
|
def _setup_piddir(self):
if self.pidfile is None:
return
piddir = os.path.dirname(self.pidfile)
if not os.path.isdir(piddir):
os.makedirs(piddir, 0o777 & ~self.umask)
os.chown(piddir, self.uid, self.gid)
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator integer unary_operator attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier
|
Create the directory for the PID file if necessary.
|
def split_pieces(piece_list, segments, num):
piece_groups = []
pieces = list(piece_list)
while pieces:
for i in range(segments):
p = pieces[i::segments][:num]
if not p:
break
piece_groups.append(p)
pieces = pieces[num * segments:]
return piece_groups
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier while_statement identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript subscript identifier slice identifier identifier slice identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier slice binary_operator identifier identifier return_statement identifier
|
Prepare a list of all pieces grouped together
|
def neighborhood(self, node, degree=4):
assert self.by_name[node.name] == node
already_visited = frontier = set([node.name])
for _ in range(degree):
neighbor_names = set()
for node_name in frontier:
outgoing = set(n.name for n in self.by_input[node_name])
incoming = set(self.by_name[node_name].input)
neighbor_names |= incoming | outgoing
frontier = neighbor_names - already_visited
already_visited |= neighbor_names
return [self.by_name[name] for name in already_visited]
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block assert_statement comparison_operator subscript attribute identifier identifier attribute identifier identifier identifier expression_statement assignment identifier assignment identifier call identifier argument_list list attribute identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call identifier generator_expression attribute identifier identifier for_in_clause identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement augmented_assignment identifier identifier return_statement list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier identifier
|
Am I really handcoding graph traversal please no
|
def generate_trajs(self, M, N, start=None, stop=None, dt=1):
from msmtools.generation import generate_trajs
return generate_trajs(self._P, M, N, start=start, stop=stop, dt=dt)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier integer block import_from_statement dotted_name identifier identifier dotted_name identifier return_statement call identifier argument_list attribute identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Generates M random trajectories of length N each with time step dt
|
def count(self):
return functools.reduce(lambda x, y: x * y, (x.count for x in self.bounds))
|
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier binary_operator identifier identifier generator_expression attribute identifier identifier for_in_clause identifier attribute identifier identifier
|
Total number of array cells
|
def hijack_require_http_methods(fn):
required_methods = ['POST']
if hijack_settings.HIJACK_ALLOW_GET_REQUESTS:
required_methods.append('GET')
return require_http_methods(required_methods)(fn)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call call identifier argument_list identifier argument_list identifier
|
Wrapper for "require_http_methods" decorator. POST required by default, GET can optionally be allowed
|
def to_dict(self):
attributes = dict(self.attributes.items())
if self.style:
attributes.update({"style": dict(self.style.items())})
vdom_dict = {'tagName': self.tag_name, 'attributes': attributes}
if self.event_handlers:
event_handlers = dict(self.event_handlers.items())
for key, value in event_handlers.items():
value = create_event_handler(key, value)
event_handlers[key] = value
vdom_dict['eventHandlers'] = event_handlers
if self.key:
vdom_dict['key'] = self.key
vdom_dict['children'] = [c.to_dict() if isinstance(c, VDOM) else c for c in self.children]
return vdom_dict
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension conditional_expression call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier for_in_clause identifier attribute identifier identifier return_statement identifier
|
Converts VDOM object to a dictionary that passes our schema
|
def _check_frames(self, frames, fill_value):
if self.seekable():
remaining_frames = self.frames - self.tell()
if frames < 0 or (frames > remaining_frames and
fill_value is None):
frames = remaining_frames
elif frames < 0:
raise ValueError("frames must be specified for non-seekable files")
return frames
|
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier binary_operator attribute identifier identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier integer parenthesized_expression boolean_operator comparison_operator identifier identifier comparison_operator identifier none block expression_statement assignment identifier identifier elif_clause comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
|
Reduce frames to no more than are available in the file.
|
def partial_trace(self, qubits: Qubits) -> 'QubitVector':
N = self.qubit_nb
R = self.rank
if R == 1:
raise ValueError('Cannot take trace of vector')
new_qubits: List[Qubit] = list(self.qubits)
for q in qubits:
new_qubits.remove(q)
if not new_qubits:
raise ValueError('Cannot remove all qubits with partial_trace.')
indices = [self.qubits.index(qubit) for qubit in qubits]
subscripts = list(EINSUM_SUBSCRIPTS)[0:N*R]
for idx in indices:
for r in range(1, R):
subscripts[r * N + idx] = subscripts[idx]
subscript_str = ''.join(subscripts)
tensor = self.asarray()
tensor = np.einsum(subscript_str, tensor)
return QubitVector(tensor, new_qubits)
|
module function_definition identifier parameters identifier typed_parameter identifier type identifier type string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier type generic_type identifier type_parameter type identifier call identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier subscript call identifier argument_list identifier slice integer binary_operator identifier identifier for_statement identifier identifier block for_statement identifier call identifier argument_list integer identifier block expression_statement assignment subscript identifier binary_operator binary_operator identifier identifier identifier subscript identifier identifier expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier
|
Return the partial trace over some subset of qubits
|
def manage_file_analysis(args: argparse.Namespace, filename: str, data: object) -> None:
key = DataStore.hashfile(filename)
print('Analyzing {} --> {}'.format(filename, key))
if data.check_key(key):
fit = LineFit(filename, data=data.get_data(key))
else:
fit = LineFit(filename)
if args.time:
noise, curvature, rnge, domn = fit.analyze(time=args.time)
newrow = [args.time, noise, curvature,
rnge, domn, fit.accepts[args.time]]
data.update1(key, newrow, len(fit.noises))
else:
fit.analyze_full()
newrows = np.array([range(len(fit.noises)), fit.noises,
fit.curves, fit.ranges, fit.domains, fit.accepts])
data.update(key, newrows)
data.save()
|
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier list attribute identifier identifier identifier identifier identifier identifier subscript attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list list call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
|
Take care of the analysis of a datafile
|
def match_file(apikey, path, metadata=None):
import audioread
with audioread.audio_open(path) as f:
return match(apikey, iter(f), f.samplerate, int(f.duration),
f.channels, metadata)
|
module function_definition identifier parameters identifier identifier default_parameter identifier none block import_statement dotted_name identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block return_statement call identifier argument_list identifier call identifier argument_list identifier attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier identifier
|
Uses the audioread library to decode an audio file and match it.
|
def dict_to_xml(xml_dict):
import lxml.etree as etree
root_tag = list(xml_dict.keys())[0]
root = etree.Element(root_tag)
_dict_to_xml_recurse(root, xml_dict[root_tag])
return root
|
module function_definition identifier parameters identifier block import_statement aliased_import dotted_name identifier identifier identifier expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier subscript identifier identifier return_statement identifier
|
Converts a dictionary to an XML ElementTree Element
|
def _mirbase_stats(data, out_dir):
utils.safe_makedir(out_dir)
out_file = os.path.join(out_dir, "%s_bcbio_mirbase.txt" % dd.get_sample_name(data))
out_file_novel = os.path.join(out_dir, "%s_bcbio_mirdeeep2.txt" % dd.get_sample_name(data))
mirbase_fn = data.get("seqbuster", None)
if mirbase_fn:
_get_stats_from_miraligner(mirbase_fn, out_file, "seqbuster")
mirdeep_fn = data.get("seqbuster_novel", None)
if mirdeep_fn:
_get_stats_from_miraligner(mirdeep_fn, out_file_novel, "mirdeep2")
return {"base": out_file, "secondary": [out_file_novel]}
|
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end list identifier
|
Create stats from miraligner
|
def _glob_events_files(self, paths, recursive):
event_files = []
for path in paths:
dirs = tf.gfile.Glob(path)
dirs = filter(lambda x: tf.gfile.IsDirectory(x), dirs)
for dir in dirs:
if recursive:
dir_files_pair = [(root, filenames) for root, _, filenames in tf.gfile.Walk(dir)]
else:
dir_files_pair = [(dir, tf.gfile.ListDirectory(dir))]
for root, filenames in dir_files_pair:
file_names = fnmatch.filter(filenames, '*.tfevents.*')
file_paths = [os.path.join(root, x) for x in file_names]
file_paths = filter(lambda x: not tf.gfile.IsDirectory(x), file_paths)
event_files += file_paths
return event_files
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier call attribute attribute identifier identifier identifier argument_list identifier identifier for_statement identifier identifier block if_statement identifier block expression_statement assignment identifier list_comprehension tuple identifier identifier for_in_clause pattern_list identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier list tuple identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier identifier return_statement identifier
|
Find all tf events files under a list of paths recursively.
|
def guess_python_env():
version, major, minor = get_version_info()
if 'PyPy' in version:
return 'pypy3' if major == 3 else 'pypy'
return 'py{major}{minor}'.format(major=major, minor=minor)
|
module function_definition identifier parameters block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block return_statement conditional_expression string string_start string_content string_end comparison_operator identifier integer string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
|
Guess the default python env to use.
|
def edit_line(self, line):
for code, code_obj in self.code_objs.items():
line = self.__edit_line(line, code, code_obj)
return line
|
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
|
Edit a single line using the code expression.
|
def _LogInvalidRunLevels(states, valid):
invalid = set()
for state in states:
if state not in valid:
invalid.add(state)
if invalid:
logging.warning("Invalid init runlevel(s) encountered: %s",
", ".join(invalid))
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
|
Log any invalid run states found.
|
def allows_simple_recursion(self):
rec_level = self.aggregate.config["recursionlevel"]
if rec_level >= 0 and self.recursion_level >= rec_level:
log.debug(LOG_CHECK, "... no, maximum recursion level reached.")
return False
if self.extern[0]:
log.debug(LOG_CHECK, "... no, extern.")
return False
return True
|
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end if_statement boolean_operator comparison_operator identifier integer comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement false if_statement subscript attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement false return_statement true
|
Check recursion level and extern status.
|
def extract_fields(d, fields, delimiter='|'):
rd = {}
for f in fields:
v = d.get(f, None)
if isinstance(v, (str, unicode)):
v = v.encode('utf8')
elif isinstance(v, list):
v = delimiter.join(v)
rd[f] = v
return rd
|
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier none if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
|
get values out of an object ``d`` for saving to a csv
|
def middleware_class(api=None):
def decorator(middleware_class):
apply_to_api = hug.API(api) if api else hug.api.from_object(middleware_class)
apply_to_api.http.add_middleware(middleware_class())
return middleware_class
return decorator
|
module function_definition identifier parameters default_parameter identifier none block function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list return_statement identifier return_statement identifier
|
Registers a middleware class
|
def dinfflowdir(np, filleddem, flowangle, slope, workingdir=None, mpiexedir=None, exedir=None,
log_file=None, runtime_file=None, hostfile=None):
fname = TauDEM.func_name('dinfflowdir')
return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir),
{'-fel': filleddem}, workingdir,
None,
{'-ang': flowangle, '-slp': slope},
{'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np},
{'logfile': log_file, 'runtimefile': runtime_file})
|
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier dictionary pair string string_start string_content string_end identifier identifier none dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
|
Run Dinf flow direction
|
def stick_perm(presenter, egg, dist_dict, strategy):
np.random.seed()
egg_pres, egg_rec, egg_features, egg_dist_funcs = parse_egg(egg)
regg = order_stick(presenter, egg, dist_dict, strategy)
regg_pres, regg_rec, regg_features, regg_dist_funcs = parse_egg(regg)
regg_pres = list(regg_pres)
egg_pres = list(egg_pres)
idx = [egg_pres.index(r) for r in regg_pres]
weights = compute_feature_weights_dict(list(regg_pres), list(regg_pres), list(regg_features), dist_dict)
orders = idx
return weights, orders
|
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier identifier expression_statement assignment identifier identifier return_statement expression_list identifier identifier
|
Computes weights for one reordering using stick-breaking method
|
def create(model_config, batch_size, normalize=True, num_workers=0, augmentations=None):
path = model_config.data_dir('mnist')
train_dataset = datasets.MNIST(path, train=True, download=True)
test_dataset = datasets.MNIST(path, train=False, download=True)
augmentations = [ToArray()] + (augmentations if augmentations is not None else [])
if normalize:
train_data = train_dataset.train_data
mean_value = (train_data.double() / 255).mean().item()
std_value = (train_data.double() / 255).std().item()
augmentations.append(Normalize(mean=mean_value, std=std_value, tags=['train', 'val']))
augmentations.append(ToTensor())
return TrainingData(
train_dataset,
test_dataset,
num_workers=num_workers,
batch_size=batch_size,
augmentations=augmentations
)
|
module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier integer default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false keyword_argument identifier true expression_statement assignment identifier binary_operator list call identifier argument_list parenthesized_expression conditional_expression identifier comparison_operator identifier none list if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier argument_list identifier argument_list expression_statement assignment identifier call attribute call attribute parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list return_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Create a MNIST dataset, normalized
|
def __we_c(cls, calib, tc, temp, we_v):
offset_v = calib.pid_elc_mv / 1000.0
response_v = we_v - offset_v
response_c = tc.correct(temp, response_v)
if response_c is None:
return None
we_c = response_c + offset_v
return we_c
|
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier float expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier binary_operator identifier identifier return_statement identifier
|
Compute weC from sensor temperature compensation of weV
|
def repackage_var(h):
if IS_TORCH_04: return h.detach() if type(h) == torch.Tensor else tuple(repackage_var(v) for v in h)
else: return Variable(h.data) if type(h) == Variable else tuple(repackage_var(v) for v in h)
|
module function_definition identifier parameters identifier block if_statement identifier block return_statement conditional_expression call attribute identifier identifier argument_list comparison_operator call identifier argument_list identifier attribute identifier identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier else_clause block return_statement conditional_expression call identifier argument_list attribute identifier identifier comparison_operator call identifier argument_list identifier identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier
|
Wraps h in new Variables, to detach them from their history.
|
def finalize(self, params, rep):
if params.get("saveNet", True):
saveDir = os.path.join(params["path"], params["name"],
"model_{}.pt".format(rep))
torch.save(self.model, saveDir)
|
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
|
Save the full model once we are done.
|
def _edit_config(xpath, element):
query = {'type': 'config',
'action': 'edit',
'xpath': xpath,
'element': element}
response = __proxy__['panos.call'](query)
return _validate_response(response)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier return_statement call identifier argument_list identifier
|
Sends an edit request to the device.
|
def multiply(a, col):
a = a.reshape(4, 4, 4)
col = col.reshape(4, 8)
return fcat(
rowxcol(a[0], col),
rowxcol(a[1], col),
rowxcol(a[2], col),
rowxcol(a[3], col),
)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list integer integer return_statement call identifier argument_list call identifier argument_list subscript identifier integer identifier call identifier argument_list subscript identifier integer identifier call identifier argument_list subscript identifier integer identifier call identifier argument_list subscript identifier integer identifier
|
Multiply a matrix by one column.
|
def run_get_clusters_from_file(self, clusters_infile, all_ref_seqs, rename_dict=None):
if rename_dict is None:
rename_dict = {}
seq_reader = pyfastaq.sequences.file_reader(self.infile)
names_list_from_fasta_file = [seq.id for seq in seq_reader]
names_set_from_fasta_file = set(names_list_from_fasta_file)
clusters = self._load_user_clusters_file(clusters_infile, all_ref_seqs, rename_dict=rename_dict)
if len(names_set_from_fasta_file) != len(names_list_from_fasta_file):
raise Error('At least one duplicate name in fasta file ' + self.infile + '. Cannot continue')
names_from_clusters_file = set()
for new_names in clusters.values():
names_from_clusters_file.update(new_names)
if not names_set_from_fasta_file.issubset(names_from_clusters_file):
raise Error('Some names in fasta file "' + self.infile + '" not given in cluster file. Cannot continue')
return clusters
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end return_statement identifier
|
Instead of running cdhit, gets the clusters info from the input file.
|
def image_load_time(self):
load_times = self.get_load_times('image')
return round(mean(load_times), self.decimal_precision)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list identifier attribute identifier identifier
|
Returns aggregate image load time for all pages.
|
def run(self, stdscr):
self.win = stdscr
curses.curs_set(0)
stdscr.timeout(0)
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_RED, curses.COLOR_BLACK)
while True:
self.refresh(True)
now = time.time()
while time.time() - now < self._refresh_rate:
time.sleep(0.1)
self.refresh(False)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier attribute identifier identifier while_statement true block expression_statement call attribute identifier identifier argument_list true expression_statement assignment identifier call attribute identifier identifier argument_list while_statement comparison_operator binary_operator call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list float expression_statement call attribute identifier identifier argument_list false
|
Initialize curses and refresh in a loop
|
def configure(self, address):
global nanoconfig_started
if len(self._endpoints):
raise ValueError("Nanoconfig address must be sole endpoint")
endpoint_id = _nn_check_positive_rtn(
wrapper.nc_configure(self.fd, address)
)
if not nanoconfig_started:
nanoconfig_started = True
ep = Socket.NanoconfigEndpoint(self, endpoint_id, address)
self._endpoints.append(ep)
return ep
|
module function_definition identifier parameters identifier identifier block global_statement identifier if_statement call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement not_operator identifier block expression_statement assignment identifier true expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
|
Configure socket's addresses with nanoconfig
|
def tree_iter_nexson_proxy(nexson_proxy):
nexml_el = nexson_proxy._nexml_el
tg_order = nexml_el['^ot:treesElementOrder']
tgd = nexml_el['treesById']
for tg_id in tg_order:
tg = tgd[tg_id]
tree_order = tg['^ot:treeElementOrder']
tbid = tg['treeById']
otus = tg['@otus']
for k in tree_order:
v = tbid[k]
yield nexson_proxy._create_tree_proxy(tree_id=k, tree=v, otus=otus)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement yield call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
|
Iterates over NexsonTreeProxy objects in order determined by the nexson blob
|
def cmd_wrapper(cmd_name, **kwds):
cmd = si.Commands(cmd_name)
if not cmd:
raise Exception(cmd_name + " doesnt found!")
for arg in cmd.Arguments:
value = kwds.get(arg.Name)
if value:
arg.Value = value
return cmd.Execute()
|
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator identifier string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list
|
Wrap and execute a softimage command accepting named arguments
|
def verify_enroll(self, response):
seed = session.pop('_u2f_enroll_')
try:
new_device, cert = complete_register(seed, response, self.__facets_list)
except Exception as e:
if self.__call_fail_enroll:
self.__call_fail_enroll(e)
return {
'status' : 'failed',
'error' : 'Invalid key handle!'
}
finally:
pass
devices = self.__get_u2f_devices()
new_device['counter'] = 0
new_device['index'] = 0
for device in devices:
if new_device['index'] <= device['index']:
new_device['index'] = device['index'] + 1
devices.append(new_device)
self.__save_u2f_devices(devices)
self.__call_success_enroll()
return {'status': 'ok', 'message': 'Successfully enrolled new U2F device!'}
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end finally_clause block pass_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end integer for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end
|
Verifies and saves U2F enroll
|
def info(args):
session = c.Session(args)
if "all" in args["names"]:
feeds = session.list_feeds()
else:
feeds = args["names"]
for feed in feeds:
aux.pretty_print(session, feed)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
|
Provide information of a number of feeds
|
def _raw_weights(self):
if self._debug:
return np.array([[],[],[],[]])
if not self._running:
raise ValueError('Weight sensor is not running!')
if len(self._weight_buffers) == 0:
time.sleep(0.3)
if len(self._weight_buffers) == 0:
raise ValueError('Weight sensor is not retrieving data!')
weights = np.array(self._weight_buffers)
return weights
|
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list list list list list list if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list float if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
|
Create a numpy array containing the raw sensor weights.
|
def binary_to_term(data):
if not isinstance(data, bytes):
raise ParseException('not bytes input')
size = len(data)
if size <= 1:
raise ParseException('null input')
if b_ord(data[0]) != _TAG_VERSION:
raise ParseException('invalid version')
try:
i, term = _binary_to_term(1, data)
if i != size:
raise ParseException('unparsed data')
return term
except struct.error:
raise ParseException('missing data')
except IndexError:
raise ParseException('missing data')
|
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list subscript identifier integer identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment pattern_list identifier identifier call identifier argument_list integer identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier except_clause attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end
|
Decode Erlang terms within binary data into Python types
|
def geo_to_pixel(geo, level):
lat, lon = float(geo[0]), float(geo[1])
lat = TileSystem.clip(lat, TileSystem.LATITUDE_RANGE)
lon = TileSystem.clip(lon, TileSystem.LONGITUDE_RANGE)
x = (lon + 180) / 360
sin_lat = sin(lat * pi / 180)
y = 0.5 - log((1 + sin_lat) / (1 - sin_lat)) / (4 * pi)
map_size = TileSystem.map_size(level)
pixel_x = int(TileSystem.clip(x * map_size + 0.5, (0, map_size - 1)))
pixel_y = int(TileSystem.clip(y * map_size + 0.5, (0, map_size - 1)))
return pixel_x, pixel_y
|
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier call identifier argument_list binary_operator binary_operator identifier identifier integer expression_statement assignment identifier binary_operator float binary_operator call identifier argument_list binary_operator parenthesized_expression binary_operator integer identifier parenthesized_expression binary_operator integer identifier parenthesized_expression binary_operator integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier float tuple integer binary_operator identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier float tuple integer binary_operator identifier integer return_statement expression_list identifier identifier
|
Transform from geo coordinates to pixel coordinates
|
def check(self, feature):
mapper = feature.as_dataframe_mapper()
mapper.fit_transform(self.X, y=self.y)
|
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier
|
Check that fit_transform can be called on reference data
|
def run_cli(
executable,
mets_url=None,
resolver=None,
workspace=None,
page_id=None,
log_level=None,
input_file_grp=None,
output_file_grp=None,
parameter=None,
working_dir=None,
):
workspace = _get_workspace(workspace, resolver, mets_url, working_dir)
args = [executable, '--working-dir', workspace.directory]
args += ['--mets', mets_url]
if log_level:
args += ['--log-level', log_level]
if page_id:
args += ['--page-id', page_id]
if input_file_grp:
args += ['--input-file-grp', input_file_grp]
if output_file_grp:
args += ['--output-file-grp', output_file_grp]
if parameter:
args += ['--parameter', parameter]
log.debug("Running subprocess '%s'", ' '.join(args))
return subprocess.call(args)
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier list identifier string string_start string_content string_end attribute identifier identifier expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
|
Create a workspace for mets_url and run MP CLI through it
|
def addStampAnnot(self, rect, stamp=0):
CheckParent(self)
val = _fitz.Page_addStampAnnot(self, rect, stamp)
if not val: return
val.thisown = True
val.parent = weakref.proxy(self)
self._annot_refs[id(val)] = val
return val
|
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement not_operator identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier call identifier argument_list identifier identifier return_statement identifier
|
Add a 'rubber stamp' in a rectangle.
|
def grace_period(msg='', seconds=10):
import time
print(msg)
override = util_arg.get_argflag(('--yes', '--y', '-y'))
print('starting grace period')
if override:
print('ending based on command line flag')
return True
for count in reversed(range(1, seconds + 1)):
time.sleep(1)
print('%d' % (count,))
print('%d' % (0,))
print('grace period is over')
return True
|
module function_definition identifier parameters default_parameter identifier string string_start string_end default_parameter identifier integer block import_statement dotted_name identifier expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement true for_statement identifier call identifier argument_list call identifier argument_list integer binary_operator identifier integer block expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple integer expression_statement call identifier argument_list string string_start string_content string_end return_statement true
|
Gives user a window to stop a process before it happens
|
def left_button_down(self, obj, event_type):
click_pos = self.iren.GetEventPosition()
picker = vtk.vtkWorldPointPicker()
picker.Pick(click_pos[0], click_pos[1], 0, self.renderer)
self.pickpoint = np.asarray(picker.GetPickPosition()).reshape((-1, 3))
if np.any(np.isnan(self.pickpoint)):
self.pickpoint[:] = 0
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer integer attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier argument_list tuple unary_operator integer integer if_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier slice integer
|
Register the event for a left button down click
|
def list_conditions(self, service_id, version_number):
content = self._fetch("/service/%s/version/%d/condition" % (service_id, version_number))
return map(lambda x: FastlyCondition(self, x), content)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement call identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier identifier identifier
|
Gets all conditions for a particular service and version.
|
def entries(self):
Tags = Query()
tag = self.table.get(Tags.name == self.name)
posts = tag['post_ids']
for id in posts:
post = self.db.posts.get(doc_id=id)
if not post:
raise ValueError("No post found for doc_id %s" % id)
yield Entry(os.path.join(CONFIG['content_root'], post['filename']), id)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list comparison_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement yield call identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier
|
return the actual lists of entries tagged with
|
def kill(self, block=False, reason="unknown"):
current_greenletid = id(gevent.getcurrent())
trace = "Job killed: %s" % reason
for greenlet, job in context._GLOBAL_CONTEXT["greenlets"].values():
greenletid = id(greenlet)
if job and job.id == self.id and greenletid != current_greenletid:
greenlet.kill(block=block)
trace += "\n\n--- Greenlet %s ---\n" % greenletid
trace += "".join(traceback.format_stack(greenlet.gr_frame))
context._GLOBAL_CONTEXT["greenlets"].pop(greenletid, None)
if reason == "timeout" and self.data["status"] != "timeout":
updates = {
"exceptiontype": "TimeoutInterrupt",
"traceback": trace
}
self._save_status("timeout", updates=updates, exception=False)
|
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end identifier for_statement pattern_list identifier identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator boolean_operator identifier comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end identifier expression_statement augmented_assignment identifier call attribute string string_start string_end identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier none if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier false
|
Forcefully kill all greenlets associated with this job
|
def svg_html_from_pyplot_figure(fig: "Figure") -> str:
if fig is None:
return ""
memfile = io.BytesIO()
fig.savefig(memfile, format="svg")
return memfile.getvalue().decode("utf-8")
|
module function_definition identifier parameters typed_parameter identifier type string string_start string_content string_end type identifier block if_statement comparison_operator identifier none block return_statement string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end
|
Converts a ``pyplot`` figure to an SVG tag.
|
def load(path):
proto = _parse_saved_model(path)
_merge_assets_key_collection(proto, path)
handler = SavedModelHandler()
handler._proto = proto
return handler
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier identifier return_statement identifier
|
Creates a SavedModelHandler from a SavedModel in `path`.
|
def runlogs_policy(log_group_ref):
p = Policy(
Statement=[
Statement(
Effect=Allow,
Resource=[
Join('', [
'arn:aws:logs:*:*:log-group:',
log_group_ref,
':log-stream:*'])],
Action=[
logs.CreateLogStream,
logs.PutLogEvents,
])])
return p
|
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier list call identifier argument_list string string_start string_end list string string_start string_content string_end identifier string string_start string_content string_end keyword_argument identifier list attribute identifier identifier attribute identifier identifier return_statement identifier
|
Policy needed for Empire -> Cloudwatch logs to record run output.
|
def show_vpnservice(self, vpnservice, **_params):
return self.get(self.vpnservice_path % (vpnservice), params=_params)
|
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
|
Fetches information of a specific VPN service.
|
def json(self):
return {
"id": self.ID,
"steps": self.steps,
"graph_source": self.source,
"errored": self.errored
}
|
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
|
Retrun JSON representation for this run
|
def build_valid_keywords_grammar(keywords=None):
from invenio_query_parser.parser import KeywordQuery, KeywordRule, \
NotKeywordValue, SimpleQuery, ValueQuery
if keywords:
KeywordRule.grammar = attr('value', re.compile(
r"(\d\d\d\w{{0,3}}|{0})\b".format("|".join(keywords), re.I)))
NotKeywordValue.grammar = attr('value', re.compile(
r'\b(?!\d\d\d\w{{0,3}}|{0}:)\S+\b:'.format(
":|".join(keywords))))
SimpleQuery.grammar = attr(
'op', [NotKeywordValue, KeywordQuery, ValueQuery])
else:
KeywordRule.grammar = attr('value', re.compile(r"[\w\d]+(\.[\w\d]+)*"))
SimpleQuery.grammar = attr('op', [KeywordQuery, ValueQuery])
|
module function_definition identifier parameters default_parameter identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier line_continuation dotted_name identifier dotted_name identifier dotted_name identifier if_statement identifier block expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end list identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end list identifier identifier
|
Update parser grammar to add a list of allowed keywords.
|
def prepare_fields_attribute(attribute_name, attributes, class_name):
attribute = attributes.get(attribute_name)
if not attribute:
attribute = tuple()
elif isinstance(attribute, std_collections.Iterable):
attribute = tuple(attribute)
else:
raise errors.Error('{0}.{1} is supposed to be a list of {2}, '
'instead {3} given', class_name, attribute_name,
fields.Field, attribute)
return attribute
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block raise_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier identifier attribute identifier identifier identifier return_statement identifier
|
Prepare model fields attribute.
|
def put_info(self, key, value):
return self.instance.put_task_info(self.name, key, value)
|
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier
|
Put associated information of the task.
|
def css(self, *props, **kwprops):
self._stable = False
styles = {}
if props:
if len(props) == 1 and isinstance(props[0], Mapping):
styles = props[0]
else:
raise WrongContentError(self, props, "Arguments not valid")
elif kwprops:
styles = kwprops
else:
raise WrongContentError(self, None, "args OR wkargs are needed")
return self.attr(style=styles)
|
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment identifier dictionary if_statement identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer call identifier argument_list subscript identifier integer identifier block expression_statement assignment identifier subscript identifier integer else_clause block raise_statement call identifier argument_list identifier identifier string string_start string_content string_end elif_clause identifier block expression_statement assignment identifier identifier else_clause block raise_statement call identifier argument_list identifier none string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
|
Adds css properties to this element.
|
def request(self, type, command_list):
req = self._build_request(type, command_list)
if self.nxargs['connect_over_uds']:
self.connection.request('POST', req['url'], req['payload'], req['headers'])
response = self.connection.getresponse()
else:
response = self.connection(req['url'],
method='POST',
opts=req['opts'],
data=req['payload'],
header_dict=req['headers'],
decode=True,
decode_type='json',
**self.nxargs)
return self.parse_response(response, command_list)
|
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end dictionary_splat attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
|
Send NX-API JSON request to the NX-OS device.
|
def send_message(
self,
title=None,
body=None,
icon=None,
data=None,
sound=None,
badge=None,
api_key=None,
**kwargs):
from .fcm import fcm_send_message
result = fcm_send_message(
registration_id=str(self.registration_id),
title=title,
body=body,
icon=icon,
data=data,
sound=sound,
badge=badge,
api_key=api_key,
**kwargs
)
self._deactivate_device_on_error_result(result)
return result
|
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
|
Send single notification message.
|
def _authorization_code_flow(self):
options = {
'scope': getattr(self, 'scope', 'non-expiring'),
'client_id': self.options.get('client_id'),
'response_type': 'code',
'redirect_uri': self._redirect_uri()
}
url = '%s%s/connect' % (self.scheme, self.host)
self._authorize_url = '%s?%s' % (url, urlencode(options))
|
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier
|
Build the the auth URL so the user can authorize the app.
|
def do_list(self, args):
try:
resources = self.resource_manager.list_resources_info()
except Exception as e:
print(e)
else:
self.resources = []
for ndx, (resource_name, value) in enumerate(resources.items()):
if not args:
print('({0:2d}) {1}'.format(ndx, resource_name))
if value.alias:
print(' alias: {}'.format(value.alias))
self.resources.append((resource_name, value.alias or None))
|
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement assignment attribute identifier identifier list for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement not_operator identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier boolean_operator attribute identifier identifier none
|
List all connected resources.
|
def functions(context):
config_file = "./lambder.json"
if os.path.isfile(config_file):
context.obj = FunctionConfig(config_file)
pass
|
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier pass_statement
|
Manage AWS Lambda functions
|
def _check_unique_together(cls):
if cls._meta.unique_together is None:
return
if not isinstance(cls._meta.unique_together, (tuple, list)):
raise ConfigurationError(
"'{}.unique_together' must be a list or tuple.".format(cls.__name__)
)
elif any(
not isinstance(unique_fields, (tuple, list))
for unique_fields in cls._meta.unique_together
):
raise ConfigurationError(
"All '{}.unique_together' elements must be lists or tuples.".format(cls.__name__)
)
else:
for fields_tuple in cls._meta.unique_together:
for field_name in fields_tuple:
field = cls._meta.fields_map.get(field_name)
if not field:
raise ConfigurationError(
"'{}.unique_together' has no '{}' "
"field.".format(cls.__name__, field_name)
)
if isinstance(field, ManyToManyField):
raise ConfigurationError(
"'{}.unique_together' '{}' field refers "
"to ManyToMany field.".format(cls.__name__, field_name)
)
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block return_statement if_statement not_operator call identifier argument_list attribute attribute identifier identifier identifier tuple identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier elif_clause call identifier generator_expression not_operator call identifier argument_list identifier tuple identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block for_statement identifier attribute attribute identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier identifier if_statement call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier identifier
|
Check the value of "unique_together" option.
|
def personastate(self):
if self._personastate == None:
return None
elif self._personastate in self.PersonaState:
return self.PersonaState[self._personastate]
else:
return None
|
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement none elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block return_statement subscript attribute identifier identifier attribute identifier identifier else_clause block return_statement none
|
Return the Persona State of the Users Profile
|
def _run_default_moderator(comment, content_object, request):
if not default_moderator.allow(comment, content_object, request):
return False
if default_moderator.moderate(comment, content_object, request):
comment.is_public = False
|
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier identifier identifier block return_statement false if_statement call attribute identifier identifier argument_list identifier identifier identifier block expression_statement assignment attribute identifier identifier false
|
Run the default moderator
|
def expire_file(filepath):
load_message.cache_clear()
orm.delete(pa for pa in model.PathAlias if pa.entry.file_path == filepath)
orm.delete(item for item in model.Entry if item.file_path == filepath)
orm.commit()
|
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier generator_expression identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier generator_expression identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
|
Expire a record for a missing file
|
def processed_file(self, new_text, filename, old_text=None, write=False,
encoding=None):
self.files.append(filename)
if old_text is None:
old_text = self._read_python_source(filename)[0]
if old_text is None:
return
equal = old_text == new_text
self.print_output(old_text, new_text, filename, equal)
if equal:
self.log_debug("No changes to %s", filename)
if not self.write_unchanged_files:
return
if write:
self.write_file(new_text, filename, old_text, encoding)
else:
self.log_debug("Not writing changes to %s", filename)
|
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier integer if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier comparison_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator attribute identifier identifier block return_statement if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
|
Called when a file has been refactored and there may be changes.
|
def pycomplex(v_str):
assert isinstance(v_str, str)
if v_str[0] == '(' and v_str[-1] == ')' and len(v_str.split(',')) == 2:
v_re, v_im = v_str[1:-1].split(',', 1)
return complex(pyfloat(v_re), pyfloat(v_im))
else:
raise ValueError('{0} must be in complex number form (x, y).'
''.format(v_str))
|
module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier identifier if_statement boolean_operator boolean_operator comparison_operator subscript identifier integer string string_start string_content string_end comparison_operator subscript identifier unary_operator integer string string_start string_content string_end comparison_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer block expression_statement assignment pattern_list identifier identifier call attribute subscript identifier slice integer unary_operator integer identifier argument_list string string_start string_content string_end integer return_statement call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier else_clause block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_end identifier argument_list identifier
|
Convert string repr of Fortran complex to Python complex.
|
def read_text(self, encoding='utf-8') -> str:
with self.open('r', encoding=encoding) as fp:
return fp.read()
|
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end type identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list
|
read all text into memory.
|
def _encode_batched_write_command(
namespace, operation, command, docs, check_keys, opts, ctx):
buf = StringIO()
to_send, _ = _batched_write_command_impl(
namespace, operation, command, docs, check_keys, opts, ctx, buf)
return buf.getvalue(), to_send
|
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier return_statement expression_list call attribute identifier identifier argument_list identifier
|
Encode the next batched insert, update, or delete command.
|
def Jobs(self):
url = self._url + "/jobs"
return Jobs(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
|
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true
|
get the Jobs object
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.