code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def key_for_code(code): <NEW_LINE> <INDENT> handle = Handle() <NEW_LINE> try: <NEW_LINE> <INDENT> res = handle.checked_call('KeyForCode', {'Code': code}) <NEW_LINE> if 'KeyEvent' in res: <NEW_LINE> <INDENT> action = KeyAction('') <NEW_LINE> action.bson_obj = res['KeyEvent'] <NEW_LINE> return action <NEW_LINE> <DEDENT> ...
Create a KeyAction with the given key code. The result is None if the code is not found. The result will have no 'event', so it will be necessary to run with_event() on it.
625941b382261d6c526ab249
def test_game_size(): <NEW_LINE> <INDENT> assert utils.game_size(2000, 10) == 1442989326579174917694151 <NEW_LINE> assert np.all( utils.game_size([10, 20, 100], 10) == [92378, 10015005, 4263421511271] ) <NEW_LINE> assert np.all( utils.game_size(10, [10, 20, 100]) == [92378, 20030010, 42634215112710] ) <NEW_LINE> assert...
Test game size
625941b3293b9510aa2c3040
def get_scheme_from_file(filename): <NEW_LINE> <INDENT> with open(filename, 'rb') as f: <NEW_LINE> <INDENT> return retype.match(f.readline().split('{')[0]).groups()[0].lower()
Return the scheme associated with filename.
625941b3507cdc57c6306a78
@pytest.fixture(scope='session') <NEW_LINE> def empty_cfg(tmpdir_factory): <NEW_LINE> <INDENT> path = tmpdir_factory.getbasetemp().join('config', 'test_empty.cfg') <NEW_LINE> path.write('', ensure=True) <NEW_LINE> return config.Config(str(path))
An empty test config file
625941b355399d3f0558845a
def transaction(self, func, *watches, **kwargs): <NEW_LINE> <INDENT> shard_hint = kwargs.pop('shard_hint', None) <NEW_LINE> pipe = self.pipeline(True, shard_hint) <NEW_LINE> while 1: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pipe.watch(*watches) <NEW_LINE> func(pipe) <NEW_LINE> return pipe.execute() <NEW_LINE> <DEDE...
Convenience method for executing the callable `func` as a transaction while watching all keys specified in `watches`. The 'func' callable should expect a single arguement which is a Pipeline object.
625941b31f037a2d8b945fa5
def get_input(text): <NEW_LINE> <INDENT> return input(text)
Get input from user. :param text: Text to print before taking input. :return: Input of user.
625941b356ac1b37e6263f89
def get_dynamic_rmse(self): <NEW_LINE> <INDENT> i_doy = np.argsort(np.mod( self.X[self.start:self.here, 1] - self.X[self.here + self.consecutive, 1], self.ndays))[:self.min_obs] <NEW_LINE> rmse = np.zeros(len(self.test_indices), np.float32) <NEW_LINE> for i_b, b in enumerate(self.test_indices): <NEW_LINE> <INDENT> m = ...
Return the dynamic RMSE for each model Dynamic RMSE refers to the Root Mean Squared Error calculated using `self.min_obs` number of observations closest in day of year to the observation `self.consecutive` steps into the future. Goal is to reduce false-positives during seasonal transitions (high variance in the signal...
625941b31f037a2d8b945fa6
def register_builder(self, key, builder): <NEW_LINE> <INDENT> self._builder[key] = builder
Registering a builder, respective key will be added to private _builder
625941b3498bea3a759b9859
def dft_naive(x): <NEW_LINE> <INDENT> N = x.shape[0] <NEW_LINE> n = np.arange(N) <NEW_LINE> k = np.arange(N).reshape(-1, 1) <NEW_LINE> cos = np.cos(2*np.pi*k*n/N) <NEW_LINE> sin = np.sin(2*np.pi*k*n/N) <NEW_LINE> X = (cos - 1j*sin) @ x <NEW_LINE> return X
Computes the naive DFT of a sequence. The DFT is computed as defined by: .. math:: :label: eq-naive-dft X_k = \sum^{N-1}_{n=0}x_n e^{-j2\pi kn/N} where :math:`X_k` is the :math:`k`th Fourier coefficients, :math:`x_n` is the :math:`n`th sample of the input signal and :math:`N` is the size of the input signa...
625941b367a9b606de4a7c64
def write(s): <NEW_LINE> <INDENT> pass
Write a string to the file.
625941b391f36d47f21ac29c
def autoscaler_pool_settings(self, **kwargs): <NEW_LINE> <INDENT> pool_name = kwargs["pool_name"] <NEW_LINE> value_map = { "pg_autoscale_mode": kwargs.get("pg_autoscale_mode"), "target_size_ratio": kwargs.get("target_size_ratio"), "target_size_bytes": kwargs.get("target_size_bytes"), "pg_num_min": kwargs.get("pg_num_mi...
Sets various options on pools wrt PG Autoscaler Args: **kwargs: various kwargs to be sent Supported kw args: 1. pg_autoscale_mode: PG saler mode for the indivudial pool. Values-> on, warn, off. (str) 2. target_size_ratio: ratio of cluster pool will utilize. Values -> 0 - 1. (float) 3...
625941b34e4d5625662d418d
def relative_rate(self): <NEW_LINE> <INDENT> return _cdma_swig.flag_gen_sptr_relative_rate(self)
relative_rate(flag_gen_sptr self) -> double
625941b399fddb7c1c9de142
def p_PRINT(t): <NEW_LINE> <INDENT> pass
PRINT : PRINT_KEYWORD OPEN_PARENTHESES M
625941b3cad5886f8bd26d89
def set_canceled(self): <NEW_LINE> <INDENT> self.canceled = True
Set canceled.
625941b3ab23a570cc24ff2e
def _is_rare_abbrev_type(self, cur_tok, next_tok): <NEW_LINE> <INDENT> if cur_tok.abbr or not cur_tok.sentbreak: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> typ = cur_tok.type_no_sentperiod <NEW_LINE> count = self._type_fdist[typ] + self._type_fdist[typ[:-1]] <NEW_LINE> if typ in self._params.abbrev_types or c...
A word type is counted as a rare abbreviation if... - it's not already marked as an abbreviation - it occurs fewer than ABBREV_BACKOFF times - either it is followed by a sentence-internal punctuation mark, *or* it is followed by a lower-case word that sometimes appears with upper case, but never occurs wi...
625941b3dc8b845886cb52db
def get_flat_image(self, full_output=False): <NEW_LINE> <INDENT> return convert_image_to_array(self.flat, full_output)
Returns the flat image. Args ---- full_output : boolean, optional Passed to converImageToArray function Returns ------- dark_image : 2D numpy array The dark image output_obj : ImageInfo, optional Object containing information about the image, if full_output=True
625941b321a7993f00bc7a8f
def test_get_instance(self): <NEW_LINE> <INDENT> region = get_data_region("us-east-1", datas) <NEW_LINE> inst = get_instance("m3.large", region) <NEW_LINE> self.assertEqual("2", inst['vCPU'])
Configuration file
625941b3eab8aa0e5d26d905
def within_class_scatter(data,label): <NEW_LINE> <INDENT> labelset = set(label) <NEW_LINE> dim = data.shape[1] <NEW_LINE> row = data.shape[0] <NEW_LINE> Sw = np.zeros((dim,dim)) <NEW_LINE> for i in labelset: <NEW_LINE> <INDENT> pos = np.where(label == i) <NEW_LINE> X = data[pos] <NEW_LINE> possize = np.size(pos) <NEW_L...
within class scatter matrix
625941b3fb3f5b602dac343e
def quest_LAL(exo, cor): <NEW_LINE> <INDENT> A, B, C = geo.choix_points(3) <NEW_LINE> nom = shuffle_nom([A, B, C]) <NEW_LINE> c = 0.1 * random.randint(40, 70) <NEW_LINE> b = 0.1 * random.randint(20, 100) <NEW_LINE> angBAC = 3 * random.randint(7, 50) <NEW_LINE> exo.append(u"\\item Trace un triangle $%s$ tel que $%s%s=\\...
on donne un angle et les longueurs de ses deux côtés
625941b3e8904600ed9f1cd0
def test_4_sampling(self): <NEW_LINE> <INDENT> tests = [([MILSERVICE], ([MEDICALSERV, SAIMAASEAL, METROPOLIS], [0, 0, 0]), ["MILSERVICE", "MEDICALSERV", "SAIMAASEAL", "METROPOLIS"], 0.183)] <NEW_LINE> for query, (E,e), fields, answer in tests: <NEW_LINE> <INDENT> prob = [approximate_distribution(self.network, query, E...
Check `approximate_distribution`.
625941b33539df3088e2e0f2
def optimal_transport_presolve_2(Y, X, Y_w=None, X_w=None): <NEW_LINE> <INDENT> if X_w is None: <NEW_LINE> <INDENT> X_w = np.ones(X.shape[0]) <NEW_LINE> <DEDENT> if Y_w is None: <NEW_LINE> <INDENT> Y_w = np.ones(Y.shape[0]) <NEW_LINE> <DEDENT> bary_X = np.average(X,axis=0,weights=X_w) <NEW_LINE> bary_Y = np.average(Y,a...
This function calculates first estimation of the potential. Parameters ---------- Y : 2D array Target samples Y_w : 1D array Weights associated to Y X : 2D array Source samples X_w : 1D array Weights asociated to X Returns ------- psi0 : 1D array Convex estimation of the potential. Its gradien...
625941b3925a0f43d2549c1a
def setup_sync(): <NEW_LINE> <INDENT> viewers = nuke.selectedNodes('Viewer') <NEW_LINE> viewer_levels = {} <NEW_LINE> remove_viewers = [] <NEW_LINE> if viewers: <NEW_LINE> <INDENT> for viewer in viewers: <NEW_LINE> <INDENT> group = '.'.join(viewer.fullName().split('.')[:-1]) <NEW_LINE> if not group: <NEW_LINE> <INDENT>...
Sets up a viewerSync between a group of Viewer nodes. This sets up callbacks between either all selected viewers, or all viewers at the current node graph level (as defined by what nuke.allNodes() returns). It also sets up a series of settings on the Viewer nodes themselves, controlling which knobs get synced between ...
625941b315baa723493c3d19
def __wait_for_cleep_process(self, module_name): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> time.sleep(1.0) <NEW_LINE> resp = requests.post(self.CLEEP_COMMAND_URL, json={ 'command': 'get_modules_updates', 'to': 'update' }) <NEW_LINE> resp.raise_for_status() <NEW_LINE> resp_json = resp.json() <NEW_LINE> if resp...
Wait for end of current Cleep process (install, update...)
625941b3236d856c2ad44587
def get_type(type, calltype, iid_is=None, size_is=None): <NEW_LINE> <INDENT> while isinstance(type, xpidl.Typedef): <NEW_LINE> <INDENT> type = type.realtype <NEW_LINE> <DEDENT> if isinstance(type, xpidl.Builtin): <NEW_LINE> <INDENT> if type.name == 'string' and size_is is not None: <NEW_LINE> <INDENT> return xpt.String...
Return the appropriate xpt.Type object for this param
625941b38a43f66fc4b53e18
def test_githuborg_initerror(githuborg_fixture): <NEW_LINE> <INDENT> githuborg_mock, _, _ = githuborg_fixture <NEW_LINE> githuborg_mock.side_effect = github.BadCredentialsException('', '') <NEW_LINE> with pytest.raises(ValueError): <NEW_LINE> <INDENT> GitHubOrg('org', auth=False)
Test initializing GitHub API failed
625941b35fc7496912cc372d
def get_test_data_folder() -> str: <NEW_LINE> <INDENT> return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
Return absolute path to test data folder.
625941b356b00c62f0f14403
def __init__(self): <NEW_LINE> <INDENT> self.files = {} <NEW_LINE> engine = db_connect() <NEW_LINE> create_deals_table(engine) <NEW_LINE> self.Session = sessionmaker(bind=engine)
Initializes database connection and sessionmaker. Creates deals table.
625941b3b57a9660fec33626
def set_Filter(self, value): <NEW_LINE> <INDENT> super(AggregatedListInputSet, self)._set_input('Filter', value)
Set the value of the Filter input for this Choreo. ((optional, string) A filter expression for narrowing results in the form: {field_name} {comparison_string} {literal_string} (e.g. name eq my_instance). Comparison strings can be eq (equals) or ne (not equals).)
625941b36e29344779a623be
def find_description(self, description, cats=None): <NEW_LINE> <INDENT> result = list() <NEW_LINE> if cats is None: <NEW_LINE> <INDENT> cats = self.cats <NEW_LINE> <DEDENT> for cat in cats: <NEW_LINE> <INDENT> if cat.get_description(description): <NEW_LINE> <INDENT> result.append(cat) <NEW_LINE> <DEDENT> <DEDENT> retur...
find cat with description :param str description: description to search for, can be regex :param list cats: optional list of Cats to search :return: list of Cats :rtype: list
625941b38c0ade5d55d3e766
def updateXAxis(self, update_immediately: bool = False) -> None: <NEW_LINE> <INDENT> if len(self._curves) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> min_x = self.plotItem.getAxis('bottom').range[0] <NEW_LINE> max_range = max([curve.max_x() for curve in self._curves]) <NEW_LINE> if min_x == 0: <NEW_LINE> <INDE...
Manages the requests to archiver appliance. When the user pans or zooms the x axis to the left, a request will be made for backfill data
625941b3d7e4931a7ee9dcc3
@login_required <NEW_LINE> def get_page_list(request): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> pages = BasicPage.objects.get_all_basic() <NEW_LINE> mainmemu = mm.objects.get(menu_name='english') <NEW_LINE> pages_dict = {"name":'english' ,"pages": [] } <NEW_LINE> for page in mainmemu.get_chil...
return a json dictionnay of all available page @return: ordered dictionnary menu_id : { id : int ,menu_name : string ,lft : int (element on the left) ,rgt : int (element on the right) ,slug : string ,description : string ...
625941b37b180e01f3dc45b0
def set_state(self, state): <NEW_LINE> <INDENT> self.n_unk,self.n_consumed,self.unk_prob,self.consumed_prob = state
Set the number of consumed words
625941b350812a4eaa59c0ce
def find_arxml_files(search_path): <NEW_LINE> <INDENT> for subdir, _dirs, files in os.walk(search_path): <NEW_LINE> <INDENT> for file in files: <NEW_LINE> <INDENT> if file.endswith(".arxml"): <NEW_LINE> <INDENT> yield os.path.join(subdir, file)
Generates a list of arxml files Args: search_path: The directory where to look for arxml files Yields: arxml_file_path
625941b3a79ad161976cbeee
def __init__(self,login, password, parent=None): <NEW_LINE> <INDENT> super().__init__(parent) <NEW_LINE> self.setupUi(self) <NEW_LINE> self.db = AccesBdd(login, password) <NEW_LINE> self.actionEnregistrer.setEnabled(False) <NEW_LINE> self.actionMise_jour.setEnabled(False) <NEW_LINE> self.tableWidget_table_etalonnage.s...
Constructor @param parent reference to the parent widget (QWidget)
625941b3167d2b6e31218946
def dive_sphere(inputfile, outputfile, onlyfrag1): <NEW_LINE> <INDENT> frags_db = FragmentsDb(inputfile) <NEW_LINE> nodes = {} <NEW_LINE> samples = len(frags_db) <NEW_LINE> sql = 'SELECT frag_id, pdb_code, het_code FROM fragments' <NEW_LINE> if onlyfrag1: <NEW_LINE> <INDENT> sql += ' WHERE frag_id LIKE "%_frag1"' <NEW_...
Export fragments as DiVE formatted sphere Args: inputfile (str): fragments db input file outputfile (file): fragments dive output file onlyfrag1 (bool): Only \*_frag1
625941b3627d3e7fe0d68bf6
def get_probability_is_argument(mdl, fm, predicate_words,pos=5): <NEW_LINE> <INDENT> X = [] <NEW_LINE> X_new = [] <NEW_LINE> X.append([] ) <NEW_LINE> X_new.append([[predicate_words , "PRED"]]) <NEW_LINE> score = [] <NEW_LINE> for p in range(pos): <NEW_LINE> <INDENT> n=1 <NEW_LINE> X_new, rs_scores, X, myscores = get_sc...
calculate the probability that a word is an argument of a predicate :param mdl: :param fm: :return:
625941b3d99f1b3c44c67348
def domains_check(domain_check_list: list, checker_name: str, n_threads=n_threads, regexp=regexp, timeout=timeout, verbose=verbose): <NEW_LINE> <INDENT> opend=[] <NEW_LINE> total_num_sites = len(domain_check_list) <NEW_LINE> log.info(f"[O] Количество {checker_name} для проверки: {str(total_num_sites)}") <NEW_LINE> if t...
Запускает проверку списка сайтов и следит, чтобы не было lock
625941b324f1403a9260091a
def is_non_science_or_lab(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> is_non_science(self) <NEW_LINE> return <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> if not self._is_on_mountain(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> raise KeyError(f"{self._log_prefix}: Requir...
Pseudo method to determine whether this is a lab or non-science header. Raises ------ KeyError If this is a science observation and on the mountain.
625941b3b5575c28eb68dda5
def build_model(self): <NEW_LINE> <INDENT> states = layers.Input(shape=(self.state_size,), name='states') <NEW_LINE> actions = layers.Input(shape=(self.action_size,), name='actions') <NEW_LINE> net_states = layers.Dense(units=32, activation='tanh')(states) <NEW_LINE> net_states = layers.Dense(units=64, activation='tanh...
Build a critic (value) network that maps (state, action) pairs -> Q-values.
625941b3b7558d58953c4cc8
def _do_add_property(self, updates, change): <NEW_LINE> <INDENT> key = change['path'][1] <NEW_LINE> if key in updates: <NEW_LINE> <INDENT> msg = _("Property %s already present.") <NEW_LINE> raise webob.exc.HTTPConflict(msg % key) <NEW_LINE> <DEDENT> updates[key] = change['value']
Add a new image property, ensuring it does not already exist.
625941b338b623060ff0ab9e
def start(update_queue, response_queue, stop_page=True, port=5000, secret_key=os.urandom(24)): <NEW_LINE> <INDENT> process = multiprocessing.Process(target=new_server, args=(update_queue, response_queue, stop_page, port, secret_key)) <NEW_LINE> process.daemon = True <NEW_LINE> process.start()
Start new server on `port`. This function create new daemon process and start it.
625941b30a50d4780f666c37
def get_revisions_until_request(self): <NEW_LINE> <INDENT> for r in self.current_page.revisions(content=True): <NEW_LINE> <INDENT> if '{{Löschantragstext' not in r.text: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> user = None if r.anon else r.user <NEW_LINE> yield user, r.timestamp
Read the version history until the deletion template was found.
625941b30a366e3fb873e5be
def save(self): <NEW_LINE> <INDENT> saved_file = os.path.join(self.__path, self.name) <NEW_LINE> with open(saved_file, 'wb') as file: <NEW_LINE> <INDENT> my_pickler = pickle.Pickler(file) <NEW_LINE> my_pickler.dump(self)
Save a game in a file. File name is game name.
625941b37047854f462a11b6
def FreezeCore(self,*args): <NEW_LINE> <INDENT> pass
FreezeCore(self: QuaternionAnimationUsingKeyFrames,isChecking: bool) -> bool Makes this instance of System.Windows.Media.Animation.QuaternionAnimationUsingKeyFrames object unmodifiable or determines whether it can be made unmodifiable. isChecking: true to check if this instance can be frozen; false to fre...
625941b3498bea3a759b985a
def parse_str_for_metadata(main_content_str): <NEW_LINE> <INDENT> meta_dict = {} <NEW_LINE> try: <NEW_LINE> <INDENT> meta_match = gv.re_metadata_finder.findall(main_content_str) <NEW_LINE> assert len(meta_match) == 1 <NEW_LINE> meta_str = meta_match[0] <NEW_LINE> meta_list = [e for e in meta_str.split('\n') if e != '']...
Look for metadata within the delimiters '## BEGIN METADATA ##' and '## END METADATA ##' (which are on their own separate lines) of the form to place in HTML format of the form <meta name="{name}" content="{content}">. Returns a string of these HTML-formatted metadata (or the empty string if no metadata exists). In the...
625941b316aa5153ce362220
def _write_after(self, indx): <NEW_LINE> <INDENT> writing_after_indx=[(line, sls) for (line, i, sls) in self._writing_after if i == indx] <NEW_LINE> for noteline, sls in writing_after_indx: <NEW_LINE> <INDENT> self.parent.write(noteline, sls)
Write everything we've been waiting to.
625941b355399d3f0558845c
def _prepare_downloaded_spm_auditory_data(subject_dir): <NEW_LINE> <INDENT> subject_data = {} <NEW_LINE> for file_name in SPM_AUDITORY_DATA_FILES: <NEW_LINE> <INDENT> file_path = os.path.join(subject_dir, file_name) <NEW_LINE> if os.path.exists(file_path): <NEW_LINE> <INDENT> subject_data[file_name] = file_path <NEW_LI...
Uncompresses downloaded spm_auditory dataset and organizes the data into apprpriate directories. Parameters ---------- subject_dir: string Path to subject's data directory. Returns ------- _subject_data: skl.Bunch object Scikit-Learn Bunch object containing data of a single subject from the SPM Auditory ...
625941b31b99ca400220a858
def create_parser() -> argparse.ArgumentParser: <NEW_LINE> <INDENT> parser = argparse.ArgumentParser() <NEW_LINE> parser.add_argument("-i", "--input", default="input/", help="Path to directory with input data.") <NEW_LINE> parser.add_argument("-o", "--output", default="output/", help="Directory where to store results."...
Initialize the command line argument parser.
625941b3d6c5a10208143dee
def tick(self, force_update=False): <NEW_LINE> <INDENT> now = datetime.datetime.now( TZOffset()).replace(second=0, microsecond=0) <NEW_LINE> if now == self.last_tick and not force_update: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if self.settings.remind_idle > datetime.timedelta(0): <NEW_LINE> <INDENT> if sel...
Tick every second.
625941b366673b3332b91e3f
def _desc(self): <NEW_LINE> <INDENT> return '%s(%s%s)' % (self.__class__.__name__, self._delay, '' if self._value is None else (', value=%s' % self._value))
Return a string *Timeout(delay[, value=value])*.
625941b3711fe17d82542125
def config_transport(transports, transport, transport_config): <NEW_LINE> <INDENT> lgr.debug('configuring transport...') <NEW_LINE> if hasattr(transports, transport): <NEW_LINE> <INDENT> transport_instance = getattr(transports, transport)(transport_config) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> lgr.error('could ...
returns a configured instance and client for the transport :param transports: transport classes to choose from. :param string transport: transport to use :param dict transport_config: transport configuration
625941b323849d37ff7b2e41
def smbus_open(bus_str, po): <NEW_LINE> <INDENT> global bus <NEW_LINE> global i2c_msg <NEW_LINE> m = re.match(r'(smbus|i2c):([0-9]+)', bus_str) <NEW_LINE> if m: <NEW_LINE> <INDENT> po.api_type = str(m.group(1)) <NEW_LINE> bus_index = int(m.group(2),0) <NEW_LINE> if po.dry_run: <NEW_LINE> <INDENT> bus = SMBusMock(bus_in...
Opens the System Managememnt Bus over I2C interface The current implementation is for Rapsberry Pi.
625941b331939e2706e4cc1a
def __init__(self): <NEW_LINE> <INDENT> print("Initializing")
Add any initialization parameters. These will be passed at runtime from the graph definition parameters defined in your seldondeployment kubernetes resource manifest.
625941b33617ad0b5ed67ca7
@click.command('new') <NEW_LINE> @click.argument('language', type=click.Choice(['python3', 'r']), default='python3') <NEW_LINE> @click.option('--mem', type=int, default=None, help='Memory allocated for this notebook in MiB.') <NEW_LINE> @click.option('--cpu', type=int, default=None, help='CPU available for this noteboo...
Create a new notebook and open it in the browser.
625941b3925a0f43d2549c1b
def do_determine_instance_ip(self): <NEW_LINE> <INDENT> options = self.options <NEW_LINE> logging.debug('Looking up IP address for "%s"...', options.deploy_google_instance) <NEW_LINE> response = check_subprocess( 'gcloud compute instances describe' ' --format json' ' --account {gcloud_account}' ' --project {project} --...
Implements GenericVmValidateBomDeployer interface.
625941b30c0af96317bb7f92
def autoRepeatDelay(self): <NEW_LINE> <INDENT> return 0
autoRepeatDelay(self) -> int
625941b3baa26c4b54cb0ecf
def _handle_exception(self, id_, data, message): <NEW_LINE> <INDENT> self.execute_error.emit('dependency', id_, data) <NEW_LINE> raise RuntimeError(message)
Slot performed if the threaded method has raised an exception.
625941b37047854f462a11b7
def load_networks(shared, task_id, device, logger, mnet, hnet, hhnet=None, dis=None): <NEW_LINE> <INDENT> ckpt_dict, score = tckpt.load_checkpoint(shared.ckpt_mnet_fn % task_id, mnet, device=device, ret_performance_score=True) <NEW_LINE> if hnet is not None: <NEW_LINE> <INDENT> tckpt.load_checkpoint(shared.ckpt_hnet_fn...
Load checkpointed networks. Args: shared (argparse.Namespace): Miscellaneous data shared among training functions (contains filenames). task_id (int): On which task have the networks been trained last. device: PyTorch device. logger: Console (and file) logger. mnet: The main network. hn...
625941b3004d5f362079a0e1
def open(filename, mode="rb", encoding=None, errors=None, newline=None, block_size=BLOCKSIZE_DEFAULT, block_linked=True, compression_level=COMPRESSIONLEVEL_MIN, content_checksum=False, block_checksum=False, auto_flush=False, return_bytearray=False, source_size=0): <NEW_LINE> <INDENT> if 't' in mode: <NEW_LINE> <INDENT>...
Open an LZ4Frame-compressed file in binary or text mode. ``filename`` can be either an actual file name (given as a str, bytes, or PathLike object), in which case the named file is opened, or it can be an existing file object to read from or write to. The ``mode`` argument can be ``'r'``, ``'rb'`` (default), ``'w'``,...
625941b3f548e778e58cd324
def discriminator(x, convolutional=True, n_features=32, rgb=False, reuse=False): <NEW_LINE> <INDENT> with tf.variable_scope('discriminator', reuse=reuse): <NEW_LINE> <INDENT> return encoder( x=x, convolutional=convolutional, filter_sizes=[5, 5, 5, 5], dimensions=[ n_features, n_features * 2, n_features * 4, n_features ...
Summary Parameters ---------- x : TYPE Description convolutional : bool, optional Description n_features : int, optional Description rgb : bool, optional Description reuse : bool, optional Description Returns ------- name : TYPE Description
625941b315baa723493c3d1a
def page_not_found(request): <NEW_LINE> <INDENT> from django.shortcuts import render_to_response <NEW_LINE> response = render_to_response('404.html', {}) <NEW_LINE> response.status_code = 404 <NEW_LINE> return response
全局404设置
625941b3ab23a570cc24ff30
def test_create(self): <NEW_LINE> <INDENT> row = baker.make(self.to_bake) <NEW_LINE> self.assertTrue(isinstance(row, self.model))
verify object can be created
625941b31f5feb6acb0c4906
def handle_data_wire3(self, pins): <NEW_LINE> <INDENT> clk, dio, stb = pins <NEW_LINE> if self.bitcount >= 8: <NEW_LINE> <INDENT> self.handle_byte_wire3() <NEW_LINE> self.clear_data() <NEW_LINE> self.ss_byte = self.samplenum <NEW_LINE> <DEDENT> self.bits.insert(0, [dio, self.samplenum, self.samplenum]) <NEW_LINE> self....
Process data bits at CLK rising edge for 3-wire bus.
625941b3099cdd3c635f0a06
def get_group_feed(self, group): <NEW_LINE> <INDENT> Url = BASE_URL + 'me/groups//{0}/'.format(group) <NEW_LINE> res = self._get(url=Url) <NEW_LINE> id = res['data'][0]['id'] <NEW_LINE> Url2 = BASE_URL + '{0}/feed'.format(id) <NEW_LINE> return self._get(url=Url2)
get the newsfeed of a group
625941b33539df3088e2e0f4
def setReportInstructions(self, assessmentNumber = 1, reportBy = 2): <NEW_LINE> <INDENT> if not isinstance(assessmentNumber, int): <NEW_LINE> <INDENT> raise CourseSubreportError("Invalid assessmentNumber parameter: must be an integer.") <NEW_LINE> <DEDENT> elif assessmentNumber < 1: <NEW_LINE> <INDENT> raise CourseSubr...
Constructor method. @param int assessmentNumber : Integer that indicates the number of the assessment to which the answers that must be counted were given. @param int reportBy : Integer that marks if the course subreport should be made by class number, professor or course. @return : @author
625941b394891a1f4081b851
def has_children(self, obj): <NEW_LINE> <INDENT> return len(self.get_children(obj)) > 0
Returns whether the object has children.
625941b315baa723493c3d1b
def get_user_self(self, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.get_user_self_with_http_info(**kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.get_user_self_with_http_info(**kwargs) <NEW_LINE> return...
Get current user Get the currently authenticated user. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> >>> thread = api.get_user...
625941b3a05bb46b383ec5d7
def linear_forward_test_case(): <NEW_LINE> <INDENT> np.random.seed(1) <NEW_LINE> A = np.random.randn(3, 2) <NEW_LINE> W = np.random.randn(1, 3) <NEW_LINE> b = np.random.randn(1, 1) <NEW_LINE> return A, W, b
【LINEAR】线性部分 linear_forward()函数测试样例。 :return: X = np.array([[ 1.62434536, -0.61175641], [-0.52817175, -1.07296862], [ 0.86540763, -2.3015387 ]]) W = np.array([[ 1.74481176, -0.7612069 , 0.3190391 ]]) b = np.array([[-0.24937038]]))
625941b3097d151d1a222c0d
def update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, background, play_button): <NEW_LINE> <INDENT> screen.fill(ai_settings.bg_color) <NEW_LINE> background.blitme() <NEW_LINE> for bullet in bullets.sprites(): <NEW_LINE> <INDENT> bullet.draw_bullet() <NEW_LINE> <DEDENT> ship.blitme() <NEW_LINE> aliens...
Update images on the screen and flip to the new screen.
625941b356b00c62f0f14405
def maxPoints(self, points): <NEW_LINE> <INDENT> result = 0 <NEW_LINE> for i in range(len(points)): <NEW_LINE> <INDENT> maps = {float("-inf"): 1} <NEW_LINE> same = 0 <NEW_LINE> for j in range(i + 1, len(points)): <NEW_LINE> <INDENT> if points[j].x == points[i].x and points[j].y == points[i].y: <NEW_LINE> <INDENT> same ...
:type points: List[Point] :rtype: int
625941b36e29344779a623c0
def xyz2input(filename): <NEW_LINE> <INDENT> abiinput = AbinitInput() <NEW_LINE> atomdict = atomic_symbol() <NEW_LINE> rf = open(filename, 'r') <NEW_LINE> natom = int(rf.readline()) <NEW_LINE> typat = [] <NEW_LINE> znucl = [] <NEW_LINE> xangst = [] <NEW_LINE> ntypat = 0 <NEW_LINE> rf.readline() <NEW_LINE> data = rf.rea...
Reads a .xyz and return an ABINIT input as a python dictionary
625941b36e29344779a623c1
def workspace_open_requested(self): <NEW_LINE> <INDENT> if self.openWorkspaceCB.isVisible(): <NEW_LINE> <INDENT> return self.openWorkspaceCB.isChecked() <NEW_LINE> <DEDENT> return True
Returns a boolean of whether the user requested the workspace be opened on model success.
625941b3cc40096d61595701
def cross_validation(train_data, train_labels, k_range=np.arange(1,16)): <NEW_LINE> <INDENT> train_data = np.array(train_data) <NEW_LINE> train_labels = np.array(train_labels) <NEW_LINE> accuracy_array = [] <NEW_LINE> for k in k_range: <NEW_LINE> <INDENT> X = train_data <NEW_LINE> kf = KFold(n_splits=10, shuffle=True) ...
Perform 10-fold cross validation to find the best value for k Note: Previously this function took knn as an argument instead of train_data,train_labels. The intention was for students to take the training data from the knn object - this should be clearer from the new function signature.
625941b34e696a04525c91ff
def get_exposed_url_endpoints(self): <NEW_LINE> <INDENT> return [ 'dashboard.index', 'dashboard.get_by_sever_id', 'dashboard.get_by_database_id', 'dashboard.session_stats', 'dashboard.get_session_stats_by_sever_id', 'dashboard.get_session_stats_by_database_id', 'dashboard.tps_stats', 'dashboard.tps_stats_by_server_id',...
Returns: list: a list of url endpoints exposed to the client.
625941b323e79379d52ee313
def test_IndexAccessNonExisting(self): <NEW_LINE> <INDENT> iLen = len(self.List) <NEW_LINE> for iIndex in range(1, 5): <NEW_LINE> <INDENT> gTarget = list(self.List) <NEW_LINE> lstTest = [9] <NEW_LINE> lstTest.extend(self.List) <NEW_LINE> self.TestFunction(gTarget, -iLen - iIndex, 9) <NEW_LINE> self.assertListEqual(gTar...
Checks that the index argument outside the range results in the new element being added in front (for negative indexes) or after (for the positive index) existing elements - only for mutable sequences. Implements tests ID TEST-T-510. Covers requirements REQ-FUN-530.
625941b3460517430c393f3b
def erdos_renyi(n,m,wantRank=False): <NEW_LINE> <INDENT> V = [] <NEW_LINE> E = [] <NEW_LINE> rank_ls = [] <NEW_LINE> ls = [] <NEW_LINE> E_set = set() <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> V.append(str(i)) <NEW_LINE> <DEDENT> i = 0 <NEW_LINE> while i < m: <NEW_LINE> <INDENT> u = random.choice(V) <NEW_LINE> v...
generates a graph (returned as a list of nodes and a list of edges) using the Erdos Renyi model. also returns a rank_ls that gives the order in which the edges were generated.
625941b30a50d4780f666c38
def chooseOntologyPath(self): <NEW_LINE> <INDENT> path = self.path.text() <NEW_LINE> path = QFileDialog.getExistingDirectory(self, 'Choose Directory', path) <NEW_LINE> self.path.setText(path)
Choose a path from the QFileDialog.
625941b3be8e80087fb209f8
def opt_algo(D, w, n): <NEW_LINE> <INDENT> h = 0 <NEW_LINE> b_h = w <NEW_LINE> k_h = floor(D/(pow(2.,n) * b_h)) <NEW_LINE> b = b_h <NEW_LINE> r = D % (pow(2.,n) * b_h) <NEW_LINE> k = k_h <NEW_LINE> itera = 0 <NEW_LINE> verif = bool(1) <NEW_LINE> while verif: <NEW_LINE> <INDENT> if (D % (pow(2.,n) * b_h)) == 0: <NEW_LIN...
Solves the tiling problem patitioning the interval [0, D-1] into k subintervals of size 2^n b and one final subinterval of size r = D - k 2^n b Input: D = dimension of the original array w = approximate estimation of value for b n = desideres level of refinement (e.g. : n = 0 => maximum level of refinement; n =1 ...
625941b3377c676e91271f5c
def get_world_bits(): <NEW_LINE> <INDENT> import stat <NEW_LINE> world_mask = stat.S_IRWXO <NEW_LINE> world_bits = { 'r' : stat.S_IROTH, 'w' : stat.S_IWOTH, 'x' : stat.S_IXOTH, 'rw' : stat.S_IROTH|stat.S_IWOTH, 'rx' : stat.S_IROTH|stat.S_IXOTH, 'wx' : stat.S_IWOTH|stat.S_IXOTH, 'rwx' : stat.S_IRWXO, } <NEW_LINE> world_...
Helper function for get_permissions() and change_permissions(). Same as get_owner_bits() except for group.
625941b33c8af77a43ae3550
def create_user(self,name, date_of_birth, contact_number, password, **extra_fields): <NEW_LINE> <INDENT> errors = {} <NEW_LINE> if not name: <NEW_LINE> <INDENT> errors['name'] = _('Name must be set') <NEW_LINE> <DEDENT> if not date_of_birth: <NEW_LINE> <INDENT> errors['date_of_birth'] = _('Date of Birth must be set') <...
Create and save an user with the given contact number and password.
625941b36aa9bd52df036b4c
def _write_encrypted_pem(self, passphrase): <NEW_LINE> <INDENT> key = PKey() <NEW_LINE> key.generate_key(TYPE_RSA, 128) <NEW_LINE> pemFile = self.mktemp() <NEW_LINE> fObj = open(pemFile, 'w') <NEW_LINE> pem = dump_privatekey(FILETYPE_PEM, key, "blowfish", passphrase) <NEW_LINE> fObj.write(pem.decode('ascii')) <NEW_LINE...
Write a new private key out to a new file, encrypted using the given passphrase. Return the path to the new file.
625941b363b5f9789fde6e8f
def search_single_page(self, iter_num=0): <NEW_LINE> <INDENT> self.dry_run() <NEW_LINE> self._test_config() <NEW_LINE> self._HTML_DATA = self.get_html() <NEW_LINE> self._SOUPED_HTML_DATA = self._soup_data() <NEW_LINE> self._RESULTS_MAIN += self.get_search_results() <NEW_LINE> self._RESULTS_KEYWORDS += self.get_related_...
1. Perform a dry run 2. shift _DEFAULT_SCRAPE_METHOD if needed 3. get results
625941b326238365f5f0ec13
def new_salary(self): <NEW_LINE> <INDENT> print("The new salary of this employee is: " + str(self.salary))
Prints an employees new salary after raise.
625941b3b7558d58953c4cc9
def simulate_static(self, steps, time = None, solution = solve_type.RK4, collect_dynamic = False): <NEW_LINE> <INDENT> dyn_output = None; <NEW_LINE> dyn_time = None; <NEW_LINE> if (collect_dynamic == True): <NEW_LINE> <INDENT> dyn_output = []; <NEW_LINE> dyn_time = []; <NEW_LINE> dyn_output.append(self._outputs); <NEW_...
! @brief Performs static simulation of pulse coupled neural network. @param[in] steps (uint): Number steps of simulations during simulation. @param[in] time (double): Can be ingored - steps are used instead of time of simulation. @param[in] solution (solve_type): Type of solution (solving). @param[in] collect_dynamic ...
625941b345492302aab5e06a
def create_and_link_vrf_table(self, vrf_conf): <NEW_LINE> <INDENT> route_family = vrf_conf.route_family <NEW_LINE> if route_family == VRF_RF_IPV4: <NEW_LINE> <INDENT> vrf_table = Vrf4Table <NEW_LINE> <DEDENT> elif route_family == VRF_RF_IPV6: <NEW_LINE> <INDENT> vrf_table = Vrf6Table <NEW_LINE> <DEDENT> elif route_fami...
Factory method to create VRF table for given `vrf_conf`. Adds mapping to this table with appropriate scope. Also, adds mapping for import RT of this VRF to created table to facilitate importing/installing of paths from global tables. Returns created table.
625941b3b57a9660fec33629
def verify_petition_token(request): <NEW_LINE> <INDENT> if not request: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> challengerToken = request.swagger_data.get('token', '') <NEW_LINE> petitionId = request.swagger_data.get('petition', '') <NEW_LINE> try: <NEW_LINE> <INDENT> sig, timestamp = base64.b64decode(chal...
Verify the token for given request. A 'token' and a 'petition' must be present in the `request`. Implementation note: - we decode the token (base64) -> '{token},{timestamp}' - we extract the timestamp - we generate the same token with extracted timestamp and given petition ID. - if the generated...
625941b321a7993f00bc7a92
def add_ordering(self, *ordering): <NEW_LINE> <INDENT> fields = [] <NEW_LINE> errors = [] <NEW_LINE> for item in ordering: <NEW_LINE> <INDENT> udf = self.process_as_udf(item) <NEW_LINE> if udf: <NEW_LINE> <INDENT> fields.append(udf) <NEW_LINE> <DEDENT> elif ORDER_PATTERN.match(item): <NEW_LINE> <INDENT> fields.append(i...
This method was copied and modified from django core. In particular, each field should be checked against UDF_ORDER_PATTERN via 'process_as_udf'
625941b3796e427e537b036c
def find_supported_translations(self): <NEW_LINE> <INDENT> url = "https://www.biblegateway.com/versions/" <NEW_LINE> translations = list() <NEW_LINE> page = urlopen(url) <NEW_LINE> soup = BeautifulSoup(page.read()) <NEW_LINE> trans = soup.findAll("tr", {"class":"language-row"}) <NEW_LINE> for t in trans: <NEW_LINE> <IN...
Retrieves a list of supported translations from BibleGateway's translation page.
625941b323e79379d52ee314
def get_data(self, channels=None, maxlen=None, fmt="rows"): <NEW_LINE> <INDENT> with self.data_lock: <NEW_LINE> <INDENT> if fmt=="columns": <NEW_LINE> <INDENT> return self.table_accum.get_data_columns(channels=channels,maxlen=maxlen) <NEW_LINE> <DEDENT> elif fmt=="rows": <NEW_LINE> <INDENT> return self.table_accum.get_...
Get accumulated table data. Args: channels: list of channels to get; all channels by default maxlen: maximal column length (if stored length is larger, return last `maxlen` rows) fmt (str): return format; can be ``"rows"`` (list of rows), ``"columns"`` (list of columns), or ``"dict"`` (dictionary of named ...
625941b3d268445f265b4c1f
def test_proxy_ip(wsgi_app): <NEW_LINE> <INDENT> assert ( wsgi_app( {"REMOTE_ADDR": "10.0.0.99", "HTTP_X_FORWARDED_FOR": "11.22.33.44"}, None ) == "ip=11.22.33.44, ff=" )
Remote addr is proxy, returns the forward.
625941b355399d3f0558845e
def select_installed_version(plugin): <NEW_LINE> <INDENT> assert 'installed_version' in plugin <NEW_LINE> installed = plugin['installed_version'] <NEW_LINE> for version in plugin['versions']: <NEW_LINE> <INDENT> if version['version'] == installed: <NEW_LINE> <INDENT> return version
Return the installed version of the `plugin`. This function raises an AssertionError if the plugin is not installed. Eg. 'installed_version' is not in `plugin`.
625941b31b99ca400220a85a
def rotatedDigits(self, N): <NEW_LINE> <INDENT> nums = 0 <NEW_LINE> for i in range(1, N+1): <NEW_LINE> <INDENT> stri = str(i) <NEW_LINE> valid1, valid2 = False, True <NEW_LINE> for j in stri: <NEW_LINE> <INDENT> if j in ["2", "5", "6", "9"]: <NEW_LINE> <INDENT> valid1 = True <NEW_LINE> <DEDENT> elif j not in ["1", "0",...
:type N: int :rtype: int
625941b3a4f1c619b28afdf6
def check(self, mailfrom, recipient): <NEW_LINE> <INDENT> return
Check if mailfrom/recipient combination is whitelisted.
625941b3046cf37aa974caf6
def test_random_non_multiple(self): <NEW_LINE> <INDENT> shuffle = True <NEW_LINE> batch_size = 3 <NEW_LINE> n = 10 <NEW_LINE> np.random.seed(0) <NEW_LINE> n_batches = int(np.ceil(n * 1. / batch_size)) <NEW_LINE> sample_indices = [] <NEW_LINE> batch_indices = [] <NEW_LINE> for batch in indices_generator(shuffle, batch_s...
Test indices generator when number of samples is not a multiple of the batch size and when generation is random
625941b3099cdd3c635f0a07
def getval(self, key): <NEW_LINE> <INDENT> if not key: <NEW_LINE> <INDENT> print ("getval command expects: key") <NEW_LINE> return <NEW_LINE> <DEDENT> kpath = key.split('.') <NEW_LINE> cv = self.wallet.wallet_config <NEW_LINE> try: <NEW_LINE> <INDENT> for k in kpath: <NEW_LINE> <INDENT> cv = cv[k] <NEW_LINE> <DEDENT> ...
Returns the value for a given key in the config. Key is expressed like so: key.subkey.subsubkey
625941b331939e2706e4cc1c
def get_user(self, id): <NEW_LINE> <INDENT> return self._connection.get_user(id)
Returns a :class:`User` with the given ID. If not found, returns None.
625941b356ac1b37e6263f8d
def __init__(self, name=None, parent=None, discovered=None, part_id=None, device=None, serial=None, manufacturer=None): <NEW_LINE> <INDENT> self._name = None <NEW_LINE> self._parent = None <NEW_LINE> self._discovered = None <NEW_LINE> self._part_id = None <NEW_LINE> self._device = None <NEW_LINE> self._serial = None <N...
Data48 - a model defined in Swagger
625941b367a9b606de4a7c68
def disable_interspersed_args(self): <NEW_LINE> <INDENT> assert self.option_parser_kind == MAIN_USE_OPTPARSE <NEW_LINE> self.option_parser.disable_interspersed_args()
See optparse.disable_interspersed_args in standard python library. This function is now deprecated and is only supported if self.option_parser_kind == MAIN_USE_OPTPARSE. Use self.option_parser.disable_interspersed_args instead.
625941b33317a56b86939a16
def get_outputs(self, index: int=0) -> List[node.Node]: <NEW_LINE> <INDENT> outs = [] <NEW_LINE> for edge in self.outputs[index].edges: <NEW_LINE> <INDENT> other_socket = edge.get_other_socket(self.outputs[index]) <NEW_LINE> outs.append(other_socket.node) <NEW_LINE> <DEDENT> return outs
. Todo: * May be able to remove this.(Used for Undo function. Not used)
625941b399fddb7c1c9de146
def GetCurrentParameters(self): <NEW_LINE> <INDENT> return _itkShapePriorSegmentationLevelSetImageFilterPython.itkShapePriorSegmentationLevelSetImageFilterIF2IF2F_GetCurrentParameters(self)
GetCurrentParameters(self) -> itkArrayD
625941b33539df3088e2e0f6