code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def parse_tablature(lines): lines = [parse_line(l) for l in lines] return Tablature(lines=lines)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier
Parse a list of lines into a `Tablature`.
def normalize(v): if 0 == np.linalg.norm(v): return v return v / np.linalg.norm(v)
module function_definition identifier parameters identifier block if_statement comparison_operator integer call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier return_statement binary_operator identifier call attribute attribute identifier identifier identifier argument_list identifier
Normalize a vector based on its 2 norm.
def stop(self): if self._progressing: self._progressing = False self._thread.join()
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list
Stop the progress bar.
def scheduled_status_delete(self, id): id = self.__unpack_id(id) url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) self.__api_request('DELETE', url)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Deletes a scheduled status.
def backup(filename): tmp_file = "/tmp/%s" % filename with cd("/"): postgres("pg_dump -Fc %s > %s" % (env.proj_name, tmp_file)) run("cp %s ." % tmp_file) sudo("rm -f %s" % tmp_file)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Backs up the project database.
def _can_merge_tail(self): if len(self.storage) < 2: return False return self.storage[-2].w <= self.storage[-1].w * self.rtol
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement false return_statement comparison_operator attribute subscript attribute identifier identifier unary_operator integer identifier binary_operator attribute subscript attribute identifier identifier unary_operator integer identifier attribute identifier identifier
Checks if the two last list elements can be merged
def _get_n_args(self, args, example, n): if len(args) != n: msg = ( 'Got unexpected number of arguments, expected {}. ' '(example: "{} config {}")' ).format(n, get_prog(), example) raise PipError(msg) if n == 1: return args[0] else: return args
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier raise_statement call identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement subscript identifier integer else_clause block return_statement identifier
Helper to make sure the command got the right number of arguments
def form_valid(self, forms): for key, form in forms.items(): setattr(self, '{}_object'.format(key), form.save()) return super(MultipleModelFormMixin, self).form_valid(forms)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
If the form is valid, save the associated model.
def sha1(filename): filename = unmap_file(filename) if filename not in file_cache: cache_file(filename) if filename not in file_cache: return None pass if file_cache[filename].sha1: return file_cache[filename].sha1.hexdigest() sha1 = hashlib.sha1() for line in file_cache[filename].lines['plain']: sha1.update(line.encode('utf-8')) pass file_cache[filename].sha1 = sha1 return sha1.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement none pass_statement if_statement attribute subscript identifier identifier identifier block return_statement call attribute attribute subscript identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier subscript attribute subscript identifier identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end pass_statement expression_statement assignment attribute subscript identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list
Return SHA1 of filename.
def load_template(self, templatename, template_string=None): if template_string is not None: return Template(template_string, **self.tmpl_options) if '/' not in templatename: templatename = '/' + templatename.replace('.', '/') + '.' +\ self.extension return self.lookup.get_template(templatename)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier dictionary_splat attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end line_continuation attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Loads a template from a file or a string
def degrees(x): if isinstance(x, UncertainFunction): mcpts = np.degrees(x._mcpts) return UncertainFunction(mcpts) else: return np.degrees(x)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Convert radians to degrees
def _os_dispatch(func, *args, **kwargs): if __grains__['kernel'] in SUPPORTED_BSD_LIKE: kernel = 'bsd' else: kernel = __grains__['kernel'].lower() _os_func = getattr(sys.modules[__name__], '_{0}_{1}'.format(kernel, func)) if callable(_os_func): return _os_func(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement call identifier argument_list identifier block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier
Internal, dispatches functions by operating system
def log_method(log, level=logging.DEBUG): def decorator(func): func_name = func.__name__ @six.wraps(func) def wrapper(self, *args, **kwargs): if log.isEnabledFor(level): pretty_args = [] if args: pretty_args.extend(str(a) for a in args) if kwargs: pretty_args.extend( "%s=%s" % (k, v) for k, v in six.iteritems(kwargs)) log.log(level, "%s(%s)", func_name, ", ".join(pretty_args)) return func(self, *args, **kwargs) return wrapper return decorator
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier list if_statement identifier block expression_statement call attribute identifier identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier if_statement identifier block expression_statement call attribute identifier identifier generator_expression binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier
Logs a method and its arguments when entered.
def proxy(self): headers = self.request.headers.filter(self.ignored_request_headers) qs = self.request.query_string if self.pass_query_string else '' if (self.request.META.get('CONTENT_LENGTH', None) == '' and get_django_version() == '1.10'): del self.request.META['CONTENT_LENGTH'] request_kwargs = self.middleware.process_request( self, self.request, method=self.request.method, url=self.proxy_url, headers=headers, data=self.request.body, params=qs, allow_redirects=False, verify=self.verify_ssl, cert=self.cert, timeout=self.timeout) result = request(**request_kwargs) response = HttpResponse(result.content, status=result.status_code) forwardable_headers = HeaderDict(result.headers).filter( self.ignored_upstream_headers) for header, value in iteritems(forwardable_headers): response[header] = value return self.middleware.process_response( self, self.request, result, response)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier conditional_expression attribute attribute identifier identifier identifier attribute identifier identifier string string_start string_end if_statement parenthesized_expression boolean_operator comparison_operator call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end none string string_start string_end comparison_operator call identifier argument_list string string_start string_content string_end block delete_statement subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier identifier identifier
Retrieve the upstream content and build an HttpResponse.
def homer_tagdirectory(self): self.parse_gc_content() self.parse_re_dist() self.parse_tagLength_dist() self.parse_tagInfo_data() self.parse_FreqDistribution_data() self.homer_stats_table_tagInfo() return sum([len(v) for v in self.tagdir_data.values()])
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
Find HOMER tagdirectory logs and parse their data
def _post_init(self, name, container=None): self.name = name self.container = container
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
Called automatically by container after container's class construction.
def confirms(self, txid): txid = deserialize.txid(txid) return self.service.confirms(txid)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Returns number of confirms or None if unpublished.
def download(query, num_results): name = quote(query) name = name.replace(' ','+') url = 'http://www.google.com/search?q=' + name if num_results != 10: url += '&num=' + str(num_results) req = request.Request(url, headers={ 'User-Agent' : choice(user_agents), }) try: response = request.urlopen(req) except Exception: print('ERROR\n') traceback.print_exc() return '' if isPython2: data = response.read().decode('utf8', errors='ignore') else: data = str(response.read(), 'utf-8', errors='ignore') return data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list return_statement string string_start string_end if_statement identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement identifier
downloads HTML after google search
def do_get_aliases(name): metric_schemas = MetricSchemas() aliases = metric_schemas.get_aliases(name) for alias in aliases: do_print(alias)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call identifier argument_list identifier
Get aliases for given metric name
def apply(self, func, *args, **kwds): wrapped = self._wrapped_apply(func, *args, **kwds) n_repeats = 3 timed = timeit.timeit(wrapped, number=n_repeats) samp_proc_est = timed / n_repeats est_apply_duration = samp_proc_est / self._SAMP_SIZE * self._nrows if est_apply_duration > self._dask_threshold: return self._dask_apply(func, *args, **kwds) else: if self._progress_bar: tqdm.pandas(desc="Pandas Apply") return self._obj_pd.progress_apply(func, *args, **kwds) else: return self._obj_pd.apply(func, *args, **kwds)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Apply the function to the transformed swifter object
def dt2ts(dt): assert isinstance(dt, (datetime.datetime, datetime.date)) ret = time.mktime(dt.timetuple()) if isinstance(dt, datetime.datetime): ret += 1e-6 * dt.microsecond return ret
module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator float attribute identifier identifier return_statement identifier
Converts to float representing number of seconds since 1970-01-01 GMT.
def serialize_for_header(key, value): if key in QUOTE_FIELDS: return json.dumps(value) elif isinstance(value, str): if " " in value or "\t" in value: return json.dumps(value) else: return value elif isinstance(value, list): return "[{}]".format(", ".join(value)) else: return str(value)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block return_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content escape_sequence string_end identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier
Serialize value for the given mapping key for a VCF header line
def match(self, p_todo): for my_tag in config().hidden_item_tags(): my_values = p_todo.tag_values(my_tag) for my_value in my_values: if not my_value in (0, '0', False, 'False'): return False return True
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute call identifier argument_list identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement not_operator comparison_operator identifier tuple integer string string_start string_content string_end false string string_start string_content string_end block return_statement false return_statement true
Returns True when p_todo doesn't have a tag to mark it as hidden.
def atmos_worker(srcs, window, ij, args): src = srcs[0] rgb = src.read(window=window) rgb = to_math_type(rgb) atmos = simple_atmo(rgb, args["atmo"], args["contrast"], args["bias"]) return scale_dtype(atmos, args["out_dtype"])
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end
A simple atmospheric correction user function.
def _validate_jp2c(self, boxes): jp2h_lst = [idx for (idx, box) in enumerate(boxes) if box.box_id == 'jp2h'] jp2h_idx = jp2h_lst[0] jp2c_lst = [idx for (idx, box) in enumerate(boxes) if box.box_id == 'jp2c'] if len(jp2c_lst) == 0: msg = ("A codestream box must be defined in the outermost " "list of boxes.") raise IOError(msg) jp2c_idx = jp2c_lst[0] if jp2h_idx >= jp2c_idx: msg = "The codestream box must be preceeded by a jp2 header box." raise IOError(msg)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause tuple_pattern identifier identifier call identifier argument_list identifier if_clause comparison_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier list_comprehension identifier for_in_clause tuple_pattern identifier identifier call identifier argument_list identifier if_clause comparison_operator attribute identifier identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end raise_statement call identifier argument_list identifier expression_statement assignment identifier subscript identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list identifier
Validate the codestream box in relation to other boxes.
def blockmix_salsa8(BY, Yi, r): start = (2 * r - 1) * 16 X = BY[start:start+16] tmp = [0]*16 for i in xrange(2 * r): salsa20_8(X, tmp, BY, i * 16, BY, Yi + i*16) for i in xrange(r): BY[i * 16:(i * 16)+(16)] = BY[Yi + (i * 2) * 16:(Yi + (i * 2) * 16)+(16)] BY[(i + r) * 16:((i + r) * 16)+(16)] = BY[Yi + (i*2 + 1) * 16:(Yi + (i*2 + 1) * 16)+(16)]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator integer identifier integer integer expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier integer expression_statement assignment identifier binary_operator list integer integer for_statement identifier call identifier argument_list binary_operator integer identifier block expression_statement call identifier argument_list identifier identifier identifier binary_operator identifier integer identifier binary_operator identifier binary_operator identifier integer for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier slice binary_operator identifier integer binary_operator parenthesized_expression binary_operator identifier integer parenthesized_expression integer subscript identifier slice binary_operator identifier binary_operator parenthesized_expression binary_operator identifier integer integer binary_operator parenthesized_expression binary_operator identifier binary_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression integer expression_statement assignment subscript identifier slice binary_operator parenthesized_expression binary_operator identifier identifier integer binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator identifier identifier integer parenthesized_expression integer subscript identifier slice binary_operator identifier binary_operator parenthesized_expression binary_operator binary_operator identifier integer integer integer binary_operator parenthesized_expression binary_operator identifier binary_operator parenthesized_expression binary_operator binary_operator identifier integer integer integer parenthesized_expression integer
Blockmix; Used by SMix
def assert_service_check(self, name, status=None, tags=None, count=None, at_least=1, hostname=None, message=None): tags = normalize_tags(tags, sort=True) candidates = [] for sc in self.service_checks(name): if status is not None and status != sc.status: continue if tags and tags != sorted(sc.tags): continue if hostname is not None and hostname != sc.hostname: continue if message is not None and message != sc.message: continue candidates.append(sc) if count is not None: msg = "Needed exactly {} candidates for '{}', got {}".format(count, name, len(candidates)) assert len(candidates) == count, msg else: msg = "Needed at least {} candidates for '{}', got {}".format(at_least, name, len(candidates)) assert len(candidates) >= at_least, msg
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier attribute identifier identifier block continue_statement if_statement boolean_operator identifier comparison_operator identifier call identifier argument_list attribute identifier identifier block continue_statement if_statement boolean_operator comparison_operator identifier none comparison_operator identifier attribute identifier identifier block continue_statement if_statement boolean_operator comparison_operator identifier none comparison_operator identifier attribute identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier call identifier argument_list identifier assert_statement comparison_operator call identifier argument_list identifier identifier identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier call identifier argument_list identifier assert_statement comparison_operator call identifier argument_list identifier identifier identifier
Assert a service check was processed by this stub
def energy_data(): cur = db.cursor().execute() original = TimeSeries() original.initialize_from_sql_cursor(cur) original.normalize("day", fusionMethod = "sum") return itty.Response(json.dumps(original, cls=PycastEncoder), content_type='application/json')
module function_definition identifier parameters block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
Connects to the database and loads Readings for device 8.
def _create_peephole_variables(self, dtype): self._w_f_diag = tf.get_variable( self.W_F_DIAG, shape=[self._hidden_size], dtype=dtype, initializer=self._initializers.get(self.W_F_DIAG), partitioner=self._partitioners.get(self.W_F_DIAG), regularizer=self._regularizers.get(self.W_F_DIAG)) self._w_i_diag = tf.get_variable( self.W_I_DIAG, shape=[self._hidden_size], dtype=dtype, initializer=self._initializers.get(self.W_I_DIAG), partitioner=self._partitioners.get(self.W_I_DIAG), regularizer=self._regularizers.get(self.W_I_DIAG)) self._w_o_diag = tf.get_variable( self.W_O_DIAG, shape=[self._hidden_size], dtype=dtype, initializer=self._initializers.get(self.W_O_DIAG), partitioner=self._partitioners.get(self.W_O_DIAG), regularizer=self._regularizers.get(self.W_O_DIAG))
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Initialize the variables used for the peephole connections.
def stop(self): self._stop_event.set() if self._func_stop_event is not None: self._func_stop_event.set() self.join(timeout=1) if self.isAlive(): print('Failed to stop thread')
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier integer if_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end
stop the thread, return after thread stopped
def detect_output_type(args): if not args['single'] and not args['multiple']: if len(args['query']) > 1 or len(args['out']) > 1: args['multiple'] = True else: args['single'] = True
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator subscript identifier string string_start string_content string_end not_operator subscript identifier string string_start string_content string_end block if_statement boolean_operator comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end integer comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end integer block expression_statement assignment subscript identifier string string_start string_content string_end true else_clause block expression_statement assignment subscript identifier string string_start string_content string_end true
Detect whether to save to a single or multiple files.
def as_yml(self): return YmlFileEvent(name=str(self.name), subfolder=str(self.subfolder))
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier
Return yml compatible version of self
def make_vertical_box(cls, children, layout=Layout(), duplicates=False): "Make a vertical box with `children` and `layout`." if not duplicates: return widgets.VBox(children, layout=layout) else: return widgets.VBox([children[0], children[2]], layout=layout)
module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list default_parameter identifier false block expression_statement string string_start string_content string_end if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block return_statement call attribute identifier identifier argument_list list subscript identifier integer subscript identifier integer keyword_argument identifier identifier
Make a vertical box with `children` and `layout`.
def utcnow_ts(): if utcnow.override_time is None: return int(time.time()) return calendar.timegm(utcnow().timetuple())
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier none block return_statement call identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list call attribute call identifier argument_list identifier argument_list
Timestamp version of our utcnow function.
def rollout(env, acts): total_rew = 0 env.reset() steps = 0 for act in acts: _obs, rew, done, _info = env.step(act) steps += 1 total_rew += rew if done: break return steps, total_rew
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier identifier if_statement identifier block break_statement return_statement expression_list identifier identifier
Perform a rollout using a preset collection of actions
def _compute_softmax(scores): if not scores: return [] max_score = None for score in scores: if max_score is None or score > max_score: max_score = score exp_scores = [] total_sum = 0.0 for score in scores: x = math.exp(score - max_score) exp_scores.append(x) total_sum += x probs = [] for score in exp_scores: probs.append(score / total_sum) return probs
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement list expression_statement assignment identifier none for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier list expression_statement assignment identifier float for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier return_statement identifier
Compute softmax probability over raw logits.
def _add_history(self, entry_type, entry): meta_string = "{time} - {etype} - {entry}".format( time=self._time(), etype=entry_type.upper(), entry=entry) self._content['history'].insert(0, meta_string) self.logger(meta_string)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list identifier
Generic method to add entry as entry_type to the history
def _get_anelastic_attenuation_term(self, C, rrup): f_atn = np.zeros(len(rrup)) idx = rrup >= 80.0 f_atn[idx] = (C["c20"] + C["Dc20"]) * (rrup[idx] - 80.0) return f_atn
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier comparison_operator identifier float expression_statement assignment subscript identifier identifier binary_operator parenthesized_expression binary_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end parenthesized_expression binary_operator subscript identifier identifier float return_statement identifier
Returns the anelastic attenuation term defined in equation 25
async def on_message(self, event): if event.chat_id != self.chat_id: return self.message_ids.append(event.id) if event.out: text = '>> ' else: sender = await event.get_sender() text = '<{}> '.format(sanitize_str( utils.get_display_name(sender))) if event.media: text += '({}) '.format(event.media.__class__.__name__) text += sanitize_str(event.text) text += '\n' self.log.insert(tkinter.END, text) self.log.yview(tkinter.END)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier await call attribute identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute attribute identifier identifier identifier identifier expression_statement augmented_assignment identifier call identifier argument_list attribute identifier identifier expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Event handler that will add new messages to the message log.
def reflected_light_intensity(self): self._ensure_mode(self.MODE_REFLECT) return self.value(0) * self._scale('REFLECT')
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement binary_operator call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list string string_start string_content string_end
A measurement of the reflected light intensity, as a percentage.
def isemhash_unbottleneck(x, hidden_size, isemhash_filter_size_multiplier=1.0): filter_size = int(hidden_size * isemhash_filter_size_multiplier) x = 0.5 * (x - 1.0) with tf.variable_scope("isemhash_unbottleneck"): h1a = tf.layers.dense(x, filter_size, name="hidden1a") h1b = tf.layers.dense(1.0 - x, filter_size, name="hidden1b") h2 = tf.layers.dense(tf.nn.relu(h1a + h1b), filter_size, name="hidden2") return tf.layers.dense(tf.nn.relu(h2), hidden_size, name="final")
module function_definition identifier parameters identifier identifier default_parameter identifier float block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier binary_operator float parenthesized_expression binary_operator identifier float with_statement with_clause with_item call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator float identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list binary_operator identifier identifier identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end
Improved semantic hashing un-bottleneck.
def make_tls_config(app_config): if not app_config['DOCKER_TLS']: return False cert_path = app_config['DOCKER_TLS_CERT_PATH'] if cert_path: client_cert = '{0}:{1}'.format( os.path.join(cert_path, 'cert.pem'), os.path.join(cert_path, 'key.pem')) ca_cert = os.path.join(cert_path, 'ca.pem') else: client_cert = app_config['DOCKER_TLS_CLIENT_CERT'] ca_cert = app_config['DOCKER_TLS_CA_CERT'] client_cert = parse_client_cert_pair(client_cert) return TLSConfig( client_cert=client_cert, ca_cert=ca_cert, verify=app_config['DOCKER_TLS_VERIFY'], ssl_version=app_config['DOCKER_TLS_SSL_VERSION'], assert_hostname=app_config['DOCKER_TLS_ASSERT_HOSTNAME'])
module function_definition identifier parameters identifier block if_statement not_operator subscript identifier string string_start string_content string_end block return_statement false expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end else_clause 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 call identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end
Creates TLS configuration object.
def uninstall_hook(ctx): try: lint_config = ctx.obj[0] hooks.GitHookInstaller.uninstall_commit_msg_hook(lint_config) hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config) click.echo(u"Successfully uninstalled gitlint commit-msg hook from {0}".format(hook_path)) ctx.exit(0) except hooks.GitHookInstallerError as e: click.echo(ustr(e), err=True) ctx.exit(GIT_CONTEXT_ERROR_CODE)
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list identifier
Uninstall gitlint commit-msg hook.
def frontend(ctx, dev, rebuild, no_install, build_type): install_frontend(instance=ctx.obj['instance'], forcerebuild=rebuild, development=dev, install=not no_install, build_type=build_type)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier not_operator identifier keyword_argument identifier identifier
Build and install frontend
def from_name_func(cls, path:PathOrStr, fnames:FilePathList, label_func:Callable, valid_pct:float=0.2, **kwargs): "Create from list of `fnames` in `path` with `label_func`." src = ImageList(fnames, path=path).split_by_rand_pct(valid_pct) return cls.create_from_ll(src.label_from_func(label_func), **kwargs)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier float dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list identifier keyword_argument identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier dictionary_splat identifier
Create from list of `fnames` in `path` with `label_func`.
def _compute_hidden_activations(self, X): self._compute_input_activations(X) acts = self.input_activations_ if (callable(self.activation_func)): args_dict = self.activation_args if (self.activation_args) else {} X_new = self.activation_func(acts, **args_dict) else: func_name = self.activation_func func = self._internal_activation_funcs[func_name] X_new = func(acts, **self._extra_args) return X_new
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier if_statement parenthesized_expression call identifier argument_list attribute identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier parenthesized_expression attribute identifier identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier dictionary_splat attribute identifier identifier return_statement identifier
Compute hidden activations given X
def flushInput(self): self.buf = '' saved_timeout = self.timeout self.timeout = 0.5 self._recv() self.timeout = saved_timeout self.buf = '' self.debug("flushInput")
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier float expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
flush any pending input
def connections(request, edges): edge_list, node_list = parse.graph_definition(edges) data = {'nodes': json.dumps(node_list), 'edges': json.dumps(edge_list)} return render_to_response('miner/connections.html', data)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement call identifier argument_list string string_start string_content string_end identifier
Plot a force-directed graph based on the edges provided
def configure_terminal(self): client = self.guake.settings.general word_chars = client.get_string('word-chars') if word_chars: self.set_word_char_exceptions(word_chars) self.set_audible_bell(client.get_boolean('use-audible-bell')) self.set_sensitive(True) cursor_blink_mode = self.guake.settings.style.get_int('cursor-blink-mode') self.set_property('cursor-blink-mode', cursor_blink_mode) if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 50): self.set_allow_hyperlink(True) if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 56): try: self.set_bold_is_bright(self.guake.settings.styleFont.get_boolean('bold-is-bright')) except: log.error("set_bold_is_bright not supported by your version of VTE") if hasattr(self, "set_alternate_screen_scroll"): self.set_alternate_screen_scroll(True) self.set_can_default(True) self.set_can_focus(True)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list true expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier 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 identifier if_statement comparison_operator tuple attribute identifier identifier attribute identifier identifier tuple integer integer block expression_statement call attribute identifier identifier argument_list true if_statement comparison_operator tuple attribute identifier identifier attribute identifier identifier tuple integer integer block try_statement block expression_statement call attribute identifier identifier argument_list call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list string string_start string_content string_end except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list true
Sets all customized properties on the terminal
def _find_image_ext(path, number=None): if number is not None: path = path.format(number) path = os.path.splitext(path)[0] for ext in _KNOWN_IMG_EXTS: this_path = '%s.%s' % (path, ext) if os.path.isfile(this_path): break else: ext = 'png' return ('%s.%s' % (path, ext), ext)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer for_statement identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block break_statement else_clause block expression_statement assignment identifier string string_start string_content string_end return_statement tuple binary_operator string string_start string_content string_end tuple identifier identifier identifier
Find an image, tolerant of different file extensions.
def factory(obj, field, source_text, lang, context=""): obj_classname = obj.__class__.__name__ obj_module = obj.__module__ source_md5 = checksum(source_text) translation = "" field_lang = trans_attr(field,lang) if hasattr(obj,field_lang) and getattr(obj,field_lang)!="": translation = getattr(obj,field_lang) is_fuzzy = True is_fuzzy_lang = trans_is_fuzzy_attr(field,lang) if hasattr(obj,is_fuzzy_lang): is_fuzzy = getattr(obj,is_fuzzy_lang) trans = FieldTranslation(module=obj_module, model=obj_classname, object_id=obj.id, field=field, lang=lang, source_text=source_text, source_md5=source_md5, translation=translation, is_fuzzy=is_fuzzy, context=context) return trans
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list identifier identifier if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier true expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Static method that constructs a translation based on its contents.
def library_directories(self) -> typing.List[str]: def listify(value): return [value] if isinstance(value, str) else list(value) is_local_project = not self.is_remote_project folders = [ f for f in listify(self.settings.fetch('library_folders', ['libs'])) if is_local_project or not f.startswith('..') ] folders.append('../__cauldron_shared_libs') folders.append(self.source_directory) return [ environ.paths.clean(os.path.join(self.source_directory, folder)) for folder in folders ]
module function_definition identifier parameters identifier type subscript attribute identifier identifier identifier block function_definition identifier parameters identifier block return_statement conditional_expression list identifier call identifier argument_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier not_operator attribute identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end if_clause boolean_operator identifier not_operator 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 attribute identifier identifier return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier for_in_clause identifier identifier
The list of directories to all of the library locations
def getInterimValue(self, keyword): interims = filter(lambda item: item["keyword"] == keyword, self.getInterimFields()) if not interims: logger.warning("Interim '{}' for analysis '{}' not found" .format(keyword, self.getKeyword())) return None if len(interims) > 1: logger.error("More than one interim '{}' found for '{}'" .format(keyword, self.getKeyword())) return None return interims[0].get('value', '')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator subscript identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list return_statement none if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list return_statement none return_statement call attribute subscript identifier integer identifier argument_list string string_start string_content string_end string string_start string_end
Returns the value of an interim of this analysis
def _interp1d(self): lines = len(self.hrow_indices) for num, data in enumerate(self.tie_data): self.new_data[num] = np.empty((len(self.hrow_indices), len(self.hcol_indices)), data.dtype) for cnt in range(lines): tck = splrep(self.col_indices, data[cnt, :], k=self.ky_, s=0) self.new_data[num][cnt, :] = splev( self.hcol_indices, tck, der=0)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list tuple call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier identifier slice keyword_argument identifier attribute identifier identifier keyword_argument identifier integer expression_statement assignment subscript subscript attribute identifier identifier identifier identifier slice call identifier argument_list attribute identifier identifier identifier keyword_argument identifier integer
Interpolate in one dimension.
def make_modules(self, groups, code_opts): modules = [] for raw_module, raw_funcs in groups: module = raw_module[0].strip().strip(string.punctuation) funcs = [func.strip() for func in raw_funcs] args = [self.database.query_args(func, raw=True) for func in funcs] if self.generic: args = [arg if arg else ('VOID *', []) for arg in args] else: args = [arg for arg in args if arg] if not args: logging.info(_('%s not found.'), module) continue logging.debug(module) module = ModuleSource(module, zip(funcs, args), code_opts) modules.append(module.c_source()) return AttrsGetter(modules)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute call attribute subscript identifier integer identifier argument_list identifier argument_list attribute identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true for_in_clause identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier list_comprehension conditional_expression identifier identifier tuple string string_start string_content string_end list for_in_clause identifier identifier else_clause block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end identifier continue_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call identifier argument_list identifier
Build shellcoding files for the module.
def xrevrange(self, stream, start='+', stop='-', count=None): if count is not None: extra = ['COUNT', count] else: extra = [] fut = self.execute(b'XREVRANGE', stream, start, stop, *extra) return wait_convert(fut, parse_messages)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier list_splat identifier return_statement call identifier argument_list identifier identifier
Retrieve messages from a stream in reverse order.
def substitute(self, values: Dict[str, Any]) -> str: return self.template.substitute(values)
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier
generate url with url template
def as_dict(self): def conv(v): if isinstance(v, SerializableAttributesHolder): return v.as_dict() elif isinstance(v, list): return [conv(x) for x in v] elif isinstance(v, dict): return {x:conv(y) for (x,y) in v.items()} else: return v return {k.replace('_', '-'): conv(v) for (k, v) in self._attributes.items()}
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement dictionary_comprehension pair identifier call identifier argument_list identifier for_in_clause tuple_pattern identifier identifier call attribute identifier identifier argument_list else_clause block return_statement identifier return_statement dictionary_comprehension pair call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call identifier argument_list identifier for_in_clause tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list
Returns a JSON-serializeable object representing this tree.
def clear(self, username, project): method = 'DELETE' url = ('/project/{username}/{project}/build-cache?' 'circle-token={token}'.format(username=username, project=project, token=self.client.api_token)) json_data = self.client.request(method, url) return json_data
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier parenthesized_expression call attribute concatenated_string 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 keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier
Clear the cache for given project.
def get(self, flex_sched_rule_id): path = '/'.join(['flexschedulerule', flex_sched_rule_id]) return self.rachio.get(path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list string string_start string_content string_end identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Retrieve the information for a flexscheduleRule entity.
def _exception_free_callback(self, callback, *args, **kwargs): try: return callback(*args, **kwargs) except Exception: self._logger.exception("An exception occurred while calling a hook! ",exc_info=True) return None
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true return_statement none
A wrapper that remove all exceptions raised from hooks
def _get_args(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--rom', '-r', type=str, help='The path to the ROM to play.', required=True, ) parser.add_argument('--mode', '-m', type=str, default='human', choices=['human', 'random'], help='The execution mode for the emulation.', ) parser.add_argument('--steps', '-s', type=int, default=500, help='The number of random steps to take.', ) return parser.parse_args()
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end 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 string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list
Parse arguments from the command line and return them.
def price_rounding(price, decimals=2): try: exponent = D('.' + decimals * '0') except InvalidOperation: exponent = D() return price.quantize(exponent, rounding=ROUND_UP)
module function_definition identifier parameters identifier default_parameter identifier integer block try_statement block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end binary_operator identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier call identifier argument_list return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Takes a decimal price and rounds to a number of decimal places
def net_send(out_data, conn): print('Sending {} bytes'.format(len(out_data))) conn.send(out_data)
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Write pending data from websocket to network.
def limit_chars(function, *args, **kwargs): output_chars_limit = args[0].reddit_session.config.output_chars_limit output_string = function(*args, **kwargs) if -1 < output_chars_limit < len(output_string): output_string = output_string[:output_chars_limit - 3] + '...' return output_string
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier attribute attribute attribute subscript identifier integer identifier identifier identifier expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier if_statement comparison_operator unary_operator integer identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator subscript identifier slice binary_operator identifier integer string string_start string_content string_end return_statement identifier
Truncate the string returned from a function and return the result.
def reset_group_subscription(self): if self._user_assignment: raise IllegalStateError(self._SUBSCRIPTION_EXCEPTION_MESSAGE) assert self.subscription is not None, 'Subscription required' self._group_subscription.intersection_update(self.subscription)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier assert_statement comparison_operator attribute identifier identifier none string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Reset the group's subscription to only contain topics subscribed by this consumer.
def angprofile(self, **kwargs): kwargs_copy = self.base_dict.copy() kwargs_copy.update(**kwargs) self._replace_none(kwargs_copy) localpath = NameFactory.angprofile_format.format(**kwargs_copy) if kwargs.get('fullpath', False): return self.fullpath(localpath=localpath) return localpath
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end false block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
return the file name for sun or moon angular profiles
def info(self): return (self.start_pc, self.end_pc, self.handler_pc, self.get_catch_type())
module function_definition identifier parameters identifier block return_statement tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list
tuple of the start_pc, end_pc, handler_pc and catch_type_ref
def process_frames(self, data, sampling_rate, offset=0, last=False, utterance=None, corpus=None): if offset == 0: self.steps_sorted = list(nx.algorithms.dag.topological_sort(self.graph)) self._create_buffers() self._define_output_buffers() self._update_buffers(None, data, offset, last) for step in self.steps_sorted: chunk = self.buffers[step].get() if chunk is not None: res = step.compute(chunk, sampling_rate, utterance=utterance, corpus=corpus) if step == self: return res else: self._update_buffers(step, res, chunk.offset + chunk.left_context, chunk.is_last)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier false default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier integer block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list none identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier identifier block return_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier
Execute the processing of this step and all dependent parent steps.
def filter(self, **kwargs): keys = self.filter_keys(**kwargs) return self.keys_to_values(keys)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier return_statement call attribute identifier identifier argument_list identifier
Filter data according to the given arguments.
def toposort_classes(classes): def get_class_topolist(class_name, name_to_class, processed_classes, current_trace): if class_name in processed_classes: return [] if class_name in current_trace: raise AssertionError( 'Encountered self-reference in dependency chain of {}'.format(class_name)) cls = name_to_class[class_name] dependencies = _list_superclasses(cls) properties = cls['properties'] if 'properties' in cls else [] for prop in properties: if 'linkedClass' in prop: dependencies.append(prop['linkedClass']) class_list = [] current_trace.add(class_name) for dependency in dependencies: class_list.extend(get_class_topolist( dependency, name_to_class, processed_classes, current_trace)) current_trace.remove(class_name) class_list.append(name_to_class[class_name]) processed_classes.add(class_name) return class_list class_map = {c['name']: c for c in classes} seen_classes = set() toposorted = [] for name in class_map.keys(): toposorted.extend(get_class_topolist(name, class_map, seen_classes, set())) return toposorted
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier identifier block return_statement list if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier list for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier expression_statement assignment identifier dictionary_comprehension pair subscript identifier string string_start string_content string_end identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier call identifier argument_list return_statement identifier
Sort class metadatas so that a superclass is always before the subclass
def solve_sdr(prob, *args, **kwargs): X = cvx.Semidef(prob.n + 1) W = prob.f0.homogeneous_form() rel_obj = cvx.Minimize(cvx.sum_entries(cvx.mul_elemwise(W, X))) rel_constr = [X[-1, -1] == 1] for f in prob.fs: W = f.homogeneous_form() lhs = cvx.sum_entries(cvx.mul_elemwise(W, X)) if f.relop == '==': rel_constr.append(lhs == 0) else: rel_constr.append(lhs <= 0) rel_prob = cvx.Problem(rel_obj, rel_constr) rel_prob.solve(*args, **kwargs) if rel_prob.status not in [cvx.OPTIMAL, cvx.OPTIMAL_INACCURATE]: raise Exception("Relaxation problem status: %s" % rel_prob.status) return X.value, rel_prob.value
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier list comparison_operator subscript identifier unary_operator integer unary_operator integer integer for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list comparison_operator identifier integer else_clause block expression_statement call attribute identifier identifier argument_list comparison_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier if_statement comparison_operator attribute identifier identifier list attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier return_statement expression_list attribute identifier identifier attribute identifier identifier
Solve the SDP relaxation.
def update_entity(self, entity, agent=None, metadata=None): body = {} if agent: body["agent_id"] = utils.get_id(agent) if metadata: body["metadata"] = metadata if body: uri = "/%s/%s" % (self.uri_base, utils.get_id(entity)) resp, body = self.api.method_put(uri, body=body)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
Updates the specified entity's values with the supplied parameters.
def solve_let(expr, vars): lhs_value = solve(expr.lhs, vars).value if not isinstance(lhs_value, structured.IStructured): raise errors.EfilterTypeError( root=expr.lhs, query=expr.original, message="The LHS of 'let' must evaluate to an IStructured. Got %r." % (lhs_value,)) return solve(expr.rhs, __nest_scope(expr.lhs, vars, lhs_value))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute call identifier argument_list attribute identifier identifier identifier identifier if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end tuple identifier return_statement call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier identifier identifier
Solves a let-form by calling RHS with nested scope.
def plot_data(self, proj, ax): x, y = proj ax.scatter(self.ig.independent_data[x], self.ig.dependent_data[y], c='b')
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier identifier subscript attribute attribute identifier identifier identifier identifier keyword_argument identifier string string_start string_content string_end
Creates and plots a scatter plot of the original data.
def run_dexseq(data): if dd.get_dexseq_gff(data, None): data = dexseq.bcbio_run(data) return [[data]]
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement list list identifier
Quantitate exon-level counts with DEXSeq
def _run_gvcfgenotyper(data, region, vrn_files, out_file): if not utils.file_exists(out_file): with file_transaction(data, out_file) as tx_out_file: input_file = "%s-inputs.txt" % utils.splitext_plus(tx_out_file)[0] with open(input_file, "w") as out_handle: out_handle.write("%s\n" % "\n".join(vrn_files)) cmd = ["gvcfgenotyper", "-f", dd.get_ref_file(data), "-l", input_file, "-r", region, "-O", "z", "-o", tx_out_file] do.run(cmd, "gvcfgenotyper: %s %s" % (dd.get_sample_name(data), region)) return out_file
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript call attribute identifier identifier argument_list identifier integer 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 binary_operator string string_start string_content escape_sequence string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier identifier return_statement identifier
Run gvcfgenotyper on a single gVCF region in input file.
def __prepare_bloom(self): self.__bloom = pybloom_live.ScalableBloomFilter() columns = [getattr(self.__table.c, key) for key in self.__update_keys] keys = select(columns).execution_options(stream_results=True).execute() for key in keys: self.__bloom.add(tuple(key))
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension call identifier argument_list attribute attribute identifier identifier identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier true identifier argument_list for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier
Prepare bloom for existing checks
def sinh(x, context=None): return _apply_function_in_current_context( BigFloat, mpfr.mpfr_sinh, (BigFloat._implicit_convert(x),), context, )
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier
Return the hyperbolic sine of x.
def sign_transaction(self, txins: Union[TxOut], tx: MutableTransaction) -> MutableTransaction: solver = P2pkhSolver(self._private_key) return tx.spend(txins, [solver for i in txins])
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier list_comprehension identifier for_in_clause identifier identifier
sign the parent txn outputs P2PKH
def debug(self, *args) -> "Err": error = self._create_err("debug", *args) print(self._errmsg(error)) return error
module function_definition identifier parameters identifier list_splat_pattern identifier type string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list_splat identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier
Creates a debug message
def authenticate(self, provider=None, identifier=None): "Fetch user for a given provider by id." provider_q = Q(provider__name=provider) if isinstance(provider, Provider): provider_q = Q(provider=provider) try: access = AccountAccess.objects.filter( provider_q, identifier=identifier ).select_related('user')[0] except IndexError: return None else: return access.user
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier try_statement block expression_statement assignment identifier subscript call attribute call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier identifier argument_list string string_start string_content string_end integer except_clause identifier block return_statement none else_clause block return_statement attribute identifier identifier
Fetch user for a given provider by id.
def ResidualFeedForward(feature_depth, feedforward_depth, dropout, mode): return layers.Residual( layers.LayerNorm(), layers.Dense(feedforward_depth), layers.Relu(), layers.Dropout(rate=dropout, mode=mode), layers.Dense(feature_depth), layers.Dropout(rate=dropout, mode=mode) )
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Residual feed-forward layer with normalization at start.
def query_instances(session, client=None, **query): if client is None: client = session.client('ec2') p = client.get_paginator('describe_instances') results = p.paginate(**query) return list(itertools.chain( *[r["Instances"] for r in itertools.chain( *[pp['Reservations'] for pp in results])]))
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier return_statement call identifier argument_list call attribute identifier identifier argument_list list_splat list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list list_splat list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier
Return a list of ec2 instances for the query.
def _create_consumer(self): if not self.closed: try: self.logger.debug("Creating new kafka consumer using brokers: " + str(self.settings['KAFKA_HOSTS']) + ' and topic ' + self.settings['KAFKA_TOPIC_PREFIX'] + ".outbound_firehose") return KafkaConsumer( self.settings['KAFKA_TOPIC_PREFIX'] + ".outbound_firehose", group_id=None, bootstrap_servers=self.settings['KAFKA_HOSTS'], consumer_timeout_ms=self.settings['KAFKA_CONSUMER_TIMEOUT'], auto_offset_reset=self.settings['KAFKA_CONSUMER_AUTO_OFFSET_RESET'], auto_commit_interval_ms=self.settings['KAFKA_CONSUMER_COMMIT_INTERVAL_MS'], enable_auto_commit=self.settings['KAFKA_CONSUMER_AUTO_COMMIT_ENABLE'], max_partition_fetch_bytes=self.settings['KAFKA_CONSUMER_FETCH_MESSAGE_MAX_BYTES']) except KeyError as e: self.logger.error('Missing setting named ' + str(e), {'ex': traceback.format_exc()}) except: self.logger.error("Couldn't initialize kafka consumer for topic", {'ex': traceback.format_exc()}) raise
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list binary_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier none keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list except_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list raise_statement
Tries to establing the Kafka consumer connection
def guidance_UV(index): if 0 < index < 3: guidance = "Low exposure. No protection required. You can safely stay outside" elif 2 < index < 6: guidance = "Moderate exposure. Seek shade during midday hours, cover up and wear sunscreen" elif 5 < index < 8: guidance = "High exposure. Seek shade during midday hours, cover up and wear sunscreen" elif 7 < index < 11: guidance = "Very high. Avoid being outside during midday hours. Shirt, sunscreen and hat are essential" elif index > 10: guidance = "Extreme. Avoid being outside during midday hours. Shirt, sunscreen and hat essential." else: guidance = None return guidance
module function_definition identifier parameters identifier block if_statement comparison_operator integer identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator integer identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator integer identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator integer identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier none return_statement identifier
Return Met Office guidance regarding UV exposure based on UV index
def peek(self): c = self.connection.cursor() first_tweet_id = c.execute("SELECT tweet from tweetlist where label='first_tweet'").next()[0] if first_tweet_id is None: return None tweet = c.execute("SELECT message from tweets WHERE id=?", (first_tweet_id,)).next()[0] c.close() return tweet
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list integer if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list string string_start string_content string_end tuple identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list return_statement identifier
Peeks at the first of the list without removing it.
def pop_int(self, key: str, default: Any = DEFAULT) -> int: value = self.pop(key, default) if value is None: return None else: return int(value)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block return_statement none else_clause block return_statement call identifier argument_list identifier
Performs a pop and coerces to an int.
def find_farthest(point, hull): d_start = np.sum((point-hull[0,:])**2) d_end = np.sum((point-hull[-1,:])**2) if d_start > d_end: i = 1 inc = 1 term = hull.shape[0] d2_max = d_start else: i = hull.shape[0]-2 inc = -1 term = -1 d2_max = d_end while i != term: d2 = np.sum((point - hull[i,:])**2) if d2 < d2_max: break i += inc d2_max = d2 return i-inc
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator identifier subscript identifier integer slice integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator identifier subscript identifier unary_operator integer slice integer if_statement comparison_operator identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier binary_operator subscript attribute identifier identifier integer integer expression_statement assignment identifier unary_operator integer expression_statement assignment identifier unary_operator integer expression_statement assignment identifier identifier while_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator identifier subscript identifier identifier slice integer if_statement comparison_operator identifier identifier block break_statement expression_statement augmented_assignment identifier identifier expression_statement assignment identifier identifier return_statement binary_operator identifier identifier
Find the vertex in hull farthest away from a point
def list(self, prefix='', delimiter=None): return self.service._list( bucket=self.name, prefix=prefix, delimiter=delimiter, objects=True )
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier none block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true
Limits a list of Bucket's objects based on prefix and delimiter.
def add_login_attempt_task(user_agent, ip_address, username, http_accept, path_info, login_valid): store_login_attempt(user_agent, ip_address, username, http_accept, path_info, login_valid)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier identifier identifier identifier
Create a record for the login attempt
def fix_quotes(cls, query_string): if query_string.count('"') % 2 == 0: return query_string fields = [] def f(match): fields.append(match.string[match.start():match.end()]) return '' terms = re.sub(r'[^\s:]*:("[^"]*"|[^\s]*)', f, query_string) query_string = '{}" {}'.format(terms.strip(), ' '.join(fields)) return query_string
module function_definition identifier parameters identifier identifier block if_statement comparison_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer integer block return_statement identifier expression_statement assignment identifier list function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier slice call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Heuristic attempt to fix unbalanced quotes in query_string.
def context_list_users(zap_helper, context_name): with zap_error_handler(): info = zap_helper.get_context_info(context_name) users = zap_helper.zap.users.users_list(info['id']) if len(users): user_list = ', '.join([user['name'] for user in users]) console.info('Available users for the context {0}: {1}'.format(context_name, user_list)) else: console.info('No users configured for the context {}'.format(context_name))
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
List the users available for a given context.
def pt_scale(pt=(0.0, 0.0), f=1.0): assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(f, float) return tuple([pt[i]*f for i in range(l_pt)])
module function_definition identifier parameters default_parameter identifier tuple float float default_parameter identifier float block assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier assert_statement comparison_operator identifier integer for_statement identifier identifier block assert_statement call identifier argument_list identifier identifier assert_statement call identifier argument_list identifier identifier return_statement call identifier argument_list list_comprehension binary_operator subscript identifier identifier identifier for_in_clause identifier call identifier argument_list identifier
Return given point scaled by factor f from origin.
def policy_get(request, policy_id, **kwargs): policy = neutronclient(request).show_qos_policy( policy_id, **kwargs).get('policy') return QoSPolicy(policy)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier identifier argument_list identifier dictionary_splat identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier
Get QoS policy for a given policy id.
def config_logging(level): logger = logging.getLogger('') logger.setLevel(level) if level < logging.DEBUG: log_format = "%(asctime)s %(message)s" else: log_format = "%(asctime)s %(module)s : %(lineno)d %(message)s" sh = logging.StreamHandler() sh.formatter = logging.Formatter(fmt=log_format) logger.handlers = [] logger.addHandler(sh)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier 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 call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment attribute identifier identifier list expression_statement call attribute identifier identifier argument_list identifier
Configure the logging given the level desired
def run(self, **kwargs): try: loop = IOLoop() app = self.make_app() app.listen(self.port) loop.start() except socket.error as serr: if serr.errno != errno.EADDRINUSE: raise serr else: logger.warning('The webserver port {} is already used. May be the HttpRobotServer is already running or another software is using this port.'.format(self.port))
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier
Start the tornado server, run forever
def _HuntOutputPluginStateFromRow(self, row): plugin_name, plugin_args_bytes, plugin_state_bytes = row plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor( plugin_name=plugin_name) if plugin_args_bytes is not None: plugin_args_cls = plugin_descriptor.GetPluginArgsClass() if plugin_args_cls is not None: plugin_descriptor.plugin_args = plugin_args_cls.FromSerializedString( plugin_args_bytes) plugin_state = rdf_protodict.AttributedDict.FromSerializedString( plugin_state_bytes) return rdf_flow_runner.OutputPluginState( plugin_descriptor=plugin_descriptor, plugin_state=plugin_state)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Builds OutputPluginState object from a DB row.
def natural_neighbor(xp, yp, variable, grid_x, grid_y): return natural_neighbor_to_grid(xp, yp, variable, grid_x, grid_y)
module function_definition identifier parameters identifier identifier identifier identifier identifier block return_statement call identifier argument_list identifier identifier identifier identifier identifier
Wrap natural_neighbor_to_grid for deprecated natural_neighbor function.
def _make_candidate_from_result(self, result): candidate = Candidate() candidate.match_addr = result['formatted_address'] candidate.x = result['geometry']['location']['lng'] candidate.y = result['geometry']['location']['lat'] candidate.locator = self.LOCATOR_MAPPING.get(result['geometry']['location_type'], '') candidate.entity_types = result['types'] candidate.partial_match = result.get('partial_match', False) component_lookups = { 'city': {'type': 'locality', 'key': 'long_name'}, 'subregion': {'type': 'administrative_area_level_2', 'key': 'long_name'}, 'region': {'type': 'administrative_area_level_1', 'key': 'short_name'}, 'postal': {'type': 'postal_code', 'key': 'long_name'}, 'country': {'type': 'country', 'key': 'short_name'}, } for (field, lookup) in component_lookups.items(): setattr(candidate, 'match_' + field, self._get_component_from_result(result, lookup)) candidate.geoservice = self.__class__.__name__ return candidate
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier dictionary pair string string_start string_content string_end 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 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 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 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 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 for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier return_statement identifier
Make a Candidate from a Google geocoder results dictionary.