code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def prepare_attacks(self): print_header('PREPARING ATTACKS DATA') if not self.ask_when_work_is_populated(self.attack_work): return self.attack_work = eval_lib.AttackWorkPieces( datastore_client=self.datastore_client) print_header('Initializing submissions') self.submissions.init_from_storage_write_to_datastore() if self.verbose: print(self.submissions) print_header('Initializing dataset batches') self.dataset_batches.init_from_storage_write_to_datastore( batch_size=self.batch_size, allowed_epsilon=ALLOWED_EPS, skip_image_ids=[], max_num_images=self.max_dataset_num_images) if self.verbose: print(self.dataset_batches) print_header('Initializing adversarial batches') self.adv_batches.init_from_dataset_and_submissions_write_to_datastore( dataset_batches=self.dataset_batches, attack_submission_ids=self.submissions.get_all_attack_ids()) if self.verbose: print(self.adv_batches) print_header('Preparing attack work pieces') self.attack_work.init_from_adversarial_batches(self.adv_batches.data) self.attack_work.write_all_to_datastore() if self.verbose: print(self.attack_work)
module function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block return_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier expression_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 attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier list keyword_argument identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier expression_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 attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call identifier argument_list attribute identifier identifier
Prepares all data needed for evaluation of attacks.
def make_annotation(self): annotation = dict() for item in dir(self): if len(item) > 0 and item[0] != '_' and \ not inspect.ismethod(getattr(self, item)): annotation[item] = getattr(self, item) return annotation
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call identifier argument_list identifier block if_statement boolean_operator boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end line_continuation not_operator call attribute identifier identifier argument_list call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier return_statement identifier
Returns a dictionary with all properties of the action mention.
def loaded_modules(self): with self._mutex: if not self._loaded_modules: self._loaded_modules = [] for mp in self._obj.get_loaded_modules(): self._loaded_modules.append(utils.nvlist_to_dict(mp.properties)) return self._loaded_modules
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
The list of loaded module profile dictionaries.
def _refresh_token_flow(self): url = '%s%s/oauth2/token' % (self.scheme, self.host) options = { 'grant_type': 'refresh_token', 'client_id': self.options.get('client_id'), 'client_secret': self.options.get('client_secret'), 'refresh_token': self.options.get('refresh_token') } options.update({ 'verify_ssl': self.options.get('verify_ssl', True), 'proxies': self.options.get('proxies', None) }) self.token = wrapped_resource( make_request('post', url, options)) self.access_token = self.token.access_token
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier 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 call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end true pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier
Given a refresh token, obtain a new access token.
def read(cls, filename, offset=None, encoding="iso-8859-1"): with fileutil.opened(filename, "rb") as file: if offset is None: file.seek(-128, 2) else: file.seek(offset) data = file.read(128) return cls.decode(data, encoding=encoding)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list unary_operator integer integer else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Read an ID3v1 tag from a file.
def stored_version(self, name): link_path = self._link_path(name) if not _path_exists(link_path): return None return _file_version(link_path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block return_statement none return_statement call identifier argument_list identifier
Returns the version of file `name` or None if it doesn't exist.
def _readlines(fname, fpointer1=open, fpointer2=open): try: with fpointer1(fname, "r") as fobj: return fobj.readlines() except UnicodeDecodeError: with fpointer2(fname, "r", encoding="utf-8") as fobj: return fobj.readlines()
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier identifier block try_statement 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 return_statement call attribute identifier identifier argument_list except_clause identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list
Read all lines from file.
def countRandomBitFrequencies(numTerms = 100000, percentSparsity = 0.01): counts = SparseMatrix() size = 128*128 counts.resize(1, size) sparseBitmap = SparseMatrix() sparseBitmap.resize(1, size) random.seed(42) numWords=0 for term in xrange(numTerms): bitmap = random.sample(xrange(size), int(size*percentSparsity)) bitmap.sort() sparseBitmap.setRowFromSparse(0, bitmap, [1]*len(bitmap)) counts += sparseBitmap numWords += 1 frequencies = SparseMatrix() frequencies.resize(1, size) frequencies.copy(counts) frequencies.divide(float(numWords)) printFrequencyStatistics(counts, frequencies, numWords, size) frequencyFilename = "bit_frequencies_random.pkl" print "Saving frequency matrix in",frequencyFilename with open(frequencyFilename, "wb") as frequencyPickleFile: pickle.dump(frequencies, frequencyPickleFile) return counts
module function_definition identifier parameters default_parameter identifier integer default_parameter identifier float block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier binary_operator integer integer expression_statement call attribute identifier identifier argument_list integer identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier integer for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer identifier binary_operator list integer call identifier argument_list identifier expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier integer expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier string string_start string_content string_end print_statement string string_start string_content string_end identifier 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 expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Create a uniformly random counts matrix through sampling.
def process_minion_update(self, event_data): tag = event_data['tag'] event_info = event_data['data'] mid = tag.split('/')[-1] if not self.minions.get(mid, None): self.minions[mid] = {} minion = self.minions[mid] minion.update({'grains': event_info['return']}) log.debug("In process minion grains update with minions=%s", self.minions) self.publish_minions()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier none block expression_statement assignment subscript attribute identifier identifier identifier dictionary expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Associate grains data with a minion and publish minion update
def asDictionary(self): template = { "type" : "simple", "symbol" : self._symbol.asDictionary, "label" : self._label, "description" : self._description, "rotationType": self._rotationType, "rotationExpression": self._rotationExpression } return template
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end attribute attribute identifier 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 return_statement identifier
provides a dictionary representation of the object
def make_path_func (*baseparts): from os.path import join base = join (*baseparts) def path_func (*args): return join (base, *args) return path_func
module function_definition identifier parameters list_splat_pattern identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list list_splat identifier function_definition identifier parameters list_splat_pattern identifier block return_statement call identifier argument_list identifier list_splat identifier return_statement identifier
Return a function that joins paths onto some base directory.
def __WaitForInstance(instance, desired_state): print 'Waiting for instance %s to change to %s' % (instance.id, desired_state) while True: try: instance.update() state = instance.state sys.stdout.write('.') sys.stdout.flush() if state == desired_state: break except boto_exception.EC2ResponseError as e: logging.info(e) time.sleep(5) return
module function_definition identifier parameters identifier identifier block print_statement binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier while_statement true block try_statement block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier identifier block break_statement except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer return_statement
Blocks until instance is in desired_state.
def fixed(ctx, number, decimals=2, no_commas=False): value = _round(ctx, number, decimals) format_str = '{:f}' if no_commas else '{:,f}' return format_str.format(value)
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
Formats the given number in decimal format using a period and commas
def parallel_multiplier(items): multiplier = 1 for data in (x[0] for x in items): if (tz.get_in(["config", "algorithm", "align_split_size"], data) is not False and tz.get_in(["algorithm", "align_split_size"], data) is not False): multiplier += 50 return multiplier
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier generator_expression subscript identifier integer for_in_clause identifier identifier block if_statement parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier false comparison_operator call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier false block expression_statement augmented_assignment identifier integer return_statement identifier
Determine if we will be parallelizing items during processing.
def _get_sync_model_vars_op(self): ops = [] for (shadow_v, local_v) in self._shadow_model_vars: ops.append(shadow_v.assign(local_v.read_value())) assert len(ops) return tf.group(*ops, name='sync_{}_model_variables_to_ps'.format(len(ops)))
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement tuple_pattern identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list assert_statement call identifier argument_list identifier return_statement call attribute identifier identifier argument_list list_splat identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier
Get the op to sync local model_variables to PS.
def safe_int_conv(number): try: return int(np.array(number).astype(int, casting='safe')) except TypeError: raise ValueError('cannot safely convert {} to integer'.format(number))
module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Safely convert a single number to integer.
def triggerLogicToStr(self): try: import json except ImportError: return "Cannot dump triggers/dependencies/executes (need json)" retval = "TRIGGERS:\n"+json.dumps(self._allTriggers, indent=3) retval += "\nDEPENDENCIES:\n"+json.dumps(self._allDepdcs, indent=3) retval += "\nTO EXECUTE:\n"+json.dumps(self._allExecutes, indent=3) retval += "\n" return retval
module function_definition identifier parameters identifier block try_statement block import_statement dotted_name identifier except_clause identifier block return_statement string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end return_statement identifier
Print all the trigger logic to a string and return it.
def bfd_parse(data): pkt = packet.Packet(data) i = iter(pkt) eth_pkt = next(i) assert isinstance(eth_pkt, ethernet.ethernet) ipv4_pkt = next(i) assert isinstance(ipv4_pkt, ipv4.ipv4) udp_pkt = next(i) assert isinstance(udp_pkt, udp.udp) udp_payload = next(i) return bfd.bfd.parser(udp_payload)[0]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier assert_statement call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier assert_statement call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier assert_statement call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement subscript call attribute attribute identifier identifier identifier argument_list identifier integer
Parse raw packet and return BFD class from packet library.
def validate_root_vertex_directives(root_ast): directives_present_at_root = set() for directive_obj in root_ast.directives: directive_name = directive_obj.name.value if is_filter_with_outer_scope_vertex_field_operator(directive_obj): raise GraphQLCompilationError(u'Found a filter directive with an operator that is not' u'allowed on the root vertex: {}'.format(directive_obj)) directives_present_at_root.add(directive_name) disallowed_directives = directives_present_at_root & VERTEX_DIRECTIVES_PROHIBITED_ON_ROOT if disallowed_directives: raise GraphQLCompilationError(u'Found prohibited directives on root vertex: ' u'{}'.format(disallowed_directives))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement call identifier argument_list 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 identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier if_statement 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 identifier
Validate the directives that appear at the root vertex field.
def entity_delete(args): msg = "WARNING: this will delete {0} {1} in {2}/{3}".format( args.entity_type, args.entity, args.project, args.workspace) if not (args.yes or _confirm_prompt(msg)): return json_body=[{"entityType": args.entity_type, "entityName": args.entity}] r = fapi.delete_entities(args.project, args.workspace, json_body) fapi._check_response_code(r, 204) if fcconfig.verbosity: print("Succesfully deleted " + args.type + " " + args.entity)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier if_statement not_operator parenthesized_expression boolean_operator attribute identifier identifier call identifier argument_list identifier block return_statement expression_statement assignment identifier list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer if_statement attribute identifier identifier block expression_statement call identifier argument_list 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
Delete entity in a workspace.
def markdown_to_notebook(infile, outfile): with open(infile, 'r') as fin: str = fin.read() str = '' nb = py2jn.py_string_to_notebook(str) py2jn.tools.write_notebook(nb, outfile, nbver=4)
module function_definition identifier parameters 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 expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier integer
Convert a markdown file to a notebook file.
def profile_list(self, provider, lookup='all'): data = {} lookups = self.lookup_profiles(provider, lookup) if not lookups: return data for alias, driver in lookups: if alias not in data: data[alias] = {} if driver not in data[alias]: data[alias][driver] = {} return data
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block return_statement identifier for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier dictionary if_statement comparison_operator identifier subscript identifier identifier block expression_statement assignment subscript subscript identifier identifier identifier dictionary return_statement identifier
Return a mapping of all configured profiles
def precision_at_proportions(self): return plot.precision_at_proportions(self.y_true, self.y_score, ax=_gen_ax())
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier call identifier argument_list
Precision at proportions plot
def draw(self): sizes = self._get_cluster_sizes() self.ax.scatter( self.embedded_centers_[:,0], self.embedded_centers_[:,1], s=sizes, c=self.facecolor, edgecolor=self.edgecolor, linewidth=1, ) for i, pt in enumerate(self.embedded_centers_): self.ax.text( s=str(i), x=pt[0], y=pt[1], va="center", ha="center", fontweight="bold" ) plt.sca(self.ax) return self.ax
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier slice integer subscript attribute identifier identifier slice integer keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier integer for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier subscript identifier integer keyword_argument identifier subscript identifier integer keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Draw the embedded centers with their sizes on the visualization.
def update(self, other): if isinstance(other, self.__class__): return self.client.sunionstore(self.name, [self.name, other.name]) else: return map(self.add, other)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier list attribute identifier identifier attribute identifier identifier else_clause block return_statement call identifier argument_list attribute identifier identifier identifier
Update this set with the union of itself and others.
def update(self): self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_charging_params(self._id) if data and (time.time() - self.__manual_update_time > 60): if data['charging_state'] != "Charging": self.__charger_state = False else: self.__charger_state = True
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier false expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator identifier parenthesized_expression comparison_operator binary_operator call attribute identifier identifier argument_list attribute identifier identifier integer block if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier false else_clause block expression_statement assignment attribute identifier identifier true
Update the charging state of the Tesla Vehicle.
def version_check(self): try: version_info = self['Version'] except KeyError: raise ValidateError('Config file has to have a Version section') try: float(version_info['version']) except KeyError: raise ValidateError('Config file has to have a version section') except ValueError: raise ValidateError('Version has to be a float.') try: version_info['name'] except KeyError: raise ValidateError("Config file has to have a name") return
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement call identifier argument_list subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement
Check if the version entry is in the proper format
def channels_delete(self, room_id=None, channel=None, **kwargs): if room_id: return self.__call_api_post('channels.delete', roomId=room_id, kwargs=kwargs) elif channel: return self.__call_api_post('channels.delete', roomName=channel, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block if_statement identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier elif_clause identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Delete a public channel.
def subsets(self, nid, contract=True): n = self.node(nid) subsets = [] meta = self._meta(nid) if 'subsets' in meta: subsets = meta['subsets'] else: subsets = [] if contract: subsets = [self._contract_subset(s) for s in subsets] return subsets
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier list if_statement identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier return_statement identifier
Retrieves subset ids for a class or ontology object
def plot_convergence(Xdata,best_Y, filename = None): n = Xdata.shape[0] aux = (Xdata[1:n,:]-Xdata[0:n-1,:])**2 distances = np.sqrt(aux.sum(axis=1)) plt.figure(figsize=(10,5)) plt.subplot(1, 2, 1) plt.plot(list(range(n-1)), distances, '-ro') plt.xlabel('Iteration') plt.ylabel('d(x[n], x[n-1])') plt.title('Distance between consecutive x\'s') grid(True) plt.subplot(1, 2, 2) plt.plot(list(range(n)),best_Y,'-o') plt.title('Value of the best selected sample') plt.xlabel('Iteration') plt.ylabel('Best y') grid(True) if filename!=None: savefig(filename) else: plt.show()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator subscript identifier slice integer identifier slice subscript identifier slice integer binary_operator identifier integer slice integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list keyword_argument identifier tuple integer integer expression_statement call attribute identifier identifier argument_list integer integer integer expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list binary_operator identifier integer identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call identifier argument_list true expression_statement call attribute identifier identifier argument_list integer integer integer expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list true if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list
Plots to evaluate the convergence of standard Bayesian optimization algorithms
def assert_string(self, string): fact = lib.EnvAssertString(self._env, string.encode()) if fact == ffi.NULL: raise CLIPSError(self._env) return new_fact(self._env, fact)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier identifier
Assert a fact as string.
def _check_and_flip(arr): if hasattr(arr, 'ndim'): if arr.ndim >= 2: return arr.T else: return arr elif not is_string_like(arr) and iterable(arr): return tuple(_check_and_flip(a) for a in arr) else: return arr
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier integer block return_statement attribute identifier identifier else_clause block return_statement identifier elif_clause boolean_operator not_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement call identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier else_clause block return_statement identifier
Transpose array or list of arrays if they are 2D.
def data_filler_company(self, number_of_rows, pipe): try: for i in range(number_of_rows): pipe.hmset('company:%s' % i, { 'id': rnd_id_generator(self), 'name': self.faker.company(), 'date': self.faker.date(pattern="%d-%m-%Y"), 'email': self.faker.company_email(), 'domain': self.faker.safe_email(), 'city': self.faker.city() }) pipe.execute() logger.warning('companies Commits are successful after write job!', extra=d) except Exception as e: logger.error(e, extra=d)
module function_definition identifier parameters identifier identifier identifier block try_statement block for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
creates keys with company data
def import_dashboards(path, recursive): p = Path(path) files = [] if p.is_file(): files.append(p) elif p.exists() and not recursive: files.extend(p.glob('*.json')) elif p.exists() and recursive: files.extend(p.rglob('*.json')) for f in files: logging.info('Importing dashboard from file %s', f) try: with f.open() as data_stream: dashboard_import_export.import_dashboards( db.session, data_stream) except Exception as e: logging.error('Error when importing dashboard from file %s', f) logging.error(e)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier elif_clause boolean_operator call attribute identifier identifier argument_list not_operator identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end elif_clause boolean_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier try_statement block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier 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 identifier
Import dashboards from JSON
def create_csr(key_file, organization_name, common_name, serial_number, file_): key = crypto.load_privatekey(crypto.FILETYPE_PEM, key_file.read()) req = crypto.X509Req() subj = req.get_subject() subj.O = organization_name subj.CN = common_name subj.serialNumber = serial_number req.set_pubkey(key) req.sign(key, 'md5') file_.write(crypto.dump_certificate_request(crypto.FILETYPE_PEM, req))
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier
Create a CSR for a key, and save it into ``file``.
def class_parameters(decorator): def decorate(the_class): if not isclass(the_class): raise TypeError( 'class_parameters(the_class=%s) you must pass a class' % ( the_class ) ) for attr in the_class.__dict__: if callable( getattr( the_class, attr)): setattr( the_class, attr, decorator( getattr(the_class, attr))) return the_class return decorate
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier for_statement identifier attribute identifier identifier block if_statement call identifier argument_list call identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier call identifier argument_list call identifier argument_list identifier identifier return_statement identifier return_statement identifier
To wrap all class methods with static_parameters decorator
def _remove_last(votes, fpl, cl, ranking): for v in votes: for r in v: if r == fpl[-1]: v.remove(r) for c in cl: if c == fpl[-1]: if c not in ranking: ranking.append((c, len(ranking) + 1))
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier identifier block for_statement identifier identifier block if_statement comparison_operator identifier subscript identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier subscript identifier unary_operator integer block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list tuple identifier binary_operator call identifier argument_list identifier integer
Remove last candidate in IRV voting.
def tear_down_instances(self): self.info_log('Tearing down all instances...') for instance in self.alive_instances: instance.tear_down() self.info_log('[Done]Tearing down all instances')
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Tear down all instances
def dict_isect_combine(dict1, dict2, combine_op=op.add): keys3 = set(dict1.keys()).intersection(set(dict2.keys())) dict3 = {key: combine_op(dict1[key], dict2[key]) for key in keys3} return dict3
module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list call attribute identifier identifier argument_list identifier argument_list call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list subscript identifier identifier subscript identifier identifier for_in_clause identifier identifier return_statement identifier
Intersection of dict keys and combination of dict values
def _name_things(self): edges = {} nodes = {None: 'root'} for n in self._tree.postorder_node_iter(): nodes[n] = '.'.join([str(x.taxon) for x in n.leaf_nodes()]) for e in self._tree.preorder_edge_iter(): edges[e] = ' ---> '.join([nodes[e.tail_node], nodes[e.head_node]]) r_edges = {value: key for key, value in edges.items()} r_nodes = {value: key for key, value in nodes.items()} return edges, nodes, r_edges, r_nodes
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary pair none string string_start string_content string_end for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list attribute identifier identifier for_in_clause identifier call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute string string_start string_content string_end identifier argument_list list subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier identifier identifier
Easy names for debugging
def group(self): split_count = self._url.lower().find("/content/") len_count = len('/content/') gURL = self._url[:self._url.lower().find("/content/")] + \ "/community/" + self._url[split_count+ len_count:] return CommunityGroup(url=gURL, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list 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 binary_operator binary_operator subscript attribute identifier identifier slice call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end subscript attribute identifier identifier slice binary_operator identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
returns the community.Group class for the current group
def _extract_html_hex(string): try: hex_string = string and _hex_regexp().search(string).group(0) or '' except AttributeError: return None if len(hex_string) == 3: hex_string = hex_string[0] * 2 + hex_string[1] * 2 + hex_string[2] * 2 return hex_string
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier boolean_operator boolean_operator identifier call attribute call attribute call identifier argument_list identifier argument_list identifier identifier argument_list integer string string_start string_end except_clause identifier block return_statement none if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator binary_operator binary_operator subscript identifier integer integer binary_operator subscript identifier integer integer binary_operator subscript identifier integer integer return_statement identifier
Get the first 3 or 6 hex digits in the string
def _login_snmp(self): logger.info("Trying to grab stats by SNMP...") from glances.stats_client_snmp import GlancesStatsClientSNMP self.stats = GlancesStatsClientSNMP(config=self.config, args=self.args) if not self.stats.check_snmp(): self.log_and_exit("Connection to SNMP server failed") return False return True
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false return_statement true
Login to a SNMP server
def compute_gmfs(rupgetter, srcfilter, param, monitor): getter = GmfGetter(rupgetter, srcfilter, param['oqparam']) with monitor('getting ruptures'): getter.init() return getter.compute_gmfs_curves(monitor)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier subscript identifier string string_start string_content string_end with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
Compute GMFs and optionally hazard curves
def _rotate(pair, step): step = Step(step) movement = { "U": "RFLB", "D": "LFRB", "R": "FUBD", "L": "FDBU", "F": "URDL", "B": "ULDR", }[step.face] movement = { movement[i]: movement[(i + step.is_clockwise + (-1 * step.is_counter_clockwise) + (2 * step.is_180)) % 4] for i in range(4) } for cubie in pair: if step.face not in cubie: if cubie.type == "edge": result_edge = cubie.copy() else: result_corner = cubie.copy() else: result = {} for face, square in cubie: if face not in movement: result[face] = square else: result[movement[face]] = square if len(result) == 2: result_edge = Edge(**result) else: result_corner = Corner(**result) return (result_corner, result_edge)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier dictionary_comprehension pair subscript identifier identifier subscript identifier binary_operator parenthesized_expression binary_operator binary_operator binary_operator identifier attribute identifier identifier parenthesized_expression binary_operator unary_operator integer attribute identifier identifier parenthesized_expression binary_operator integer attribute identifier identifier integer for_in_clause identifier call identifier argument_list integer for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier subscript identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier else_clause block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier return_statement tuple identifier identifier
Simulate the cube rotation by updating the pair.
def schema(self): if not hasattr(self, "_schema"): ret = None o = self._type if isinstance(o, type): ret = getattr(o, "schema", None) elif isinstance(o, Schema): ret = o else: module, klass = utils.get_objects(o) ret = klass.schema self._schema = ret return self._schema
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier none expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
return the schema instance if this is reference to another table
def reference(self, tkn: str): return self.grammarelts[tkn] if tkn in self.grammarelts else UndefinedElement(tkn)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block return_statement conditional_expression subscript attribute identifier identifier identifier comparison_operator identifier attribute identifier identifier call identifier argument_list identifier
Return the element that tkn represents
def compare_arrays(left, right): "Eq check with a short-circuit for identical objects." return ( left is right or ((left.shape == right.shape) and (left == right).all()) )
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end return_statement parenthesized_expression boolean_operator comparison_operator identifier identifier parenthesized_expression boolean_operator parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier call attribute parenthesized_expression comparison_operator identifier identifier identifier argument_list
Eq check with a short-circuit for identical objects.
def etree(A): assert isinstance(A,spmatrix), "A must be a sparse matrix" assert A.size[0] == A.size[1], "A must be a square matrix" n = A.size[0] cp,ri,_ = A.CCS parent = matrix(0,(n,1)) w = matrix(0,(n,1)) for k in range(n): parent[k] = k w[k] = -1 for p in range(cp[k],cp[k+1]): i = ri[p] while ((not i == -1) and (i < k)): inext = w[i] w[i] = k if inext == -1: parent[i] = k i = inext; return parent
module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end assert_statement comparison_operator subscript attribute identifier identifier integer subscript attribute identifier identifier integer string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment pattern_list identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list integer tuple identifier integer expression_statement assignment identifier call identifier argument_list integer tuple identifier integer for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier expression_statement assignment subscript identifier identifier unary_operator integer for_statement identifier call identifier argument_list subscript identifier identifier subscript identifier binary_operator identifier integer block expression_statement assignment identifier subscript identifier identifier while_statement parenthesized_expression boolean_operator parenthesized_expression not_operator comparison_operator identifier unary_operator integer parenthesized_expression comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier identifier identifier if_statement comparison_operator identifier unary_operator integer block expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier identifier return_statement identifier
Compute elimination tree from upper triangle of A.
def config_cython(): if not with_cython: return [] if os.name == 'nt': print("WARNING: Cython is not supported on Windows, will compile without cython module") return [] try: from Cython.Build import cythonize if sys.version_info >= (3, 0): subdir = "_cy3" else: subdir = "_cy2" ret = [] path = "mxnet/cython" if os.name == 'nt': library_dirs = ['mxnet', '../build/Release', '../build'] libraries = ['libmxnet'] else: library_dirs = None libraries = None for fn in os.listdir(path): if not fn.endswith(".pyx"): continue ret.append(Extension( "mxnet/%s/.%s" % (subdir, fn[:-4]), ["mxnet/cython/%s" % fn], include_dirs=["../include/", "../3rdparty/tvm/nnvm/include"], library_dirs=library_dirs, libraries=libraries, language="c++")) return cythonize(ret) except ImportError: print("WARNING: Cython is not installed, will compile without cython module") return []
module function_definition identifier parameters block if_statement not_operator identifier block return_statement list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end return_statement list try_statement block import_from_statement dotted_name identifier identifier dotted_name identifier if_statement comparison_operator attribute identifier identifier tuple integer integer block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier 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 list string string_start string_content string_end else_clause block expression_statement assignment identifier none expression_statement assignment identifier none for_statement identifier call attribute identifier identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement call attribute identifier identifier argument_list call identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier slice unary_operator integer list binary_operator string string_start string_content string_end identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement list
Try to configure cython and return cython configuration
async def _get_user(self): if self._cache is None: try: self._cache = \ await self.facebook.get_user(self.fbid, self.page_id) except PlatformOperationError: self._cache = {} return self._cache
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block try_statement block expression_statement assignment attribute identifier identifier line_continuation await call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier dictionary return_statement attribute identifier identifier
Get the user dict from cache or query it from the platform if missing.
def __visit_index_model_instance(self, models, p, k, v): cp = p + (k,) for model in models: try: if model.validator(v): if cp in self.path_index: self.path_index[cp].add_model(model, v) else: self.path_index[cp] = PathCacheObject(val=v, path=cp, regs=[model]) except: pass
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier tuple identifier for_statement identifier identifier block try_statement block if_statement call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier list identifier except_clause block pass_statement
Called during model research on merged data
def list_ikepolicies(self, retrieve_all=True, **_params): return self.list('ikepolicies', self.ikepolicies_path, retrieve_all, **_params)
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier
Fetches a list of all configured IKEPolicies for a project.
def join(self): self._root_state.join() if len(self._execution_histories) > 0: if self._execution_histories[-1].execution_history_storage is not None: set_read_and_writable_for_all = global_config.get_config_value("EXECUTION_LOG_SET_READ_AND_WRITABLE_FOR_ALL", False) self._execution_histories[-1].execution_history_storage.close(set_read_and_writable_for_all) from rafcon.core.states.state import StateExecutionStatus self._root_state.state_execution_status = StateExecutionStatus.INACTIVE
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block if_statement comparison_operator attribute subscript attribute identifier identifier unary_operator integer identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement call attribute attribute subscript attribute identifier identifier unary_operator integer identifier identifier argument_list identifier import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier
Wait for root state to finish execution
def parse_restriction_dist(self, f): parsed_data = dict() firstline = True for l in f['f']: if firstline: firstline = False continue s = l.split("\t") if len(s) > 1: nuc = float(s[0].strip()) v1 = float(s[1].strip()) v2 = float(s[2].strip()) v = v1 + v2 parsed_data.update({nuc:v}) return parsed_data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier true for_statement identifier subscript identifier string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier false continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair identifier identifier return_statement identifier
Parse HOMER tagdirectory petagRestrictionDistribution file.
def emergency(self): self.send(at.REF(at.REF.input.select))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier
Sends the emergency command.
def build_service(name=None, **kwargs): if name is not None: for kw, value in iteritems(SERVICES[name]): kwargs.setdefault(kw, value) return apiclient.discovery.build(**kwargs)
module function_definition identifier parameters default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block for_statement pattern_list identifier identifier call identifier argument_list subscript identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
Return a service endpoint for interacting with a Google API.
def _is_kpoint(line): toks = line.split() if len(toks) != 4: return False try: xs = [float(x) for x in toks[:3]] w = float(toks[3]) return all(abs(x) <= 0.5 for x in xs) and w >= 0.0 and w <= 1.0 except ValueError: return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block return_statement false try_statement block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier subscript identifier slice integer expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement boolean_operator boolean_operator call identifier generator_expression comparison_operator call identifier argument_list identifier float for_in_clause identifier identifier comparison_operator identifier float comparison_operator identifier float except_clause identifier block return_statement false
Is this line the start of a new k-point block
def tab_change(self, event): self.remove_error() if event.new == 1: self.widget.disabled = False
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment attribute attribute identifier identifier identifier false
When tab changes remove error, and enable widget if on url tab
def write_ply(self, output_file): points = np.hstack([self.coordinates, self.colors]) with open(output_file, 'w') as outfile: outfile.write(self.ply_header.format( vertex_count=len(self.coordinates))) np.savetxt(outfile, points, '%f %f %f %d %d %d')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list attribute identifier identifier attribute identifier identifier 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 expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end
Export ``PointCloud`` to PLY file for viewing in MeshLab.
def firstAttr(self, *attrs): for attr in attrs: value = self.__dict__.get(attr) if value is not None: return value
module function_definition identifier parameters identifier list_splat_pattern identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement identifier
Return the first attribute in attrs that is not None.
def export(outfile): if not nav: sys.exit(1) ecode = 0 savelist = list() for imageId in imagelist: try: record = {} record['image'] = {} record['image']['imageId'] = imageId record['image']['imagedata'] = contexts['anchore_db'].load_image_new(imageId) savelist.append(record) except Exception as err: anchore_print_err("could not find record for image ("+str(imageId)+")") ecode = 1 if ecode == 0: try: if outfile == '-': print json.dumps(savelist, indent=4) else: with open(outfile, 'w') as OFH: OFH.write(json.dumps(savelist)) except Exception as err: anchore_print_err("operation failed: " + str(err)) ecode = 1 sys.exit(ecode)
module function_definition identifier parameters identifier block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block try_statement block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier integer if_statement comparison_operator identifier integer block try_statement block if_statement comparison_operator identifier string string_start string_content string_end block print_statement call attribute identifier identifier argument_list identifier keyword_argument identifier integer else_clause 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 expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list identifier
Export image anchore data to a JSON file.
def visdom_send_metrics(vis, metrics, update='replace'): visited = {} sorted_metrics = sorted(metrics.columns, key=_column_original_name) for metric_basename, metric_list in it.groupby(sorted_metrics, key=_column_original_name): metric_list = list(metric_list) for metric in metric_list: if vis.win_exists(metric_basename) and (not visited.get(metric, False)): update = update elif not vis.win_exists(metric_basename): update = None else: update = 'append' vis.line( metrics[metric].values, metrics.index.values, win=metric_basename, name=metric, opts={ 'title': metric_basename, 'showlegend': True }, update=update ) if metric_basename != metric and len(metric_list) > 1: if vis.win_exists(metric): update = update else: update = None vis.line( metrics[metric].values, metrics.index.values, win=metric, name=metric, opts={ 'title': metric, 'showlegend': True }, update=update )
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list identifier parenthesized_expression not_operator call attribute identifier identifier argument_list identifier false block expression_statement assignment identifier identifier elif_clause not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier none else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute subscript identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end true keyword_argument identifier identifier if_statement boolean_operator comparison_operator identifier identifier comparison_operator call identifier argument_list identifier integer block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list attribute subscript identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end true keyword_argument identifier identifier
Send set of metrics to visdom
def create_module(module, target): module_x = module.split('.') cur_path = '' for path in module_x: cur_path = os.path.join(cur_path, path) if not os.path.isdir(os.path.join(target, cur_path)): os.mkdir(os.path.join(target, cur_path)) if not os.path.exists(os.path.join(target, cur_path, '__init__.py')): touch(os.path.join(target, cur_path, '__init__.py')) return cur_path
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end return_statement identifier
Create a module directory structure into the target directory.
def analysis(self): if self._analysis is None: with open(self.path, 'rb') as f: self.read_analysis(f) return self._analysis
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Get ANALYSIS segment of the FCS file.
def _read(name): logging.debug("Reading config-file: %s" % name) try: with open(name, "r") as config_file: prm_dict = yaml.load(config_file) except yaml.YAMLError: raise yaml.YAMLErrorr else: return prm_dict
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier try_statement 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 expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause attribute identifier identifier block raise_statement attribute identifier identifier else_clause block return_statement identifier
read the yml file
def next_intent_handler(request): message = "Sorry, couldn't find anything in your next queue" end_session = True if True: user_queue = twitter_cache.user_queue(request.access_token()) if not user_queue.is_finished(): message = user_queue.read_out_next(MAX_RESPONSE_TWEETS) if not user_queue.is_finished(): end_session = False message = message + ". Please, say 'next' if you want me to read out more. " return alexa.create_response(message=message, end_session=end_session)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier true if_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier false expression_statement assignment identifier binary_operator identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Takes care of things whenver the user says 'next'
def _point_estimate(X_val, XM_val, M_val, y_val, idx, n_mediator, mtype='linear'): beta_m = [] for j in range(n_mediator): if mtype == 'linear': beta_m.append(linear_regression(X_val[idx], M_val[idx, j], coef_only=True)[1]) else: beta_m.append(logistic_regression(X_val[idx], M_val[idx, j], coef_only=True)[1]) beta_y = linear_regression(XM_val[idx], y_val[idx], coef_only=True)[2:(2 + n_mediator)] return beta_m * beta_y
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript call identifier argument_list subscript identifier identifier subscript identifier identifier identifier keyword_argument identifier true integer else_clause block expression_statement call attribute identifier identifier argument_list subscript call identifier argument_list subscript identifier identifier subscript identifier identifier identifier keyword_argument identifier true integer expression_statement assignment identifier subscript call identifier argument_list subscript identifier identifier subscript identifier identifier keyword_argument identifier true slice integer parenthesized_expression binary_operator integer identifier return_statement binary_operator identifier identifier
Point estimate of indirect effect based on bootstrap sample.
def make_empty(self, axes=None): if axes is None: axes = [ensure_index([])] + [ensure_index(a) for a in self.axes[1:]] if self.ndim == 1: blocks = np.array([], dtype=self.array_dtype) else: blocks = [] return self.__class__(blocks, axes)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator list call identifier argument_list list list_comprehension call identifier argument_list identifier for_in_clause identifier subscript attribute identifier identifier slice integer if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list list keyword_argument identifier attribute identifier identifier else_clause block expression_statement assignment identifier list return_statement call attribute identifier identifier argument_list identifier identifier
return an empty BlockManager with the items axis of len 0
def _filter_by_statement(self, statement): self.__class__._check_conditional_statement(statement, 1) _filt_values, _filt_datetimes = [], [] for i, a in enumerate(self._values): if eval(statement, {'a': a}): _filt_values.append(a) _filt_datetimes.append(self.datetimes[i]) return _filt_values, _filt_datetimes
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment pattern_list identifier identifier expression_list list list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement call identifier argument_list identifier dictionary pair string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier return_statement expression_list identifier identifier
Filter the data collection based on a conditional statement.
def representCleanOpenAPIOperation(dumper, data): dct = _orderedCleanDict(data) if '_extended' in dct: for k, ext in list(data._extended.items()): dct[k] = ext del dct['_extended'] return dumper.yaml_representers[type(dct)](dumper, dct)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier delete_statement subscript identifier string string_start string_content string_end return_statement call subscript attribute identifier identifier call identifier argument_list identifier argument_list identifier identifier
Unpack nonstandard attributes while representing an OpenAPIOperation
def calmarnorm(sharpe, T, tau = 1.0): return calmar(sharpe,tau)/calmar(sharpe,T)
module function_definition identifier parameters identifier identifier default_parameter identifier float block return_statement binary_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier
Multiplicator for normalizing calmar ratio to period tau
def error_response(response): if response.status_code >= 500: raise exceptions.GeocodioServerError elif response.status_code == 403: raise exceptions.GeocodioAuthError elif response.status_code == 422: raise exceptions.GeocodioDataError(response.json()["error"]) else: raise exceptions.GeocodioError( "Unknown service error (HTTP {0})".format(response.status_code) )
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block raise_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier integer block raise_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier integer block raise_statement call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier
Raises errors matching the response code
def _init_record(self, record_type_idstr): record_type_data = self._all_supported_record_type_data_sets[Id(record_type_idstr).get_identifier()] module = importlib.import_module(record_type_data['module_path']) record = getattr(module, record_type_data['query_record_class_name']) self._records[record_type_idstr] = record(self)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier
Initializes a query record
def add_posts(self, path='posts'): path = os.path.join(self.root_path, path) self.cm.add_posts([ self.cm.Post.from_file(file) for file in _listfiles(path) ])
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list_comprehension call attribute attribute attribute identifier identifier identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier
Look through a directory for markdown files and add them as posts.
def _register_extensions(self, namespace): extmanager = ExtensionManager( 'extensions.classes.{}'.format(namespace), propagate_map_exceptions=True ) if extmanager.extensions: extmanager.map(util.register_extension_class, base=self) extmanager = ExtensionManager( 'extensions.methods.{}'.format(namespace), propagate_map_exceptions=True ) if extmanager.extensions: extmanager.map(util.register_extension_method, base=self)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier true if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier true if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Register any extensions under the given namespace.
def add(self, items): for item in items: if item.ack_id not in self._leased_messages: self._leased_messages[item.ack_id] = _LeasedMessage( added_time=time.time(), size=item.byte_size ) self._bytes += item.byte_size else: _LOGGER.debug("Message %s is already lease managed", item.ack_id)
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
Add messages to be managed by the leaser.
def _set_time(self, time): if len(self.time) == 0 : self.time = np.array(time) if self.h5 is not None: self.h5.create_dataset('time', self.time.shape, dtype=self.time.dtype, data=self.time, compression="gzip", shuffle=True, scaleoffset=3) else: if(len(time) != len(self.time)): raise AssertionError("\nTime or number of frame mismatch in input files.\n Exiting...\n")
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier integer else_clause block if_statement parenthesized_expression comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end
Set time in both class and hdf5 file
def remove_device(self, path): "Remove a device from the daemon's internal search list." if self.__get_control_socket(): self.sock.sendall("-%s\r\n\x00" % path) self.sock.recv(12) self.sock.close()
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list
Remove a device from the daemon's internal search list.
def list_commands(self, ctx): config = load_config(**self.load_config_kwargs) services = self._get_services_config(config) return sorted(services.keys())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list
list the services that can be configured
def _from_dict(self, obj_dict): self._n_folds = obj_dict["param"]["n_folds"] self._n_rows = obj_dict["param"]["n_rows"] self._use_stored_folds = obj_dict["param"]["use_stored_folds"] self._concise_model = Concise.from_dict(obj_dict["init_model"]) if obj_dict["trained_global_model"] is None: self._concise_global_model = None else: self._concise_global_model = Concise.from_dict(obj_dict["trained_global_model"]) self._kf = [(fold, np.asarray(train), np.asarray(test)) for fold, train, test in obj_dict["folds"]] self._cv_model = {fold: Concise.from_dict(model_dict) for fold, model_dict in obj_dict["output"].items()}
module function_definition identifier parameters identifier identifier block 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 attribute identifier identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end 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 attribute identifier identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end none block expression_statement assignment attribute identifier identifier none else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier list_comprehension tuple identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list
Initialize a model from the dictionary
def _log(code, message, level, domain): entry = LogEntry(level, domain, code, message) Logger.journal.append(entry) if Logger.silent: return if level >= Logger._verbosity: _print_entry(entry)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block return_statement if_statement comparison_operator identifier attribute identifier identifier block expression_statement call identifier argument_list identifier
Call this to add an entry in the journal
def setBranch(self, *args, **kwargs): try: branch = self.mambubranchclass(entid=self['assignedBranchKey'], *args, **kwargs) except AttributeError as ae: from .mambubranch import MambuBranch self.mambubranchclass = MambuBranch branch = self.mambubranchclass(entid=self['assignedBranchKey'], *args, **kwargs) self['assignedBranchName'] = branch['name'] self['assignedBranch'] = branch return 1
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end list_splat identifier dictionary_splat identifier expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement integer
Adds the branch to which the client belongs.
def astral(msg): utf32 = msg.encode("utf32")[4:] code_points = struct.unpack("%dI" % (len(utf32) / 4), utf32) return any(cp > 0xFFFF for cp in code_points)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end slice integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator call identifier argument_list identifier integer identifier return_statement call identifier generator_expression comparison_operator identifier integer for_in_clause identifier identifier
Does `msg` have characters outside the Basic Multilingual Plane?
def AsPrimitiveProto(self): if self.protobuf: result = self.protobuf() result.ParseFromString(self.SerializeToString()) return result
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Return an old style protocol buffer object.
def getRawIdent(self, node): if node is self: return node ident = getattr(node, 'graphident', None) return ident
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none return_statement identifier
Get the identifier for a node object
def parse(self): try: self.parsed_data = json.loads(self.data) except UnicodeError as e: self.parsed_data = json.loads(self.data.decode('latin1')) except Exception as e: raise Exception('Error while converting response from JSON to python. %s' % e) if self.parsed_data.get('type', '') != 'FeatureCollection': raise Exception('GeoJson synchronizer expects a FeatureCollection object at root level') self.parsed_data = self.parsed_data['features']
module function_definition identifier parameters identifier block try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end
parse geojson and ensure is collection
def diskdata(): p = os.popen("/bin/df -l -P") ddata = {} tsize = 0 for line in p.readlines(): d = line.split() if ("/dev/sd" in d[0] or "/dev/hd" in d[0] or "/dev/mapper" in d[0]): tsize = tsize + int(d[1]) ddata["Disk_GB"] = int(tsize)/1000000 p.close() return ddata
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator string string_start string_content string_end subscript identifier integer comparison_operator string string_start string_content string_end subscript identifier integer comparison_operator string string_start string_content string_end subscript identifier integer block expression_statement assignment identifier binary_operator identifier call identifier argument_list subscript identifier integer expression_statement assignment subscript identifier string string_start string_content string_end binary_operator call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list return_statement identifier
Get total disk size in GB.
def _check_stringify_year_column(self, column_index): table_column = TableTranspose(self.table)[column_index] prior_year = None for row_index in range(self.start[0]+1, self.end[0]): current_year = table_column[row_index] if not self._check_years(current_year, prior_year): return if current_year: prior_year = current_year self._stringify_column(column_index)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier none for_statement identifier call identifier argument_list binary_operator subscript attribute identifier identifier integer integer subscript attribute identifier identifier integer block expression_statement assignment identifier subscript identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier block return_statement if_statement identifier block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Same as _check_stringify_year_row but for columns.
def validate_commits(repo_dir, commits): log.debug("Validating {c} exist in {r}".format(c=commits, r=repo_dir)) repo = Repo(repo_dir) for commit in commits: try: commit = repo.commit(commit) except Exception: msg = ("Commit {commit} could not be found in repo {repo}. " "You may need to pass --update to fetch the latest " "updates to the git repositories stored on " "your local computer.".format(repo=repo_dir, commit=commit)) raise exceptions.InvalidCommitException(msg) return True
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier raise_statement call attribute identifier identifier argument_list identifier return_statement true
Test if a commit is valid for the repository.
def mold_id_to_path(self, mold_id, default=_marker): def handle_default(debug_msg=None): if debug_msg: logger.debug('mold_id_to_path:' + debug_msg, mold_id) if default is _marker: raise KeyError( 'Failed to lookup mold_id %s to a path' % mold_id) return default result = self.molds.get(mold_id) if result: return result if not self.tracked_entry_points: return handle_default() try: prefix, mold_basename = mold_id.split('/') except ValueError: return handle_default( 'mold_id %s not found and not in standard format') entry_point = self.tracked_entry_points.get(prefix) if entry_point is None: return handle_default() return join(self._entry_point_to_path(entry_point), mold_basename)
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block function_definition identifier parameters default_parameter identifier none block if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block return_statement identifier if_statement not_operator attribute identifier identifier block return_statement call identifier argument_list try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block return_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call identifier argument_list return_statement call identifier argument_list call attribute identifier identifier argument_list identifier identifier
Lookup the filesystem path of a mold identifier.
def press_button(self, value): button = find_button(world.browser, value) if not button: raise AssertionError( "Cannot find a button named '{}'.".format(value)) button.click()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Click the button with the given label.
def _update_mean_coords(self, dig, N, centers_sum, **paircoords): if N is None or centers_sum is None: return N.flat[:] += utils.bincount(dig, 1., minlength=N.size) for i, dim in enumerate(self.dims): size = centers_sum[i].size centers_sum[i].flat[:] += utils.bincount(dig, paircoords[dim], minlength=size)
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block return_statement expression_statement augmented_assignment subscript attribute identifier identifier slice call attribute identifier identifier argument_list identifier float keyword_argument identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier attribute subscript identifier identifier identifier expression_statement augmented_assignment subscript attribute subscript identifier identifier identifier slice call attribute identifier identifier argument_list identifier subscript identifier identifier keyword_argument identifier identifier
Update the mean coordinate sums
def from_file(self, vasprun_file): vrun_obj = Vasprun(vasprun_file, parse_projected_eigen=True) return VasprunLoader(vrun_obj)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true return_statement call identifier argument_list identifier
Get a vasprun.xml file and return a VasprunLoader
def remove_callback(self, callback): if callback in self.callbacks: self.callbacks.remove(callback)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Remove callback from the list of callbacks if it exists
def add_tag(self, tag): if tag not in self._tags: self._tags[tag] = dict()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list
add a tag to the tag list
def dirty(self): return not os.path.exists(self.cachename) or \ (os.path.getmtime(self.filename) > os.path.getmtime(self.cachename))
module function_definition identifier parameters identifier block return_statement boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier line_continuation parenthesized_expression comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
True if the cache needs to be updated, False otherwise
def filter_content_types(self, content_type_qs): valid_ct_ids = [] for ct in content_type_qs: model = ct.model_class() if model and issubclass(model, EventBase): valid_ct_ids.append(ct.id) return content_type_qs.filter(pk__in=valid_ct_ids)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Filter the content types selectable to only event subclasses
def _set_mask(self, mask): self.mask = mask.copy() if self.h5 is not None: if 'mask' in self.h5: self.h5.pop('mask') self.h5.create_dataset('mask', mask.shape, dtype=self.mask.dtype, data=mask, compression="gzip", shuffle=True)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true
Set mask array in both class and hdf5 file
def _iter_texts(self, tree): skip = ( not isinstance(tree, lxml.html.HtmlElement) or tree.tag in self.skipped_tags ) if not skip: if tree.text: yield Text(tree.text, tree, 'text') for child in tree: for text in self._iter_texts(child): yield text if tree.tail: yield Text(tree.tail, tree, 'tail')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier parenthesized_expression boolean_operator not_operator call identifier argument_list identifier attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier if_statement not_operator identifier block if_statement attribute identifier identifier block expression_statement yield call identifier argument_list attribute identifier identifier identifier string string_start string_content string_end for_statement identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement yield identifier if_statement attribute identifier identifier block expression_statement yield call identifier argument_list attribute identifier identifier identifier string string_start string_content string_end
Iterates over texts in given HTML tree.