code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def positions(self): <NEW_LINE> <INDENT> return self.inorder()
Generates an iteration of the Tree's Positions.
625941cc21bff66bcd684a3c
def restart(self): <NEW_LINE> <INDENT> self.result.configure(text='') <NEW_LINE> for square in self.canvas.find_all(): <NEW_LINE> <INDENT> self.canvas.itemconfigure(square, fill='white') <NEW_LINE> <DEDENT> self.canvas.bind("<Button-1>",self.play) <NEW_LINE> self.box =[0,1,2,3,4,5,6,7,8] <NEW_LINE> del self.player[:] <...
This method restarts the game when ever user clicks button. :return: NONE
625941cc498bea3a759b9b97
def _fileToMatrix(file_name): <NEW_LINE> <INDENT> if 1 < 3: <NEW_LINE> <INDENT> lres = [] <NEW_LINE> for line in open(file_name, 'r').readlines(): <NEW_LINE> <INDENT> if len(line) > 0 and line[0] not in ('%', '#'): <NEW_LINE> <INDENT> lres.append(list(map(float, line.split()))) <NEW_LINE> <DEDENT> <DEDENT> res = lres <...
rudimentary method to read in data from a file
625941cc283ffb24f3c559ea
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, RemoveNetworkInterfaceAccessControlGroupResponse): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941cc76d4e153a657ec19
def hydrogenate_dangling_bonds(self, terminal_atoms_list, cutoff_atoms_list, atomic_cluster, atoms): <NEW_LINE> <INDENT> pos = atoms.get_positions() <NEW_LINE> cutoff_atoms_list = np.asarray(cutoff_atoms_list) <NEW_LINE> for tAI in terminal_atoms_list: <NEW_LINE> <INDENT> cutoff_neighs = [item for item in self.mediator...
Change atoms that were cut-off into hydrogens Parameters ---------- terminal_atoms_list : list of ints (atomic indexes) last atoms in the buffer region, bonded to the atoms not in the buffer cutoff_atoms_list : list of ints (atomic indexes) atoms to be changed into hydrogen, first atoms not in the buffer atomi...
625941ccc4546d3d9de72b1c
def remove_block(self, position, immediate=True): <NEW_LINE> <INDENT> del self.world[position] <NEW_LINE> self.sectors[self.block.sectorize(position)].remove(position) <NEW_LINE> if immediate: <NEW_LINE> <INDENT> if position in self.shown: <NEW_LINE> <INDENT> self.hide_block(position) <NEW_LINE> <DEDENT> self.check_nei...
Remove the block at the given `position`. Parameters ---------- position : tuple of len 3 The (x, y, z) position of the block to remove. immediate : bool Whether or not to immediately remove block from canvas.
625941cc8e71fb1e9831d892
def _single_iteration(self): <NEW_LINE> <INDENT> system = self._system <NEW_LINE> outputs = system._outputs <NEW_LINE> use_aitken = self.options['use_aitken'] <NEW_LINE> if use_aitken: <NEW_LINE> <INDENT> aitken_min_factor = self.options['aitken_min_factor'] <NEW_LINE> aitken_max_factor = self.options['aitken_max_facto...
Perform the operations in the iteration loop.
625941cc0383005118ecf6cb
def __ne__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, TenantDefaultCustomPropertyNames): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return self.to_dict() != other.to_dict()
Returns true if both objects are not equal
625941cc0fa83653e46570a4
def generate_random_array(self, n_events): <NEW_LINE> <INDENT> rnds, idx, xjac_raw = self._generate_random_array(n_events) <NEW_LINE> xjac = xjac_raw / self.xjac / n_events <NEW_LINE> return rnds, idx, xjac
External interface for the generation of random points as a 2D array of (n_events, n_dim). It calls the internal version of ``_generate_random_array`` Parameters ---------- `n_events`: number of events to generate Returns ------- `rnds`: array of (n_events, n_dim) random points `idx` : index associated t...
625941cc67a9b606de4a7fa2
def is_binary_string(bytes_to_check): <NEW_LINE> <INDENT> if not bytes_to_check: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> low_chars = bytes_to_check.translate(None, _printable_ascii) <NEW_LINE> nontext_ratio1 = float(len(low_chars)) / float(len(bytes_to_check)) <NEW_LINE> logger.debug('nontext_ratio1: %(non...
Uses a simplified version of the Perl detection algorithm, based roughly on Eli Bendersky's translation to Python: http://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/ This is biased slightly more in favour of deeming files as text files than the Perl algorithm, since al...
625941cc293b9510aa2c337f
def adjust_speeds(balls, speed_up): <NEW_LINE> <INDENT> for ball in balls: <NEW_LINE> <INDENT> unimpeded = True <NEW_LINE> for other_ball in balls: <NEW_LINE> <INDENT> if ball is other_ball: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if ball.can_see(other_ball): <NEW_LINE> <INDENT> unimpeded = False <NEW_LINE> sp...
To adjust speed of all balls
625941cc2eb69b55b151c997
def memo_base(memo_func, cache_duration=settings.CACHE_MIDDLEWARE_SECONDS): <NEW_LINE> <INDENT> def decorator(key_func): <NEW_LINE> <INDENT> @wraps(memo_func) <NEW_LINE> def call_func(*args, **kwargs): <NEW_LINE> <INDENT> cache_key_chunks = key_func(*args, **kwargs) <NEW_LINE> if cache_key_chunks is None: <NEW_LINE> <I...
check out cache_view for usage
625941ccab23a570cc25026b
def test_correct_html(self): <NEW_LINE> <INDENT> request = HttpRequest() <NEW_LINE> response = home(request) <NEW_LINE> self.assertIn(b'42 Coffee Cups Test Assignment', response.content) <NEW_LINE> self.assertTemplateUsed(response, 'home.html')
Check home page returns correct html
625941cc4e696a04525c9534
def con_began_gen_lossfun(y_true, y_pred): <NEW_LINE> <INDENT> half_x_hat = y_pred[..., 0] <NEW_LINE> con_half_x_hat = y_pred[..., 1] <NEW_LINE> half_x_hat_reconstructed = y_pred[..., 2] <NEW_LINE> con_ae_loss = K.mean(K.abs(half_x_hat - half_x_hat_reconstructed)) - K.mean(K.abs(half_x_hat - con_half_x_hat)) <NEW_LINE>...
y_pred[:,0]: half1 (Gx(z)) y_pred[:,1]: half2 (Gx(z)) y_pred[:,2]: D(half1 Gx(z)) y_pred[:,3]: half1 x y_pred[:,4]: half2 x y_pred[:,5]: D(half1 x)
625941ccd53ae8145f87a359
def add2query_struct( self ): <NEW_LINE> <INDENT> filter = "" <NEW_LINE> items_fields = [u"رقم_الآية", u"رقم", u"ركوع", u"رقم_السورة", u"صفحة", u"ربع", u"حزب", u"جزء", u"منزل"] <NEW_LINE> index = self.o_struct_as.currentIndex() <NEW_LINE> vfrom = self.o_struct_from.value() <NEW_LINE> vto = self.o_struct_to.value() <NEW...
625941cc97e22403b379d082
def test2(self): <NEW_LINE> <INDENT> ls = [2,3,4,5,-1,1,-3,6,-10] <NEW_LINE> self.assertEqual(sort_negative_remove(ls), [1,2,3,4,5,6])
Test 2
625941cc090684286d50edce
def PreProcessFEC(TimeSepForceObject,**kwargs): <NEW_LINE> <INDENT> Appr,Retr = GetApproachRetract(TimeSepForceObject) <NEW_LINE> Appr,Retr = PreProcessApproachAndRetract(Appr,Retr,**kwargs) <NEW_LINE> return Appr,Retr
Returns the pre-processed (zeroed, flipped, etc) approach and retract Args: TimeSepForceObject: the object we are dealing with. copied, not changed **kwargs: passed directly to PreProcessApproachAndRetract Returns: tuple of pre-processed approach and retract, see PreProcessApproachAndRetract
625941cc66656f66f7cbc293
def serialize(self, root: TreeNode) -> str: <NEW_LINE> <INDENT> res = [] <NEW_LINE> self._serial(root, res) <NEW_LINE> return ','.join(res)
Encodes a tree to a single string. Args: root (TreeNode): the root of tree Returns: str: a serial str of binary tree
625941cc66656f66f7cbc294
def test_fetch_ge_job_runner_with_extra_args(self): <NEW_LINE> <INDENT> runner = fetch_runner("GEJobRunner(-j y)") <NEW_LINE> self.assertTrue(isinstance(runner,GEJobRunner)) <NEW_LINE> self.assertEqual(runner.ge_extra_args,['-j','y'])
fetch_runner returns a GEJobRunner with additional arguments
625941cc8da39b475bd6505c
def scrape_committee_agendas(self, chamber, session): <NEW_LINE> <INDENT> url = 'http://www.azleg.gov/CommitteeAgendas.asp?Body=%s' % self._chamber_short[chamber] <NEW_LINE> with self.urlopen(url) as agendas: <NEW_LINE> <INDENT> root = html.fromstring(agendas) <NEW_LINE> if cham...
Scrape upper or lower committee agendas
625941cc8da39b475bd6505d
def get_label_topk(scores, top_num=1): <NEW_LINE> <INDENT> predicted_labels = [] <NEW_LINE> predicted_scores = [] <NEW_LINE> scores = np.ndarray.tolist(scores) <NEW_LINE> for score in scores: <NEW_LINE> <INDENT> score_list = [] <NEW_LINE> index_list = np.argsort(score)[-top_num:] <NEW_LINE> index_list = index_list[::-1...
Get the predicted labels based on the topK number. Note: Only Used in `test_model.py` Args: scores: The all classes predicted scores provided by network top_num: The max topK number (default: 5) Returns: The predicted labels
625941cc32920d7e50b282b9
def select(self, population): <NEW_LINE> <INDENT> prob_wheel = self._set_up_wheel(population) <NEW_LINE> probs = prob_wheel.keys() <NEW_LINE> probs.sort() <NEW_LINE> new_population = [] <NEW_LINE> for pair_spin in range(len(population) / 2): <NEW_LINE> <INDENT> choice_num_1 = random.random() <NEW_LINE> choice_num_2 = r...
Perform selection on the population based using a Roulette model. Arguments: o population -- A population of organisms on which we will perform selection. The individuals are assumed to have fitness values which are due to their current genome.
625941cc925a0f43d2549f60
def click(self, x, y, btn): <NEW_LINE> <INDENT> pass
Called upon a button supporting click. Override in subclass. :param int x: X mouse position in pixels. :param int y: Y mouse position in pixels. :param str btn: The mouse button which was clicked.
625941cceab8aa0e5d26dc41
def get_markings(self, markable, descendants=False, null_markings=False): <NEW_LINE> <INDENT> item_markings = api.get_markings(markable) <NEW_LINE> descendant_markings_collection = () <NEW_LINE> null_markings_collection = () <NEW_LINE> if descendants: <NEW_LINE> <INDENT> descendant_markings_collection = self._get_desce...
Return the markings associated with the input `markable` object. Note: This will include any global markings that have not been explicitly applied to this field. Args: markable: A markable object (e.g., indicator.title). descendants: If True, return markings which apply to the input field and ...
625941cc7cff6e4e81117a6f
def validate_user_registration(username, pswd, conf_pswd, photo): <NEW_LINE> <INDENT> response_data = dict() <NEW_LINE> if User.objects.filter(username=username): <NEW_LINE> <INDENT> response_data['username'] = u"This username already exist" <NEW_LINE> <DEDENT> if pswd != conf_pswd: <NEW_LINE> <INDENT> response_data['p...
:param username: str :param pswd: str :param conf_pswd: str :param photo: file or none :return: {valid: bool, responseData: dict}
625941cc9f2886367277a976
def get_independent_slices(incoming): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> x, y, z, t = incoming.shape <NEW_LINE> incoming = np.transpose(incoming, (2, 3, 0, 1)) <NEW_LINE> incoming = np.reshape(incoming, (z * t, x, y)) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> x, y, z = incoming.shape <NEW_LINE> incoming...
Reshape the input array so that has every frame on axis 0. Temporal frames are treated as different spatial frames. :param incoming: np.array of shape [width, height, depth, time] :return: [depth * time, width, height]
625941cc5fc7496912cc3a67
def __init__(self, taille): <NEW_LINE> <INDENT> self.taille = taille <NEW_LINE> self.elements = []
initialiser la pile avec une taille
625941cca219f33f34628a53
def inverse(self): <NEW_LINE> <INDENT> group = self.group <NEW_LINE> r = tuple([(i, -j) for i, j in self.array_form[::-1]]) <NEW_LINE> return group.dtype(r)
Returns the inverse of a `FreeGroupElement` element Examples ======== >>> from sympy.combinatorics.free_group import free_group >>> f, x, y, z = free_group("x y z") >>> x.inverse() x**-1 >>> (x*y).inverse() y**-1*x**-1
625941ccbe8e80087fb20d2c
def __init__(self, customization_func=None, **kwargs): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.customized = None <NEW_LINE> if not kwargs.get('payload_path'): <NEW_LINE> <INDENT> self.base = self.get_template(kwargs.get('catalog_item_id')) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.base = load_pa...
Init ResourceAction object for vRa 7.x payload object customization_func ([type], optional): Defaults to None. If not None, this function will add a second customization after the initial one.
625941cca17c0f6771cbe139
def post(self): <NEW_LINE> <INDENT> if self.current_user: <NEW_LINE> <INDENT> self.redirect('/') <NEW_LINE> return <NEW_LINE> <DEDENT> getusername = str(escape.xhtml_escape(self.get_argument('username'))[:48]) <NEW_LINE> getpassword = str(escape.xhtml_escape(self.get_argument('password'))[:64]) <NEW_LINE> if not self.r...
Post register form and try to sign up with these credentials
625941cc8e7ae83300e4b0b5
def is_reflexive(self, language: str, w_before: List[etree._Element]) -> bool: <NEW_LINE> <INDENT> reflexive_lemmata = self.config.get(language, 'reflexive_lemmata').split('|') <NEW_LINE> precondition = any(reflexive_lemmata) and w_before is not None and len(w_before) >= 2 <NEW_LINE> if precondition: <NEW_LINE> <INDENT...
Check whether we are dealing with a reflexive Perfect
625941cc15baa723493c405e
def test_prepare_storage_directory_exception(self, tmpdir): <NEW_LINE> <INDENT> p = tmpdir.mkdir("test") <NEW_LINE> newdir = "{0}/subdir/subdir/subdir".format(str(p)) <NEW_LINE> with raises(OSError): <NEW_LINE> <INDENT> osa_differ.prepare_storage_dir(newdir)
Verify that we can create a storage directory.
625941cc4527f215b584c540
def create_zone(domain, profile, type="master", ttl=None): <NEW_LINE> <INDENT> conn = _get_driver(profile=profile) <NEW_LINE> zone = conn.create_record(domain, type=type, ttl=ttl) <NEW_LINE> return _simple_zone(zone)
Create a new zone. :param domain: Zone domain name (e.g. example.com) :type domain: ``str`` :param profile: The profile key :type profile: ``str`` :param type: Zone type (master / slave). :type type: ``str`` :param ttl: TTL for new records. (optional) :type ttl: ``int`` CLI Example: .. code-block:: bash s...
625941cc293b9510aa2c3380
def test_CVectorToNumpy(self): <NEW_LINE> <INDENT> v = pg.CVector(10, 1.1 + 1j*3) <NEW_LINE> a = np.array(v) <NEW_LINE> self.assertEqual(type(a), np.ndarray) <NEW_LINE> self.assertEqual(a.dtype, np.complex) <NEW_LINE> self.assertEqual(len(a), 10) <NEW_LINE> self.assertEqual(a[0], 1.1 + 1j*3)
Implemented through hand_made_wrapper.py
625941cccc40096d61595a3a
def load_words(): <NEW_LINE> <INDENT> with open(DICTIONARY, 'r') as f: <NEW_LINE> <INDENT> word_list = f.read().split() <NEW_LINE> <DEDENT> return word_list
Load dictionary into a list and return list
625941cc377c676e91272292
def check_password(password, safe_password): <NEW_LINE> <INDENT> if not isinstance(password, bytes): <NEW_LINE> <INDENT> password = str(password).encode('utf8') <NEW_LINE> <DEDENT> hash_value = sha256(password).hexdigest() <NEW_LINE> return hash_value == safe_password[32:]
检查密码
625941cccb5e8a47e48b7b94
def gramps_upgrade_18(self): <NEW_LINE> <INDENT> length = self.get_number_of_places() <NEW_LINE> self.set_total(length) <NEW_LINE> self._txn_begin() <NEW_LINE> for handle in self.get_place_handles(): <NEW_LINE> <INDENT> place = self.get_raw_place_data(handle) <NEW_LINE> new_place = list(place) <NEW_LINE> new_place[6] =...
Upgrade database from version 17 to 18.
625941cc4a966d76dd5510f9
def yolo(inputs, anchors, num_classes): <NEW_LINE> <INDENT> num_anchors = len(anchors) <NEW_LINE> body = yolo_body(inputs, num_anchors, num_classes) <NEW_LINE> outputs = yolo_head(body.output, anchors, num_classes) <NEW_LINE> return outputs
Generate a complete YOLO_v2 localization model.
625941cc01c39578d7e74f25
def check(): <NEW_LINE> <INDENT> json_filenames = [] <NEW_LINE> for json_f in os.listdir(args.json_folder): <NEW_LINE> <INDENT> if os.path.isfile(os.path.join(args.json_folder, json_f)): <NEW_LINE> <INDENT> if json_f.endswith('.json'): <NEW_LINE> <INDENT> json_filenames.append(json_f) <NEW_LINE> <DEDENT> <DEDENT> <DEDE...
Fact check images.
625941cc63d6d428bbe445d9
def sort_sentence(sentence): <NEW_LINE> <INDENT> words = break_words(sentence) <NEW_LINE> return sort_words(words)
Takes in a full snetence and returns the sorted words.
625941ccbe7bc26dc91cd6ea
def forward(self, x, encoder_padding_mask): <NEW_LINE> <INDENT> residual = x <NEW_LINE> x = self.maybe_layer_norm(0, x, before=True) <NEW_LINE> x = self.input_dropout_module(x) <NEW_LINE> x = self.linear1(x) <NEW_LINE> if self.act is not None: <NEW_LINE> <INDENT> x = self.act(x) <NEW_LINE> <DEDENT> if encoder_padding_m...
Args: x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)` encoder_padding_mask (ByteTensor): binary ByteTensor of shape `(batch, src_len)` where padding elements are indicated by ``1``. Returns: encoded output of shape `(batch, src_len, embed_dim)`
625941cc15fb5d323cde0bf9
def _handler_unknown_discover(self, *args, **kwargs): <NEW_LINE> <INDENT> result = self._do_cmd_resp(InstrumentCommand.DATA_OFF) <NEW_LINE> return (ProtocolState.COMMAND, ResourceAgentState.IDLE)
Discover current state @retval (next_state, result)
625941cc1b99ca400220ab9b
def __init__(self, size): <NEW_LINE> <INDENT> self.size = size <NEW_LINE> self.screen = pyte.DiffScreen(*size) <NEW_LINE> self.stream = pyte.Stream() <NEW_LINE> self.stream.attach(self.screen) <NEW_LINE> self.saved_state_exist = False
Initialize pyte's screen and stream. :param (int, int) size: size of the terminal screen
625941cc4e696a04525c9535
def has_apical_dendrite(neuron, min_number=1, treefun=_read_neurite_type): <NEW_LINE> <INDENT> types = [treefun(n) for n in neuron.neurites] <NEW_LINE> return CheckResult(types.count(NeuriteType.apical_dendrite) >= min_number)
Check if a neuron has apical dendrites. Arguments: neuron(Neuron): The neuron object to test min_number: minimum number of apical dendrites required treefun: Optional function to calculate the tree type of neuron's neurites Returns: CheckResult with result
625941cce5267d203edcdd87
def restart_radius_server(self): <NEW_LINE> <INDENT> if self.sbr: <NEW_LINE> <INDENT> self.device_handle.su() <NEW_LINE> self.device_handle.shell(command="/opt/JNPRsbr/radius/sbrd restart") <NEW_LINE> pid = self.device_handle.shell(command='cat /opt/JNPRsbr/radius/radius.pid').resp.strip() <NEW_LINE> if re.match(r'\d+'...
Restarts FreeRadius process on the radius server. :return: True if radius server stop command is issued on the server Throws BBEConfigError otherwise
625941cc97e22403b379d083
def myAtoi(self, str): <NEW_LINE> <INDENT> dic = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} <NEW_LINE> sign = {'+': 1, '-': -1} <NEW_LINE> isSigned = False <NEW_LINE> outOfEmptySpace = False <NEW_LINE> num = 0 <NEW_LINE> sig = 1 <NEW_LINE> for st in str: <NEW_LINE> <INDENT> if st =...
:type str: str :rtype: int
625941cce76e3b2f99f3a8f5
def get_team_tasks_full(self, company_id, team_id): <NEW_LINE> <INDENT> url = 'tasks/companies/%s/teams/%s/tasks/full_list' % (str(company_id), str(team_id)) <NEW_LINE> result = self.get(url) <NEW_LINE> return result["tasks"] or []
Retrieve a list of all tasks assigned to a team (with detail of level at which the task is assigned) The user authenticated must have been granted the appropriate hiring manager permissions Parameters company_id Company ID team_id Team ID
625941cc956e5f7376d70f57
def top_level_folders(self): <NEW_LINE> <INDENT> folders = [self.root_folder] <NEW_LINE> if settings.ENABLE_SPONSORED_USERS and self.sponsored_root_folder: <NEW_LINE> <INDENT> folders.append(self.sponsored_root_folder) <NEW_LINE> <DEDENT> return folders + [org.shared_folder for org in self.get_orgs().select_related('sh...
Get top level folders for this user, including personal folder, sponsored folder, and shared folders.
625941cc187af65679ca5208
def SendDM(self, user, text, options={}): <NEW_LINE> <INDENT> options['user'] = user <NEW_LINE> options['text'] = text <NEW_LINE> return self.ApiCall("direct_messages/new", "POST", options)
Send DM to specified user Args: user: The id or screen name of the recipient of the DM text: The text of the DM to be sent options: A dict of options for the statuses/update call. See the link below for what options can be passed http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-re...
625941ccb7558d58953c4ffe
def format_element(bfo): <NEW_LINE> <INDENT> from invenio.messages import gettext_set_language <NEW_LINE> _ = gettext_set_language(bfo.lang) <NEW_LINE> control_nos = [d['a'] for d in bfo.fields('035__') if d['a'] is not None] <NEW_LINE> control_nos = filter(None, control_nos) <NEW_LINE> style = "style='width:auto;heigh...
Prints the control number of an author authority record in HTML. By default prints brief version. @param brief: whether the 'brief' rather than the 'detailed' format @type brief: 'yes' or 'no'
625941cc5f7d997b87174b81
@pyqtSlot() <NEW_LINE> def shutdown() -> None: <NEW_LINE> <INDENT> if objects.backend == usertypes.Backend.QtWebEngine: <NEW_LINE> <INDENT> from qutebrowser.browser.webengine import webenginesettings <NEW_LINE> webenginesettings.shutdown() <NEW_LINE> <DEDENT> elif objects.backend == usertypes.Backend.QtWebKit: <NEW_LIN...
Shut down QWeb(Engine)Settings.
625941cc3346ee7daa2b2e55
def test_nbands_gtiff_object(self): <NEW_LINE> <INDENT> self.assertEqual(_test_object(landsat_gtiff)[0], 6)
Test the object band count
625941cc38b623060ff0aed7
def MyFirstFunction(): <NEW_LINE> <INDENT> print("This is MyFirstFunction")
函数说明是在这里 可以写很多行
625941cc91f36d47f21ac5dc
def logical_chassis_fwdl_sanity_input_file(self, **kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> logical_chassis_fwdl_sanity = ET.Element("logical_chassis_fwdl_sanity") <NEW_LINE> config = logical_chassis_fwdl_sanity <NEW_LINE> input = ET.SubElement(logical_chassis_fwdl_sanity, "input") <NEW_LIN...
Auto Generated Code
625941cc711fe17d82542456
@login_required <NEW_LINE> def edit(request, short): <NEW_LINE> <INDENT> if request.user.registereduser.blocked: <NEW_LINE> <INDENT> return render(request, 'banned.html') <NEW_LINE> <DEDENT> url = get_object_or_404(URL, short__iexact=short) <NEW_LINE> if url.owner == request.user.registereduser: <NEW_LINE> <INDENT> if ...
This view allows a logged in user to edit the details of a Go link that they own. They can modify any value that they wish. If `short` is modified then we will need to create a new link and copy over stats from the previous.
625941cc3539df3088e2e434
def setup(self): <NEW_LINE> <INDENT> base_path = detect_base_path() <NEW_LINE> self.config = Configuration(base_path, mock()) <NEW_LINE> self.config.initialise(herculeum.config.levels)
Setup test case
625941cc1d351010ab855c05
def draw(self, dependent, cache=None, content=None): <NEW_LINE> <INDENT> context, cache = self.update_context_and_cache(context, cache) <NEW_LINE> return dig(dependents, context=context, cache=cache)
Returns a string representing the tree structure of a dependent's dependencies. See :func:`~revscoring.dependencies.functions.draw` for call signature.
625941cc45492302aab5e3ac
def clean_sample(df, verbose=0): <NEW_LINE> <INDENT> for col in ['date_modif_prod', 'date_renewal', 'date_first_activ']: <NEW_LINE> <INDENT> inds = pd.isnull(df[col]) <NEW_LINE> if verbose > 2: <NEW_LINE> <INDENT> print('\tFilling %i values of %s using date_activ' % (np.sum(inds), col)) <NEW_LINE> <DEDENT> df[col][inds...
Cleans the input DataFrame based on the preliminary analyses. Handles missing values (use replacement by median, other feature or 0), removes some columns.
625941cc94891a1f4081bb93
def _configureLayout(self, layout): <NEW_LINE> <INDENT> self._dataTable = FastDmDataViewer(self._model) <NEW_LINE> self._rtSpecifier = FastDmRtSpecifier(self._model, self._dataTable) <NEW_LINE> self._dataTable.connectTo(self._rtSpecifier) <NEW_LINE> self._dataFilesList = FastDmDfViewer(self._model, self._modelTab, self...
Initializes widgets and sets the main layout of the tab.
625941cc6fece00bbac2d828
def metadata_field(key, r): <NEW_LINE> <INDENT> value = None <NEW_LINE> _, key = key.split(':', 1) <NEW_LINE> metadata = _get_reading_attr(r, 'metadata') <NEW_LINE> i_map = _i_map(metadata) <NEW_LINE> value = _i_get(metadata, i_map, 'metadata.{}'.format(key)) <NEW_LINE> if not value: <NEW_LINE> <INDENT> value = _i_get(...
Get value of metadata field if present. Special field function that is not called like the others. Only accepts a key parameter and a reading. :param key: Metadata key. Looks like metadata:<real key> :type key: String :param reading: Meter reading. :type reading: usage.reading.Reading :return: Value of metadata key :...
625941ccec188e330fd5a889
def __init__( self, dbconnection, outdir="/tmp", prefix="planet_osm", network="lwn", separator="|", debug=False, ): <NEW_LINE> <INDENT> self.conn = psycopg2.connect(dbconnection) <NEW_LINE> self.outdir = outdir <NEW_LINE> self.prefix = prefix <NEW_LINE> self.sep = separator <NEW_LINE> self.regsql = None <NEW_LINE> self...
Inizialize :param obj dbconnection: a psycopg2 connection :param str outdir: the directory where to save file with info :param str prefix: the prefix used in osm2pgsql :param str network: the network tag to consider :param str separator: the separator string for CSV output :param bool debug: set debug
625941cc99fddb7c1c9de47b
def ah__conf__load_from_yaml(self, parsed_config): <NEW_LINE> <INDENT> for key, value in parsed_config.parameters.iteritems(): <NEW_LINE> <INDENT> setattr(self, key, value)
Loads all the params from a YAMLConfiguration into expando fields. We set these expando properties with a special name prefix 'p_' to keep them separate from the static attributes of Config. That way we don't have to check elsewhere to make sure the user doesn't stomp on our built in properties. Args: parse_config...
625941ccb7558d58953c4fff
def update(self): <NEW_LINE> <INDENT> if self.moving_right and self.rect.right < self.screen_rect.right: <NEW_LINE> <INDENT> self.center += self.settings.ship_speed_factor <NEW_LINE> <DEDENT> if self.moving_left and self.rect.left > 0: <NEW_LINE> <INDENT> self.center -= self.settings.ship_speed_factor <NEW_LINE> <DEDEN...
根据移动标志调整飞船的位置
625941cc26068e7796caedc9
def get_nucleus_centroids(self, nID, z=-1): <NEW_LINE> <INDENT> return self.get_param_from_nucleus('data_centroid', ['z', 'y', 'x'], nID, multi_rows=True, z=z)
Get centroids of nucleus :param nID: :return:
625941cc3d592f4c4ed1d158
def run_test_save_no_strategy_restore_strategy(self, model_and_input, distribution, experimental_run_tf_function): <NEW_LINE> <INDENT> saved_dir = os.path.join(self.get_temp_dir(), '0') <NEW_LINE> model = model_and_input.get_model( experimental_run_tf_function=experimental_run_tf_function) <NEW_LINE> x_train, y_train, ...
Save a model without DS, and restore it with DS.
625941cc1f037a2d8b9462e8
def bfind(k,s): <NEW_LINE> <INDENT> if str(k).find(s) == -1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return True
This is a find function that returns true/false instead of an index. Inputs: ------ k : str Input string being searched s : str String being searched for Returns: ------ True/False : boolean Was 's' found in 'k'?
625941ccd18da76e235325c0
def session_verify(self, sessionid, user=None): <NEW_LINE> <INDENT> if user: <NEW_LINE> <INDENT> token = user.lastuser_token <NEW_LINE> token_type = user.lastuser_token_type <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> token = token_type = None <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> result = self.call_resource('...
Verify the user's session.
625941cc8c3a8732951584a5
def _dump_in_memory_config_to_stdout(data, stream=None): <NEW_LINE> <INDENT> if stream is None: <NEW_LINE> <INDENT> inefficient = True <NEW_LINE> yaml.dump(data, sys.stdout) <NEW_LINE> print() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> inefficient = False <NEW_LINE> print(yaml.dump(data)) <NEW_LINE> <DEDENT> logger....
[dump in memory config] Arguments: data {[ruamel.yaml.comments.CommentedMap]} -- [CommentedMap object]
625941cc23e79379d52ee64e
def check_dealer_natural(self): <NEW_LINE> <INDENT> if self.dealer_hand.is_blackjack(): <NEW_LINE> <INDENT> self.outcome = 'Draw' <NEW_LINE> print('And so does the dealer!') <NEW_LINE> print(self.dealer_hand) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.outcome = 'Win' <NEW_LINE> print('And the dealer does not!')...
Method to check if dealer has a natural blackjack. Executed when the player gets a blackjack.
625941cc5e10d32532c5f011
def sendHeaders(self): <NEW_LINE> <INDENT> for key, values in self.headers: <NEW_LINE> <INDENT> for value in values: <NEW_LINE> <INDENT> if key == b"Connection": <NEW_LINE> <INDENT> value = b"close" <NEW_LINE> <DEDENT> self.sendHeader(key, value) <NEW_LINE> <DEDENT> <DEDENT> self.endHeaders()
Send HTTP headers.
625941cc2ae34c7f2600d21b
def _get_pm_commission_total(self): <NEW_LINE> <INDENT> return currency(0)
Return the payment method commission total. Usually credit card payment method is the most common method which uses commission
625941cc31939e2706e4cf55
def __init__(self, s=0, a=0, b=0, c=0, d=0): <NEW_LINE> <INDENT> self.s = s <NEW_LINE> self.a = a <NEW_LINE> self.b = b <NEW_LINE> self.c = c <NEW_LINE> self.d = d
initalize the LaneOffset class Parameters ---------- s (float): s start coordinate of the LaneOffset a (float): a coefficient of the polynomial b (float): b coefficient of the polynomial c (float): c coefficient of the polynomial d (float): d coefficient of the polynomial
625941cc009cb60464c6349c
def isImgPath(name, silent=False): <NEW_LINE> <INDENT> if not type(name) is str: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if cv2.imread(name) is not None: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if not silent: <NEW_LINE> <INDENT> print('[{0}] is not Image'.format(name))...
入力されたパスが画像か判定する [in] name: 画像か判定したいパス [in] silent: cv2.imread失敗時にエラーを表示させない場合はTrue [out] 画像ならTrue
625941cc7047854f462a14f4
def dealing_with_extremely_insane_dependencies(): <NEW_LINE> <INDENT> pass
There was a problem with analysis of dependencies taking a long time, in part because the analysis would get repeated every time a package was encountered in a dependency list. Now, we don't do the analysis any more: >>> import os >>> for i in range(5): ... p = 'pack%s' % i ... deps = [('pack%s' % j) for j in...
625941ccc4546d3d9de72b1f
def drevo(zelva, red, velikost, faktor, kot): <NEW_LINE> <INDENT> if red == 0: return <NEW_LINE> if red <= 2: <NEW_LINE> <INDENT> zelva.pencolor("green") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> zelva.pencolor("brown") <NEW_LINE> <DEDENT> zelva.pensize(log(2*red)) <NEW_LINE> zelva.down() <NEW_LINE> zelva.forward(v...
Nariše drevo kot fraktal danega reda in velikosti. Faktor predstavlja zmanjševanje na vejah in kot predstavlja kot med vejama.
625941ccf9cc0f698b1406e6
def update_certificate_policy( self, vault_base_url, certificate_name, certificate_policy, **kwargs ): <NEW_LINE> <INDENT> api_version = self._get_api_version('update_certificate_policy') <NEW_LINE> if api_version == '2016-10-01': <NEW_LINE> <INDENT> from .v2016_10_01.operations import KeyVaultClientOperationsMixin as ...
Updates the policy for a certificate. Set specified members in the certificate policy. Leave others as null. This operation requires the certificates/update permission. :param vault_base_url: The vault name, for example https://myvault.vault.azure.net. :type vault_base_url: str :param certificate_name: The name of th...
625941cc67a9b606de4a7fa4
def complement(self, comp=utils.complement): <NEW_LINE> <INDENT> return self.__class__._from_domain( self.domain, mu=lambda x: comp(self.mu(x)) )
Finds the complement of the fuzzy set. :param comp: a callable that takes a membership degree (float between 0 and 1) and returns a membership degree. This callable (denoted by C below) must also satisfy the following axioms: 1) boundary condition: C(0) = 1; C(1) = 0 2) if a <= b then C(a) >= C(b) Defaults to `1...
625941cca79ad161976cc230
def main(): <NEW_LINE> <INDENT> print(double_letters("loop")) <NEW_LINE> print(double_letters("yummy")) <NEW_LINE> print(double_letters("orange")) <NEW_LINE> print(double_letters("munchkin"))
Run sample double_letters functions. Do not import.
625941cc66673b3332b9217c
def __init__(self, values, weights, ignore_missing=False): <NEW_LINE> <INDENT> if ignore_missing: <NEW_LINE> <INDENT> values = np.array(values) <NEW_LINE> weights = np.array(weights) <NEW_LINE> weights[np.isnan(values)] = 0 <NEW_LINE> values[np.isnan(values)] = 0 <NEW_LINE> if np.sum(weights) == 0 and len(weights) > 0:...
Takes a list of values and weights
625941cccdde0d52a9e5311e
def make_test_function(self): <NEW_LINE> <INDENT> test_fn = super(ContrackModel, self).make_test_function() <NEW_LINE> def adapted_test_fn(iterator): <NEW_LINE> <INDENT> outputs = test_fn(iterator) <NEW_LINE> if 'print_prediction' in outputs: <NEW_LINE> <INDENT> pred_msgs = outputs['print_prediction'] <NEW_LINE> if sel...
Creates a function that executes one step of evaluation.
625941cc4e696a04525c9536
@require(indexid=int) <NEW_LINE> def grib_new_from_index(indexid): <NEW_LINE> <INDENT> ih = get_index(indexid) <NEW_LINE> err, h = err_last(lib.grib_handle_new_from_index)(ih) <NEW_LINE> if h == ffi.NULL or err == lib.GRIB_END_OF_INDEX: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> elif err: <NEW_LINE> <INDENT> G...
@brief Create a new handle from an index after having selected the key values. All the keys belonging to the index must be selected before calling this function. Successive calls to this function will return all the handles compatible with the constraints defined selecting the values of the index keys. The message ca...
625941cc32920d7e50b282ba
def test_HINFO(self): <NEW_LINE> <INDENT> return self.namesTest( self.resolver.lookupHostInfo('test-domain.com'), [dns.Record_HINFO(os='Linux', cpu='A Fast One, Dontcha know', ttl=19283784)] )
Test DNS 'HINFO' record queries
625941cc379a373c97cfac2f
def test_summand(self): <NEW_LINE> <INDENT> for full_name in ( FullName("foo", {"bar", "baz"}), FullName("foo", frozenset()), FullName("", {"bar", "baz"}), FullName("", frozenset()), ): <NEW_LINE> <INDENT> self.assertEqual( src.interpreter._summand( full_name.name + "".join(f"[{tag}]" for tag in full_name.tags) ), full...
Test summand. Trying: string is summand Expecting: FullName
625941cc57b8e32f52483585
def update(self, request, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> current_user = HelperRecoveryPWD.helperUpdate( self, request, self.serializer_class) <NEW_LINE> if current_user: <NEW_LINE> <INDENT> return Response({'data': 'password changed.'}, status=status.HTTP_200_OK) <NEW_LINE> <DEDENT> return Resp...
method to recovery - change password user
625941cc3c8af77a43ae388b
def dumpMeteoConfig(self): <NEW_LINE> <INDENT> Domoticz.Log( "detailNo: {}\ndetailLang: {}\n" "langKey: {}\niconNo: {}\niconType:{}" .format( self.detailNo, self.detailLang, self.langKey, self.iconNo, self.iconType ) )
just print configuration and settings to log
625941ccb545ff76a8913f01
def redact_location(candidates): <NEW_LINE> <INDENT> location_re = re.compile("^sentry://project_debug_file/[0-9]+$") <NEW_LINE> for candidate in candidates: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> location = candidate["location"] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT...
Redacts the sentry location URI to be independent of the specific ID. This modifies the data passed in, returns None.
625941cc5510c4643540f4d0
def ensure_index(index_like, copy=False): <NEW_LINE> <INDENT> if isinstance(index_like, Index): <NEW_LINE> <INDENT> if copy: <NEW_LINE> <INDENT> index_like = index_like.copy() <NEW_LINE> <DEDENT> return index_like <NEW_LINE> <DEDENT> if hasattr(index_like, "name"): <NEW_LINE> <INDENT> return Index(index_like, name=inde...
Ensure that we have an index from some index-like object. Parameters ---------- index : sequence An Index or other sequence copy : bool Returns ------- index : Index or MultiIndex Examples -------- >>> ensure_index(['a', 'b']) Index(['a', 'b'], dtype='object') >>> ensure_index([('a', 'a'), ('b', 'c')]) Index([...
625941cc090684286d50edd0
def START(self, datatype, value): <NEW_LINE> <INDENT> if self._engine_version_code >= 3010500 and AceConfig.vlcuse: <NEW_LINE> <INDENT> stream_type = 'output_format=hls' + ' transcode_audio=' + str(AceConfig.transcode_audio) + ' transcode_mp3=' + str(AceConfig.transcode_mp3) ...
Start video method
625941cc96565a6dacc8f7b6
def get_depended_udf(self): <NEW_LINE> <INDENT> self.get_proc_w_dependency(aggregate=False)
@brief Get dependent UDFs
625941cc32920d7e50b282bb
def add_production(self, lhs, rhs): <NEW_LINE> <INDENT> self.cnf_grammar.setdefault(lhs, []).append(rhs)
Add the given production into the dictionary of CNF rules :param lhs: the left-hand side of the new production :param rhs: the right-hand side of the new production :return: void
625941cc76e4537e8c35175d
def lägg_in_månadsalmanacka(mån, månalma, årsalma): <NEW_LINE> <INDENT> def uppdatera(ml): <NEW_LINE> <INDENT> if not ml or månadsnummer(mån) < månadsnummer(skapa_månad(ml[0][0])): <NEW_LINE> <INDENT> return [(packa_upp(mån), månalma)] + ml <NEW_LINE> <DEDENT> elif månadsnummer(mån) == månadsnummer(skapa_månad(ml[0][0]...
månad x månadsalmanacka x årsalmanacka -> årsalmanacka
625941cceab8aa0e5d26dc43
def edges_nbrto(self, edge): <NEW_LINE> <INDENT> results = [] <NEW_LINE> l1, l2 = edge <NEW_LINE> p2 = self.node_coordinates(l2) <NEW_LINE> for l3, p3 in self.nodes_nbrto(l2): <NEW_LINE> <INDENT> results.append((l2, p2, l3, p3)) <NEW_LINE> <DEDENT> return results
Return all edges that are linked to ``edge``. Defaults to ``nodes_nbrto``. :param edge: Edge identifier :return: list[tuple[label1, label2, loc1, loc2]]
625941cc7cff6e4e81117a71
def preprocess(): <NEW_LINE> <INDENT> data_mat = loadmat('mnist_all.mat') <NEW_LINE> train_data=np.empty((0,784)) <NEW_LINE> test_data=np.empty((0,784)) <NEW_LINE> train_label=np.empty((0,1)) <NEW_LINE> test_label=np.empty((0,1)) <NEW_LINE> for i in range(10): <NEW_LINE> <INDENT> train_data_temp = data_mat.get('train'+...
Input: Although this function doesn't have any input, you are required to load the MNIST data set from file 'mnist_all.mat'. Output: train_data: matrix of training set. Each row of train_data contains feature vector of a image train_label: vector of label corresponding to each image in the training set validation...
625941cc7c178a314d6ef54b
def solve(list_of_kingdom_names, starting_kingdom, adjacency_matrix, params=[]): <NEW_LINE> <INDENT> closed_walk = [] <NEW_LINE> conquered_kingdoms = [] <NEW_LINE> return list_of_kingdom_names, starting_kingdom, adjacency_matrix <NEW_LINE> raise Exception('"solve" function not defined')
Write your algorithm here. Input: list_of_kingdom_names: An list of kingdom names such that node i of the graph corresponds to name index i in the list starting_kingdom: The name of the starting kingdom for the walk adjacency_matrix: The adjacency matrix from the input file Output: Return 2 things. The...
625941cc91af0d3eaac9bb04
@P.cluster_runnable <NEW_LINE> def compareFovsGC(infile, fo_gc, image_dir): <NEW_LINE> <INDENT> name_list = infile.split("/")[-1].split("_") <NEW_LINE> p_name = name_list[0] + "_" + name_list[2] <NEW_LINE> p_name = p_name.rstrip("-time.tsv") <NEW_LINE> df = pd.read_table(infile, sep="\t", header=0, index_col=0) <NEW_LI...
Compare results from time point differential expression analysis to Fo -> GC differential analysis results.
625941ccde87d2750b85fe7e
def unbounded(self, data): <NEW_LINE> <INDENT> return False
Get whether the object is unbounded (a list). @param data: The current object being built. @type data: L{Object} @return: True if unbounded, else False @rtype: boolean '
625941cc07d97122c4178976
def __str__(self): <NEW_LINE> <INDENT> return ( "<Location=%s, Vs30=%.4f, Vs30Measured=%r, Depth1.0km=%.4f, " "Depth2.5km=%.4f>") % ( self.location, self.vs30, self.vs30measured, self.z1pt0, self.z2pt5)
>>> import nhlib >>> loc = nhlib.geo.point.Point(1, 2, 3) >>> str(Site(loc, 760.0, True, 100.0, 5.0)) '<Location=<Latitude=2.000000, Longitude=1.000000, Depth=3.0000>, Vs30=760.0000, Vs30Measured=True, Depth1.0km=100.0000, Depth2.5km=5.0000>'
625941cca79ad161976cc231
def process_requested_swagger_operations(self, sess): <NEW_LINE> <INDENT> if len(self.requested_operations_by_swagger) > 0: <NEW_LINE> <INDENT> for requested_operation in self.requested_operations_by_swagger: <NEW_LINE> <INDENT> for key, value in requested_operation.items(): <NEW_LINE> <INDENT> function_name = key <NEW...
processes the operations requested by swagger :param sess: tensorflow session :return:
625941cc15baa723493c4060
def report_success(self, msg, content=None): <NEW_LINE> <INDENT> log = logging.getLogger(self.cls_logger + '.report_success') <NEW_LINE> log_msg = msg <NEW_LINE> if content: <NEW_LINE> <INDENT> self.create_output_file(msg, content) <NEW_LINE> log_msg += '\n' + content <NEW_LINE> <DEDENT> log.info(log_msg) <NEW_LINE> wi...
Reports success :param msg (str) success message :param content (str) output file content :return: None
625941cc4a966d76dd5510fa
def set_source_system_priorities(self, priorities): <NEW_LINE> <INDENT> self._source_system_priorities = priorities
Set the source system priorities.
625941ccd18da76e235325c1