code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def test_bst_delete_node_two_children(bst): <NEW_LINE> <INDENT> bst.insert(8) <NEW_LINE> bst.insert(6) <NEW_LINE> bst.insert(7) <NEW_LINE> bst.insert(5) <NEW_LINE> bst.delete(6) <NEW_LINE> assert bst.root.val == 8 <NEW_LINE> assert bst.root.left.val == 5 <NEW_LINE> assert bst.root.left.right.val == 7 <NEW_LINE> assert ... | . | 625941bd6e29344779a62501 |
def MLbinomOptim_while(k,n,pCurr=0.5,diff=0.1,thresh=0.001): <NEW_LINE> <INDENT> pCurrLike = binomPMF(k,n,pCurr) <NEW_LINE> pUpLike = binomPMF(k,n,(pCurr+diff)) <NEW_LINE> pDownLike = binomPMF(k,n,(pCurr-diff)) <NEW_LINE> while (diff > thresh): <NEW_LINE> <INDENT> while (pCurrLike < pUpLike) or (pCurrLike < pDownLike):... | This function optimizes the value of p for a binomial according to ML, based on
observed data (k successes in n trial). Uses while loops instead of recursion. | 625941bd1f037a2d8b9460ec |
def _pause_callback(self, event=None): <NEW_LINE> <INDENT> self.pause() | The method called when 'PAUSE' is clicked -- pauses the program | 625941bd76e4537e8c351563 |
def t310002_x8(): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> call = t310002_x6() <NEW_LINE> assert IsClientPlayer() == 1 <NEW_LINE> call = t310002_x7() <NEW_LINE> assert not IsClientPlayer() <NEW_LINE> <DEDENT> """Unused""" <NEW_LINE> return 0 | State 0 | 625941bd76d4e153a657ea1d |
def tail(f, window=20): <NEW_LINE> <INDENT> if window == 0: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> BUFSIZ = 1024 <NEW_LINE> f.seek(0, 2) <NEW_LINE> bytes = f.tell() <NEW_LINE> size = window + 1 <NEW_LINE> block = -1 <NEW_LINE> data = [] <NEW_LINE> while size > 0 and bytes > 0: <NEW_LINE> <INDENT> if bytes - ... | Returns the last `window` lines of file `f` as a list. | 625941bdb57a9660fec3376e |
def AddValue(self, Value): <NEW_LINE> <INDENT> return super(IGPMultiValue, self).AddValue(Value) | Method IGPMultiValue.AddValue
INPUT
Value : IGPValue* | 625941bda79ad161976cc032 |
def sync(self, registers): <NEW_LINE> <INDENT> return self.__client.sync(registers) | Sync the registers.
Args:
registers (dict): Registers
Returns:
bool: Status of sync. | 625941bd38b623060ff0acdb |
def _extract_pixel(self, char: str) -> list: <NEW_LINE> <INDENT> font = ImageFont.truetype( self.font_path, self.original_size*self.multipler) <NEW_LINE> tmp = Image.new('RGB', (1, 1), (0, 0, 0)) <NEW_LINE> tmp_d = ImageDraw.Draw(tmp) <NEW_LINE> width, height = tmp_d.textsize(char, font=font) <NEW_LINE> img = Image.new... | Extract pixel information of the unicode charactor
Args:
char:
charactor you want to extract, length shoud be 1
Returns:
2 dim list of grayscale value | 625941bd3617ad0b5ed67de5 |
def get_tag_names(self): <NEW_LINE> <INDENT> return self.get_sorted_ref_names('refs/tags') | Returns a sorted list of tag names. | 625941bdcdde0d52a9e52f1d |
def test_name_set_no_changes(self): <NEW_LINE> <INDENT> field1 = basic.numeric_float(4, 2, name='field1') <NEW_LINE> field2 = basic.numeric_float(4, 2, name='field2') <NEW_LINE> self.assertEqual('field1', field1.name) <NEW_LINE> self.assertEqual('field2', field2.name) | Tests that the field name does not change for creating a new one | 625941bd45492302aab5e1ad |
def insertNode(self,refNodeNum,newNodeNum,stop=False,after=True): <NEW_LINE> <INDENT> newNode = Node(newNodeNum) <NEW_LINE> if stop==True: newNode.setStop(True) <NEW_LINE> for nodeIdx in range(len(self.n)): <NEW_LINE> <INDENT> currentNodeNum = abs(int(self.n[nodeIdx].num)) <NEW_LINE> if currentNodeNum == abs(refNodeNum... | Inserts the given *newNodeNum* into this line, as a stop if *stop* is True.
The new node is inserted after *refNodeNum* if *after* is True, otherwise it is inserted
before *refNodeNum*.
*refNodeNum* and *newNodeNum* are ints. | 625941bd2eb69b55b151c799 |
def newLap(self): <NEW_LINE> <INDENT> self.laps.append(time.time()) <NEW_LINE> return self.laps | Adds current time to laps list.
Returns
-------
laps: list
List of all the lap times. | 625941bd32920d7e50b280ba |
def delete(fqdn, rdtype=None, origin=None): <NEW_LINE> <INDENT> if rdtype is not None: <NEW_LINE> <INDENT> assert rdtype in ['A', 'AAAA', ] <NEW_LINE> rdtypes = [rdtype, ] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rdtypes = ['A', 'AAAA'] <NEW_LINE> <DEDENT> for rdtype in rdtypes: <NEW_LINE> <INDENT> update_ns(fqdn,... | dns deleter
:param fqdn: fully qualified domain name (str)
:param rdtype: 'A', 'AAAA' or None (deletes 'A' and 'AAAA') | 625941bdbe8e80087fb20b34 |
def get_match_info_from_link(page_link): <NEW_LINE> <INDENT> time.sleep(10) <NEW_LINE> response = futblot24.send_request(page_link) <NEW_LINE> page = scrapy.Selector(response) <NEW_LINE> actions = page.xpath(""".//tbody/tr""") <NEW_LINE> actions_list = [] <NEW_LINE> number_of_goals = {} <NEW_LINE> for _index in range(l... | Get match details
:param page_link: string -- page url of match details
:return: list -- [{minute: {'home_team': home_team_score, 'guest_team': guest_team_score,
first_half': first_half, 'second_half': second_half}}] | 625941bd442bda511e8be30a |
def load_user_credentials(client_secrets, storage, flags): <NEW_LINE> <INDENT> flow = client.flow_from_clientsecrets( client_secrets, scope=API_SCOPES, message=tools.message_if_missing(client_secrets)) <NEW_LINE> credentials = storage.get() <NEW_LINE> if credentials is None or credentials.invalid: <NEW_LINE> <INDENT> c... | Attempts to load user credentials from the provided client secrets file.
Args:
client_secrets: path to the file containing client secrets.
storage: the data store to use for caching credential information.
flags: command-line flags.
Returns:
A credential object initialized with user account credentials. | 625941bdd164cc6175782c3b |
def get_value(self, series, key): <NEW_LINE> <INDENT> s = com.values_from_object(series) <NEW_LINE> try: <NEW_LINE> <INDENT> value = super().get_value(s, key) <NEW_LINE> <DEDENT> except (KeyError, IndexError): <NEW_LINE> <INDENT> if isinstance(key, str): <NEW_LINE> <INDENT> asdt, parsed, reso = parse_time_string(key, s... | Fast lookup of value from 1-dimensional ndarray. Only use this if you
know what you're doing | 625941bd3c8af77a43ae368b |
def testPlayWaitForPlayTimeout(self): <NEW_LINE> <INDENT> action = play.PlayAction(selector='#video_1', playing_event_timeout_in_seconds=0.1) <NEW_LINE> action.WillRunAction(self._tab) <NEW_LINE> self._tab.EvaluateJavaScript('document.getElementById("video_1").src = ""') <NEW_LINE> self.assertFalse(self._tab.EvaluateJa... | Tests that wait_for_playing timeouts if video does not play. | 625941bd004d5f362079a223 |
def withinit(init,n,sz=9): <NEW_LINE> <INDENT> if init=="": <NEW_LINE> <INDENT> return withdup(sz,n) <NEW_LINE> <DEDENT> matched = any([a==b for a,b in zip(init,init[1:])]) <NEW_LINE> l = init[-1] <NEW_LINE> available = sz+1-int(l) <NEW_LINE> lenleft = n-len(init) <NEW_LINE> if matched: <NEW_LINE> <INDENT> return ci(av... | How many length `n` sequences are there beginning with `init` (part 1 conditions) | 625941bd63d6d428bbe443dd |
def test_delete_media(self): <NEW_LINE> <INDENT> pass | Test case for delete_media
| 625941bd5510c4643540f2d9 |
def test_ask_for_nothing(self, req, includes): <NEW_LINE> <INDENT> cookiejar = RequestsCookieJar() <NEW_LINE> cookiejar.set("a", 2) <NEW_LINE> mock_session = Mock(spec=requests.Session, cookies=cookiejar) <NEW_LINE> req["cookies"] = [] <NEW_LINE> assert _read_expected_cookies(mock_session, req, includes) == {} | explicitly ask fo rno cookies | 625941bd460517430c39407a |
def normalize_title(title): <NEW_LINE> <INDENT> title = title.replace(' ', '_').strip('_') <NEW_LINE> if not is_valid_title(title): <NEW_LINE> <INDENT> return title <NEW_LINE> <DEDENT> title = urllib.unquote(title).replace(' ','_').strip('_') <NEW_LINE> title = clean_anchors(title) <NEW_LINE> if not title: <NEW_LINE> <... | Get a title and return its normalized form | 625941bd0383005118ecf4d2 |
def _getpricestring(amount, denom): <NEW_LINE> <INDENT> return '{:g} {}'.format( amount, denom + 's' if denom in ('Key', 'Weapon') and amount != 1 else denom) | Return a human-readable price string | 625941bda05bb46b383ec712 |
def _setup(self, config): <NEW_LINE> <INDENT> self.model_setup(config) | Custom initialization.
Args:
config (dict): Hyperparameters and other configs given.
Copy of `self.config`. | 625941bd711fe17d8254225e |
@pytest.fixture(scope="session") <NEW_LINE> def bolt_app(): <NEW_LINE> <INDENT> _app = Flask(__name__) <NEW_LINE> with _app.app_context(): <NEW_LINE> <INDENT> yield _app | Setup the test app context
:return: Flask app instance | 625941bd15fb5d323cde09f9 |
def text(screen, health, len_zombies, fps, level, ammo, power_ups): <NEW_LINE> <INDENT> lifes_text_f = lifes_text.format(math.ceil(health)) <NEW_LINE> screen.blit(text_render(lifes_text_f), (0, 0)) <NEW_LINE> zombies_left_text_f = zombies_left_text.format(len_zombies) <NEW_LINE> screen.blit(text_render(zombies_left_tex... | Writes all the text during the standard game loop | 625941bd92d797404e304077 |
def kit(): <NEW_LINE> <INDENT> if len(request.args) == 2: <NEW_LINE> <INDENT> s3db.configure("budget_kit", update_next=URL(f="kit_item", args=request.args[1])) <NEW_LINE> <DEDENT> return s3_rest_controller(rheader=s3db.budget_rheader, main="code") | REST controller for kits | 625941bd6aa9bd52df036c90 |
def __init__(self, command): <NEW_LINE> <INDENT> self.command = command | Initialize the service. | 625941bdbf627c535bc130bc |
def compute_total_distance(road_map): <NEW_LINE> <INDENT> total_distance = 0 <NEW_LINE> for i in range(len(road_map)): <NEW_LINE> <INDENT> lat1degrees = float(road_map[i][2]) <NEW_LINE> long1degrees = float(road_map[i][3]) <NEW_LINE> lat2degrees = float(road_map[(i+1) % len(road_map)][2]) <NEW_LINE> long2degrees = floa... | Returns, as a floating point number, the sum of the distances of all
the connections in the road_map. Remember that it's a cycle, so that
(for example) in the initial road_map,Wyoming connects to Alabama.. | 625941bdb545ff76a8913d0b |
def wait(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self._server is not None: <NEW_LINE> <INDENT> self._server.wait() <NEW_LINE> <DEDENT> <DEDENT> except greenlet.GreenletExit: <NEW_LINE> <INDENT> LOG.info("WSGI server has stopped.") | Block, until the server has stopped.
Waits on the server's eventlet to finish, then returns.
:returns: None | 625941bdff9c53063f47c0e3 |
def run_forever(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.event_loop.run_forever() <NEW_LINE> <DEDENT> except KeyboardInterrupt: <NEW_LINE> <INDENT> print("Active OutputThings: %s" % ', '.join([('%s'%o) for o in self.active_schedules.keys()])) <NEW_LINE> raise <NEW_LINE> <DEDENT> if self.fatal_error is n... | Call the event loop's run_forever(). We don't really run forever:
the event loop is exited if we run out of scheduled events or if stop()
is called. | 625941bd3539df3088e2e239 |
def __tidy_list(self): <NEW_LINE> <INDENT> self.word_list[:] = self.__remove_empty_strings(self.word_list) <NEW_LINE> self.word_list[:] = map(self.__clean_trailing_symbols, self.word_list) <NEW_LINE> self.word_list[:] = self.__remove_case_from_list(self.word_list) | This function removes trailing symbols and empty entries from the list
as well as forces lowercase to prepare for the word frequency count | 625941bd099cdd3c635f0b4a |
def test_get_globalconfig(self): <NEW_LINE> <INDENT> res = self.client().post('/globalconfig', headers={'Content-Type': 'application/json'}, data=json.dumps(self.globalconfig)) <NEW_LINE> json_data = json.loads(res.data) <NEW_LINE> self.assertEqual(res.status_code, 201) <NEW_LINE> res = self.client().get('/globalconfig... | test globalconfig getAll | 625941bd596a8972360899b1 |
def calculate_availability(self, product): <NEW_LINE> <INDENT> logger.info('WeeklyMenu calculating availability') <NEW_LINE> required = {} <NEW_LINE> counter_list = [] <NEW_LINE> counter = 0 <NEW_LINE> try: <NEW_LINE> <INDENT> serve = product.serve <NEW_LINE> ingredientslist = self.Ingredient.search(['dish', '=', produ... | calculate if the dish is available | 625941bdf8510a7c17cf95e8 |
def __str__(self): <NEW_LINE> <INDENT> answer = [] <NEW_LINE> n = self.n <NEW_LINE> x = max(len(str(self.matrix[i,j])) for i in range(n) for j in range(n)) <NEW_LINE> for i in range(self.n): <NEW_LINE> <INDENT> answer.append(" ".join([str(self.matrix[i,j]).ljust(x) for j in range(n)])... | String representation of the matrix, used by the print command | 625941bdbe383301e01b537a |
def options(self): <NEW_LINE> <INDENT> return _gnsdk.GnVideo_options(self) | options(GnVideo self) -> GnVideoOptions | 625941bd66656f66f7cbc098 |
def test_pecas_iguais_success(self): <NEW_LINE> <INDENT> for pieces in self.pieces: <NEW_LINE> <INDENT> p1 = target.cria_peca(pieces) <NEW_LINE> p2 = target.cria_peca(pieces) <NEW_LINE> self.assertTrue(target.pecas_iguais(p1, p2)) | Testa pecas_iguais para todas as peças válidas possíveis | 625941bd99fddb7c1c9de280 |
def testBuildBotWithGoodChromeRootOption(self): <NEW_LINE> <INDENT> args = ['--local', '--buildroot=/tmp', '--chrome_root=.', self._X86_PREFLIGHT] <NEW_LINE> self.mox.ReplayAll() <NEW_LINE> (options, args) = cbuildbot._ParseCommandLine(self.parser, args) <NEW_LINE> self.mox.VerifyAll() <NEW_LINE> self.assertEquals(opti... | chrome_root can be set without chrome_rev. | 625941bdde87d2750b85fc7d |
@error_context.context_aware <NEW_LINE> def run(test, params, env): <NEW_LINE> <INDENT> vm = env.get_vm(params["main_vm"]) <NEW_LINE> session = vm.wait_for_login() <NEW_LINE> driver_name = params["driver_name"] <NEW_LINE> session = utils_test.qemu.windrv_check_running_verifier(session, vm, test, driver_name) <NEW_LINE>... | sigverif test:
1) Boot guest with related virtio devices
2) Run sigverif command(an autoit script) in guest
3) Open sigverif log and check whether driver is signed
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment | 625941bdc432627299f04b31 |
def t_NUMBER(t): <NEW_LINE> <INDENT> t.value = float(t.value) <NEW_LINE> return t | [\d+][.][\d+]| \d+ | 625941bd498bea3a759b999e |
def test_post_profile_error(self): <NEW_LINE> <INDENT> FacebookPost.query.delete() <NEW_LINE> FacebookInfo.query.delete() <NEW_LINE> db.session.commit() <NEW_LINE> result = self.client.get("/post_profile", follow_redirects=True) <NEW_LINE> self.assertIn("You need to log into Facebook first!", result.data) | Testing post_profile page error | 625941bdc432627299f04b32 |
@csrf_protect <NEW_LINE> @require_POST <NEW_LINE> def post_comment_ajax(request, using=None): <NEW_LINE> <INDENT> if not request.is_ajax(): <NEW_LINE> <INDENT> return HttpResponseBadRequest("Expecting Ajax call") <NEW_LINE> <DEDENT> data = request.POST.copy() <NEW_LINE> if request.user.is_authenticated(): <NEW_LINE> <I... | Post a comment, via an Ajax call. | 625941bda8370b771705278e |
def recurse(subreddit, after={}): <NEW_LINE> <INDENT> listings = [] <NEW_LINE> url = "https://www.reddit.com/r/{}.json".format(subreddit) <NEW_LINE> headers = {"User-agent": 'Shoji'} <NEW_LINE> params = {"after": after} <NEW_LINE> response = requests.get(url, headers=headers, params=params, allow_redirects=False) <NEW_... | Returns a list of titles | 625941bd462c4b4f79d1d5be |
def monitorHUDManagement(func): <NEW_LINE> <INDENT> metaHUD = None <NEW_LINE> currentHUDs = getMetaNodes(mTypes=MetaHUDNode, mAttrs='mNodeID=CBMonitorHUD') <NEW_LINE> if currentHUDs: <NEW_LINE> <INDENT> metaHUD = currentHUDs[0] <NEW_LINE> <DEDENT> if func == 'delete': <NEW_LINE> <INDENT> if metaHUD: <NEW_LINE> <INDENT>... | ChannelBox wrappers for the HUD : kill any current MetaHUD headsUpDisplay blocks | 625941bdcc0a2c11143dcd7e |
def strip_sep(path: str) -> str: <NEW_LINE> <INDENT> retval = path.replace(os.sep, "") <NEW_LINE> if ON_WINDOWS: <NEW_LINE> <INDENT> retval = retval.replace(os.altsep, "") <NEW_LINE> <DEDENT> return retval | remove all path separators from argument | 625941bd26238365f5f0ed58 |
def getLows(self, start_time = 0, end_time = 0, window_size = 50): <NEW_LINE> <INDENT> if start_time == 0: <NEW_LINE> <INDENT> start_time = self.start_time <NEW_LINE> <DEDENT> if end_time == 0: <NEW_LINE> <INDENT> end_time = self.end_time <NEW_LINE> <DEDENT> times, tides = self.getTidesBasedOnPeriod(start_time, end_tim... | Method to retrieve low water (both times and water levels)
:param start_time: datetime object of start of the requested period
:param end_time: datetime object of end of the requested period
:param window_size: parameter to define peaks
:return: times and tides series with the times and water levels of the requested l... | 625941bdcc40096d61595840 |
def change_size(self, percent): <NEW_LINE> <INDENT> self.radius *= (percent / 100.0) | Change the size of the circle in percent.
Operation does not change the anchor.
Args:
percent (float): the percentage by which we change the size. | 625941bd8e7ae83300e4aeba |
def test_address(test): <NEW_LINE> <INDENT> if hasattr(test, "address"): <NEW_LINE> <INDENT> return test.address() <NEW_LINE> <DEDENT> t = type(test) <NEW_LINE> file = module = call = None <NEW_LINE> if t == types.ModuleType: <NEW_LINE> <INDENT> file = getattr(test, '__file__', None) <NEW_LINE> module = getattr(test, '... | Find the test address for a test, which may be a module, filename,
class, method or function. | 625941bd85dfad0860c3ad47 |
def setattr(self, attr_name, *, mc_overwrite_property=False, mc_set_unknown=False, mc_force=False, mc_error_info_up_level=2, **env_values): <NEW_LINE> <INDENT> if attr_name[0] == '_': <NEW_LINE> <INDENT> msg = "Trying to set attribute '{}' on a config item. ".format(attr_name) <NEW_LINE> msg += ("Atributes starting wit... | Set env specific values for an attribute.
Arguments:
attr_name (str): The name of the attribute to set.
mc_overwrite_property (bool=False): Setting this to True allows overwriting a @property method with env specific values.
Any env for which the @property is not overridden will still get the value of ... | 625941bda17c0f6771cbdf41 |
def trajectoryDistances(self, poses): <NEW_LINE> <INDENT> dist = [0] <NEW_LINE> sort_frame_idx = sorted(poses.keys()) <NEW_LINE> for i in range(len(sort_frame_idx)-1): <NEW_LINE> <INDENT> cur_frame_idx = sort_frame_idx[i] <NEW_LINE> next_frame_idx = sort_frame_idx[i+1] <NEW_LINE> P1 = poses[cur_frame_idx] <NEW_LINE> P2... | Compute the length of the trajectory
poses dictionary: [frame_idx: pose] | 625941bd63b5f9789fde6fd3 |
def get_irow(self, i, *field_names): <NEW_LINE> <INDENT> res = [] <NEW_LINE> if not field_names: <NEW_LINE> <INDENT> field_names = self.value.keys() <NEW_LINE> <DEDENT> for field_name in field_names: <NEW_LINE> <INDENT> res.append(self.value[field_name][i]) <NEW_LINE> <DEDENT> return res | 返回第i行字段名为field_names的数据,i从0开始算起 | 625941bd3d592f4c4ed1cf64 |
def export_model(model, export_model_dir, model_version ): <NEW_LINE> <INDENT> with tf.get_default_graph().as_default(): <NEW_LINE> <INDENT> last_conv_layer = model.get_layer('mixed10') <NEW_LINE> pool = model.get_layer('global_average_pooling2d_1') <NEW_LINE> tensor_info_input = tf.saved_model.utils.build_tensor_info(... | :param export_model_dir: type string, save dir for exported model
:param model_version: type int best
:return:no return | 625941bd293b9510aa2c3187 |
def test_client_can_obtain_production_url_as_base_url(): <NEW_LINE> <INDENT> client = AvataxClient('test app', 'ver 0.0', 'test machine') <NEW_LINE> assert client.base_url == 'https://rest.avatax.com' | Test the default option for base url is production url. | 625941bdd10714528d5ffbcf |
def _init_inverse_lookup(self): <NEW_LINE> <INDENT> logging.debug("First request of a reverse lookup. Building the " "inverse lookup dictionary.") <NEW_LINE> self._invlookup={} <NEW_LINE> for k, items in self._tree.iteritems(): <NEW_LINE> <INDENT> for item in items.position: <NEW_LINE> <INDENT> sel... | Sets up the internal data store to perform reverse lookups. | 625941bd23849d37ff7b2f7f |
def _on_cells_selection(self, added, removed): <NEW_LINE> <INDENT> items = list(self.items()) <NEW_LINE> indexes = self.table_view.selectionModel().selectedIndexes() <NEW_LINE> selected = [] <NEW_LINE> for index in indexes: <NEW_LINE> <INDENT> index = self.model.mapToSource(index) <NEW_LINE> obj = items[index.row()] <N... | Handle the cells selection being changed. | 625941bd796e427e537b04b1 |
def hasCycle(self, head): <NEW_LINE> <INDENT> if not head: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> slow, fast = head, head <NEW_LINE> while fast.next and fast.next.next: <NEW_LINE> <INDENT> slow , fast = slow.next, fast.next.next <NEW_LINE> if slow == fast: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDEN... | :type head: ListNode
:rtype: bool | 625941bd66673b3332b91f7f |
def translate(self, to_cipher=True): <NEW_LINE> <INDENT> if to_cipher: <NEW_LINE> <INDENT> return self.cipher.cipher() <NEW_LINE> <DEDENT> return self.cipher.decipher() | Ciphers or deciphers the currently loaded
cipher and returns the result. | 625941bd1d351010ab855a0b |
def VSIFCloseL(*args): <NEW_LINE> <INDENT> return _gdal.VSIFCloseL(*args) | VSIFCloseL(VSILFILE * arg1) | 625941bd5fcc89381b1e15ab |
def __init__(self, index, change): <NEW_LINE> <INDENT> self.index = index <NEW_LINE> self.change = change | Initialises Insert object.
Parameters
----------
index : int
Index of the node
change : ast
AST of inserted code | 625941bdbaa26c4b54cb1011 |
def test_smoothing(self): <NEW_LINE> <INDENT> N = 500 <NEW_LINE> D = 2 <NEW_LINE> A0 = np.array([[.9, -.4], [.4, .9]]) <NEW_LINE> A1 = np.array([[.98, -.1], [.1, .98]]) <NEW_LINE> l = np.linspace(0, 1, N-1).reshape((-1,1,1)) <NEW_LINE> A = (1-l)*A0 + l*A1 <NEW_LINE> v = np.random.rand(D) <NEW_LINE> V = np.diag(v) <NEW_... | Test the posterior estimation of GaussianMarkovChain.
Create time-variant dynamics and compare the results of BayesPy VB
inference and standard Kalman filtering & smoothing.
This is not that useful anymore, because the moments are checked much
better in another test method. | 625941bd26238365f5f0ed59 |
def set_pocket(self, card1, card2): <NEW_LINE> <INDENT> self.pocket = [card1, card2] | Bot.set_pocket(cards) -> None
Dealer provides bot with cards | 625941bd4f88993c3716bf5a |
def exception_to_validation_msg(e): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> error = json.loads(str(e)) <NEW_LINE> return error['error'].get('message', None) <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> validation_patterns = [ "Remote error: \w* {'Error': '(.*?)'}", 'Remote error: \w* (.*?) \[', '400 B... | Extracts a validation message to display to the user. | 625941bd4c3428357757c218 |
def print(self, *msg): <NEW_LINE> <INDENT> for m in msg: <NEW_LINE> <INDENT> if self._current_train_progress is None: <NEW_LINE> <INDENT> print(m) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._current_train_progress.write(m) <NEW_LINE> <DEDENT> self.log_file.write(f'{m}\n') <NEW_LINE> <DEDENT> return self | Print log message without interfering the current `tqdm`
progress bar | 625941bd8a43f66fc4b53f57 |
def teardown_zookeeper(self): <NEW_LINE> <INDENT> if not self.cluster[0].running: <NEW_LINE> <INDENT> self.cluster.start() <NEW_LINE> <DEDENT> tries = 0 <NEW_LINE> if self.client and self.client.connected: <NEW_LINE> <INDENT> while tries < 3: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.client.retry(self.client.de... | Clean up any ZNodes created during the test
| 625941bdbde94217f3682ce3 |
def urldata_init(self, ud, d): <NEW_LINE> <INDENT> ud.proto = ud.parm.get('protocol', 'git') <NEW_LINE> ud.branch = ud.parm.get('branch', 'master') <NEW_LINE> ud.manifest = ud.parm.get('manifest', 'default.xml') <NEW_LINE> if not ud.manifest.endswith('.xml'): <NEW_LINE> <INDENT> ud.manifest += '.xml' <NEW_LINE> <DEDENT... | We don"t care about the git rev of the manifests repository, but
we do care about the manifest to use. The default is "default".
We also care about the branch or tag to be used. The default is
"master". | 625941bd7d847024c06be1a7 |
def backchain_to_goal_tree(rules, hypothesis): <NEW_LINE> <INDENT> raise NotImplementedError | Takes a hypothesis (string) and a list of rules (list
of IF objects), returning an AND/OR tree representing the
backchain of possible statements we may need to test
to determine if this hypothesis is reachable or not.
This method should return an AND/OR tree, that is, an
AND or OR object, whose constituents are the su... | 625941bddc8b845886cb5422 |
def plugin_loaded(): <NEW_LINE> <INDENT> start_kernel() | The ST3 entry point for plugins. | 625941bd21a7993f00bc7bda |
def ck_add_s(x,str_add): <NEW_LINE> <INDENT> if x != 1: <NEW_LINE> <INDENT> return str(x) + ' ' + str_add + 's' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return str(x) + ' ' + str_add | add x infront of the str_add and
add 's' to the str_add if x ~! 1 | 625941bdd486a94d0b98e034 |
def delete_credentials(self): <NEW_LINE> <INDENT> Credentials.list_of_credentials.remove(self) | function that deletes credentials | 625941bd23e79379d52ee455 |
def compose_left_right(left, right): <NEW_LINE> <INDENT> return lambda x: left(right(x)) | Compose a pair of functions | 625941bda934411ee3751586 |
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): <NEW_LINE> <INDENT> problem_ids = super(pxgo_account_chart_checker_problem, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count) <NEW_LINE> for arg in args: <NEW_LINE> <INDENT> if ... | Redefinition of the search method (as osv_memory wizards currently don't
support domain filters by themselves. | 625941bdd6c5a10208143f37 |
def on_idle(self, event): <NEW_LINE> <INDENT> state = self.state <NEW_LINE> if state.close_window.acquire(False): <NEW_LINE> <INDENT> self.state.app.ExitMainLoop() <NEW_LINE> <DEDENT> obj = None <NEW_LINE> while not state.object_queue.empty(): <NEW_LINE> <INDENT> obj = state.object_queue.get() <NEW_LINE> if isinstance(... | prevent the main loop spinning too fast | 625941bd379a373c97cfaa35 |
def get_rate_limit(): <NEW_LINE> <INDENT> method = 'GET' <NEW_LINE> path = '/open/api/v2/common/rate_limit' <NEW_LINE> url = '{}{}'.format(ROOT_URL, path) <NEW_LINE> params = {'api_key': API_KEY} <NEW_LINE> response = requests.request(method, url, params=params) <NEW_LINE> return response.json() | rate limit | 625941bd5166f23b2e1a5048 |
def synchronize(self, timeout=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.queue.get(timeout=timeout) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return None | Wait for receiving message with a common queue
Args:
timeout (int): timeout for waiting a message in seconds
Returns:
dict: a received message | 625941bd8c0ade5d55d3e8ae |
def clear(self): <NEW_LINE> <INDENT> with self._lock: <NEW_LINE> <INDENT> self._flag = False | Clear the internal flag. | 625941bdb57a9660fec33770 |
@pytest.mark.parametrize( "wmts_capabilities, expected", [ ("simple", {"OSM": {"http://tile.openstreetmap.org/{zoom}/{x}/{y}.png"}}), ], indirect=["wmts_capabilities"], ) <NEW_LINE> def test_generate_tms_url(wmts_capabilities: wmtshelper.WMTSCapabilities, expected: Dict[str, str]): <NEW_LINE> <INDENT> for layer, expect... | Test generation of tms url for simpleProfileTile compatible layers | 625941bd3eb6a72ae02ec3c4 |
def main(): <NEW_LINE> <INDENT> num = input() <NEW_LINE> print(fact(int(num))) | factorial of a number | 625941bddc8b845886cb5423 |
def get_candlestick_24h(self): <NEW_LINE> <INDENT> return self.candlestick_24h | :return: 24h candlestick | 625941bdd7e4931a7ee9de0b |
def test_0010_single_payment_CASE2(self): <NEW_LINE> <INDENT> with Transaction().start(DB_NAME, USER, context=CONTEXT): <NEW_LINE> <INDENT> self.setup_defaults() <NEW_LINE> sale = self._create_sale( payment_authorize_on='manual', payment_capture_on='sale_confirm', ) <NEW_LINE> self.assertEqual(sale.total_amount, Decima... | ===================================
Total Sale Amount | $200
Payment Authorize On: | 'manual'
Payment Capture On: | 'sale_confirm'
===================================
Total Payment Lines | 1
Payment 1 | $200
=================================== | 625941bd442bda511e8be30b |
def test_yy_no_visual_command(vim_bot): <NEW_LINE> <INDENT> main, editor_stack, editor, vim, qtbot = vim_bot <NEW_LINE> editor.stdkey_backspace() <NEW_LINE> editor.go_to_line(3) <NEW_LINE> editor.moveCursor(QTextCursor.StartOfLine, QTextCursor.KeepAnchor) <NEW_LINE> cmd_line = vim.get_focus_widget() <NEW_LINE> qtbot.ke... | Copy current line. | 625941bd67a9b606de4a7dab |
def begin_site(self): <NEW_LINE> <INDENT> for resource in self.site.content.walk_resources(): <NEW_LINE> <INDENT> if resource.source_file.kind == 'styl': <NEW_LINE> <INDENT> new_name = resource.source_file.name_without_extension + ".css" <NEW_LINE> target_folder = File(resource.relative_deploy_path).parent <NEW_LINE> r... | Find all the styl files and set their relative deploy path. | 625941bde8904600ed9f1e18 |
def serialize(self, root): <NEW_LINE> <INDENT> res = [] <NEW_LINE> stack = [] <NEW_LINE> stack.append(root) <NEW_LINE> while stack: <NEW_LINE> <INDENT> curr = stack.pop() <NEW_LINE> if curr: <NEW_LINE> <INDENT> res.append(curr.val) <NEW_LINE> if curr.right: <NEW_LINE> <INDENT> stack.append(curr.right) <NEW_LINE> <DEDEN... | Encodes a tree to a single string.
:type root: TreeNode
:rtype: str | 625941bd63d6d428bbe443de |
def age_dia_model(m, x): <NEW_LINE> <INDENT> return (x * 0.0) + m | given (intercept,slope), calculates predicted hgt assuming hgt=m[1]*x+m[0] | 625941bdb5575c28eb68deed |
def cli_host_uuid_error(): <NEW_LINE> <INDENT> cli_error('You must pass at least the host UUID to this command.') | This function is not exported, but used only inside this module. | 625941bdcdde0d52a9e52f1f |
def __wNoise_Power__(self,SC_Bandwidth): <NEW_LINE> <INDENT> wNoise_Power = (pow(10,(-70+10 * math.log10(SC_Bandwidth * 10e6))/10))/1000 <NEW_LINE> return wNoise_Power | 求噪声功率
:param SC_Bandwidth: 子信道的带宽 MHZ
:return: 噪声功率 单位:w | 625941bda219f33f3462885c |
def test_031_item_insert(self): <NEW_LINE> <INDENT> self.cahandler.xdb_file = self.dir_path + '/ca/acme2certifier.xdb' <NEW_LINE> self.cahandler.issuing_ca_name = 'sub-ca' <NEW_LINE> item_dic = {'name': 'name', 'type': 2, 'source': 0, 'comment': 'comment'} <NEW_LINE> self.assertFalse(self.cahandler._item_insert(item_di... | CAhandler._item_insert no date | 625941bd57b8e32f52483389 |
def numberOfMatches(self, n: int) -> int: <NEW_LINE> <INDENT> dp=[0]*(n+1) <NEW_LINE> for i in range(1,n+1): <NEW_LINE> <INDENT> if i%2==0: <NEW_LINE> <INDENT> dp[i]=dp[i//2]+i//2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dp[i]=dp[(i-1)//2+1]+(i-1)//2 <NEW_LINE> <DEDENT> <DEDENT> return dp[n] | dp[i]表示n=i时,需要匹配的次数,则有
dp[1]=1
dp[2]=1
dp[i]=dp[i/2]+i/2 i为偶数
dp[i]=dp[(i-1/2)+1]+(i-1)/2 i为奇数
:param n:
:return: | 625941bda05bb46b383ec713 |
def insert_new(self, record): <NEW_LINE> <INDENT> self.storage.append(record) <NEW_LINE> index = len(self.storage) <NEW_LINE> self.emit(SIGNAL('rowsInserted(QModelIndex, int, int)'), QModelIndex(), index, index) <NEW_LINE> return True | Метод для вставки новой записи в модель.
@type record: dict
@param record: Словарь с данными.
@rtype: boolean
@return: Результат выполнения операции. | 625941bd099cdd3c635f0b4b |
def ComputeMetrics(prob, batch_labels, p1, p2, rgb=None, save_path=None, ind=0): <NEW_LINE> <INDENT> GT = label(batch_labels.copy()) <NEW_LINE> PRED = PostProcess(prob, p1, p2) <NEW_LINE> lbl = GT.copy() <NEW_LINE> pred = PRED.copy() <NEW_LINE> aji = AJI_fast(lbl, pred) <NEW_LINE> lbl[lbl > 0] = 1 <NEW_LINE> pred[pred ... | Computes all metrics between probability map and corresponding label.
If you give also an rgb image it will save many extra meta data image. | 625941bd9f2886367277a77f |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, StorageExistResponse): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941bd91af0d3eaac9b905 |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> param_defaults = { 'Status': None, 'Message': None, 'Reason': None, 'Details': None, 'Code': None} <NEW_LINE> for (param, default) in param_defaults.iteritems(): <NEW_... | An object to hold a Kubernete Status.
Arg:
Status:
One of: "Success", "Failure", "Working" (for operations not yet completed)
Message:
A human-readable description of the status of this operation.
Reason:
A machine-readable description of why this operation is in the
"Failure" or "Working" stat... | 625941bd8e71fb1e9831d69a |
def testCopyNodeFailure(self): <NEW_LINE> <INDENT> self._task.set_default("stderr", False) <NEW_LINE> dest = make_temp_filename(suffix='LocalhostCopyF') <NEW_LINE> worker = self._task.copy("/etc/hosts", dest, nodes='unlikely-node,localhost') <NEW_LINE> self.assert_(worker != None) <NEW_LINE> self._task.resume() <NEW_LI... | test node failure error handling on simple copy | 625941bd442bda511e8be30c |
def feed_data(self, data_point): <NEW_LINE> <INDENT> self._cur_timestamp = data_point['EventTimestamp(ns)'] <NEW_LINE> acc_x = data_point['AccelX'] <NEW_LINE> acc_y = data_point['AccelY'] <NEW_LINE> acc_z = data_point['AccelZ'] <NEW_LINE> activity_type = data_point['Activity'] <NEW_LINE> updated = self._model.process_d... | main function processes data and count steps | 625941bd30c21e258bdfa38a |
def __repr__(self): <NEW_LINE> <INDENT> return "{}({}, {})".format(self.__class__.__name__, self.__x, self.__y) | Returns the representational form of an object | 625941bd07f4c71912b11376 |
def test_clone_alert(self): <NEW_LINE> <INDENT> pass | Test case for clone_alert
Clones the specified alert # noqa: E501 | 625941bd097d151d1a222d4b |
def createSelectBox(self, buttonText, labelText): <NEW_LINE> <INDENT> button1 = QPushButton(buttonText) <NEW_LINE> button1.setMinimumWidth(220) <NEW_LINE> button1.setMaximumWidth(220) <NEW_LINE> button2 = QPushButton("Edit") <NEW_LINE> button2.setMinimumWidth(100) <NEW_LINE> button2.setMaximumWidth(100) <NEW_LINE> labe... | Creates a Layout containing 2 buttons and a Label
The first button allows the user to "Select" from file
The second button allows the user to "Edit" currently selected file
@param buttonText The text on the first button
@param labelText The text on the label
@return (layout, button1, button2, label) as a tuple | 625941bd63d6d428bbe443df |
def create_smooth(fwhm=6, name='smooth'): <NEW_LINE> <INDENT> smooth = pe.Node(interface=spm.Smooth(), name=name) <NEW_LINE> smooth.inputs.fwhm = fwhm <NEW_LINE> return smooth | Smooth the functional data using
:class:`nipype.interfaces.spm.Smooth`. | 625941bd8e7ae83300e4aebb |
def forward(self, src, src_key_padding_mask=None): <NEW_LINE> <INDENT> output = super().forward(src, src_key_padding_mask=src_key_padding_mask) <NEW_LINE> return output | Arguments:
----------
- `src` of shape (B, T, E)
- `src_key_padding_mask` of shape (B, T)
Outputs:
--------
- output of shape (B, T, E) | 625941bd8da39b475bd64e60 |
def validate_params(r_param_valid_list, g_params): <NEW_LINE> <INDENT> import re <NEW_LINE> if not r_param_valid_list: <NEW_LINE> <INDENT> return Ret() <NEW_LINE> <DEDENT> for r_param_valid in r_param_valid_list: <NEW_LINE> <INDENT> valid_method = None <NEW_LINE> process = None <NEW_LINE> if isinstance(r_param_valid, s... | 验证参数
[
('a', '[a-z]+'),
'b',
('c', valid_c_func),
('d', valid_d_func, default_d_value)
{
"value": "e",
"func": valid_e_func,
"default": True,
"default_value": default_e_value,
"process": process_e_value (str to int)
}
] | 625941bd9b70327d1c4e0cc3 |
def _set_state(self, brightness=None, powered=None): <NEW_LINE> <INDENT> new_state = {} <NEW_LINE> if brightness is not None: <NEW_LINE> <INDENT> new_state['brightness'] = brightness <NEW_LINE> <DEDENT> if powered is not None: <NEW_LINE> <INDENT> new_state['powered'] = powered <NEW_LINE> <DEDENT> self.update(dict(desir... | Change the devices state | 625941bd8c3a8732951582a7 |
def get_game_root(): <NEW_LINE> <INDENT> path = os.getcwd().replace("\\", "/") <NEW_LINE> if "floobits" in path or "PycharmProjects" in path: <NEW_LINE> <INDENT> path_parts = path.split("/") <NEW_LINE> path = path_parts[0] + "/" + path_parts[1] + "/" + path_parts[ 2] + "/Desktop/Auden Pres" <NEW_LINE> <DEDENT> else: <N... | Gets the path to the root folder of the game | 625941bd4e4d5625662d42cb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.