code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def _equivalent(self, other):
if other.__class__ is not self.__class__:
raise NotImplementedError('Cannot compare different model classes. '
'%s is not %s' % (self.__class__.__name__,
other.__class_.__name__))
if set(self._projection) != set(other._projection):
return False
if len(self._properties) != len(other._properties):
return False
my_prop_names = set(self._properties.iterkeys())
their_prop_names = set(other._properties.iterkeys())
if my_prop_names != their_prop_names:
return False
if self._projection:
my_prop_names = set(self._projection)
for name in my_prop_names:
if '.' in name:
name, _ = name.split('.', 1)
my_value = self._properties[name]._get_value(self)
their_value = other._properties[name]._get_value(other)
if my_value != their_value:
return False
return True | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier block return_statement false if_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier block return_statement false expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier identifier block return_statement false if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement false return_statement true | Compare two entities of the same class, excluding keys. |
def rowget(self,tables_dict,row_list,index):
"row_list in self.row_order"
tmp=row_list
for i in self.index_tuple(tables_dict,index,False): tmp=tmp[i]
return tmp | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier identifier false block expression_statement assignment identifier subscript identifier identifier return_statement identifier | row_list in self.row_order |
def add_and_shuffle(self, peer):
self.push_peer(peer)
r = random.randint(0, self.size() - 1)
self.swap_order(peer.index, r) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer binary_operator call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier | Push a new peer into the heap and shuffle the heap |
def _group_by_batches(samples, check_fn):
batch_groups = collections.defaultdict(list)
extras = []
for data in [x[0] for x in samples]:
if check_fn(data):
batch_groups[multi.get_batch_for_key(data)].append(data)
else:
extras.append([data])
return batch_groups, extras | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier list_comprehension subscript identifier integer for_in_clause identifier identifier block if_statement call identifier argument_list identifier block expression_statement call attribute subscript identifier call attribute identifier identifier argument_list identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list list identifier return_statement expression_list identifier identifier | Group calls by batches, processing families together during ensemble calling. |
def save_and_check(response, local_file, expected_checksum):
with open(local_file, 'wb') as handle:
for chunk in response.iter_content(4096):
handle.write(chunk)
actual_checksum = md5sum(local_file)
if actual_checksum != expected_checksum:
logging.error('Checksum mismatch for %r. Expected %r, got %r',
local_file, expected_checksum, actual_checksum)
return False
return True | module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier return_statement false return_statement true | Save the content of an http response and verify the checksum matches. |
def heading(headingtext, headinglevel, lang='en'):
lmap = {'en': 'Heading', 'it': 'Titolo'}
paragraph = makeelement('p')
pr = makeelement('pPr')
pStyle = makeelement(
'pStyle', attributes={'val': lmap[lang]+str(headinglevel)})
run = makeelement('r')
text = makeelement('t', tagtext=headingtext)
pr.append(pStyle)
run.append(text)
paragraph.append(pr)
paragraph.append(run)
return paragraph | module function_definition identifier parameters identifier identifier default_parameter identifier 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 string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end binary_operator subscript identifier identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier 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 identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Make a new heading, return the heading element |
def _connected(self, watcher, events):
self.connected = True
self._finish()
self.deferred.callback(self.sock) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | Connector is successful, return the socket. |
def apmRecent(self, maxMatches=c.RECENT_MATCHES, **criteria):
if not self.matches: return 0
apms = [m.apm(self) for m in self.recentMatches(maxMatches=maxMatches, **criteria)]
return sum(apms) / len(apms) | module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block return_statement integer expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier return_statement binary_operator call identifier argument_list identifier call identifier argument_list identifier | collect recent match history's apm data to report player's calculated MMR |
def update(self, result, spec):
if isinstance(spec, dict):
if spec:
spec_value = next(iter(spec.values()))
for key, value in result.items():
result[key] = self.update(value, spec_value)
if isinstance(spec, list):
if spec:
for i, value in enumerate(result):
result[i] = self.update(value, spec[0])
if isinstance(spec, tuple):
return tuple(self.update(value, s)
for s, value in zip(spec, result))
if callable(spec):
return spec(result)
return result | module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block if_statement identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier subscript identifier integer if_statement call identifier argument_list identifier identifier block return_statement call identifier generator_expression call attribute identifier identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier block return_statement call identifier argument_list identifier return_statement identifier | Replace elements with results of calling callables. |
def snake(s):
if len(s) < 2:
return s.lower()
out = s[0].lower()
for c in s[1:]:
if c.isupper():
out += "_"
c = c.lower()
out += c
return out | module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list for_statement identifier subscript identifier slice integer block if_statement call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier identifier return_statement identifier | Convert from title or camelCase to snake_case. |
def remove_proxy(self, proxy):
del self.search_flag[proxy.protocol][proxy.addr]
del self.addr_list[proxy.protocol][proxy.addr] | module function_definition identifier parameters identifier identifier block delete_statement subscript subscript attribute identifier identifier attribute identifier identifier attribute identifier identifier delete_statement subscript subscript attribute identifier identifier attribute identifier identifier attribute identifier identifier | Remove a proxy out of the pool |
def read_files(*files):
text = ""
for single_file in files:
content = read(single_file)
text = text + content + "\n"
return text | module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier string string_start string_content escape_sequence string_end return_statement identifier | Read files into setup |
def count_rows_duplicates(self, table, cols='*'):
return self.count_rows(table, '*') - self.count_rows_distinct(table, cols) | module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement binary_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier | Get the number of rows that do not contain distinct values. |
def update(self, source_file, configuration, declarations, included_files):
record = record_t(
source_signature=file_signature(source_file),
config_signature=configuration_signature(configuration),
included_files=included_files,
included_files_signature=list(
map(
file_signature,
included_files)),
declarations=declarations)
self.__cache[record.key()] = record
self.__cache[record.key()].was_hit = True
self.__needs_flushed = True | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute subscript attribute identifier identifier call attribute identifier identifier argument_list identifier true expression_statement assignment attribute identifier identifier true | Update a cached record with the current key and value contents. |
def release(self, connection):
"Releases the connection back to the pool."
self._checkpid()
if connection.pid != self.pid:
return
try:
self.pool.put_nowait(connection)
except Full:
pass | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement | Releases the connection back to the pool. |
def _set_value(self, new_value):
if self.min_value is not None and new_value < self.min_value:
raise SettingOutOfBounds(
"Trying to set parameter {0} = {1}, which is less than the minimum allowed {2}".format(
self.name, new_value, self.min_value))
if self.max_value is not None and new_value > self.max_value:
raise SettingOutOfBounds(
"Trying to set parameter {0} = {1}, which is more than the maximum allowed {2}".format(
self.name, new_value, self.max_value))
if self.has_auxiliary_variable():
with warnings.catch_warnings():
warnings.simplefilter("always", RuntimeWarning)
warnings.warn("You are trying to assign to a parameter which is either linked or "
"has auxiliary variables. The assignment has no effect.", RuntimeWarning)
if self._transformation is None:
new_internal_value = new_value
else:
new_internal_value = self._transformation.forward(new_value)
if new_internal_value != self._internal_value:
self._internal_value = new_internal_value
for callback in self._callbacks:
try:
callback(self)
except:
raise NotCallableOrErrorInCall("Could not call callback for parameter %s" % self.name) | module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier attribute identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list block with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier attribute identifier identifier block try_statement block expression_statement call identifier argument_list identifier except_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier | Sets the current value of the parameter, ensuring that it is within the allowed range. |
def load_data(train_path='./data/regression.train', test_path='./data/regression.test'):
print('Load data...')
df_train = pd.read_csv(train_path, header=None, sep='\t')
df_test = pd.read_csv(test_path, header=None, sep='\t')
num = len(df_train)
split_num = int(0.9 * num)
y_train = df_train[0].values
y_test = df_test[0].values
y_eval = y_train[split_num:]
y_train = y_train[:split_num]
X_train = df_train.drop(0, axis=1).values
X_test = df_test.drop(0, axis=1).values
X_eval = X_train[split_num:, :]
X_train = X_train[:split_num, :]
lgb_train = lgb.Dataset(X_train, y_train)
lgb_eval = lgb.Dataset(X_eval, y_eval, reference=lgb_train)
return lgb_train, lgb_eval, X_test, y_test | module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier none keyword_argument identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier none keyword_argument identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator float identifier expression_statement assignment identifier attribute subscript identifier integer identifier expression_statement assignment identifier attribute subscript identifier integer identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list integer keyword_argument identifier integer identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list integer keyword_argument identifier integer identifier expression_statement assignment identifier subscript identifier slice identifier slice expression_statement assignment identifier subscript identifier slice identifier slice expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier return_statement expression_list identifier identifier identifier identifier | Load or create dataset |
def displayMakewcsWarningBox(display=True, parent=None):
if sys.version_info[0] >= 3:
from tkinter.messagebox import showwarning
else:
from tkMessageBox import showwarning
ans = {'yes':True,'no':False}
if ans[display]:
msg = 'Setting "updatewcs=yes" will result '+ \
'in all input WCS values to be recomputed '+ \
'using the original distortion model and alignment.'
showwarning(parent=parent,message=msg, title="WCS will be overwritten!")
return True | module function_definition identifier parameters default_parameter identifier true default_parameter identifier none block if_statement comparison_operator subscript attribute identifier identifier integer integer block import_from_statement dotted_name identifier identifier dotted_name identifier else_clause block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end true pair string string_start string_content string_end false if_statement subscript identifier identifier block expression_statement assignment identifier binary_operator binary_operator 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 keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end return_statement true | Displays a warning box for the 'makewcs' parameter. |
def visit_Stmt(self, node):
save_defs, self.defs = self.defs or list(), list()
self.generic_visit(node)
new_defs, self.defs = self.defs, save_defs
return new_defs + [node] | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier attribute identifier identifier expression_list boolean_operator attribute identifier identifier call identifier argument_list call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier attribute identifier identifier expression_list attribute identifier identifier identifier return_statement binary_operator identifier list identifier | Add new variable definition before the Statement. |
def template_to_dict_iter_debug(elm):
if elm.text is not None:
print(" <%s>%s</%s>" % (elm.tag, elm.text, elm.tag), end='')
if elm.tail is not None:
print(elm.tail)
else:
print()
else:
if elm.tail is not None:
print(" <%s>%s" % (elm.tag, elm.tail))
else:
print(" <%s>" % elm.tag) | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier string string_start string_end if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list attribute identifier identifier else_clause block expression_statement call identifier argument_list else_clause block if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier else_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier | Print expanded element on stdout for debugging |
def associate_flavor(self, flavor, body):
return self.post(self.flavor_profile_bindings_path %
(flavor), body=body) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier | Associate a Neutron service flavor with a profile. |
def _put_attachment_data(self, id, filename, data, content_type, include_online=False):
uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename])
params = {'IncludeOnline': 'true'} if include_online else {}
headers = {'Content-Type': content_type, 'Content-Length': str(len(data))}
return uri, params, 'put', data, headers, False | module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list attribute identifier identifier attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier conditional_expression dictionary pair string string_start string_content string_end string string_start string_content string_end identifier dictionary expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list call identifier argument_list identifier return_statement expression_list identifier identifier string string_start string_content string_end identifier identifier false | Upload an attachment to the Xero object. |
def new(type_dict, type_factory, *type_parameters):
type_tuple = (type_factory,) + type_parameters
if type_tuple not in type_dict:
factory = TypeFactory.get_factory(type_factory)
reified_type = factory.create(type_dict, *type_parameters)
type_dict[type_tuple] = reified_type
return type_dict[type_tuple] | module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement assignment identifier binary_operator tuple identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier expression_statement assignment subscript identifier identifier identifier return_statement subscript identifier identifier | Create a fully reified type from a type schema. |
def end(self):
self.end_time = time.time()
return self.path(), self.duration(), self._self_time(), self.has_label(WorkUnitLabel.TOOL) | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement expression_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier | Mark the time at which this workunit ended. |
def file_path(self) -> str:
user_dir = self.__get_user_path()
file_path = path.abspath(path.join(user_dir, self.FILENAME))
return file_path | module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement identifier | Settings file absolute path |
def put(self, item):
if self.isfini:
return False
self.fifo.append(item)
if len(self.fifo) == 1:
self.event.set()
return True | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement false expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list return_statement true | Add an item to the queue. |
def _verify_validator(self, validator, path):
if not callable(validator):
raise SchemaFormatException("Invalid validations for {}", path)
(args, varargs, keywords, defaults) = getargspec(validator)
if len(args) != 1:
raise SchemaFormatException("Invalid validations for {}", path) | module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment tuple_pattern identifier identifier identifier identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end identifier | Verifies that a given validator associated with the field at the given path is legitimate. |
def create_from_euler_angles(cls, rx, ry, rz, degrees=False):
if degrees:
rx, ry, rz = np.radians([rx, ry, rz])
qx = Quaternion(np.cos(rx/2), 0, 0, np.sin(rx/2))
qy = Quaternion(np.cos(ry/2), 0, np.sin(ry/2), 0)
qz = Quaternion(np.cos(rz/2), np.sin(rz/2), 0, 0)
return qx*qy*qz | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false block if_statement identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list list identifier identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier integer integer integer call attribute identifier identifier argument_list binary_operator identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier integer integer call attribute identifier identifier argument_list binary_operator identifier integer integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier integer call attribute identifier identifier argument_list binary_operator identifier integer integer integer return_statement binary_operator binary_operator identifier identifier identifier | Classmethod to create a quaternion given the euler angles. |
def dot(vec1, vec2):
if isinstance(vec1, Vector2) \
and isinstance(vec2, Vector2):
return ((vec1.X * vec2.X) + (vec1.Y * vec2.Y))
else:
raise TypeError("vec1 and vec2 must be Vector2's") | module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier line_continuation call identifier argument_list identifier identifier block return_statement parenthesized_expression binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end | Calculate the dot product between two Vectors |
def _add_remove(self, action, album, objects, object_type=None,
**kwds):
if not isinstance(objects, collections.Iterable):
objects = [objects]
if object_type is None:
object_type = objects[0].get_type()
for i, obj in enumerate(objects):
if isinstance(obj, TroveboxObject):
if obj.get_type() != object_type:
raise ValueError("Not all objects are of type '%s'"
% object_type)
objects[i] = obj.id
result = self._client.post("/album/%s/%s/%s.json" %
(self._extract_id(album),
object_type, action),
ids=objects, **kwds)["result"]
if isinstance(result, bool):
result = self._client.get("/album/%s/view.json" %
self._extract_id(album))["result"]
return Album(self._client, result) | module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call identifier argument_list identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript identifier identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier dictionary_splat identifier string string_start string_content string_end if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement call identifier argument_list attribute identifier identifier identifier | Common code for the add and remove endpoints. |
def serve(self, app, conf):
if self.args.reload:
try:
self.watch_and_spawn(conf)
except ImportError:
print('The `--reload` option requires `watchdog` to be '
'installed.')
print(' $ pip install watchdog')
else:
self._serve(app, conf) | module function_definition identifier parameters identifier identifier identifier block if_statement attribute attribute identifier identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list concatenated_string 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 else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier | A very simple approach for a WSGI server. |
def prt_tsv(self, prt, goea_results, **kws):
prt_flds = kws.get('prt_flds', self.get_prtflds_default(goea_results))
tsv_data = MgrNtGOEAs(goea_results).get_goea_nts_prt(prt_flds, **kws)
RPT.prt_tsv(prt, tsv_data, **kws) | module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier | Write tab-separated table data |
def close( self ):
if self.db is not None:
self.db.commit()
self.db.close()
self.db = None
return | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none return_statement | Close the db and release memory |
def query_topology_db(self, dict_convert=False, **req):
session = db.get_session()
with session.begin(subtransactions=True):
try:
topo_disc = session.query(DfaTopologyDb).filter_by(**req).all()
except orm_exc.NoResultFound:
LOG.info("No Topology results found for %s", req)
return None
if dict_convert:
return self._convert_topo_obj_dict(topo_disc)
return topo_disc | module function_definition identifier parameters identifier default_parameter identifier false dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item call attribute identifier identifier argument_list keyword_argument identifier true block try_statement block expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list identifier identifier argument_list dictionary_splat identifier identifier argument_list except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none if_statement identifier block return_statement call attribute identifier identifier argument_list identifier return_statement identifier | Query an entry to the topology DB. |
def get(self,style):
level = len(self.stack) -1
while level >= 0:
if style in self.stack[level]:
return self.stack[level][style]
else:
level = level - 1
return None | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier integer while_statement comparison_operator identifier integer block if_statement comparison_operator identifier subscript attribute identifier identifier identifier block return_statement subscript subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier binary_operator identifier integer return_statement none | what's the value of a style at the current stack level |
def bands(self):
if self._bands is None:
self._bands = self._compute_bands()
return self._bands | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement attribute identifier identifier | An iterable of all bands in this scale |
def execute_query(self, payload):
if vars(self).get('oauth'):
if not self.oauth.token_is_valid():
self.oauth.refresh_token()
response = self.oauth.session.get(self.PRIVATE_URL, params= payload, header_auth=True)
else:
response = requests.get(self.PUBLIC_URL, params= payload)
self._response = response
return response | module function_definition identifier parameters identifier identifier block if_statement call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier true else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Execute the query and returns and response |
def _is_pid_running_on_unix(pid):
try:
os.kill(pid, 0)
except OSError as err:
return not err.errno == os.errno.ESRCH
return True | module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier integer except_clause as_pattern identifier as_pattern_target identifier block return_statement not_operator comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier return_statement true | Check if PID is running for Unix systems. |
def add_str(self, seq, name=None, description=""):
self.add_seq(SeqRecord(Seq(seq), id=name, description=description)) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier | Use this method to add a sequence as a string to this fasta. |
def make_query(catalog):
query = {}
request = api.get_request()
index = get_search_index_for(catalog)
limit = request.form.get("limit")
q = request.form.get("q")
if len(q) > 0:
query[index] = q + "*"
else:
return None
portal_type = request.form.get("portal_type")
if portal_type:
if not isinstance(portal_type, list):
portal_type = [portal_type]
query["portal_type"] = portal_type
if limit and limit.isdigit():
query["sort_limit"] = int(limit)
return query | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier binary_operator identifier string string_start string_content string_end else_clause block return_statement none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement boolean_operator identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier return_statement identifier | A function to prepare a query |
def make_index(gff_file):
import gffutils
db_file = gff_file + ".db"
if need_update(gff_file, db_file):
if op.exists(db_file):
os.remove(db_file)
logging.debug("Indexing `{0}`".format(gff_file))
gffutils.create_db(gff_file, db_file, merge_strategy="create_unique")
else:
logging.debug("Load index `{0}`".format(gff_file))
return gffutils.FeatureDB(db_file) | module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier binary_operator identifier string string_start string_content string_end if_statement call identifier argument_list identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Make a sqlite database for fast retrieval of features. |
def schema_columns(self):
t = self.schema_term
columns = []
if t:
for i, c in enumerate(t.children):
if c.term_is("Table.Column"):
p = c.all_props
p['pos'] = i
p['name'] = c.value
p['header'] = self._name_for_col_term(c, i)
columns.append(p)
return columns | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list if_statement identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier 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 call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Return column informatino only from this schema |
def at_rank(self, rank):
s = self
while s:
if s.rank == rank:
return s
s = s.parent
raise ValueError("No node at rank {0} for {1}".format(
rank, self.tax_id)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier while_statement identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier expression_statement assignment identifier attribute identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier | Find the node above this node at rank ``rank`` |
def serialize_on_parent(
self,
parent,
value,
state
):
xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
self._processor.serialize_on_parent(parent, xml_value, state) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier | Serialize the value directory on the parent. |
def _control_longitude(self):
if self.lonm < 0.0:
self.lonm = 360.0 + self.lonm
if self.lonM < 0.0:
self.lonM = 360.0 + self.lonM
if self.lonm > 360.0:
self.lonm = self.lonm - 360.0
if self.lonM > 360.0:
self.lonM = self.lonM - 360.0 | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier float block expression_statement assignment attribute identifier identifier binary_operator float attribute identifier identifier if_statement comparison_operator attribute identifier identifier float block expression_statement assignment attribute identifier identifier binary_operator float attribute identifier identifier if_statement comparison_operator attribute identifier identifier float block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier float if_statement comparison_operator attribute identifier identifier float block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier float | Control on longitude values |
def _next_radiotap_extpm(pkt, lst, cur, s):
if cur is None or (cur.present and cur.present.Ext):
st = len(lst) + (cur is not None)
return lambda *args: RadioTapExtendedPresenceMask(*args, index=st)
return None | module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator comparison_operator identifier none parenthesized_expression boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier parenthesized_expression comparison_operator identifier none return_statement lambda lambda_parameters list_splat_pattern identifier call identifier argument_list list_splat identifier keyword_argument identifier identifier return_statement none | Generates the next RadioTapExtendedPresenceMask |
def post_process(table, post_processors):
table_result = table
for processor in post_processors:
table_result = processor(table_result)
return table_result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier | Applies the list of post processing methods if any |
async def executescript(self, sql_script: str) -> Cursor:
cursor = await self._execute(self._conn.executescript, sql_script)
return Cursor(self, cursor) | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier return_statement call identifier argument_list identifier identifier | Helper to create a cursor and execute a user script. |
def check_conflicts(self):
shutit_global.shutit_global_object.yield_to_draw()
cfg = self.cfg
self.log('PHASE: conflicts', level=logging.DEBUG)
errs = []
self.pause_point('\nNow checking for conflicts between modules', print_input=False, level=3)
for module_id in self.module_ids():
if not cfg[module_id]['shutit.core.module.build']:
continue
conflicter = self.shutit_map[module_id]
for conflictee in conflicter.conflicts_with:
conflictee_obj = self.shutit_map.get(conflictee)
if conflictee_obj is None:
continue
if ((cfg[conflicter.module_id]['shutit.core.module.build'] or
self.is_to_be_built_or_is_installed(conflicter)) and
(cfg[conflictee_obj.module_id]['shutit.core.module.build'] or
self.is_to_be_built_or_is_installed(conflictee_obj))):
errs.append(('conflicter module id: ' + conflicter.module_id + ' is configured to be built or is already built but conflicts with module_id: ' + conflictee_obj.module_id,))
return errs | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end keyword_argument identifier false keyword_argument identifier integer for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator subscript subscript identifier identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier subscript attribute identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block continue_statement if_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator subscript subscript identifier attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier parenthesized_expression boolean_operator subscript subscript identifier attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list tuple binary_operator binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | Checks for any conflicts between modules configured to be built. |
def _connect(self):
timeout = None
if self._options is not None and 'timeout' in self._options:
timeout = self._options['timeout']
if self._client._credentials:
self._connection = self._connection_class(
host=self._node.host,
port=self._node.http_port,
credentials=self._client._credentials,
timeout=timeout)
else:
self._connection = self._connection_class(
host=self._node.host,
port=self._node.http_port,
timeout=timeout)
self.server_version | module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier expression_statement attribute identifier identifier | Use the appropriate connection class; optionally with security. |
def some(arr):
return functools.reduce(lambda x, y: x or (y is not None), arr, False) | module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier boolean_operator identifier parenthesized_expression comparison_operator identifier none identifier false | Return True iff there is an element, a, of arr such that a is not None |
def _set_internal_compiler_error(self):
self.severity = "Low"
self.description_tail += (
" This issue is reported for internal compiler generated code."
)
self.description = "%s\n%s" % (self.description_head, self.description_tail)
self.code = "" | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier parenthesized_expression string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end | Adds the false positive to description and changes severity to low |
def _remove_otiose(lst):
listtype = type([])
while type(lst) == listtype and len(lst) == 1:
lst = lst[0]
return lst | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list list while_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier integer return_statement identifier | lift deeply nested expressions out of redundant parentheses |
def disable_reporting(self):
if self.type == ANALOG:
self.reporting = False
msg = bytearray([REPORT_ANALOG + self.pin_number, 0])
self.board.sp.write(msg)
else:
self.port.disable_reporting() | module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment identifier call identifier argument_list list binary_operator identifier attribute identifier identifier integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list | Disable the reporting of an input pin. |
def sanitize_jid(s):
jid = unicode_to_ascii(s).lower()
jid = WHITESPACE.sub('-', jid)
jid = INVALID_JID_CHARS.sub('', jid)
return jid.strip()[:256] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end identifier return_statement subscript call attribute identifier identifier argument_list slice integer | Generates a valid JID node identifier from a string |
def fromarray(A):
subs = np.nonzero(A)
vals = A[subs]
return sptensor(subs, vals, shape=A.shape, dtype=A.dtype) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier return_statement call identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Create a sptensor from a dense numpy array |
def render_configuration(self, configuration=None):
if configuration is None:
configuration = self.environment
if isinstance(configuration, dict):
return {k: self.render_configuration(v) for k, v in configuration.items()}
elif isinstance(configuration, list):
return [self.render_configuration(x) for x in configuration]
elif isinstance(configuration, Variable):
return configuration.resolve(self.parameters)
else:
return configuration | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block return_statement dictionary_comprehension pair identifier call attribute identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block return_statement identifier | Render variables in configuration object but don't instantiate anything |
def _serialized(self):
return {'title': self.title,
'summary': self.summary,
'areadesc': self.areadesc,
'event': self.event,
'samecodes': self.samecodes,
'zonecodes': self.zonecodes,
'expiration': self.expiration,
'updated': self.updated,
'effective': self.effective,
'published': self.published,
'severity': self.severity,
'category': self.category,
'urgency': self.urgency,
'msgtype': self.msgtype,
'link': self.link,
} | 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 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 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 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 | Provides a sanitized & serializeable dict of the alert mainly for forward & backwards compatibility |
def create_from_config(self, config):
configService = ConfigService()
template = TemplateService()
template.output = config["output"]["location"]
template_file = configService.get_template_from_config(config)
template.input = os.path.basename(template_file)
template.env = Environment(loader=FileSystemLoader(os.path.dirname(template_file)))
return template | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Create a template object file defined in the config object |
def shutdown(self):
sys.stdout = self.old_stdout
sys.stdin = self.old_stdin
self.skt.close()
self.set_continue() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list | Revert stdin and stdout, close the socket. |
def desk_locale(self, locale):
locale = locale.lower().replace('-', '_')
return self.vendor_locale_map.get(locale, locale) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier | Return the Desk-style locale for locale. |
def step(self, action):
if self.done:
raise ValueError("executing action in terminated episode")
self.timestep += 1
self._pre_action(action)
end_time = self.cur_time + self.control_timestep
while self.cur_time < end_time:
self.sim.step()
self.cur_time += self.model_timestep
reward, done, info = self._post_action(action)
return self._get_observation(), reward, done, info | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier while_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier return_statement expression_list call attribute identifier identifier argument_list identifier identifier identifier | Takes a step in simulation with control command @action. |
def _validate_series_dtype(self, series: pd.Series) -> pd.Series:
return series.apply(lambda i: isinstance(i, self.dtype)) | module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type attribute identifier identifier block return_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier attribute identifier identifier | Validate that the series data is the correct dtype. |
def clear_silence(self, kwargs):
self._request('POST', '/silenced/clear', data=json.dumps(kwargs))
return True | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list identifier return_statement true | Clear a silence entry. |
def OnReplaceAll(self, event):
find_string = event.GetFindString()
flags = self._wxflag2flag(event.GetFlags())
replace_string = event.GetReplaceString()
findpositions = self.grid.actions.find_all(find_string, flags)
with undo.group(_("Replace all")):
self.grid.actions.replace_all(findpositions, find_string,
replace_string)
event.Skip() | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier with_statement with_clause with_item call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list | Called when a replace all operation is started |
def pixel_to_geo(pixel, level):
pixel_x = pixel[0]
pixel_y = pixel[1]
map_size = float(TileSystem.map_size(level))
x = (TileSystem.clip(pixel_x, (0, map_size - 1)) / map_size) - 0.5
y = 0.5 - (TileSystem.clip(pixel_y, (0, map_size - 1)) / map_size)
lat = 90 - 360 * atan(exp(-y * 2 * pi)) / pi
lon = 360 * x
return round(lat, 6), round(lon, 6) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier tuple integer binary_operator identifier integer identifier float expression_statement assignment identifier binary_operator float parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier tuple integer binary_operator identifier integer identifier expression_statement assignment identifier binary_operator integer binary_operator binary_operator integer call identifier argument_list call identifier argument_list binary_operator binary_operator unary_operator identifier integer identifier identifier expression_statement assignment identifier binary_operator integer identifier return_statement expression_list call identifier argument_list identifier integer call identifier argument_list identifier integer | Transform from pixel to geo coordinates |
def _pipdeptree(python_bin, package_name: str = None, warn: bool = False) -> typing.Optional[dict]:
cmd = "{} -m pipdeptree --json".format(python_bin)
_LOGGER.debug("Obtaining pip dependency tree using: %r", cmd)
output = run_command(cmd, is_json=True).stdout
if not package_name:
return output
for entry in output:
if entry["package"]["key"].lower() == package_name.lower():
return entry
if warn:
_LOGGER.warning("Package %r was not found in pipdeptree output %r", package_name, output)
return None | module function_definition identifier parameters identifier typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier false type subscript attribute identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier attribute call identifier argument_list identifier keyword_argument identifier true identifier if_statement not_operator identifier block return_statement identifier for_statement identifier identifier block if_statement comparison_operator call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list block return_statement identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement none | Get pip dependency tree by executing pipdeptree tool. |
def render_long_description(self, dirname):
with changedir(dirname):
self.setuptools.check_valid_package()
long_description = self.setuptools.get_long_description()
outfile = abspath('.long-description.html')
self.docutils.publish_string(long_description, outfile, self.styles)
return outfile | module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier attribute identifier identifier return_statement identifier | Convert a package's long description to HTML. |
def list_repo(self):
req = proto.ListRepoRequest()
res = self.stub.ListRepo(req, metadata=self.metadata)
if hasattr(res, 'repo_info'):
return res.repo_info
return [] | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement attribute identifier identifier return_statement list | Returns info about all Repos. |
def _make_unknown_name(self, cursor):
parent = cursor.lexical_parent
pname = self.get_unique_name(parent)
log.debug('_make_unknown_name: Got parent get_unique_name %s',pname)
_cursor_decl = cursor.type.get_declaration()
_i = 0
found = False
for m in parent.get_children():
log.debug('_make_unknown_name child %d %s %s %s',_i,m.kind, m.type.kind,m.location)
if m.kind not in [CursorKind.STRUCT_DECL,CursorKind.UNION_DECL,
CursorKind.CLASS_DECL]:
continue
if m == _cursor_decl:
found = True
break
_i+=1
if not found:
raise NotImplementedError("_make_unknown_name BUG %s"%cursor.location)
_premainer = '_'.join(pname.split('_')[1:])
name = '%s_%d'%(_premainer,_i)
return name | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier integer expression_statement assignment identifier false for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier attribute attribute identifier identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier block continue_statement if_statement comparison_operator identifier identifier block expression_statement assignment identifier true break_statement expression_statement augmented_assignment identifier integer if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end slice integer expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier | Creates a name for unname type |
def bind(self, name):
return _BoundColumnDescr(
dtype=self.dtype,
missing_value=self.missing_value,
name=name,
doc=self.doc,
metadata=self.metadata,
) | module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Bind a `Column` object to its name. |
def safe_log_error(self, error: Exception, *info: str):
self.__do_safe(lambda: self.logger.error(error, *info)) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter list_splat_pattern identifier type identifier block expression_statement call attribute identifier identifier argument_list lambda call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier | Log error failing silently on error |
def _initialize_chrome_driver(self):
try:
print(colored('\nInitializing Headless Chrome...\n', 'yellow'))
self._initialize_chrome_options()
self._chromeDriver = webdriver.Chrome(
chrome_options=self._chromeOptions)
self._chromeDriver.maximize_window()
print(colored('\nHeadless Chrome Initialized.', 'green'))
except Exception as exception:
print(colored('Error - Driver Initialization: ' + format(exception)), 'red') | module function_definition identifier parameters identifier block try_statement block expression_statement call identifier argument_list call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list call identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end | Initializes chrome in headless mode |
def correlations(self):
corr_df = self._sensors_num_df.corr()
corr_names = []
corrs = []
for i in range(len(corr_df.index)):
for j in range(len(corr_df.index)):
c_name = corr_df.index[i]
r_name = corr_df.columns[j]
corr_names.append("%s-%s" % (c_name, r_name))
corrs.append(corr_df.ix[i, j])
corrs_all = pd.DataFrame(index=corr_names)
corrs_all["value"] = corrs
corrs_all = corrs_all.dropna().drop(
corrs_all[(corrs_all["value"] == float(1))].index
)
corrs_all = corrs_all.drop(corrs_all[corrs_all["value"] == float(-1)].index)
corrs_all = corrs_all.sort_values("value", ascending=False)
corrs_all = corrs_all.drop_duplicates()
return corrs_all | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list attribute subscript identifier parenthesized_expression comparison_operator subscript identifier string string_start string_content string_end call identifier argument_list integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute subscript identifier comparison_operator subscript identifier string string_start string_content string_end call identifier argument_list unary_operator integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier | Calculate the correlation coefficients. |
def convolveSpectrumSame(Omega,CrossSection,Resolution=0.1,AF_wing=10.,
SlitFunction=SLIT_RECTANGULAR):
step = Omega[1]-Omega[0]
x = arange(-AF_wing,AF_wing+step,step)
slit = SlitFunction(x,Resolution)
print('step=')
print(step)
print('x=')
print(x)
print('slitfunc=')
print(SlitFunction)
CrossSectionLowRes = convolve(CrossSection,slit,mode='same')*step
return Omega,CrossSectionLowRes,None,None,slit | module function_definition identifier parameters identifier identifier default_parameter identifier float default_parameter identifier float default_parameter identifier identifier block expression_statement assignment identifier binary_operator subscript identifier integer subscript identifier integer expression_statement assignment identifier call identifier argument_list unary_operator identifier binary_operator identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end identifier return_statement expression_list identifier identifier none none identifier | Convolves cross section with a slit function with given parameters. |
def humanize_timedelta(seconds):
hours, remainder = divmod(seconds, 3600)
days, hours = divmod(hours, 24)
minutes, seconds = divmod(remainder, 60)
if days:
result = '{}d'.format(days)
if hours:
result += ' {}h'.format(hours)
if minutes:
result += ' {}m'.format(minutes)
return result
if hours:
result = '{}h'.format(hours)
if minutes:
result += ' {}m'.format(minutes)
return result
if minutes:
result = '{}m'.format(minutes)
if seconds:
result += ' {}s'.format(seconds)
return result
return '{}s'.format(seconds) | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier | Creates a string representation of timedelta. |
def addskip(skips, skip):
if skip < 1:
complain(CoconutInternalException("invalid skip of line " + str(skip)))
else:
skips.append(skip)
return skips | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement call identifier argument_list call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Add a line skip to the skips. |
def make_stereo(attrs_dict, globe):
attr_mapping = [('scale_factor', 'scale_factor_at_projection_origin')]
kwargs = CFProjection.build_projection_kwargs(attrs_dict, attr_mapping)
return ccrs.Stereographic(globe=globe, **kwargs) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier | Handle generic stereographic projection. |
def _clean_params(self, params):
clean_params = {}
for key, value in params.iteritems():
if value is not None:
clean_params[key] = value
return clean_params | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block expression_statement assignment subscript identifier identifier identifier return_statement identifier | Removes parameters whose values are set to None. |
def create(self, publish):
target_url = self.client.get_url('PUBLISH', 'POST', 'create')
r = self.client.request('POST', target_url, json=publish._serialize())
return self.create_from_result(r.json()) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list | Creates a new publish group. |
def create_domain_name(self,
domain_name,
certificate_name,
certificate_body=None,
certificate_private_key=None,
certificate_chain=None,
certificate_arn=None,
lambda_name=None,
stage=None,
base_path=None):
if not certificate_arn:
agw_response = self.apigateway_client.create_domain_name(
domainName=domain_name,
certificateName=certificate_name,
certificateBody=certificate_body,
certificatePrivateKey=certificate_private_key,
certificateChain=certificate_chain
)
else:
agw_response = self.apigateway_client.create_domain_name(
domainName=domain_name,
certificateName=certificate_name,
certificateArn=certificate_arn
)
api_id = self.get_api_id(lambda_name)
if not api_id:
raise LookupError("No API URL to certify found - did you deploy?")
self.apigateway_client.create_base_path_mapping(
domainName=domain_name,
basePath='' if base_path is None else base_path,
restApiId=api_id,
stage=stage
)
return agw_response['distributionDomainName'] | module function_definition identifier parameters 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 default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier 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 call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier conditional_expression string string_start string_end comparison_operator identifier none identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement subscript identifier string string_start string_content string_end | Creates the API GW domain and returns the resulting DNS name. |
def to_match(self):
self.validate()
translation_table = {
u'size': u'size()',
}
match_operator = translation_table.get(self.operator)
if not match_operator:
raise AssertionError(u'Unrecognized operator used: '
u'{} {}'.format(self.operator, self))
template = u'%(inner)s.%(operator)s'
args = {
'inner': self.inner_expression.to_match(),
'operator': match_operator,
}
return template % args | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier 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 expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end identifier return_statement binary_operator identifier identifier | Return a unicode object with the MATCH representation of this UnaryTransformation. |
def validate(self):
schema = Schema(self.__class__.SCHEMA)
resolver = RefResolver.from_schema(
schema,
store=REGISTRY,
)
validate(self, schema, resolver=resolver) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier | Validate that this instance matches its schema. |
def assert_valid(self, instance, value=None):
valid = super(Instance, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
if isinstance(value, HasProperties):
value.validate()
return True | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier if_statement not_operator identifier block return_statement false if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement true | Checks if valid, including HasProperty instances pass validation |
def build_dummies_dict(data):
unique_val_list = unique(data)
output = {}
for val in unique_val_list:
output[val] = (data == val)
return output | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier identifier parenthesized_expression comparison_operator identifier identifier return_statement identifier | Return a dict with unique values as keys and vectors as values |
def decorateSubHeader(title, columnWidths, options):
title = title.lower()
if title != options.sortCategory:
s = "| %*s%*s%*s%*s%*s " % (
columnWidths.getWidth(title, "min"), "min",
columnWidths.getWidth(title, "med"), "med",
columnWidths.getWidth(title, "ave"), "ave",
columnWidths.getWidth(title, "max"), "max",
columnWidths.getWidth(title, "total"), "total")
return s
else:
s = "| "
for field, width in [("min", columnWidths.getWidth(title, "min")),
("med", columnWidths.getWidth(title, "med")),
("ave", columnWidths.getWidth(title, "ave")),
("max", columnWidths.getWidth(title, "max")),
("total", columnWidths.getWidth(title, "total"))]:
if options.sortField == field:
s += "%*s*" % (width - 1, field)
else:
s += "%*s" % (width, field)
s += " "
return s | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier else_clause block expression_statement assignment identifier string string_start string_content string_end for_statement pattern_list identifier identifier list tuple string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end tuple string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end tuple string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end tuple string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end tuple string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end tuple binary_operator identifier integer identifier else_clause block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier | Add a marker to the correct field if the TITLE is sorted on. |
def siblings(self):
return list(filter(lambda x: id(x) != id(self), self.parent.childs)) | module function_definition identifier parameters identifier block return_statement call identifier argument_list call identifier argument_list lambda lambda_parameters identifier comparison_operator call identifier argument_list identifier call identifier argument_list identifier attribute attribute identifier identifier identifier | Returns all the siblings of this element as a list. |
def pad(cls, data):
if sys.version_info > (3, 0):
try:
data = data.encode("utf-8")
except AttributeError:
pass
length = AES.block_size - (len(data) % AES.block_size)
data += bytes([length]) * length
return data
else:
return data + (AES.block_size - len(data) % AES.block_size) * chr(AES.block_size - len(data) % AES.block_size) | module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier tuple integer integer block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression binary_operator call identifier argument_list identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator call identifier argument_list list identifier identifier return_statement identifier else_clause block return_statement binary_operator identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier binary_operator call identifier argument_list identifier attribute identifier identifier call identifier argument_list binary_operator attribute identifier identifier binary_operator call identifier argument_list identifier attribute identifier identifier | Pads data to match AES block size |
def _close_event_stream(self):
self.__subscribed = False
del self.__events[:]
self.__event_handle.clear() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false delete_statement subscript attribute identifier identifier slice expression_statement call attribute attribute identifier identifier identifier argument_list | Stop the Event stream thread. |
def prox_xline(x, step):
if not np.isscalar(x):
x= x[0]
if x > 0.5:
return np.array([0.5])
else:
return np.array([x]) | module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator identifier float block return_statement call attribute identifier identifier argument_list list float else_clause block return_statement call attribute identifier identifier argument_list list identifier | Projection onto line in x |
def print_version(wrapper):
scanner_name = wrapper.get_scanner_name()
server_version = wrapper.get_server_version()
print("OSP Server for {0} version {1}".format(scanner_name, server_version))
protocol_version = wrapper.get_protocol_version()
print("OSP Version: {0}".format(protocol_version))
daemon_name = wrapper.get_daemon_name()
daemon_version = wrapper.get_daemon_version()
print("Using: {0} {1}".format(daemon_name, daemon_version))
print("Copyright (C) 2014, 2015 Greenbone Networks GmbH\n"
"License GPLv2+: GNU GPL version 2 or later\n"
"This is free software: you are free to change"
" and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.") | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list call attribute string string_start string_content 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 expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call identifier argument_list concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content string_end string string_start string_content escape_sequence string_end string string_start string_content string_end | Prints the server version and license information. |
def nepali_number(number):
nepnum = ""
for n in str(number):
nepnum += values.NEPDIGITS[int(n)]
return nepnum | module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier subscript attribute identifier identifier call identifier argument_list identifier return_statement identifier | Convert a number to nepali |
def getVersion():
print('CDFread version:', str(CDF.version) + '.' + str(CDF.release) +
'.' + str(CDF.increment))
print('Date: 2018/01/11') | module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end binary_operator binary_operator binary_operator binary_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end | Shows the code version and last modified date. |
def _unset_magic_constants(self):
if '__FILE__' in self._replace:
del self._replace['__FILE__']
if '__ROUTINE__' in self._replace:
del self._replace['__ROUTINE__']
if '__DIR__' in self._replace:
del self._replace['__DIR__']
if '__LINE__' in self._replace:
del self._replace['__LINE__'] | module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block delete_statement subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block delete_statement subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block delete_statement subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block delete_statement subscript attribute identifier identifier string string_start string_content string_end | Removes magic constants from current replace list. |
def _gatk_extract_reads_cl(data, region, prep_params, tmp_dir):
args = ["PrintReads",
"-L", region_to_gatk(region),
"-R", dd.get_ref_file(data),
"-I", data["work_bam"]]
if "gatk4" in dd.get_tools_off(data):
args = ["--analysis_type"] + args
runner = broad.runner_from_config(data["config"])
return runner.cl_gatk(args, tmp_dir) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier | Use GATK to extract reads from full BAM file. |
def slice(l,num_slices=None,slice_length=None,runts=True,random=False):
if random:
import random
random.shuffle(l)
if not num_slices and not slice_length: return l
if not slice_length: slice_length=int(len(l)/num_slices)
newlist=[l[i:i+slice_length] for i in range(0, len(l), slice_length)]
if runts: return newlist
return [lx for lx in newlist if len(lx)==slice_length] | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true default_parameter identifier false block if_statement identifier block import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator not_operator identifier not_operator identifier block return_statement identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension subscript identifier slice identifier binary_operator identifier identifier for_in_clause identifier call identifier argument_list integer call identifier argument_list identifier identifier if_statement identifier block return_statement identifier return_statement list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator call identifier argument_list identifier identifier | Returns a new list of n evenly-sized segments of the original list |
def do_class(self, element, decl, pseudo):
step = self.state[self.state['current_step']]
actions = step['actions']
strval = self.eval_string_value(element, decl.value)
actions.append(('attrib', ('class', strval))) | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier subscript attribute identifier 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 attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end tuple string string_start string_content string_end identifier | Implement class declaration - pre-match. |
def listofmodeluserfunctions(self):
lines = []
for (name, member) in vars(self.model.__class__).items():
if (inspect.isfunction(member) and
(name not in ('run', 'new2old')) and
('fastaccess' in inspect.getsource(member))):
lines.append((name, member))
run = vars(self.model.__class__).get('run')
if run is not None:
lines.append(('run', run))
for (name, member) in vars(self.model).items():
if (inspect.ismethod(member) and
('fastaccess' in inspect.getsource(member))):
lines.append((name, member))
return lines | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement tuple_pattern identifier identifier call attribute call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list block if_statement parenthesized_expression boolean_operator boolean_operator call attribute identifier identifier argument_list identifier parenthesized_expression comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end parenthesized_expression comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment identifier call attribute call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end identifier for_statement tuple_pattern identifier identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list block if_statement parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier parenthesized_expression comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier | User functions of the model class. |
def _safe_region(region=None, context=None):
ret = region or settings.get("region")
context = context or identity
if not ret:
if not context:
_create_identity()
context = identity
ret = context.get_default_region()
if not ret:
try:
ret = regions[0]
except IndexError:
ret = ""
return ret | module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier identifier if_statement not_operator identifier block if_statement not_operator identifier block expression_statement call identifier argument_list expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block try_statement block expression_statement assignment identifier subscript identifier integer except_clause identifier block expression_statement assignment identifier string string_start string_end return_statement identifier | Value to use when no region is specified. |
def _validate_singletons(self, boxes):
count = self._collect_box_count(boxes)
multiples = [box_id for box_id, bcount in count.items() if bcount > 1]
if 'dtbl' in multiples:
raise IOError('There can only be one dtbl box in a file.') | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier integer if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start string_content string_end | Several boxes can only occur once. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.