code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def get_tag_codes( self, query: Optional[Dict[str, Any]] = None, size: Optional[int] = 100, headers: Optional[Dict[str, Any]] = None, callback: Optional[Callable[[requests.Response], requests.Response]] = None ) -> Tuple[Dict[str, List[str]], int]: <NEW_LINE> <INDENT> if not self._read_url: <NEW_LINE> <INDENT> return {...
Helper method to get the list of tag codes used in Asset metadata :param dict query: Optional elasticsearch query to apply :param int size: The maximum number of tag codes to return (defaults to 100) :param dict headers: Dictionary of headers to apply :param callback: A callback function to manipulate the response :re...
625941cb73bcbd0ca4b2c138
def resnet50_C(pretrained=False, classnum=3,**kwargs): <NEW_LINE> <INDENT> model = ResNet(CAttentionBlock, [3, 4, 6, 3],num_classes=classnum, **kwargs) <NEW_LINE> if pretrained: <NEW_LINE> <INDENT> pretrained_dict = model_zoo.load_url(model_urls['resnet50']) <NEW_LINE> model_dict = model.state_dict() <NEW_LINE> pretrai...
Constructs a ResNet-50-Attention model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
625941cb435de62698dfdd0f
@jit(nopython=True) <NEW_LINE> def genotype_idx_to_arr_idx(geno_idx, num_cols): <NEW_LINE> <INDENT> return (geno_idx // num_cols, geno_idx % num_cols)
Converts index in chromosome to corresponding index in pixel array. Returns: (row_index, col_index)
625941cb29b78933be1e576f
def next_event(self): <NEW_LINE> <INDENT> if not self._recv_buf: <NEW_LINE> <INDENT> if self.closed: <NEW_LINE> <INDENT> return events.ConnectionClosed() <NEW_LINE> <DEDENT> return None <NEW_LINE> <DEDENT> event_id = self._recv_buf[0] <NEW_LINE> try: <NEW_LINE> <INDENT> Event = event_types[event_id] <NEW_LINE> <DEDENT>...
Get next event, if any. :return: An event object or None if not enough data exists.
625941cb63b5f9789fde71a8
def outline(self, level=logging.INFO, message=""): <NEW_LINE> <INDENT> steps = 1 <NEW_LINE> logger.log(level, "Plan \"%s\":", self.description) <NEW_LINE> while not self.completed: <NEW_LINE> <INDENT> step_name, step = self.list_pending()[0] <NEW_LINE> logger.log( level, " - step: %s: target: \"%s\", action: \"%s\"", ...
Print an outline of the actions the plan is going to take. The outline will represent the rough ordering of the steps that will be taken. Args: level (int, optional): a valid log level that should be used to log the outline message (str, optional): a message that will be logged to the user aft...
625941cbe76e3b2f99f3a8ce
def __init__(self,loss,beta_m=1-1e-1,beta_v=1-1e-3,epsilon=1e-8,alpha=1e-2): <NEW_LINE> <INDENT> GradientDescent.__init__(self,loss) <NEW_LINE> self.beta_m=beta_m <NEW_LINE> self.beta_v=beta_v <NEW_LINE> self.epsilon=epsilon <NEW_LINE> self.alpha=alpha <NEW_LINE> self.beta_m_ac=beta_m <NEW_LINE> self.beta_v_ac=beta_v <...
loss: the loss function beta_m: decay parameter for the average m beta_v: decay parameter for the average v epsilon: safety parameter (to avoid division by 0) alpha: a learning rate that multiplies the rate of AdaDelta.
625941cb56ac1b37e6264292
def calc(self, sublist): <NEW_LINE> <INDENT> stats = self.info[sublist] <NEW_LINE> yds = int(stats[4])/(4.05 * int(stats[3])) <NEW_LINE> perTDs = (39.5 * int(stats[5])) / int(stats[3]) <NEW_LINE> perFumbles = 2.375 - ((21.5 * int(stats[6])) / int(stats[3])) <NEW_LINE> if int(stats[3]) == 0: <NEW_LINE> <INDENT> rating =...
Calculates a rusher rating for one sub-list year in the info list
625941cbbf627c535bc13291
def get_env_var( env_var_name: str, break_if_missing: bool = False, allowed_values: list = [] ) -> str: <NEW_LINE> <INDENT> env_var = os.getenv(env_var_name) <NEW_LINE> if break_if_missing and not env_var: <NEW_LINE> <INDENT> raise ValueError(f"Env var '{env_var_name}' doesn't exist") <NEW_LINE> <DEDENT> if allowed_val...
Returns env var, optional check to see if exists and optional check against allowed values.
625941cb5510c4643540f4a8
def get_relationship_mdata(): <NEW_LINE> <INDENT> return { 'source': { 'element_label': 'source', 'instructions': 'accepts an osid.id.Id object', 'required': False, 'read_only': False, 'linked': False, 'array': False, 'default_id_values': [''], 'syntax': 'ID', 'id_set': [], }, 'destination': { 'element_label': 'destina...
Return default mdata map for Relationship
625941cb4428ac0f6e5ba8b4
def decode_output_path(self, econf, fold): <NEW_LINE> <INDENT> if fold is None: <NEW_LINE> <INDENT> parent_dir = self.combined_dir_path() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> parent_dir = self.fold_dir_path(fold) <NEW_LINE> <DEDENT> return fp.join(parent_dir, self._decode_output_basename(econf))
Return path to output graph for given fold and config
625941cb1f5feb6acb0c4c13
def password_box(title, text): <NEW_LINE> <INDENT> psw, fl = QtWidgets.QInputDialog.getText( self, title, text, QtWidgets.QLineEdit.Password) <NEW_LINE> return psw, fl
Displays a QInputDialog that asks for a password :param title: window title :type title: str :param text: text to be displayed :type text: str :return: password, and True or False depending on which button was pressed, Ok or Cancel :rtype: str, bool
625941cb3d592f4c4ed1d131
def forward_backward(vec_embed_log_probs, log_p_continue, N, n_slices_min=0, n_slices_max=0, i_utt=None, anneal_temp=1): <NEW_LINE> <INDENT> pass
Segment an utterance of length `N` based on its `vec_embed_log_probs` vector and return a bool vector of boundaries. Parameters ---------- vec_embed_log_probs : N(N + 1)/2 length vector For t = 1, 2, ..., N the entries `vec_embed_log_probs[i:i + t]` contains the log probabilties of sequence[0:t] up to sequence...
625941cb3346ee7daa2b2e2d
def has_banner(self, indexer_id): <NEW_LINE> <INDENT> banner_path = self.banner_path(indexer_id) <NEW_LINE> sickrage.srLogger.debug("Checking if file " + str(banner_path) + " exists") <NEW_LINE> return os.path.isfile(banner_path)
Returns true if a cached banner exists for the given Indexer ID
625941cb6fb2d068a760f15f
def calcDensityAltitude(self): <NEW_LINE> <INDENT> tempStd = E6BCore.tempStdSea - self.alt_pre*E6BCore.lapseRate <NEW_LINE> self.alt_den = self.alt_pre + tempStd/E6BCore.lapseRate*(1. - math.pow(tempStd/(self.temp + E6BCore.tempZero), 0.234969))
from pressure altitude to density altitude
625941cb0fa83653e465707e
def __reset_bird(self): <NEW_LINE> <INDENT> if self.monkey.collides_with(self.bird): <NEW_LINE> <INDENT> self.bird = Bird() <NEW_LINE> self.bird.rect.x = 656 <NEW_LINE> self.bird.rect.y = random.randint(100, 600) <NEW_LINE> self.bird_list.add(self.bird) <NEW_LINE> self.all_sprites_list.add(self.bird)
resets the bird's position when the game restarts (private method).
625941cbbd1bec0571d906f2
def __iter__(self): <NEW_LINE> <INDENT> product_ids = self.cart.keys() <NEW_LINE> products = Product.objects.filter(id__in=product_ids) <NEW_LINE> for product in products: <NEW_LINE> <INDENT> self.cart[str(product.id)]['product']=product <NEW_LINE> <DEDENT> for item in self.cart.values(): <NEW_LINE> <INDENT> item['pric...
Iterate over the items in the cart and get the products from the database. :return:
625941cbf8510a7c17cf97bf
def shape_line(self): <NEW_LINE> <INDENT> path_shp = self.path_shp <NEW_LINE> layer_line = ogr.Open(path_shp) <NEW_LINE> layer = layer_line.GetLayer() <NEW_LINE> union_line = ogr.Geometry(ogr.wkbLineString) <NEW_LINE> for feature in layer: <NEW_LINE> <INDENT> geom = feature.GetGeometryRef() <NEW_LINE> union_line = unio...
Fonction pour unifier le réseau
625941cbab23a570cc250244
def compare_cnotdihedral_circuit(self, cnotdihedral_Z_circ, cnotdihedral_X_circ, nq, rb_opts_cnotdihedral, vec_len): <NEW_LINE> <INDENT> qlist_flat, _, _ = rb.circuits.check_pattern( rb_opts_cnotdihedral['rb_pattern']) <NEW_LINE> if not hasattr(rb_opts_cnotdihedral['length_multiplier'], "__len__"): <NEW_LINE> <INDENT> ...
Verifies that cnotdihedral RB circuits are the same, except of the first and last H gates. Args: cnotdihedral_Z_circ: original rb circuits (meassure |0...0> state) cnotdihedral_X_circ: rb circuits that measure |+...+> state. nq: number of qubits rb_opts_cnotdihedral: the specification that ...
625941cb5fdd1c0f98dc02f5
def _generate_banner(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> tpl_params = dict(self.BANNER_TEMPLATE.defaults) <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> tpl_params = {} <NEW_LINE> <DEDENT> connection_details = self._server.connection_details <NEW_LINE> transport = connection_details.tran...
Generates a banner that can be useful to display before running.
625941cb31939e2706e4cf2d
def add_movie_id_arg(parser): <NEW_LINE> <INDENT> parser.add_argument( 'movie_id', help='The movie for which a prediction is being made.', type=to_movie_id, )
Add the positional ``movie_id`` parameter to a parser.
625941cb23e79379d52ee627
def forward(self, x, t): <NEW_LINE> <INDENT> score = self.predict(x) <NEW_LINE> loss = self.loss_layer.forward(score, t) <NEW_LINE> return loss
Given a dataset (or mini-batch) and a corresponding label set, calculate the loss of current model Parameters: x: a dataset or a mini-batch t: corresponding label set Return: loss: the loss of current model
625941cb71ff763f4b54974d
def get_items_from_range(items, index): <NEW_LINE> <INDENT> return items[index]
:param items: :param index: :return:
625941cb8e05c05ec3eea437
def register_cllbck(self, event, func): <NEW_LINE> <INDENT> if event not in self.__cllbcks: <NEW_LINE> <INDENT> self.__cllbcks[event] = {} <NEW_LINE> <DEDENT> callbacks = self.__cllbcks[event] <NEW_LINE> key = 0 <NEW_LINE> while key in callbacks: <NEW_LINE> <INDENT> key += 1 <NEW_LINE> <DEDENT> callbacks[key] = func <N...
Store function and return unique key which can be used to unregister the callback later
625941cbfff4ab517eb2f4ff
def tau353_to_ebv(data, header, error=None): <NEW_LINE> <INDENT> header['BUNIT'] = 'mag' <NEW_LINE> ebv = data * 1.49e4 <NEW_LINE> if error is None: <NEW_LINE> <INDENT> return (ebv, header) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ebv_error = ebv * ((0.03e4 / 1.49e4)**2 + (error / data)**2)**0.5 <NEW_LINE> return ...
The dust emission maps are derived from: Planck 2013 results. XI. All-sky model of thermal dust emission Whereby they fit for the dust optical depth at 353 GHz, and then calibrated the conversion of the optical depth to color excess using background quasars. E(B-V) can be calculated from the dust optical depth at 353...
625941cb16aa5153ce36253b
def _fill_mapping(self, space, source): <NEW_LINE> <INDENT> if isinstance(space, NullSpace): <NEW_LINE> <INDENT> assert source == '' <NEW_LINE> return None <NEW_LINE> <DEDENT> elif not isinstance(space, CompositeSpace): <NEW_LINE> <INDENT> if isinstance(source, tuple): <NEW_LINE> <INDENT> source, = source <NEW_LINE> <D...
Builds a nested tuple of integers representing the mapping
625941cb0a50d4780f666f54
def process_file(filename): <NEW_LINE> <INDENT> with open(filename) as f: <NEW_LINE> <INDENT> for i, line in enumerate(f): <NEW_LINE> <INDENT> line = line.strip() <NEW_LINE> if i == 0: <NEW_LINE> <INDENT> dim = int(line) <NEW_LINE> matrix = np.zeros((dim, dim), dtype=np.int32) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDE...
data format: 4 0 13 21 22 13 0 12 13 21 12 0 13 22 13 13 0
625941cbc4546d3d9de72af6
def job(func_or_queue, connection=None, *args, **kwargs): <NEW_LINE> <INDENT> if callable(func_or_queue): <NEW_LINE> <INDENT> func = func_or_queue <NEW_LINE> queue = 'default' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> func = None <NEW_LINE> queue = func_or_queue <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> from dja...
The same as RQ's job decorator, but it works automatically works out the ``connection`` argument from RQ_QUEUES. And also, it allows simplified ``@job`` syntax to put job into default queue.
625941cb21bff66bcd684a16
def choose_action(self, state): <NEW_LINE> <INDENT> self.state = state <NEW_LINE> self.next_waypoint = self.planner.next_waypoint() <NEW_LINE> action = None <NEW_LINE> if not self.learning or random.random() < self.epsilon: <NEW_LINE> <INDENT> action = random.choice(self.valid_actions) <NEW_LINE> <DEDENT> else: <NEW_LI...
The choose_action function is called when the agent is asked to choose which action to take, based on the 'state' the smartcab is in.
625941cb76d4e153a657ebf3
def __execute(queue, nb_iterations, function, *args): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> start = time.clock() <NEW_LINE> for i in range(nb_iterations): <NEW_LINE> <INDENT> function(*args) <NEW_LINE> <DEDENT> queue.put(time.clock() - start) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> queue.p...
Executes the provided function nb_iterations times and pushes the time it took into the queue. Args: queue (Queue): The queue to push the result in. nb_iterations (int): The number of times the function should be called. function (func.): The function to call. args (whatever): The arguments for the fun...
625941cbfb3f5b602dac3755
def get_index_weight(self): <NEW_LINE> <INDENT> df = pd.read_csv(os.path.join(self.folder, 'index_weights/all_index_sw_weights.csv'), sep='\t', index_col=[0,1], header=[0,1]) <NEW_LINE> names = df.index.levels[1] <NEW_LINE> indexs = df.index.codes[1] <NEW_LINE> sw_codes = df.index.levels[0].tolist() <NEW_LINE> sw_names...
获取部分 A 股指数申万 28 行业的权重占比
625941cba79ad161976cc208
def test_missing_user(self): <NEW_LINE> <INDENT> with login_user(self.flask_app, self.admin): <NEW_LINE> <INDENT> output = self.client.post('/users/42/admin/true') <NEW_LINE> self.assertEqual(404, output.status_code)
Assert trying to set the state of a non-existent user results in HTTP 404.
625941cb0383005118ecf6a5
def SecondaryIonizationRate(self, absorber, donor): <NEW_LINE> <INDENT> if self.esec.Method < 2: <NEW_LINE> <INDENT> IonizationRate = self.PsiN[donor].copy() <NEW_LINE> IonizationRate -= self.E_th[donor] * erg_per_ev * self.PhiN[donor] <NEW_LINE> if self.pf['photon_conserving']: <NEW_LINE> <INDENT> Ioniz...
Secondary ionization rate which we denote elsewhere as gamma (note little g). absorber = species being ionized by photo-electron donor = species the photo-electron came from If this routine is called, it means TabulateIntegrals = 1.
625941cbd18da76e23532599
def get_user_timeline(self, target_user): <NEW_LINE> <INDENT> statuses = [] <NEW_LINE> tweet_count = 0 <NEW_LINE> flag = False <NEW_LINE> target_user = target_user.lower() <NEW_LINE> db = DataBase() <NEW_LINE> t_id = db.execute_query(GET_TWITTER_ID % target_user).fetchone() <NEW_LINE> print(t_id) <NEW_LINE> if t_id is ...
This method will give the detailed information about twitter user passed and store in database Before storing into database it will check whether user exists on database of not if not it will write entries
625941cb4428ac0f6e5ba8b5
def stop(self): <NEW_LINE> <INDENT> self.shutdown.set() <NEW_LINE> for monitor in self.observers: <NEW_LINE> <INDENT> monitor.stop() <NEW_LINE> <DEDENT> self.wind_down() <NEW_LINE> for monitor in self.observers: <NEW_LINE> <INDENT> monitor.join() <NEW_LINE> <DEDENT> for thread in self.thread_pool.values(): <NEW_LINE> <...
Method for shutting down the watcher. All config file observers are stopped and their threads joined, along with the worker thread pool.
625941cb76d4e153a657ebf4
def draw_annotation_table(annotations, include_ratio=True): <NEW_LINE> <INDENT> wpart = '' <NEW_LINE> for dataRow in annotations: <NEW_LINE> <INDENT> wpart += ' <tr>' <NEW_LINE> expid = dataRow.get('expid', 'not found') <NEW_LINE> wpart += "<td><a href=%s>%s</a></td>" % (url_for('.experiment_info', expid=expid), expid...
Draw the annotations list table. Note annotations are written according to the list order It uses the annottable.html template for the table. If the 'website_sequences' is filled in each annotation, it also writes it (XXX/YYY) where XXX is the 'website_sequences' Parameters ---------- annotations: list of annotations...
625941cb30bbd722463cbe88
def squeeze_weight_matrix(tensor, shrink_ratio=1.0): <NEW_LINE> <INDENT> U, S, Vt = np.linalg.svd(np.asarray(tensor), full_matrices=False) <NEW_LINE> print(np.array(U).shape) <NEW_LINE> print(np.array(S).shape) <NEW_LINE> print(np.array(Vt).shape) <NEW_LINE> shrink_factor = int(np.array(S).shape[0] * shrink_ratio) <NEW...
To obtain good accuracy using squeezing weights, larger value for shrink_ratio should be used. Please note that a shrink_ratio of 1 means the weight matrices will not be shrinked. shrink_ratio should be 0.25, 0.5, 0.75 or 1
625941cba4f1c619b28b00fd
def test_all_function_docs(self): <NEW_LINE> <INDENT> all_functions = TestAmenityDocs.all_funcs <NEW_LINE> for function in all_functions: <NEW_LINE> <INDENT> self.assertIsNotNone(function[1].__doc__)
... tests for ALL DOCS for all functions in db_storage file
625941cb956e5f7376d70f31
def get_directives(lines: Iterable[str]) -> Iterable[Tuple[int, int, str]]: <NEW_LINE> <INDENT> tokens = tokenize.generate_tokens(lines.__iter__().__next__) <NEW_LINE> ret = [] <NEW_LINE> for (toktyp, tokval, begin, _, _) in tokens: <NEW_LINE> <INDENT> linenum, colnum = begin <NEW_LINE> if toktyp == tokenize.COMMENT: <...
Extract directive text from source lines. :returns: a list of (line number, column number, directive text) tuples >>> get_directives(["pass", "# crosshair: foo=bar"]) [(2, 0, 'foo=bar')]
625941cbbe8e80087fb20d06
def encode(self, C, num_rows): <NEW_LINE> <INDENT> x = np.zeros((num_rows, len(self.chars))) <NEW_LINE> for i, c in enumerate(C): <NEW_LINE> <INDENT> x[i, self.char_indices[c]] = 1 <NEW_LINE> <DEDENT> return x
One hot encode given string C. # Arguments num_rows: Just number of characters in input C. Number of rows in the returned one hot encoding. This is used to keep the # of rows for each data the same.
625941cb4e4d5625662d449b
def setUp(self): <NEW_LINE> <INDENT> self.ref_pkgs = [] <NEW_LINE> self.targ_pkgs = [] <NEW_LINE> self.exp_pkgs = [] <NEW_LINE> for s in self.pkgs: <NEW_LINE> <INDENT> ref = s + "_ref" <NEW_LINE> targ = s + "_targ" <NEW_LINE> exp = s + "_exp" <NEW_LINE> try: <NEW_LINE> <INDENT> self.ref_pkgs.append(getattr(self, ref)) ...
Start 3 depots, 1 for reference repo, 1 for the target and 1 which should be equal to the reversioned target.
625941cb8da39b475bd65037
def check_iw_validity(self): <NEW_LINE> <INDENT> iwPath = which('iw') <NEW_LINE> if iwPath is None: <NEW_LINE> <INDENT> print('Err: iw command not found!') <NEW_LINE> return False <NEW_LINE> <DEDENT> p = subprocess.Popen( "iw --help | grep FTM", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True ) <NEW_LINE> ou...
check if iw exists and support FTM commands
625941cbdd821e528d63b26c
def ssd_anchors_all_layers(img_shape, layers_shapes, anchor_sizes, anchor_ratios, anchor_steps, offset=0.5, dtype=np.float32): <NEW_LINE> <INDENT> layers_anchors = [] <NEW_LINE> for i, layer_shape in enumerate(layers_shapes): <NEW_LINE> <INDENT> anchor_bboxes = ssd_anchors_one_layer(img_shape, layer_shape, anchor_sizes...
Compute anchor boxes for all feature layers
625941cb21a7993f00bc7db2
def un_unitize(key, x): <NEW_LINE> <INDENT> if has_astropy_unit(x): <NEW_LINE> <INDENT> if key in par_units: <NEW_LINE> <INDENT> rv = x.to(par_units[key]).value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> NotImplementedError("Key {0} has unknown units".format(key)) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDEN...
Return the unitless representation of a parameter
625941cbd8ef3951e3243600
def lower(self): <NEW_LINE> <INDENT> return self.change(-self.INC)
Lower the volume by one increment
625941cba79ad161976cc209
def __init__(self, model): <NEW_LINE> <INDENT> VectorizedCard.__init__(self, model) <NEW_LINE> self._cards = [] <NEW_LINE> self._comments = []
Defines the POINTAX object. Parameters ---------- model : BDF the BDF object +---------+-----+-----+-----+ | 1 | 2 | 3 | 4 | +=========+=====+=====+=====+ | POINTAX | NID | RID | PHI | +---------+-----+-----+-----+
625941cb711fe17d82542430
def get_greatest(number_list): <NEW_LINE> <INDENT> _max = number_list[0] <NEW_LINE> for x in number_list: <NEW_LINE> <INDENT> if x > _max: <NEW_LINE> <INDENT> _max = x <NEW_LINE> <DEDENT> <DEDENT> greatest_number = _max <NEW_LINE> return greatest_number
주어진 리스트에서 가장 큰 숫자를 반환함 Parameters: number_list (list): integer로 값으로만 구성된 list ex - [10, 33, 22, 99, 33] Returns: greatest_number (int): parameter number_list 중 가장 큰 값 Examples: >>> number_list = [39, 54, 32, 11, 99] >>> import basic_math as bm >>> bm.get_gr...
625941cbbaa26c4b54cb11e3
def __init__(self, ai_game): <NEW_LINE> <INDENT> self.screen = ai_game.screen <NEW_LINE> self.settings = ai_game.settings <NEW_LINE> self.screen_rect = ai_game.screen.get_rect() <NEW_LINE> """Load the ship image and get it's rect.""" <NEW_LINE> self.image = pygame.image.load('images/ship.bmp') <NEW_LINE> self.rect = se...
Initialize the ship and set it's starting location.
625941cbd58c6744b4257d23
def StoreNoiseTextureLDR(Texture,OutputPNGFilePath,nRank=-1): <NEW_LINE> <INDENT> if(nRank<=0): <NEW_LINE> <INDENT> nRank=Texture.shape[0]*Texture.shape[1]; <NEW_LINE> <DEDENT> Texture=np.asarray((Texture*256)//nRank,dtype=np.uint8); <NEW_LINE> if(len(Texture.shape)<3): <NEW_LINE> <INDENT> Texture=Texture[:,:,np.newaxi...
This function stores the given texture to a standard low-dynamic range png file with four channels and 8 bits per channel. \param Texture An array of shape (Height,Width) or (Height,Width,nChannel). The former is handled like (Height,Width,1). If nChannel>4 the superfluous channels are ignored. If nCh...
625941cbd10714528d5ffda6
def close_db(e=None): <NEW_LINE> <INDENT> db = g.pop('db', None) <NEW_LINE> if db is not None: <NEW_LINE> <INDENT> db.close()
Close Database connection
625941cbd99f1b3c44c67652
def get_memory_voltage_sdram_c(): <NEW_LINE> <INDENT> return get_voltage("sdram_c")
Get the memory voltage of SDRAM C. :returns: The memory voltage of SDRAM C. :rtype: int, long :raises: raspy.invalid_operation_exception.InvalidOperationException if invalid command ("measure_volts") or response.
625941cbbde94217f3682eb5
def load_all(self, target_uris, **kwargs): <NEW_LINE> <INDENT> yaml_series = self._load_first( target_uris, yamlsettings.yamldict.load_all, **kwargs ) <NEW_LINE> yaml_dicts = [] <NEW_LINE> for yaml_dict in yaml_series: <NEW_LINE> <INDENT> yaml_dicts.append(yaml_dict) <NEW_LINE> <DEDENT> return yaml_dicts
Load *all* YAML settings from a list of file paths given. - File paths in the list gets the priority by their orders of the list.
625941cbe5267d203edcdd61
def send_message_no_auth(self, request): <NEW_LINE> <INDENT> body = { "userId": request.get_user_id(), "message": request.get_message(), } <NEW_LINE> if request.get_meta() is not None: <NEW_LINE> <INDENT> body["meta"] = request.get_meta() <NEW_LINE> <DEDENT> headers = {} <NEW_LINE> if request.get_request_id() is not No...
メッセージを送信します。<br> <br> :param request: リクエストパラメータ :type request: gs2_chat_client.control.SendMessageNoAuthRequest.SendMessageNoAuthRequest :return: 結果 :rtype: gs2_chat_client.control.SendMessageNoAuthResult.SendMessageNoAuthResult
625941cb8a43f66fc4b54129
def _indent(elem, level=0): <NEW_LINE> <INDENT> i = "\n" + level * " " <NEW_LINE> if len(elem): <NEW_LINE> <INDENT> if not elem.text or not elem.text.strip(): <NEW_LINE> <INDENT> elem.text = i + " " <NEW_LINE> <DEDENT> if not elem.tail or not elem.tail.strip(): <NEW_LINE> <INDENT> elem.tail = i <NEW_LINE> <DEDENT> fo...
Helper function to fix indentation of XML files.
625941cbfbf16365ca6f6287
def visit_dict(self, node, parent, assign_ctx=None): <NEW_LINE> <INDENT> newnode = new.Dict() <NEW_LINE> _lineno_parent(node, newnode, parent) <NEW_LINE> newnode.items = list(self._visit_dict_items(node, parent, newnode, assign_ctx)) <NEW_LINE> return newnode
visit a Dict node by returning a fresh instance of it
625941cb63d6d428bbe445b3
def test_altitude(self): <NEW_LINE> <INDENT> for alt, num in (("2000", 2000), ("9999", 9999), ("0500", 500)): <NEW_LINE> <INDENT> ret_alt = pirep._altitude(alt) <NEW_LINE> self.assertIsInstance(ret_alt, structs.Number) <NEW_LINE> self.assertEqual(ret_alt.repr, alt) <NEW_LINE> self.assertEqual(ret_alt.value, num) <NEW_L...
Tests converting altitude to Number
625941cb4a966d76dd5510d3
def new_toegang(persoons_id, ruimte_id, heeft_toegang): <NEW_LINE> <INDENT> toegang_id = randint(100000, 1000000) <NEW_LINE> connection = sqlite3.connect('toegangssysteem.db') <NEW_LINE> connection.execute('''INSERT INTO toegang(toegang_id, persoons_id, ruimte_id, heeft_toegang) VALUES ({0}, {1}, {2}, {3})'''.format(st...
Voegt nieuwe toegang toe aan bestaande gebruiker Args: persoons_id(int) -- Random int, ID van persoon ruimte_id(int) -- Nummerige int van ruimte heeft_toegang(int) -- 1 of 0 of de gebruiker toegang heeft Returns: None
625941cb3317a56b86939d1d
def first_column(file_name): <NEW_LINE> <INDENT> return
Reads in a CSV file and returns a list of all entries in column 1
625941cbd58c6744b4257d24
def config(self): <NEW_LINE> <INDENT> return _Client.ConfigDB_config(self)
config(self) -> Config
625941cb38b623060ff0aeb1
def __create_board(self): <NEW_LINE> <INDENT> m = self.size[0] <NEW_LINE> n = self.size[1] <NEW_LINE> edge_length = 24 <NEW_LINE> y_top, x_right = self.__Hex_size(edge_length) <NEW_LINE> canvas_width = x_right * n + x_right * m / 2 + 50 <NEW_LINE> canvas_height = y_top * m + 100 <NEW_LINE> self.w = Canvas(self.master, ...
Creates a Canvas widget where Hexagon fields are marked on it
625941cb07f4c71912b11545
def test_empty_paths_without_crossing(): <NEW_LINE> <INDENT> with pytest.raises(ValueError): <NEW_LINE> <INDENT> pwc('')
Tests for paths_without_crossing() function with empty values.
625941cb91f36d47f21ac5b6
def question4(s): <NEW_LINE> <INDENT> test_string = s.replace(' ', '') <NEW_LINE> test_string = test_string.lower() <NEW_LINE> char_count = {c: test_string.count(c) for c in test_string} <NEW_LINE> found_single = False <NEW_LINE> for key in char_count.keys(): <NEW_LINE> <INDENT> if char_count[key] % 2 == 1 and found_si...
Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words. :param s: string to check ...
625941cb507cdc57c6306d9e
def substrings(a, b, n): <NEW_LINE> <INDENT> astrings = [] <NEW_LINE> bstrings = [] <NEW_LINE> a_len = len(a) - n + 1 <NEW_LINE> b_len = len(b) - n + 1 <NEW_LINE> for i in range(a_len): <NEW_LINE> <INDENT> tempa = "" <NEW_LINE> for j in range(n): <NEW_LINE> <INDENT> tempa = tempa + a[i + j] <NEW_LINE> <DEDENT> astrings...
Return substrings of length n in both a and b
625941cb097d151d1a222f1e
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <...
Returns the model properties as a dict
625941cbaad79263cf390b04
def do_transaction(self, bot, update, args): <NEW_LINE> <INDENT> group_id = update.message.chat_id <NEW_LINE> logger = logging.getLogger('do_transaction') <NEW_LINE> logger.info("Start do transaction") <NEW_LINE> if len(args) != 3: <NEW_LINE> <INDENT> bot.sendMessage(chat_id=group_id, text="This command requires three ...
do_transaction {amount} {source} {destination}
625941cb0fa83653e465707f
def test_recv_all_packets_template_middle(self): <NEW_LINE> <INDENT> self._test_recv_all_packets(NUM_PACKETS, NUM_PACKETS // 2)
Test all packets are received when the template is sent in the middle
625941cb3c8af77a43ae3864
def __init__(self, option, dbstate, uistate, track, override): <NEW_LINE> <INDENT> gtk.HBox.__init__(self) <NEW_LINE> self.__option = option <NEW_LINE> self.__dbstate = dbstate <NEW_LINE> self.__db = dbstate.get_database() <NEW_LINE> self.__uistate = uistate <NEW_LINE> self.__track = track <NEW_LINE> self.__surnames = ...
@param option: The option to display. @type option: gen.plug.menu.SurnameColorOption @return: nothing
625941cbf8510a7c17cf97c0
def __init__(self, amount=None): <NEW_LINE> <INDENT> self._amount = None <NEW_LINE> self.discriminator = None <NEW_LINE> self.amount = amount
PurgedInvitations - a model defined in Swagger
625941cb45492302aab5e386
def makeCall(signal, data=None, source_id=None, timeout_ms=1000, use_timeout_exception=False): <NEW_LINE> <INDENT> return CallHandler(signal, data, source_id, timeout_ms, use_timeout_exception).waitForReturn()
Make a call to the source add-on :param signal: name of the function to call (can be the same used in registerSlot/returnCall/...) :param data: data to send :param source_id: the name used for call/answer (e.g. add-on id) :param timeout_ms: maximum waiting time before the timeout :param use_timeout_exception: if True w...
625941cb15baa723493c4039
def getKirchhoff(self): <NEW_LINE> <INDENT> if self._kirchhoff is None: return None <NEW_LINE> return self._kirchhoff.copy()
Return a copy of the Kirchhoff matrix.
625941cb82261d6c526ab563
def energy_yield(E, P_ref): <NEW_LINE> <INDENT> EY = E/P_ref <NEW_LINE> return EY
Compute energy yield is defined as: :math:`EY=\dfrac{E}{P_{ref}}` where :math:`E` is the observed energy from a PV system and :math:`P_{ref}` is the DC power rating of the system at STC conditions. Parameters ----------- E : pandas Series or float Observed energy P_ref : float DC power rating at STC cond...
625941cbec188e330fd5a864
def clone(self, repo_url, quiet=True): <NEW_LINE> <INDENT> if os.path.exists(self.repo_dir): <NEW_LINE> <INDENT> raise OSError('Repo {0} already exists.'.format(self.repo_dir)) <NEW_LINE> <DEDENT> git_cmd = 'git clone {0} {1} {2}'.format('-q' if quiet else '', repo_url, self.repo_dir) <NEW_LINE> git(shlex_split(git_cmd...
Clone remote repository to local working directory
625941cb7047854f462a14ce
def connect_devices(self, win_panel_com=None, win_ard_com=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.pan = Panel(win_panel_com) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(e.strerror) <NEW_LINE> print("Panel failed") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self.lux = Arduino(...
Tries to connect the panel and arduino. Arguments: win_panel_com (str): If not on windows OS, defaults to None win_ard_com (str): If not on windows OS, defaults to None
625941cb23e79379d52ee628
def med_num(num_list): <NEW_LINE> <INDENT> sort_list = sorted(num_list) <NEW_LINE> if len(num_list) % 2 == 0: <NEW_LINE> <INDENT> index = int(len(num_list) / 2) <NEW_LINE> index2 = int(index - 1) <NEW_LINE> average = ((sort_list[index] + sort_list[index2]) / 2) <NEW_LINE> return average <NEW_LINE> <DEDENT> else: <NEW_L...
Takes in a list and returns the median of that list, averaging if even
625941cbd53ae8145f87a335
def set_font_face(self, face): <NEW_LINE> <INDENT> user = User(self._name) <NEW_LINE> user._font_face = face
Set font face/family. @type face: str @param face: the font face
625941cbfbf16365ca6f6288
def assert_attr_equal(attr: str, left, right, obj: str = "Attributes"): <NEW_LINE> <INDENT> __tracebackhide__ = True <NEW_LINE> left_attr = getattr(left, attr) <NEW_LINE> right_attr = getattr(right, attr) <NEW_LINE> if left_attr is right_attr: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif ( is_number(left_at...
Check attributes are equal. Both objects must have attribute. Parameters ---------- attr : str Attribute name being compared. left : object right : object obj : str, default 'Attributes' Specify object name being compared, internally used to show appropriate assertion message
625941cb236d856c2ad4489e
def parse_odd(self, odds, home_goals, away_goals, status): <NEW_LINE> <INDENT> def winning_odd(): <NEW_LINE> <INDENT> winning_team = self.calculate_winning_team(home_goals, away_goals, status) <NEW_LINE> return winning_team <NEW_LINE> <DEDENT> def average_odd(odd_in): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return...
Parses the odds and returns a Odds namedtuple
625941cbcad5886f8bd2709d
def delete_consistencygroup(self, context, group): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> cg_name = self._get_3par_vvs_name(group.id) <NEW_LINE> self.client.deleteVolumeSet(cg_name) <NEW_LINE> <DEDENT> except hpeexceptions.HTTPNotFound: <NEW_LINE> <INDENT> err = (_LW("Virtual Volume Set '%s' doesn't exist on arra...
Deletes a consistency group.
625941cb66673b3332b92155
def derivatives(x, y): <NEW_LINE> <INDENT> new_x = [] <NEW_LINE> for i in range(len(x)-1): <NEW_LINE> <INDENT> between = 0.5 * (x[i] + x[i+1]) <NEW_LINE> new_x.append(between) <NEW_LINE> <DEDENT> new_y = np.diff(y) / np.diff(x) <NEW_LINE> return new_x, new_y
This function calculates the derivative values using finite differences :param x: :param y: :return:
625941cb6fb2d068a760f161
def enqueue(self, value: object) -> None: <NEW_LINE> <INDENT> return self.s1.push(value)
Adds a new value to the end of the que
625941cbb545ff76a8913edb
def test_group(host): <NEW_LINE> <INDENT> app_user = host.user('zeppelin') <NEW_LINE> assert app_user.exists
Test zeppelin group
625941cbbd1bec0571d906f4
@set_module('numpy') <NEW_LINE> def issubclass_(arg1, arg2): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return issubclass(arg1, arg2) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return False
Determine if a class is a subclass of a second class. `issubclass_` is equivalent to the Python built-in ``issubclass``, except that it returns False instead of raising a TypeError if one of the arguments is not a class. Parameters ---------- arg1 : class Input class. True is returned if `arg1` is a subclass of `...
625941cbab23a570cc250246
def addNIC(self, nicname): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> nic = NICFactory(nicname, mediator=self) <NEW_LINE> self._nics.append(nic) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise
add a nic
625941cb3617ad0b5ed67fbc
def _calc_uint8_squares(): <NEW_LINE> <INDENT> s = np.empty(256, dtype=np.uint16) <NEW_LINE> for i in range(256): <NEW_LINE> <INDENT> s[i] = (127 - i) * (127 - i) <NEW_LINE> <DEDENT> return s
Lookup table of centered squared np.uint8 stored as np.uint16.
625941cb6aa9bd52df036e68
def folders(self, mountPoint): <NEW_LINE> <INDENT> if isinstance(mountPoint, basestring): <NEW_LINE> <INDENT> mountPoint = self.mountPoints[mountPoint] <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return [JFSFolder(f, self, parentpath='%s/%s' % (self.path, mountPoint.name)) for f in self.contents(mountPoint).folders.it...
Get an iterator of JFSFolder() from the given mountPoint. "mountPoint" may be either an actual mountPoint element from JFSDevice.mountPoints{} or its .name.
625941cb26068e7796caeda3
def getGroup(self, search_string): <NEW_LINE> <INDENT> groups = [] <NEW_LINE> group = requests.get(self.client.baseurl+'groups', auth=self.client.cred, params={'searchPattern':search_string, 'searchType':4, 'limit':3000}) <NEW_LINE> if group.json().get('groups'): <NEW_LINE> <INDENT> for grp in group.json()['groups']: <...
Receives a string and looks for it in directory service. If the string search isn't found, the message "Group not Found" will be returned, otherwise a list with all matching cases, limited to 50 results will be returned. Usage: >>> users = pe.getGroup('group_name')
625941cb091ae35668667023
def primeintscheat(a): <NEW_LINE> <INDENT> total = 0 <NEW_LINE> while a: <NEW_LINE> <INDENT> if isprimebitint(a): <NEW_LINE> <INDENT> total += 1 <NEW_LINE> <DEDENT> a -= 1 <NEW_LINE> <DEDENT> return total
How many ints <= 1 have prime bits
625941cb8c3a87329515847f
def linefeed(self): <NEW_LINE> <INDENT> self.index() <NEW_LINE> if mo.LNM in self.mode: <NEW_LINE> <INDENT> self.carriage_return() <NEW_LINE> <DEDENT> self.ensure_bounds()
Performs an index and, if :data:`~pyte.modes.LNM` is set, a carriage return.
625941cb7cff6e4e81117a4a
def canSetScriptSource(self, command): <NEW_LINE> <INDENT> utils.assert_main_thread() <NEW_LINE> global set_script_source <NEW_LINE> set_script_source = False <NEW_LINE> if 'result' in command.data: <NEW_LINE> <INDENT> set_script_source = command.data['result']
Notification that script can be edited during debugging
625941cba219f33f34628a2e
def lacp_update_actor_state(self, port, lacp_up, now=None, lacp_pkt=None, cold_start=False): <NEW_LINE> <INDENT> prev_actor_state = port.actor_state() <NEW_LINE> new_actor_state = port.lacp_actor_update( lacp_up, now=now, lacp_pkt=lacp_pkt, cold_start=cold_start) <NEW_LINE> if prev_actor_state != new_actor_state: <NEW_...
Updates a LAG actor state. Args: port: LACP port lacp_up (bool): Whether LACP is going UP or DOWN now (float): Current epoch time lacp_pkt (PacketMeta): LACP packet cold_start (bool): Whether the port is being cold started Returns: bool: True if LACP state changed
625941cb31939e2706e4cf2f
def __init__(self, iface): <NEW_LINE> <INDENT> self.iface = iface <NEW_LINE> self.plugin_dir = os.path.dirname(__file__) <NEW_LINE> locale = QSettings().value('locale/userLocale')[0:2] <NEW_LINE> locale_path = os.path.join( self.plugin_dir, 'i18n', 'LatLngJump_{}.qm'.format(locale)) <NEW_LINE> if os.path.exists(locale_...
Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface
625941cb8e05c05ec3eea439
def set_rotation(self, value): <NEW_LINE> <INDENT> return self.create_element(FloatElement, 'rotation', value)
kml:angle180
625941cb596a897236089b85
def rain(walls): <NEW_LINE> <INDENT> raindrops = 0 <NEW_LINE> if len(walls) < 1: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> for i in range(len(walls)): <NEW_LINE> <INDENT> left = walls[i] <NEW_LINE> for j in range(i): <NEW_LINE> <INDENT> left = max(left, walls[j]) <NEW_LINE> <DEDENT> right = walls[i] <NEW_LINE> f...
calculate contained raindrops
625941cb796e427e537b068a
def write_raw(self, data: bytes) -> None: <NEW_LINE> <INDENT> metrics.sent_messages.labels(self.__class__.__name__).inc() <NEW_LINE> if not self.is_connected(): <NEW_LINE> <INDENT> raise DisconnectedError("Protocol is not connected!") <NEW_LINE> <DEDENT> self.writer.write(data)
Write raw bytes into the message buffer. Should generally not be used. # Errors May raise `DisconnectedError`.
625941cb0a50d4780f666f56
def test_sbml2amici_no_observables(simple_sbml_model): <NEW_LINE> <INDENT> sbml_doc, sbml_model = simple_sbml_model <NEW_LINE> sbml_importer = SbmlImporter(sbml_source=sbml_model, from_file=False) <NEW_LINE> with TemporaryDirectory() as tmpdir: <NEW_LINE> <INDENT> sbml_importer.sbml2amici(model_name="test", output_dir=...
Test model generation works for model without observables
625941cb6aa9bd52df036e69
def deserialize_numpy(self, str, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 8 <NEW_LINE> (_x.upperleft, _x.lowerRight,) = _get_struct_2i().unpack(str[start:end]) <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (length,) = _struct_I.un...
unpack serialized message in str into this message instance using numpy for array types :param str: byte array of serialized message, ``str`` :param numpy: numpy python module
625941cb76d4e153a657ebf5
def diff(self, rev=None): <NEW_LINE> <INDENT> args = [] <NEW_LINE> if rev is not None: <NEW_LINE> <INDENT> args.append("-r %d" % rev) <NEW_LINE> <DEDENT> out = self._authsvn('diff', args) <NEW_LINE> return out
return a diff of the current path against revision rev (defaulting to the last one).
625941cbcc0a2c11143dcf55
def decide_speeds(self, distance_offset, time_delta): <NEW_LINE> <INDENT> leftspeed = 0 <NEW_LINE> rightspeed = 0 <NEW_LINE> if self.control_mode == "LINEAR": <NEW_LINE> <INDENT> leftspeed, rightspeed = self.decide_speeds_linear( distance_offset ) <NEW_LINE> <DEDENT> elif self.control_mode == "PID": <NEW_LINE> <INDENT>...
Set up return values at the start
625941cbd6c5a1020814410f
def delete_ticket(ticket_id): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ticket = Ticket.query.get(ticket_id) <NEW_LINE> ticket.delete() <NEW_LINE> <DEDENT> except NoResultFound: <NEW_LINE> <INDENT> raise RequestDoesnotExistsException(ticket_id) <NEW_LINE> <DEDENT> return True
Delete a ticket by id. :ticket_id: an int object :returns: ticket
625941cbfb3f5b602dac3757
def get_crs_name(fc_path): <NEW_LINE> <INDENT> sr = arcpy.Describe(fc_path).spatialReference <NEW_LINE> log.debug("get_crs_name returning: " + sr.name) <NEW_LINE> return sr.name
:param fc_path: fully qualified path to a feature class :type fc_path: basestring :returns sr.name: the coordinate system name :rtype sr.name: basestring
625941cbeab8aa0e5d26dc1c
def __init__(self): <NEW_LINE> <INDENT> O.__init__(self) <NEW_LINE> self.n = 0 <NEW_LINE> self.left = None <NEW_LINE> self.right = None
Points to root of the tree and number of children under it :return:
625941cb30bbd722463cbe8a