code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def by_own_time_per_call(stat): return (-stat.own_time_per_call if stat.own_hits else -stat.own_time, by_deep_time_per_call(stat))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'by_own_time_per_call'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Sorting by exclusive elapsed time per call in descending order.
def rigid_linear_interpolate_by_datetime(datetime_axis, y_axis, datetime_new_axis): numeric_datetime_axis = [ totimestamp(a_datetime) for a_datetime in datetime_axis ] numeric_datetime_new_axis = [ totimestamp(a_datetime) for a_datetime in datetime_new_axis ] return rigid_linear_inte...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rigid_linear_interpolate_by_datetime'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifie...
A datetime-version that takes datetime object list as x_axis.
def refine (self, requirements): assert isinstance(requirements, PropertySet) if requirements not in self.refined_: r = property.refine(self.all_, requirements.all_) self.refined_[requirements] = create(r) return self.refined_[requirements]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refine'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Refines this set's properties using the requirements passed as an argument.
def ipynb_to_rst(directory, filename): print(filename) os.chdir(directory) subprocess.Popen(["ipython", "nbconvert", "--to", "rst", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=directory)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ipynb_to_rst'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Converts a given file in a directory to an rst in the same directory.
def _repr_html_(self): out="<table class='taqltable'>\n" if not(self.name()[:4]=="Col_"): out+="<tr>" out+="<th><b>"+self.name()+"</b></th>" out+="</tr>" cropped=False rowcount=0 colkeywords=self.getkeywords() for row in self: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_repr_html_'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Give a nice representation of columns in notebooks.
def copy(self, **kwargs): msg = Message(self.encode(), self.gateway) for key, val in kwargs.items(): setattr(msg, key, val) return msg
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Copy a message, optionally replace attributes with kwargs.
def _convert_labeled_point_to_libsvm(p): from pyspark.mllib.regression import LabeledPoint assert isinstance(p, LabeledPoint) items = [str(p.label)] v = _convert_to_vector(p.features) if isinstance(v, SparseVector): nnz = len(v.indices) for i in xrange(nnz...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_labeled_point_to_libsvm'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children'...
Converts a LabeledPoint to a string in LIBSVM format.
def to_dict(self): return { "state_size": self.state_size, "chain": self.chain.to_json(), "parsed_sentences": self.parsed_sentences if self.retain_original else None }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Returns the underlying data as a Python dict.
def flush(self, multithread=True, **kwargs): if self._write_buf.tell() > 0: data = self._write_buf.getvalue() self._write_buf = BytesIO() if multithread: self._async_upload_part_request(data, index=self._cur_part, **kwargs) else: se...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flush'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Flushes the internal write buffer.
def add_upsert(self, value, criteria): value = value.strip() v = value.lower() self.lower_val_to_val[v] = value criteria_array = self.upserts.get(v) if criteria_array is None: criteria_array = [] self.upserts_size[v] = 31 + len(value) criteria_arra...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_upsert'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Add a tag or populator to the batch by value and criteria
def unquote(text): while '%' in text: newtext = url_unquote(text) if newtext == text: break text = newtext return text
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unquote'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {...
Replace all percent-encoded entities in text.
def com_google_fonts_check_name_rfn(ttFont): failed = False for entry in ttFont["name"].names: string = entry.toUnicode() if "reserved font name" in string.lower(): yield WARN, ("Name table entry (\"{}\")" " contains \"Reserved Font Name\"." " This is an error exc...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'com_google_fonts_check_name_rfn'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':...
Name table strings must not contain the string 'Reserved Font Name'.
async def on_isupport_targmax(self, value): if not value: return for entry in value.split(','): command, limit = entry.split(':', 1) if not limit: continue self._target_limits[command] = int(limit)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_isupport_targmax'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
The maximum number of targets certain types of commands can affect.
def _download_images(data, img_cols): images = collections.defaultdict(list) for d in data: for img_col in img_cols: if d.get(img_col, None): if isinstance(d[img_col], Image.Image): images[img_col].append(d[img_col]) else: with file_io.FileIO(d[img_col], 'rb') as fi: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_download_images'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Download images given image columns.
def closeEvent(self, event): self.stop_process() self.backend.stop() try: self.modes.remove('_LinkHighlighter') except KeyError: pass super(OutputWindow, self).closeEvent(event)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'closeEvent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Terminates the child process on close.
def make_vol_opt(hostdir, contdir, options=None): vol = '--volume={}:{}'.format(hostdir, contdir) if options != None: if isinstance(options, str): options = (options,) vol += ':' + ','.join(options) return vol
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_vol_opt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Generate a docker volume option
def _load_market_scheme(self): try: self.scheme = yaml.load(open(self.scheme_path, 'r')) except Exception, error: raise LoadMarketSchemeFailed(reason=error)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_market_scheme'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Load market yaml description
def add(self, *number): return self._format_result(sum( [int(n) for n in number]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Adds all parameters interpreted as integers
def CalcDayOfWeek(self): year, month, day, day_of_week = self.value day_of_week = 255 if year == 255: pass elif month in _special_mon_inv: pass elif day in _special_day_inv: pass else: try: today = time.mktim...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'CalcDayOfWeek'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Calculate the correct day of the week.
def find_java_home(cratedb_version: tuple) -> str: if MIN_VERSION_FOR_JVM11 <= cratedb_version < (4, 0): return os.environ.get('JAVA_HOME', '') if cratedb_version < MIN_VERSION_FOR_JVM11: return _find_matching_java_home(lambda ver: ver[0] == 8) else: return _find_matching_java_home(l...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_java_home'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5',...
Return a path to a JAVA_HOME suites for the given CrateDB version
def _get_ann(dbs, features): value = "" for db, feature in zip(dbs, features): value += db + ":" + feature return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_ann'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dbs...
Gives format to annotation for html table output
def normalize_time(timestamp): offset = timestamp.utcoffset() if offset is None: return timestamp return timestamp.replace(tzinfo=None) - offset
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_time'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ti...
Normalize time in arbitrary timezone to UTC naive object.
def load_children(self, f): while True: line = self.readline(f) if line[0] == '&': if line[1:].startswith("END"): check_name = line[4:].strip().upper() if check_name != self.__name: raise FileFormatError("CP2...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_children'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Load the children of this section from a file-like object
def authenticate_credentials(self, request, access_token): try: token = oauth2_provider.oauth2.models.AccessToken.objects.select_related('user') token = token.get(token=access_token, expires__gt=provider_now()) except oauth2_provider.oauth2.models.AccessToken.DoesNotExist: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate_credentials'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre...
Authenticate the request, given the access token.
def select(self): if sys.platform=='win32': self.dc.SelectObject(self.bitmap) self.IsSelected = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Select the current bitmap into this wxDC instance
def update_buildroot_koji(self, buildroot, output): docker = output[1]['extra']['docker'] name = '' for tag in docker['tags']: for repo in docker['repositories']: if tag in repo: iname = ImageName.parse(repo) name = iname.to_str...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_buildroot_koji'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':...
put the final koji information in the buildroot under extra.osbs
def multidict(ordered_pairs): d = defaultdict(list) for k, v in ordered_pairs: d[k].append(v) dict_copy = deepcopy(d) for k, v in iteritems(dict_copy): if len(v) == 1: d[k] = v[0] return dict(d)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multidict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ordered...
Convert duplicate keys values to lists.
def tag_map(self): tm = dd(list) for tag in self.__tags: tm[tag.tagtype].append(tag) return tm
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tag_map'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Build a map from tagtype to list of tags
async def _set_subscriptions(self, subscriptions): url, params = self._get_subscriptions_endpoint() data = { 'object': 'page', 'callback_url': self.webhook_url, 'fields': ', '.join(subscriptions), 'verify_token': self.verify_token, } header...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_subscriptions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Set the subscriptions to a specific list of values
def add_last_closed_file(self, fname): if fname in self.last_closed_files: self.last_closed_files.remove(fname) self.last_closed_files.insert(0, fname) if len(self.last_closed_files) > 10: self.last_closed_files.pop(-1)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_last_closed_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Add to last closed file list.
def mapstr_to_list(mapstr): maplist = [] with StringIO(mapstr) as infile: for row in infile: maplist.append(row.strip()) return maplist
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mapstr_to_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ma...
Convert an ASCII map string with rows to a list of strings, 1 string per row.
def clear(self): self._imgobj = None try: self.canvas.delete_object_by_tag(self._canvas_img_tag) self.redraw() except KeyError: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Clear the displayed image.
def interfaces(self): if not self._interfaces_cache: response = yield from self.get("/network/interfaces") self._interfaces_cache = response.json return self._interfaces_cache
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interfaces'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Get the list of network on compute
def __update_rating(uid, rating): entry = TabPost.update( rating=rating ).where(TabPost.uid == uid) entry.execute()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__update_rating'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Update the rating for post.
def unpy2exe(filename, python_version=None, output_dir=None): if output_dir is None: output_dir = '.' elif not os.path.exists(output_dir): os.makedirs(output_dir) pe = pefile.PE(filename) is_py2exe = check_py2exe_file(pe) if not is_py2exe: raise ValueError('Not a py2exe execu...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unpy2exe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Process input params and produce output pyc files.
def _django_to_es_field(self, field): from django.db import models prefix = "" if field.startswith("-"): prefix = "-" field = field.lstrip("-") if field in ["id", "pk"]: return "_id", models.AutoField try: dj_field, _, _, _ = self.m...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_django_to_es_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
We use this function in value_list and ordering to get the correct fields name
def stderr_file(self): stderr_file = None if self.connection_file is not None: stderr_file = self.kernel_id + '.stderr' if self.stderr_dir is not None: stderr_file = osp.join(self.stderr_dir, stderr_file) else: try: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stderr_file'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Filename to save kernel stderr output.
def create_configwidget(self, parent): if self.CONFIGWIDGET_CLASS is not None: configwidget = self.CONFIGWIDGET_CLASS(self, parent) configwidget.initialize() return configwidget
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_configwidget'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Create configuration dialog box page widget
def label_from_func(self, func:Callable, label_cls:Callable=None, **kwargs)->'LabelList': "Apply `func` to every input to get its label." return self._label_from_list([func(o) for o in self.items], label_cls=label_cls, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'label_from_func'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '14']}; {'id': '4', 'type': 'identifier', 'chi...
Apply `func` to every input to get its label.
def _hierarchy(self): self.hierarchy = {} for rank in self.taxonomy: taxslice = self._slice(level=self.taxonomy.index(rank)) self.hierarchy[rank] = self._group(taxslice)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_hierarchy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Generate dictionary of referenced idents grouped by shared rank
def from_name(cls, name): result = cls.list() dc_names = {} for dc in result: dc_names[dc['name']] = dc['id'] return dc_names.get(name)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cl...
Retrieve datacenter id associated to a name.
def full_analysis(self, analysis_set, output_directory, verbose = True, compile_pdf = True, quick_plots = False): if not os.path.isdir(output_directory): os.makedirs(output_directory) self.analysis_directory = output_directory self.calculate_metrics(analysis_set = analysis_set, analy...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'full_analysis'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', '...
Combines calculate_metrics, write_dataframe_to_csv, and plot
def pull_repo(repo_name): repo = ClonedRepo.objects.get(pk=repo_name) repo.pull()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pull_repo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'repo_na...
Pull from origin for repo_name.
def _get_websocket(self, reuse=True): if self.ws and reuse: if self.ws.connected: return self.ws logging.debug("Stale connection, reconnecting.") self.ws = self._create_connection() return self.ws
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_websocket'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Reuse existing connection or create a new connection.
def vec_by_id(self, docid): pos = self.id2pos[docid] return self.qindex.vector_by_id(pos)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vec_by_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Return indexed vector corresponding to document `docid`.
def drain_events(self, allowed_methods=None, timeout=None): return self.wait_multi(self.channels.values(), timeout=timeout)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drain_events'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Wait for an event on any channel.
def fan_maxcfm(ddtt): if str(ddtt.Maximum_Flow_Rate).lower() == 'autosize': return 'autosize' else: m3s = float(ddtt.Maximum_Flow_Rate) return m3s2cfm(m3s)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fan_maxcfm'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ddtt'}...
return the fan max cfm
def open_fileswitcher(self, symbol=False): if self.fileswitcher is not None and \ self.fileswitcher.is_visible: self.fileswitcher.hide() self.fileswitcher.is_visible = False return if symbol: self.fileswitcher.plugin = self.editor ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open_fileswitcher'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Open file list management dialog box.
def sodium_memcmp(inp1, inp2): ensure(isinstance(inp1, bytes), raising=exc.TypeError) ensure(isinstance(inp2, bytes), raising=exc.TypeError) ln = max(len(inp1), len(inp2)) buf1 = ffi.new("char []", ln) buf2 = ffi.new("char []", ln) ffi.memmove(buf1, inp1, len(inp1)) ffi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sodium_memcmp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Compare contents of two memory regions in constant time
def load_template_source(template_name, template_dirs=None): template_zipfiles = getattr(settings, "TEMPLATE_ZIP_FILES", []) for fname in template_zipfiles: try: z = zipfile.ZipFile(fname) source = z.read(template_name) except (IOError, KeyError): continue ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_template_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Template loader that loads templates from a ZIP file.
def start(self): self._events_to_write = [] self._new_contracts_to_write = [] @events.on(SmartContractEvent.CONTRACT_CREATED) @events.on(SmartContractEvent.CONTRACT_MIGRATED) def call_on_success_event(sc_event: SmartContractEvent): self.on_smart_contract_created(sc_ev...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Handle EventHub events for SmartContract decorators
def create_from_eflux(cls, params, emin, emax, eflux, scale=1.0): params = params.copy() params[0] = 1.0 params[0] = eflux / cls.eval_eflux(emin, emax, params, scale=scale) return cls(params, scale)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_from_eflux'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier',...
Create a spectral function instance given its energy flux.
def load(self): try: self._read() self._parse() except Exception as exc: self.failed = True params = {'path': self._path, 'exception': exc} if self.fail_silently: LOG.warning("Error processing message json file '%(path)s': " ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Read and parse the message file.
def rgb2short(r, g, b): r, g, b = [len(tuple(s for s in snaps if s < x)) for x in (r, g, b)] return (r * 36) + (g * 6) + b + 16
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rgb2short'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Converts RGB values to the nearest equivalent xterm-256 color.
def can_user_approve_this_page(self, user): self.ensure_one() if not self.is_approval_required: return True if user.has_group('document_page.group_document_manager'): return True if not user.has_group( 'document_page_approval.group_document_approve...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'can_user_approve_this_page'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
Check if a user can approve this page.
def _styleof(expr, styles): style = dict() for expr_filter, sty in styles: if expr_filter(expr): style.update(sty) return style
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_styleof'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'exp...
Merge style dictionaries in order
def connection_made(self, transport): self.logger.info('Connection made at object %s', id(self)) self.transport = transport self.keepalive = True if self._timeout: self.logger.debug('Registering timeout event') self._timout_handle = self._loop.call_later( ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connection_made'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Called when the connection is made
def _get_vswitch_for_physical_network(self, phys_network_name): for pattern in self._physical_network_mappings: if phys_network_name is None: phys_network_name = '' if re.match(pattern, phys_network_name): return self._physical_network_mappings[pattern]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_vswitch_for_physical_network'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chi...
Get the vswitch name for the received network name.
def _md5(path, blocksize=2 ** 20): m = hashlib.md5() with open(path, 'rb') as f: while True: buf = f.read(blocksize) if not buf: break m.update(buf) return m.hexdigest()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_md5'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}...
Compute the checksum of a file.
def doc_browse(self, args, range=None): self.log.debug('browse: in') self.call_options[self.call_id] = {"browse": True} self.send_at_position("DocUri", False, "point")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'doc_browse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Browse doc of whatever at cursor.
def _pulse_enable(self): GPIO.output(self.pins.e, 0) c.usleep(1) GPIO.output(self.pins.e, 1) c.usleep(1) GPIO.output(self.pins.e, 0) c.usleep(100)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pulse_enable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Pulse the `enable` flag to process data.
def _add_spanning_relation(self, source, target): self.add_edge(source, target, layers={self.ns, self.ns+':unit'}, edge_type=EdgeTypes.spanning_relation)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_spanning_relation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'...
add a spanning relation to this docgraph
def add(self, queue_name, transactional=False): task = self.to_task() task.add(queue_name, transactional)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Add task to the queue.
def _make_index(df, cols=META_IDX): return pd.MultiIndex.from_tuples( pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Create an index from the columns of a dataframe
def _call(self, x, out=None): if out is None: out = self.range.element() with writable_array(out) as out_arr: finite_diff(x.asarray(), axis=self.axis, dx=self.dx, method=self.method, pad_mode=self.pad_mode, pad_const=self.pad_const,...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_call'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Calculate partial derivative of ``x``.
def homer_stats_table_interChr(self): headers = OrderedDict() headers['InterChr'] = { 'title': 'InterChr', 'description': 'Fraction of Reads forming inter chromosomal interactions', 'format': '{:,.4f}' } self.general_stats_addcols(self.tagdir_data['Fre...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'homer_stats_table_interChr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Add core HOMER stats to the general stats table from FrequencyDistribution file
def del_actor(self, actor): if _debug: TCPClientDirector._debug("del_actor %r", actor) del self.clients[actor.peer] if self.serviceElement: self.sap_request(del_actor=actor) if actor.peer in self.reconnect: connect_task = FunctionTask(self.connect, actor.peer) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'del_actor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Remove an actor when the socket is closed.
def matches_truth(call_alleles, truth_alleles, data): if not truth_alleles: return "" else: def _remove_p(x): return x[:-1] if x.endswith("P") else x t_cmp = set([_remove_p(hla_groups.hla_protein(x, data)) for x in truth_alleles]) c_cmp = set([_remove_p(hla_groups.hla...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'matches_truth'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Flexibly check if truth and call alleles match, using p-groups.
def fetch(elastic, backend, limit=None, search_after_value=None, scroll=True): logging.debug("Creating a elastic items generator.") elastic_scroll_id = None search_after = search_after_value while True: if scroll: rjson = get_elastic_items(elastic, elastic_scroll_id, limit) e...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [],...
Fetch the items from raw or enriched index
def _update_const_classes(): klasses = (bool, int, float, complex, str, bytes) for kls in klasses: CONST_CLS[kls] = Const
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_const_classes'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '15']}; {'i...
update constant classes, so the keys of CONST_CLS can be reused
def _relative_uris(self, uri_list): return [u for u in (self._relative(uri) for uri in uri_list) if u]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_relative_uris'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
if uris in list are relative, re-relate them to our basedir
def setup_custom_logger(name): global loggers if loggers.get(name): return loggers.get(name) formatter = logging.Formatter( fmt='%(levelname)s: %(message)s' ) handler = TqdmLoggingHandler() handler.setFormatter(formatter) if system() not in ['Windows', 'cli']: logging...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_custom_logger'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Create a logger with a certain name and level
def notify_exception(self, exception, run_done_callbacks=True): logger.error("%s : %s" % (exception.__class__.__name__, str(exception))) self._exception = exception if self.is_running(True): for _cnt in range(0, 5): if not self._cancel(): time.slee...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'notify_exception'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
set the exception message, stop transfer if running and set the done event
def update_params(self, params): if not params.get('BINARY', True): raise Warning('To increase performance please use ElastiCache' ' in binary mode') else: params['BINARY'] = True if 'OPTIONS' not in params: params['OPTIONS'] = { ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
update connection params to maximize performance
def run(self): self._clearQuantities() self._clearPrices() self._clipPrices() self._logClearances() return self.offers, self.bids
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'...
Clears a set of bids and offers.
def parse_negation_operation(operation: str) -> Tuple[bool, str]: _operation = operation.strip() if not _operation: raise QueryParserException('Operation is not valid: {}'.format(operation)) negation = False if _operation[0] == '~': negation = True _operation = _operation[1:] ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_negation_operation'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'childr...
Parse the negation modifier in an operation.
def _basis_polynomial_factory(cls, kind): valid_kind = cls._validate(kind) basis_polynomial = getattr(np.polynomial, valid_kind) return basis_polynomial
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_basis_polynomial_factory'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ...
Return a polynomial given some coefficients.
def validate_file_permissions(config): files = config.get('files', {}) for file_name, options in files.items(): for key in options.keys(): if key not in ["owner", "group", "mode"]: raise RuntimeError( "Invalid ownership configuration: {}".format(key)) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_file_permissions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Verify that permissions on configuration files are secure enough.
def _set_duty(self, motor_duty_file, duty, friction_offset, voltage_comp): duty_int = int(round(duty*voltage_comp)) if duty_int > 0: duty_int = min(100, duty_int + friction_offset) elif duty_int < 0: duty_int = max(-100, duty_int - friction_offset) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_duty'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [...
Function to set the duty cycle of the motors.
def imagenet_clamp_batch(batch, low, high): F.clip(batch[:,0,:,:],low-123.680, high-123.680) F.clip(batch[:,1,:,:],low-116.779, high-116.779) F.clip(batch[:,2,:,:],low-103.939, high-103.939)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'imagenet_clamp_batch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ...
Not necessary in practice
def to_csv(self, fileobj=sys.stdout): openclose = is_string(fileobj) if openclose: fileobj = open(fileobj, "w") for idx, section in enumerate(self.sections): fileobj.write(section.to_csvline(with_header=(idx == 0))) fileobj.flush() if openclose: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_csv'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Write data on file fileobj using CSV format.
def GetConfigPolicy(self, request, context): try: policy = self.plugin.get_config_policy() return policy._pb except Exception as err: msg = "message: {}\n\nstack trace: {}".format( err.message, traceback.format_exc()) return GetConfigPolicy...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetConfigPolicy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Dispatches the request to the plugins get_config_policy method
def preproc_directive(self) -> bool: self._stream.save_context() if self.read_until("\n", '\\'): return self._stream.validate_context() return self._stream.restore_context()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'preproc_directive'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Consume a preproc directive.
def map(self, width, height): template = ti.load(os.path.join(script_dir, 'assets', 'template.tmx'))['map0'] template.set_view(0, 0, width*template.tw, height*template.th) border_x = template.cells[width] for y in xrange(0,height+1): border_x[y].tile = template.cells[0][0].ti...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Creates and returns a new randomly generated map
def dateadd(value: fields.DateTime(), addend: fields.Int(validate=Range(min=1)), unit: fields.Str(validate=OneOf(['minutes', 'days']))='days'): value = value or dt.datetime.utcnow() if unit == 'minutes': delta = dt.timedelta(minutes=addend) else: delta = dt.timedelta(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '45']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dateadd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '12', '28']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5',...
Add a value to a date.
def _update_or_init_po_files(target, source, env): import SCons.Action from SCons.Tool.GettextCommon import _init_po_files for tgt in target: if tgt.rexists(): action = SCons.Action.Action('$MSGMERGECOM', '$MSGMERGECOMSTR') else: action = _init_po_files status = action([tgt], source, env) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_or_init_po_files'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre...
Action function for `POUpdate` builder
def folderitems(self): items = super(AnalysisRequestAnalysesView, self).folderitems() self.categories.sort() return items
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'folderitems'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
XXX refactor if possible to non-classic mode
def assemble_english(): if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) stmts_json = body.get('statements') stmts = stmts_from_json(stmts_json) sentences = {} for st in stmts: enga = EnglishAssembler() ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assemble_english'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '29', '38'...
Assemble each statement into
def visit_Variable(self, node): var_name = node.identifier.name var_symbol = self.table[var_name] if var_symbol is None: raise SementicError(f"Variable `{var_name}` is not declared.")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_Variable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Visitor for `Variable` AST node.
async def _set_whitelist(self): page = self.settings() if 'whitelist' in page: await self._send_to_messenger_profile(page, { 'whitelisted_domains': page['whitelist'], }) logger.info('Whitelisted %s for page %s', page['whitelist'...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_whitelist'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Whitelist domains for the messenger extensions
def submit_tag_batch(self, batch): url = '%s/api/v5/batch/tags' % self.base_url self._submit_batch(url, batch)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'submit_tag_batch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Submit a tag batch
def _elements(cls): if not cls.__is_selector(): raise Exception("Invalid selector[%s]." %cls.__control["by"]) driver = Web.driver try: elements = WebDriverWait(driver, cls.__control["timeout"]).until(lambda driver: getattr(driver,"find_elements")(cls.__co...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_elements'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; ...
find the elements with controls
def _roots_to_targets(self, build_graph, target_roots): with self._run_tracker.new_workunit(name='parse', labels=[WorkUnitLabel.SETUP]): return [ build_graph.get_target(address) for address in build_graph.inject_roots_closure(target_roots, self._fail_fast) ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_roots_to_targets'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
Populate the BuildGraph and target list from a set of input TargetRoots.
def create_parameterized_CAG(input, output, filename="CAG_with_indicators_and_values.pdf"): with open(input, "rb") as f: G = pickle.load(f) G.parameterize(year=2017, month=4) G.get_timeseries_values_for_indicators() with open(output, "wb") as f: pickle.dump(G, f)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_parameterized_CAG'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre...
Create a CAG with mapped and parameterized indicators
def class_name_for_annotation_type(annotation_type, ns=None): assert isinstance(annotation_type, AnnotationType) name = fmt_class(annotation_type.name) if ns: return prefix_with_ns_if_necessary(name, annotation_type.namespace, ns) return name
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'class_name_for_annotation_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childr...
Same as class_name_for_data_type, but works with annotation types.
def delete_video(video_id, cascade=False, delete_shares=False, _connection=None): c = _connection if not c: c = connection.APIConnection() c.post('delete_video', video_id=video_id, cascade=cascade, delete_shares=delete_shares)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_video'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [...
Delete the video represented by the ``video_id`` parameter.
def add_parameters(parser): group = parser.add_argument_group('Evaluation arguments') group.add_argument('--eval-batch-size', type=int, default=1024) group.add_argument( '--similarity-datasets', type=str, default=nlp.data.word_embedding_evaluation.word_similarity_datasets, nargs='*',...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_parameters'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pa...
Add evaluation specific parameters to parser.
def _get_taxon(taxon): if not taxon: return None sep = taxon.find(':') taxid = taxon[sep + 1:] assert taxid.isdigit(), "UNEXPECTED TAXON({T})".format(T=taxid) return int(taxid)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_taxon'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'taxon'...
Return Interacting taxon ID | optional | 0 or 1 | gaf column 13.
def parse_sig(sig): label, sig = sig assert label == b'sig-val' algo_name = sig[0] parser = {b'rsa': _parse_rsa_sig, b'ecdsa': _parse_ecdsa_sig, b'eddsa': _parse_eddsa_sig, b'dsa': _parse_dsa_sig}[algo_name] return parser(args=sig[1:])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_sig'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sig'}; ...
Parse signature integer values from s-expr.
def stashed(func): @functools.wraps(func) def _wrapper(*args, **kwargs): if CTX.stash and not CTX.repo.stashed: CTX.repo.stash(func.__name__) try: func(*args, **kwargs) finally: CTX.repo.unstash() else: func(*args, *...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stashed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {...
Simple decorator to stash changed files between a destructive repo operation