code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def execute(self, fetchcommand, sql, params=None): cur = self.conn.cursor() if params: if not type(params).__name__ == 'tuple': raise ValueError('the params argument needs to be a tuple') return None cur.execute(sql, params) else: cur.execute(sql) self.conn.commit() if not fetchcommand or fet...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
where 'fetchcommand' is either 'fetchone' or 'fetchall'
def update(): with settings(warn_only=True): print(cyan('\nInstalling/Updating required packages...')) pip = local('venv/bin/pip install -U --allow-all-external --src libs -r requirements.txt', capture=True) if pip.failed: print(red(pip)) abort("pip exited with return...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'wit...
Update virtual env with requirements packages.
def new(self, request): form = (self.form or generate_form(self.model))() return self._render( request = request, template = 'new', context = { 'form': form }, status = 200 )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'new'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Render a form to create a new object.
def fetch_url(url, dest, parent_to_remove_before_fetch): logger.debug('Downloading file {} from {}', dest, url) try: shutil.rmtree(parent_to_remove_before_fetch) except FileNotFoundError: pass os.makedirs(parent_to_remove_before_fetch) resp = requests.get(url, stream=True) with o...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Helper function to fetch a file from a URL.
def build(self): monomers = [HelicalHelix(major_pitch=self.major_pitches[i], major_radius=self.major_radii[i], major_handedness=self.major_handedness[i], aa=self.aas[i], minor_heli...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Builds a model of a coiled coil protein using input parameters.
def _optimize_providers(self, providers): new_providers = {} provider_by_driver = {} for alias, driver in six.iteritems(providers): for name, data in six.iteritems(driver): if name not in provider_by_driver: provider_by_driver[name] = {} ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_optimize_providers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Return an optimized mapping of available providers
def upload(): build = g.build utils.jsonify_assert(len(request.files) == 1, 'Need exactly one uploaded file') file_storage = request.files.values()[0] data = file_storage.read() content_type, _ = mimetypes.guess_type(file_storage.filename) artifact = _save_artifact(build...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '26', '38', '46', '5...
Uploads an artifact referenced by a run.
def vip_create_event(self, vip_info): vip_data = vip_info.get('vip') port_id = vip_data.get('port_id') vip_id = vip_data.get('id') self.add_lbaas_port(port_id, vip_id)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vip_create_event'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Process vip create event.
def _import_class(self, module2cls): d = module2cls.rfind(".") classname = module2cls[d + 1: len(module2cls)] m = __import__(module2cls[0:d], globals(), locals(), [classname]) return getattr(m, classname)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_import_class'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Import class by module dot split string
def createNetcon(self, thresh=10): nc = h.NetCon(self.soma(0.5)._ref_v, None, sec = self.soma) nc.threshold = thresh return nc
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'createNetcon'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
created netcon to record spikes
def cart2spher(x, y, z): hxy = np.hypot(x, y) r = np.hypot(hxy, z) theta = np.arctan2(z, hxy) phi = np.arctan2(y, x) return r, theta, phi
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cart2spher'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Cartesian to Spherical coordinate conversion.
def iterkeys(obj): "Get key iterator from dictionary for Python 2 and 3" return iter(obj.keys()) if sys.version_info.major == 3 else obj.iterkeys()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iterkeys'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {...
Get key iterator from dictionary for Python 2 and 3
def invert_delete_row(self, key, value): self.rows = filter(lambda x: x.get(key) == value, self.rows)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'invert_delete_row'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
Inverts delete_row and returns the rows where key = value
def excursion(directory): old_dir = os.getcwd() try: os.chdir(directory) yield finally: os.chdir(old_dir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'excursion'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'directo...
Context-manager that temporarily changes to a new working directory.
def countWordOverlapFrequencies(filename="goodOverlapPairs.pkl"): with open(filename,"rb") as f: goodOverlapPairs = pickle.load(f) with open("word_bitmaps_40_bits_minimum.pkl","rb") as f: bitmaps = pickle.load(f) wordFrequencies = {} for w1, w2, overlap in goodOverlapPairs: wordFrequencies[w1] = wor...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'countWordOverlapFrequencies'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'childre...
Count how many high overlaps each word has, and print it out
def parse_iso8601_date(string): match = _RE_ISO8601_DATE.search(string) if not match: raise ValueError('Expected ISO 8601 date') year = int(match.group('year')) month = int(match.group('month')) day = int(match.group('day')) return date(year, month, day)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_iso8601_date'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Parse an ISO 8601 date string
def management(self): endpoint = self._instance.get_endpoint_for_service_type( "management", region_name=self._instance._region_name, ) token = self._instance.auth.get_token(self._instance.session) self._management = tuskar_client.get_client( 2, os_aut...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'management'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Returns an management service client
def example_lab_to_xyz(): print("=== Simple Example: Lab->XYZ ===") lab = LabColor(0.903, 16.296, -2.22) print(lab) xyz = convert_color(lab, XYZColor) print(xyz) print("=== End Example ===\n")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'example_lab_to_xyz'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '10', '20', '2...
This function shows a simple conversion of an Lab color to an XYZ color.
def path_to_reference(path): path = str(path) if '.' not in path: try: return globals()["__builtins__"][path] except KeyError: try: return getattr(globals()["__builtins__"], path) except AttributeError: pass try: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'path_to_reference'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Convert an object path reference to a reference.
def _check_prob_and_prob_vector(predictions): from .._deps import numpy ptype = predictions.dtype import array if ptype not in [float, numpy.ndarray, array.array, int]: err_msg = "Input `predictions` must be of numeric type (for binary " err_msg += "classification) or array (of probabil...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_prob_and_prob_vector'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],...
Check that the predictionsa are either probabilities of prob-vectors.
def _get_mosaik_nn_args(out_file): base_nn_url = "https://raw.github.com/wanpinglee/MOSAIK/master/src/networkFile/" out = [] for arg, fname in [("-annse", "2.1.26.se.100.005.ann"), ("-annpe", "2.1.26.pe.100.0065.ann")]: arg_fname = os.path.join(os.path.dirname(out_file), fname...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_mosaik_nn_args'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Retrieve default neural network files from GitHub to pass to Mosaik.
def _handle_ping(client, topic, dct): if dct['type'] == 'request': resp = { 'type': 'answer', 'name': client.name, 'source': dct } client.publish('ping', resp)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_ping'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Internal method that will be called when receiving ping message.
def rand_pad(padding:int, size:int, mode:str='reflection'): "Fixed `mode` `padding` and random crop of `size`" return [pad(padding=padding,mode=mode), crop(size=size, **rand_pos)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rand_pad'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5',...
Fixed `mode` `padding` and random crop of `size`
def upload_data(job, master_ip, inputs, hdfs_name, upload_name, spark_on_toil): if mock_mode(): truncate_file(master_ip, hdfs_name, spark_on_toil) log.info("Uploading output BAM %s to %s.", hdfs_name, upload_name) call_conductor(job, master_ip, hdfs_name, upload_name, memory=inputs.memory) remov...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chil...
Upload file hdfsName from hdfs to s3
def object(self): proxy = self._proxy return ObjectProxy(proxy.get_connection(), proxy.get_name(), proxy.get_object_path())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'object'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Get an ObjectProxy instanec for the underlying object.
def append(self, item: TransItem): self.data[item.key].append(item)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Append an item to the internal dictionary.
def calculate_dimensions(image, long_side, short_side): if image.width >= image.height: return '{0}x{1}'.format(long_side, short_side) return '{0}x{1}'.format(short_side, long_side)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_dimensions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ...
Returns the thumbnail dimensions depending on the images format.
def createCenterPointMarker(self): self.axes.add_patch(patches.Rectangle((-0.75,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Rectangle((0.25,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Circle((0,0),radius=...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'createCenterPointMarker'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Creates the center pointer in the middle of the screen.
def cublasDsymm(handle, side, uplo, m, n, alpha, A, lda, B, ldb, beta, C, ldc): status = _libcublas.cublasDsymm_v2(handle, _CUBLAS_SIDE_MODE[side], _CUBLAS_FILL_MODE[uplo], m, n, ctypes.byref(ctypes...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cublasDsymm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']...
Matrix-matrix product for real symmetric matrix.
def setup_options_button(self): if not self.options_button: self.options_button = create_toolbutton( self, text=_('Options'), icon=ima.icon('tooloptions')) actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions self.options_menu = QMenu(self) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_options_button'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Add the cog menu button to the toolbar.
def parseFile(self, filename): modname = self.filenameToModname(filename) module = Module(modname, filename) self.modules[modname] = module if self.trackUnusedNames: module.imported_names, module.unused_names = \ find_imports_and_track_names(filename, ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parseFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Parse a single file.
def getUmis(self, n): if n < (self.random_fill_size - self.random_ix): barcodes = self.random_umis[self.random_ix: self.random_ix+n] else: if n > self.random_fill_size: self.random_fill_size = n * 2 self.refill_random() barcodes = self.rand...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getUmis'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
return n umis from the random_umis atr.
def schema_exists(cls, cur, schema_name): cur.execute("SELECT EXISTS (SELECT schema_name FROM information_schema.schemata WHERE schema_name = '{0}');" .format(schema_name)) return cur.fetchone()[0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schema_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Check if schema exists
def generate_nonce_timestamp(): global count rng = botan.rng().get(30) uuid4 = uuid.uuid4().bytes tmpnonce = (bytes(str(count).encode('utf-8'))) + uuid4 + rng nonce = tmpnonce[:41] count += 1 return nonce
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_nonce_timestamp'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '20...
Generate unique nonce with counter, uuid and rng.
def _load_data(batch, targets, major_axis): if isinstance(batch, list): new_batch = [] for i in range(len(targets)): new_batch.append([b.data[i] for b in batch]) new_targets = [[dst for _, dst in d_target] for d_target in targets] _load_general(new_batch, new_targets, maj...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Load data into sliced arrays.
def create_filehandlers(self, filenames, fh_kwargs=None): filenames = list(OrderedDict.fromkeys(filenames)) logger.debug("Assigning to %s: %s", self.info['name'], filenames) self.info.setdefault('filenames', []).extend(filenames) filename_set = set(filenames) created_fhs = {} ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_filehandlers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
Organize the filenames into file types and create file handlers.
def proj_units_to_meters(proj_str): proj_parts = proj_str.split() new_parts = [] for itm in proj_parts: key, val = itm.split('=') key = key.strip('+') if key in ['a', 'b', 'h']: val = float(val) if val < 6e6: val *= 1000. val = ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'proj_units_to_meters'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Convert projection units from kilometers to meters.
def sphinx_class(self): classdoc = self.prop.sphinx_class().replace( ':class:`', '{info} of :class:`' ) return classdoc.format(info=self.class_info)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sphinx_class'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Redefine sphinx class to point to prop class
def _get_first_assessment_section(self): if ('sections' not in self._my_map or not self._my_map['sections']): assessment_id = self.get_assessment_offered().get_assessment().get_id() first_part_id = get_first_part_id_for_assessment(assessment_id, runtime=self._runtime, proxy=self._proxy) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_first_assessment_section'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [...
Gets the first section for this Taken's Assessment.
def _project_eigenvectors(self): self._p_eigenvectors = [] for vecs_q in self._eigenvectors: p_vecs_q = [] for vecs in vecs_q.T: p_vecs_q.append(np.dot(vecs.reshape(-1, 3), self._projection_direction)) self._p_eig...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_project_eigenvectors'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Eigenvectors are projected along Cartesian direction
def _assert_git_repo(target): hooks_dir = os.path.abspath(os.path.join(target, HOOKS_DIR_PATH)) if not os.path.isdir(hooks_dir): raise GitHookInstallerError(u"{0} is not a git repository.".format(target))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_assert_git_repo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Asserts that a given target directory is a git repository
def register_phonon_task(self, *args, **kwargs): kwargs["task_class"] = PhononTask return self.register_task(*args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_phonon_task'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': ...
Register a phonon task.
def common_options(func): def parse_preset(ctx, param, value): return PRESETS.get(value, (None, None)) def parse_private(ctx, param, value): return hex_from_b64(value) if value else None func = click.option('--private', default=None, help='Private.', callback=parse_private)(func) func = ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'common_options'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fu...
Commonly used command options.
def register_laser_hooks(self, hook_type: str, hook: Callable): if hook_type == "add_world_state": self._add_world_state_hooks.append(hook) elif hook_type == "execute_state": self._execute_state_hooks.append(hook) elif hook_type == "start_sym_exec": self._star...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_laser_hooks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children':...
registers the hook with this Laser VM
def extensions(): import numpy from Cython.Build import cythonize ext = [ Extension('phydmslib.numutils', ['phydmslib/numutils.pyx'], include_dirs=[numpy.get_include()], extra_compile_args=['-Wno-unused-function']), ] return cythonize(e...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extensions'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '8', '14', '36']}; {'i...
Returns list of `cython` extensions for `lazy_cythonize`.
def ingest_containers(self, containers=None): containers = containers or self.stream or {} output_containers = [] for container_name, definition in containers.items(): container = definition.copy() container['name'] = container_name output_containers.append(co...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ingest_containers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Transform the YAML into a dict with normalized keys
def shovel_help(shovel, *names): if not len(names): return heirarchical_help(shovel, '') else: for name in names: task = shovel[name] if isinstance(task, Shovel): return heirarchical_help(task, name) else: return task.help()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shovel_help'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Return a string about help with the tasks, or lists tasks available
def flash_errors(form, category='warning'): for (field, errors) in form.errors.items(): for error in errors: flash('{0} - {1}'.format(getattr(form, field).label.text, error), category)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flash_errors'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Flash all form error messages
def compute_radius(wcs): ra, dec = wcs.wcs.crval img_center = SkyCoord(ra=ra * u.degree, dec=dec * u.degree) wcs_foot = wcs.calc_footprint() img_corners = SkyCoord(ra=wcs_foot[:, 0] * u.degree, dec=wcs_foot[:, 1] * u.degree) radius = img_center.separation(img_corners).max(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_radius'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'wc...
Compute the radius from the center to the furthest edge of the WCS.
def _get_ssh_client(self): return ipa_utils.get_ssh_client( self.instance_ip, self.ssh_private_key_file, self.ssh_user, timeout=self.timeout )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_ssh_client'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Return a new or existing SSH client for given ip.
def measure_cost(repeat, scipy_trans_lhs, scipy_dns_lhs, func_name, *args, **kwargs): mx.nd.waitall() args_list = [] for arg in args: args_list.append(arg) start = time.time() if scipy_trans_lhs: args_list[0] = np.transpose(args_list[0]) if scipy_dns_lhs else sp.spmatrix.transpose(ar...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'measure_cost'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '10']}; {'id': '4', 'type': 'identifier', 'ch...
Measure time cost of running a function
def build(mnemonic, oprnd1, oprnd2, oprnd3): ins = ReilInstruction() ins.mnemonic = mnemonic ins.operands = [oprnd1, oprnd2, oprnd3] return ins
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Return the specified instruction.
def _parse_region(self, rec, line_iter): had_info = False keyvals, section = self._parse_keyvals(line_iter) if keyvals: rec.metadata = keyvals[0] while section and section[0] != "STUDY": had_info = True keyvals, next_section = self._parse_keyvals(line_...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_region'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Parse a section of an ISA-Tab, assigning information to a supplied record.
def _get_collection_for_user(self, collection_id, user): collection_query = Collection.objects.filter(pk=collection_id) if not collection_query.exists(): raise exceptions.ValidationError('Collection id does not exist') collection = collection_query.first() if not user.has_per...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_collection_for_user'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre...
Check that collection exists and user has `add` permission.
def scale_edges(self, multiplier): if not isinstance(multiplier,int) and not isinstance(multiplier,float): raise TypeError("multiplier must be an int or float") for node in self.traverse_preorder(): if node.edge_length is not None: node.edge_length *= multiplier
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scale_edges'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Multiply all edges in this ``Tree`` by ``multiplier``
def lower_coerce_type_blocks(ir_blocks): new_ir_blocks = [] for block in ir_blocks: new_block = block if isinstance(block, CoerceType): predicate = BinaryComposition( u'contains', Literal(list(block.target_class)), LocalField('@class')) new_block = Filter(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lower_coerce_type_blocks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Lower CoerceType blocks into Filter blocks with a type-check predicate.
def _draw_outline(o:Patch, lw:int): "Outline bounding box onto image `Patch`." o.set_path_effects([patheffects.Stroke( linewidth=lw, foreground='black'), patheffects.Normal()])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_draw_outline'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', ...
Outline bounding box onto image `Patch`.
def _construct_mongos(self, logpath, port, configdb): extra = '' auth_param = '' if self.args['auth']: key_path = os.path.abspath(os.path.join(self.dir, 'keyfile')) auth_param = '--keyFile %s' % key_path if self.unknown_args: extra = self._filter_valid...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_construct_mongos'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'...
Construct command line strings for a mongos process.
def probes_used_extract_scores(full_scores, same_probes): if full_scores.shape[1] != same_probes.shape[0]: raise "Size mismatch" import numpy as np model_scores = np.ndarray((full_scores.shape[0],np.sum(same_probes)), 'float64') c=0 for i in range(0,full_scores.shape[1]): if same_probes[i]: for j in...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'probes_used_extract_scores'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
Extracts a matrix of scores for a model, given a probes_used row vector of boolean
def count(self, query): if self.manual: return self.total if isinstance(query, Select): q = query.with_only_columns([func.count()]).order_by(None).limit(None).offset(None) return do_(q).scalar() return query.count()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
If query is Select object, this function will try to get count of select
def format_sms_payload(self, message, to, sender='elkme', options=[]): self.validate_number(to) if not isinstance(message, str): message = " ".join(message) message = message.rstrip() sms = { 'from': sender, 'to': to, 'message': message ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_sms_payload'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'c...
Helper function to create a SMS payload with little effort
def run_cli(): "Command line interface to hiwenet." features_path, groups_path, weight_method, num_bins, edge_range, \ trim_outliers, trim_percentile, return_networkx_graph, out_weights_path = parse_args() features, groups = read_features_and_groups(features_path, groups_path) extract(features, grou...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_cli'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '23', '33']}; {'id':...
Command line interface to hiwenet.
def _onArgument(self, name, annotation): self.objectsStack[-1].arguments.append(Argument(name, annotation))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_onArgument'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Memorizes a function argument
def validate_path(ctx, param, value): client = ctx.obj if value is None: from renku.models.provenance import ProcessRun activity = client.process_commit() if not isinstance(activity, ProcessRun): raise click.BadParameter('No tool was found.') return activity.path ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Detect a workflow path if it is not passed.
def community_colors(n): if (n > 0): colors = cl.scales['12']['qual']['Paired'] shuffle(colors) return colors[:n] else: return choice(cl.scales['12']['qual']['Paired'])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'community_colors'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Returns a list of visually separable colors according to total communities
def _op_msg_uncompressed(flags, command, identifier, docs, check_keys, opts): data, total_size, max_bson_size = _op_msg_no_header( flags, command, identifier, docs, check_keys, opts) request_id, op_message = __pack_message(2013, data) return request_id, op_message, total_size, max_bson_size
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_op_msg_uncompressed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifie...
Internal compressed OP_MSG message helper.
def distribute_javaclasses(self, javaclass_dir, dest_dir="src"): info('Copying java files') ensure_dir(dest_dir) for filename in glob.glob(javaclass_dir): shprint(sh.cp, '-a', filename, dest_dir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distribute_javaclasses'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'...
Copy existing javaclasses from build dir to current dist dir.
def extract_cab (archive, compression, cmd, verbosity, interactive, outdir): cmdlist = [cmd, '-d', outdir] if verbosity > 0: cmdlist.append('-v') cmdlist.append(archive) return cmdlist
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_cab'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chil...
Extract a CAB archive.
def com_google_fonts_check_name_line_breaks(ttFont): failed = False for name in ttFont["name"].names: string = name.string.decode(name.getEncoding()) if "\n" in string: failed = True yield FAIL, ("Name entry {} on platform {} contains" " a line-break.").format(NameID(name.name...
{'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_line_breaks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'ch...
Name table entries should not contain line-breaks.
def _authenticate_client(self, client): if self.login and not self.restart_required: try: db = client[self.auth_source] if self.x509_extra_user: db.authenticate( DEFAULT_SUBJECT, mechanism='MONGODB-X5...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_authenticate_client'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Authenticate the client if necessary.
def _sig_handler(self, signum, stack): log_debug("Got SIGINT.") if signum == signal.SIGINT: LLNetReal.running = False if self._pktqueue.qsize() == 0: self._pktqueue.put( (None,None,None) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sig_handler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Handle process INT signal.
def to_browser_mode(self): for message_no in range(len(self.messages)): self.__to_browser(message_no)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_browser_mode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Write all the messages to files and open them in the browser
def input_validate_aead(aead, name='aead', expected_len=None, max_aead_len = pyhsm.defines.YSM_AEAD_MAX_SIZE): if isinstance(aead, pyhsm.aead_cmd.YHSM_GeneratedAEAD): aead = aead.data if expected_len != None: return input_validate_str(aead, name, exact_len = expected_len) else: retur...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'input_validate_aead'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'child...
Input validation for YHSM_GeneratedAEAD or string.
def build( c, clean=False, browse=False, nitpick=False, opts=None, source=None, target=None, ): if clean: _clean(c) if opts is None: opts = "" if nitpick: opts += " -n -W -T" cmd = "sphinx-build{0} {1} {2}".format( (" " + opts) if opts else "",...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'c...
Build the project's Sphinx docs.
def _assign_as_root(self, id_): rfc = self._ras.get_relationship_form_for_create(self._phantom_root_id, id_, []) rfc.set_display_name('Implicit Root to ' + str(id_) + ' Parent-Child Relationship') rfc.set_description(self._relationship_type.get_display_name().get_text() + ' relationship for impl...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_assign_as_root'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Assign an id_ a root object in the hierarchy
def value_to_sql_str(v): if v is None: return 'null' if type(v) in (types.IntType, types.FloatType, types.LongType): return str(v) if type(v) in (types.StringType, types.UnicodeType): return "'%s'" %(v.replace(u"'", u"\\'")) if isinstance(v, datetime): return "'%s'" %(v.s...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'value_to_sql_str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
transform a python variable to the appropriate representation in SQL
def create_prefix_dir(nb_file, fmt): if 'prefix' in fmt: nb_dir = os.path.dirname(nb_file) + os.path.sep if not os.path.isdir(nb_dir): logging.log(logging.WARNING, "[jupytext] creating missing directory %s", nb_dir) os.makedirs(nb_dir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_prefix_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Create directory if fmt has a prefix
def _make_walker(self, *args, **kwargs): walker = self.walker_class(*args, **kwargs) return walker
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_walker'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Create a walker instance.
def show(self, y:Image=None, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[str]=None, hide_axis:bool=True, color:str='white', **kwargs): "Show the `ImageBBox` on `ax`." if ax is None: _,ax = plt.subplots(figsize=figsize) bboxes, lbls = self._compute_boxes() h,w = self.flo...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '45']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10', '17', '24', '33', '38', '43']}; {'id': '4', 'type': 'identifie...
Show the `ImageBBox` on `ax`.
def render_description_meta_tag(context, is_og=False): request = context['request'] content = '' if context.get('object'): try: content = context['object'].get_meta_description() except AttributeError: pass elif context.get('meta_tagger'): content = contex...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_description_meta_tag'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'...
Returns the description as meta or open graph tag.
def _make_graph(self, max_insert): if len(self.partial_links) != 0: raise Error('Error in _make_graph(). Cannot continue because there are partial links') self.contig_links = {} for key in self.links: for l in self.links[key]: insert_size = l.insert_size()...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
helper function to construct graph from current state of object
def tags(self): tag_list = self.spec.get('tag', []) if isinstance(tag_list, (list, set, tuple)): return list(tag_list) return [tag_list]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tags'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Returns a list of all the tags applied to this view
def _sync_reminders(self, reminders_json): for reminder_json in reminders_json: reminder_id = reminder_json['id'] task_id = reminder_json['item_id'] if task_id not in self.tasks: continue task = self.tasks[task_id] self.reminders[remind...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sync_reminders'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Populate the user's reminders from a JSON encoded list.
def build_available_time_string(availabilities): prefix = 'We have availabilities at ' if len(availabilities) > 3: prefix = 'We have plenty of availability, including ' prefix += build_time_output_string(availabilities[0]) if len(availabilities) == 2: return '{} and {}'.format(prefix, bu...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_available_time_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],...
Build a string eliciting for a possible time slot among at least two availabilities.
def galprop_gasmap(self, **kwargs): kwargs_copy = self.base_dict.copy() kwargs_copy.update(**kwargs) self._replace_none(kwargs_copy) localpath = NameFactory.galprop_gasmap_format.format(**kwargs_copy) if kwargs.get('fullpath', False): return self.fullpath(loca...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'galprop_gasmap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
return the file name for Galprop input gasmaps
def main(): if len(argv) < 2: print 'Usage: %s fst_file [optional: save_file]' % argv[0] return flex_a = Flexparser() mma = flex_a.yyparse(argv[1]) mma.minimize() print mma if len(argv) == 3: mma.save(argv[2])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '20', '26', '37', '43', '45'...
Testing function for Flex Regular Expressions to FST DFA
def process_exception(self, request, e): if isinstance(e, RedirectException): response = e.get_response() self.process_response(request, response)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_exception'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
Still process session data when specially Exception
def update_time_reset_passwd(user_name, the_time): entry = TabMember.update( time_reset_passwd=the_time, ).where(TabMember.user_name == user_name) try: entry.execute() return True except: return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_time_reset_passwd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
Update the time when user reset passwd.
def save(self, fname=''): if fname is '': self.case.save() else: self.case.SaveAs(self.path+os.sep+fname)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Save the current case
def mask_roi_unique(self): A = np.vstack([self.mask_1.mask_roi_sparse,self.mask_2.mask_roi_sparse]).T B = A[np.lexsort(A.T[::-1])] return B[np.concatenate(([True],np.any(B[1:]!=B[:-1],axis=1)))]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mask_roi_unique'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Assemble a set of unique magnitude tuples for the ROI
def InterfaceMatcher(clazz, subclass, protocol): interface = (clazz, subclass, protocol) def Matcher(device): for setting in device.iterSettings(): if GetInterface(setting) == interface: return setting return Matcher
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'InterfaceMatcher'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Returns a matcher that returns the setting with the given interface.
def _get_previous_open_tag(self, obj): prev_instance = self.get_previous_instance(obj) if prev_instance and prev_instance.plugin_type == self.__class__.__name__: return prev_instance.glossary.get('open_tag')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_previous_open_tag'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
Return the open tag of the previous sibling
def uid(self, p_todo): try: return self._todo_id_map[p_todo] except KeyError as ex: raise InvalidTodoException from ex
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Returns the unique text-based ID for a todo item.
def erase(ctx): if os.path.exists(ctx.obj['report']): os.remove(ctx.obj['report'])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'erase'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id...
Erase the existing smother report.
def require_content_type(self, content_type): if self.request.headers.get('content-type', '') != content_type: self.halt(400, 'Content type must be ' + content_type)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'require_content_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Raises a 400 if request content type is not as specified.
def tax_for_order(self, order_deets): request = self._post('taxes', order_deets) return self.responder(request)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tax_for_order'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Shows the sales tax that should be collected for a given order.
def _allow_custom_expire(self, load): expire_override = self.opts.get('token_expire_user_override', False) if expire_override is True: return True if isinstance(expire_override, collections.Mapping): expire_whitelist = expire_override.get(load['eauth'], []) if...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_allow_custom_expire'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Return bool if requesting user is allowed to set custom expire
def handle_pre_response(self, item_session: ItemSession) -> Actions: action = self.consult_pre_response_hook(item_session) if action == Actions.RETRY: item_session.set_status(Status.skipped) elif action == Actions.FINISH: item_session.set_status(Status.done) elif ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_pre_response'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ...
Process a response that is starting.
def key(self): prefix = type(self).cls_key() return '{}:{}:obj'.format(prefix, self.id)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'key'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'...
Returns the redis key to access this object's values
def convert_to_annotation(file, output): resource = parse_bel_resource(file) write_annotation( keyword=resource['Namespace']['Keyword'], values={k: '' for k in resource['Values']}, citation_name=resource['Citation']['NameString'], description=resource['Namespace']['DescriptionStr...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_annotation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Convert a namespace file to an annotation file.